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 dfc630e04..9ec75f3f5 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; - Vector3d pos = VecHelper.getCenterOf(source.getPos()) + Vector3d pos = VecHelper.getCenterOf(source.getAirCurrentPos()) .add(Vector3d.of(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; } - Vector3d center = VecHelper.getCenterOf(source.getPos()); + Vector3d center = VecHelper.getCenterOf(source.getAirCurrentPos()); Vector3i 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; Direction facing = direction; Vector3d directionVec = Vector3d.of(facing.getDirectionVec()); @@ -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/components/fan/EncasedFanTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java index 0f5514a6a..31d774c84 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 @@ -14,6 +14,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 { @@ -94,6 +99,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() @@ -110,6 +126,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/contraptions/particle/AirFlowParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java index 138af7457..93d347ac9 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 Vector3d(posX, posY, posZ).subtract(VecHelper.getCenterOf(source.getPos())) + double distance = new Vector3d(posX, posY, posZ).subtract(VecHelper.getCenterOf(source.getAirCurrentPos())) .mul(directionVec).length() - .5f; if (distance > source.getAirCurrent().maxDistance + 1 || distance < -.25f) { dissipate(); 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 f021f8dd8..c050a2785 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 @@ -42,6 +42,7 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; 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; @@ -689,6 +690,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) @@ -705,6 +717,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)