diff --git a/src/main/java/com/minelittlepony/unicopia/EquineContext.java b/src/main/java/com/minelittlepony/unicopia/EquineContext.java index 41e19806..596c2cbb 100644 --- a/src/main/java/com/minelittlepony/unicopia/EquineContext.java +++ b/src/main/java/com/minelittlepony/unicopia/EquineContext.java @@ -31,7 +31,7 @@ public interface EquineContext { static EquineContext of(ShapeContext context) { if (context == ShapeContext.absent()) { - return InteractionManager.getInstance().getClientPony().map(EquineContext.class::cast).orElse(ABSENT); + return InteractionManager.getInstance().getEquineContext(); } EquineContext result = context instanceof Container c ? c.get() : ABSENT; return result == null ? ABSENT : result; diff --git a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java index d865eb70..5326ce75 100644 --- a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java @@ -37,6 +37,8 @@ public class InteractionManager { @Nullable private SyncedConfig config; + private EquineContext equineContext = EquineContext.ABSENT; + public static InteractionManager getInstance() { return INSTANCE; } @@ -106,6 +108,14 @@ public class InteractionManager { } + public void setEquineContext(EquineContext context) { + equineContext = context; + } + + public EquineContext getEquineContext() { + return getClientPony().map(EquineContext.class::cast).orElse(equineContext); + } + public Optional getClientPony() { return Optional.empty(); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBedBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBedBlock.java index 6ecc1497..e6eb8ddf 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBedBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBedBlock.java @@ -24,7 +24,7 @@ public class CloudBedBlock extends FancyBedBlock implements CloudLike { private final CloudBlock baseBlock; public CloudBedBlock(String base, BlockState baseState, Settings settings) { - super(base, settings); + super(base, settings.dynamicBounds()); this.baseState = baseState; this.baseBlock = (CloudBlock)baseState.getBlock(); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java index 2479021c..fd526300 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java @@ -30,7 +30,7 @@ public class CloudBlock extends Block implements CloudLike { protected final boolean meltable; public CloudBlock(Settings settings, boolean meltable) { - super((meltable ? settings.ticksRandomly() : settings).nonOpaque()); + super((meltable ? settings.ticksRandomly() : settings).nonOpaque().dynamicBounds()); this.meltable = meltable; } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudChestBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudChestBlock.java index cc6bb636..f4f5ba0b 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudChestBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudChestBlock.java @@ -77,7 +77,7 @@ public class CloudChestBlock extends ChestBlock implements CloudLike { }; public CloudChestBlock(Settings settings, BlockState baseState) { - super(settings, () -> UBlockEntities.CLOUD_CHEST); + super(settings.dynamicBounds(), () -> UBlockEntities.CLOUD_CHEST); this.baseState = baseState; this.baseBlock = (CloudBlock)baseState.getBlock(); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudDoorBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudDoorBlock.java index be730174..e0b495d1 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudDoorBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudDoorBlock.java @@ -26,7 +26,7 @@ public class CloudDoorBlock extends DoorBlock implements CloudLike { private final CloudBlock baseBlock; public CloudDoorBlock(Settings settings, BlockState baseState, BlockSetType blockSet) { - super(settings, blockSet); + super(settings.dynamicBounds(), blockSet); this.baseState = baseState; this.baseBlock = (CloudBlock)baseState.getBlock(); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java index bafd9e21..a2b1e4ba 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java @@ -21,7 +21,7 @@ public class CloudStairsBlock extends StairsBlock implements CloudLike { private final CloudBlock baseBlock; public CloudStairsBlock(BlockState baseState, Settings settings) { - super(baseState, settings); + super(baseState, settings.dynamicBounds()); this.baseBlock = (CloudBlock)baseState.getBlock(); } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerManager.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerManager.java index eb70cb8a..ce8be7b9 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerManager.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerManager.java @@ -5,7 +5,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.minelittlepony.unicopia.EquineContext; +import com.minelittlepony.unicopia.InteractionManager; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.entity.Entity; @@ -34,4 +37,13 @@ abstract class MixinPlayerManager { } } + @Inject(method = "respawnPlayer", at = @At("HEAD")) + private void beforeRespawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable info) { + InteractionManager.getInstance().setEquineContext(EquineContext.of(player)); + } + + @Inject(method = "respawnPlayer", at = @At("RETURN")) + private void afterRespawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable info) { + InteractionManager.getInstance().setEquineContext(EquineContext.ABSENT); + } }