From 23beff40f385fd7a1c54369da36a2f353b7b8bff Mon Sep 17 00:00:00 2001 From: grimmauld Date: Fri, 9 Oct 2020 20:28:20 +0200 Subject: [PATCH 1/2] Chute and Air: hopefully fix non-dev env issues --- .../components/fan/EncasedFanTileEntity.java | 21 +++++++++++++++++++ .../components/fan/IAirCurrentSource.java | 6 +++--- .../block/chute/ChuteTileEntity.java | 17 +++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java index eab69aaa9..d52123a8c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java @@ -13,6 +13,11 @@ import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import javax.annotation.Nullable; + @MethodsReturnNonnullByDefault public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements IAirCurrentSource { @@ -93,6 +98,17 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements return airCurrent; } + @Nullable + @Override + public World getAirCurrentWorld() { + return world; + } + + @Override + public BlockPos getAirCurrentPos() { + return pos; + } + @Override public Direction getAirflowOriginSide() { return this.getBlockState() @@ -109,6 +125,11 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements return speed > 0 ? facing : facing.getOpposite(); } + @Override + public boolean isSourceRemoved() { + return removed; + } + @Override public void onSpeedChanged(float prevSpeed) { super.onSpeedChanged(prevSpeed); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java index 658d7c5f3..7e93a5ded 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java @@ -16,9 +16,9 @@ public interface IAirCurrentSource { AirCurrent getAirCurrent(); @Nullable - World getWorld(); + World getAirCurrentWorld(); - BlockPos getPos(); + BlockPos getAirCurrentPos(); float getSpeed(); @@ -36,5 +36,5 @@ public interface IAirCurrentSource { return this.getSpeed() > 0 ? pushDistance : pullDistance; } - boolean isRemoved(); + boolean isSourceRemoved(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java index 49ddadb53..854a64ca2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java @@ -40,6 +40,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -687,6 +688,17 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return airCurrent; } + @Nullable + @Override + public World getAirCurrentWorld() { + return world; + } + + @Override + public BlockPos getAirCurrentPos() { + return pos; + } + @Override public float getSpeed() { if (getBlockState().get(ChuteBlock.SHAPE) == Shape.NORMAL && getBlockState().get(ChuteBlock.FACING) != Direction.DOWN) @@ -703,6 +715,11 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return speed > 0 ? Direction.UP : Direction.DOWN; } + @Override + public boolean isSourceRemoved() { + return removed; + } + @Override public Direction getAirflowOriginSide() { return world != null && !(world.getTileEntity(pos.down()) instanceof IAirCurrentSource) From f593aca95da14586550d845ed84e734ad9458030 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Fri, 9 Oct 2020 20:36:40 +0200 Subject: [PATCH 2/2] fix build issues --- .../components/fan/AirCurrent.java | 18 +++++++++--------- .../contraptions/particle/AirFlowParticle.java | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java index f034db5bf..a1d6e89ca 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java @@ -63,14 +63,14 @@ public class AirCurrent { public void tick() { if (direction == null) rebuild(); - World world = source.getWorld(); + World world = source.getAirCurrentWorld(); Direction facing = direction; if (world != null && world.isRemote) { float offset = pushing ? 0.5f : maxDistance + .5f; - Vec3d pos = VecHelper.getCenterOf(source.getPos()) + Vec3d pos = VecHelper.getCenterOf(source.getAirCurrentPos()) .add(new Vec3d(facing.getDirectionVec()).scale(offset)); if (world.rand.nextFloat() < AllConfigs.CLIENT.fanParticleDensity.get()) - world.addParticle(new AirFlowParticleData(source.getPos()), pos.x, pos.y, pos.z, 0, 0, 0); + world.addParticle(new AirFlowParticleData(source.getAirCurrentPos()), pos.x, pos.y, pos.z, 0, 0, 0); } for (Iterator iterator = caughtEntities.iterator(); iterator.hasNext();) { @@ -81,7 +81,7 @@ public class AirCurrent { continue; } - Vec3d center = VecHelper.getCenterOf(source.getPos()); + Vec3d center = VecHelper.getCenterOf(source.getAirCurrentPos()); Vec3i flow = (pushing ? facing : facing.getOpposite()).getDirectionVec(); float sneakModifier = entity.isSneaking() ? 4096f : 512f; @@ -165,8 +165,8 @@ public class AirCurrent { pushing = source.getAirFlowDirection() == direction; maxDistance = source.getMaxDistance(); - World world = source.getWorld(); - BlockPos start = source.getPos(); + World world = source.getAirCurrentWorld(); + BlockPos start = source.getAirCurrentPos(); float max = this.maxDistance; Vec3d directionVec = new Vec3d(direction.getDirectionVec()); // if (source instanceof EncasedFanTileEntity) // debug @@ -269,13 +269,13 @@ public class AirCurrent { public void findEntities() { caughtEntities.clear(); - caughtEntities = source.getWorld() + caughtEntities = source.getAirCurrentWorld() .getEntitiesWithinAABBExcludingEntity(null, bounds); } public void findAffectedHandlers() { - World world = source.getWorld(); - BlockPos start = source.getPos(); + World world = source.getAirCurrentWorld(); + BlockPos start = source.getAirCurrentPos(); affectedItemHandlers.clear(); for (int i = 0; i < maxDistance + 1; i++) { Type type = getSegmentAt(i); diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java index c93e96e9b..ccfc5fa5f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java @@ -50,7 +50,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle { @Override public void tick() { - if (source == null || source.isRemoved()) { + if (source == null || source.isSourceRemoved()) { dissipate(); return; } @@ -70,7 +70,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle { if (!source.getAirCurrent().pushing) motion = motion.scale(-1); - double distance = new Vec3d(posX, posY, posZ).subtract(VecHelper.getCenterOf(source.getPos())) + double distance = new Vec3d(posX, posY, posZ).subtract(VecHelper.getCenterOf(source.getAirCurrentPos())) .mul(directionVec).length() - .5f; if (distance > source.getAirCurrent().maxDistance + 1 || distance < -.25f) { dissipate();