Fixed crash when disguising as a block with a block entity

This commit is contained in:
Sollace 2021-08-19 21:24:42 +02:00
parent 762b211124
commit 2f32cdf6bb
3 changed files with 22 additions and 8 deletions

View file

@ -8,8 +8,8 @@ import com.minelittlepony.unicopia.entity.Equine;
import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.entity.Living;
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
import com.minelittlepony.unicopia.entity.behaviour.FallingBlockBehaviour;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -144,7 +144,7 @@ public class WorldRenderDelegate {
if (blockEntity != null) {
BlockEntityRenderer<BlockEntity> r = MinecraftClient.getInstance().getBlockEntityRenderDispatcher().get(blockEntity);
if (r != null) {
((MixinBlockEntity)blockEntity).setPos(e.getBlockPos());
((FallingBlockBehaviour.Positioned)blockEntity).setPos(e.getBlockPos());
matrices.push();
BlockState state = blockEntity.getCachedState();

View file

@ -6,7 +6,6 @@ import java.util.Optional;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
import com.minelittlepony.unicopia.mixin.MixinFallingBlock;
import com.minelittlepony.unicopia.util.Tickable;
@ -25,6 +24,7 @@ import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
@ -115,9 +115,13 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
}
be.setWorld(entity.world);
((MixinBlockEntity)be).setPos(entity.getBlockPos());
((Positioned)be).setPos(entity.getBlockPos());
ceb.tick();
be.setWorld(null);
}
}
public interface Positioned {
void setPos(BlockPos pos);
}
}

View file

@ -1,13 +1,23 @@
package com.minelittlepony.unicopia.mixin;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import com.minelittlepony.unicopia.entity.behaviour.FallingBlockBehaviour;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
@Mixin(BlockEntity.class)
public interface MixinBlockEntity {
@Accessor("pos")
void setPos(BlockPos pos);
abstract class MixinBlockEntity implements FallingBlockBehaviour.Positioned {
@Shadow
@Mutable
private @Final BlockPos pos;
@Override
public void setPos(BlockPos pos) {
this.pos = pos;
}
}