From d0f6f5e8319329c5d9e5ea71b4c7df8aa13e580f Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 28 Sep 2020 20:56:04 +0200 Subject: [PATCH] Changelings disguised as chests can now open themselves up :V --- .../behaviour/FallingBlockBehaviour.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java index 767ae71b..75657063 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java @@ -5,6 +5,7 @@ import java.util.List; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; +import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.mixin.MixinBlockEntity; import net.minecraft.block.Block; @@ -13,11 +14,14 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.DoorBlock; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.ChestBlockEntity; +import net.minecraft.block.entity.EnderChestBlockEntity; import net.minecraft.block.enums.DoubleBlockHalf; import net.minecraft.entity.Entity; import net.minecraft.entity.FallingBlockEntity; import net.minecraft.state.property.Properties; import net.minecraft.tag.BlockTags; +import net.minecraft.util.Tickable; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; @@ -67,9 +71,25 @@ public class FallingBlockBehaviour extends EntityBehaviour { } } - List attachments = ((DisguiseSpell)spell).getDisguise().getAttachments(); + Disguise disguise = ((DisguiseSpell)spell).getDisguise(); + List attachments = disguise.getAttachments(); if (attachments.size() > 0) { copyBaseAttributes(source.getOwner(), attachments.get(0), UP); } + + BlockEntity be = disguise.getBlockEntity(); + + if (source instanceof Pony && be instanceof Tickable && (be instanceof ChestBlockEntity || be instanceof EnderChestBlockEntity)) { + Pony player = (Pony)source; + Tickable ceb = (Tickable)disguise.getBlockEntity(); + + if (player.sneakingChanged()) { + be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0); + } + + be.setLocation(entity.world, entity.getBlockPos()); + ceb.tick(); + be.setLocation(null, entity.getBlockPos()); + } } }