Converted to 1.16 appropriate ways - builds

This commit is contained in:
Bob Dole 2020-10-30 03:11:07 -04:00
parent c739fdbb09
commit 16ab29be1d
7 changed files with 27 additions and 29 deletions

View File

@ -6,13 +6,13 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState;
import net.minecraft.particles.BlockParticleData; import net.minecraft.particles.BlockParticleData;
import net.minecraft.particles.IParticleData; import net.minecraft.particles.IParticleData;
import net.minecraft.particles.ParticleTypes; import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -25,22 +25,22 @@ public class FluidFX {
if (fluid == Fluids.EMPTY) if (fluid == Fluids.EMPTY)
return; return;
IFluidState defaultState = fluid.getDefaultState(); FluidState defaultState = fluid.getDefaultState();
if (defaultState == null || defaultState.isEmpty()) { if (defaultState == null || defaultState.isEmpty()) {
return; return;
} }
BlockParticleData blockParticleData = new BlockParticleData(ParticleTypes.BLOCK, defaultState.getBlockState()); BlockParticleData blockParticleData = new BlockParticleData(ParticleTypes.BLOCK, defaultState.getBlockState());
Vec3d center = VecHelper.getCenterOf(pos); Vector3d center = VecHelper.getCenterOf(pos);
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
Vec3d v = VecHelper.offsetRandomly(Vec3d.ZERO, r, .25f); Vector3d v = VecHelper.offsetRandomly(Vector3d.ZERO, r, .25f);
particle(blockParticleData, center.add(v), v); particle(blockParticleData, center.add(v), v);
} }
} }
private static void particle(IParticleData data, Vec3d pos, Vec3d motion) { private static void particle(IParticleData data, Vector3d pos, Vector3d motion) {
world().addParticle(data, pos.x, pos.y, pos.z, motion.x, motion.y, motion.z); world().addParticle(data, pos.x, pos.y, pos.z, motion.x, motion.y, motion.z);
} }

View File

@ -84,7 +84,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
BlockState emptied = blockState; BlockState emptied = blockState;
Fluid fluid = Fluids.EMPTY; Fluid fluid = Fluids.EMPTY;
if (blockState.has(BlockStateProperties.WATERLOGGED) && blockState.get(BlockStateProperties.WATERLOGGED)) { if (blockState.contains(BlockStateProperties.WATERLOGGED) && blockState.get(BlockStateProperties.WATERLOGGED)) {
emptied = blockState.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false)); emptied = blockState.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false));
fluid = Fluids.WATER; fluid = Fluids.WATER;
} else if (blockState.getBlock() instanceof FlowingFluidBlock) { } else if (blockState.getBlock() instanceof FlowingFluidBlock) {
@ -192,7 +192,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
} }
protected FluidBlockType canPullFluidsFrom(BlockState blockState, BlockPos pos) { protected FluidBlockType canPullFluidsFrom(BlockState blockState, BlockPos pos) {
if (blockState.has(BlockStateProperties.WATERLOGGED) && blockState.get(BlockStateProperties.WATERLOGGED)) if (blockState.contains(BlockStateProperties.WATERLOGGED) && blockState.get(BlockStateProperties.WATERLOGGED))
return FluidBlockType.SOURCE; return FluidBlockType.SOURCE;
if (blockState.getBlock() instanceof FlowingFluidBlock) if (blockState.getBlock() instanceof FlowingFluidBlock)
return blockState.get(FlowingFluidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING; return blockState.get(FlowingFluidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING;

View File

@ -15,8 +15,8 @@ import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FlowingFluidBlock; import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -113,7 +113,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
int maxBlocks = maxBlocks(); int maxBlocks = maxBlocks();
if (infinite) { if (infinite) {
IFluidState fluidState = world.getFluidState(rootPos); FluidState fluidState = world.getFluidState(rootPos);
boolean equivalentTo = fluidState.getFluid() boolean equivalentTo = fluidState.getFluid()
.isEquivalentTo(fluid); .isEquivalentTo(fluid);
if (!equivalentTo) if (!equivalentTo)
@ -153,7 +153,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
playEffect(world, currentPos, fluid, false); playEffect(world, currentPos, fluid, false);
BlockState blockState = world.getBlockState(currentPos); BlockState blockState = world.getBlockState(currentPos);
if (blockState.has(BlockStateProperties.WATERLOGGED) && fluid.isEquivalentTo(Fluids.WATER)) { if (blockState.contains(BlockStateProperties.WATERLOGGED) && fluid.isEquivalentTo(Fluids.WATER)) {
world.setBlockState(currentPos, blockState.with(BlockStateProperties.WATERLOGGED, true), world.setBlockState(currentPos, blockState.with(BlockStateProperties.WATERLOGGED, true),
2 | 16); 2 | 16);
} else { } else {
@ -220,9 +220,9 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
protected SpaceType getAtPos(World world, BlockPos pos, Fluid toFill) { protected SpaceType getAtPos(World world, BlockPos pos, Fluid toFill) {
BlockState blockState = world.getBlockState(pos); BlockState blockState = world.getBlockState(pos);
IFluidState fluidState = blockState.getFluidState(); FluidState fluidState = blockState.getFluidState();
if (blockState.has(BlockStateProperties.WATERLOGGED)) if (blockState.contains(BlockStateProperties.WATERLOGGED))
return toFill.isEquivalentTo(Fluids.WATER) return toFill.isEquivalentTo(Fluids.WATER)
? blockState.get(BlockStateProperties.WATERLOGGED) ? SpaceType.FILLED : SpaceType.FILLABLE ? blockState.get(BlockStateProperties.WATERLOGGED) ? SpaceType.FILLED : SpaceType.FILLABLE
: SpaceType.BLOCKING; : SpaceType.BLOCKING;

View File

@ -14,7 +14,7 @@ import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.IFluidState; import net.minecraft.fluid.FluidState;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
@ -25,7 +25,7 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents; import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox; import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -101,11 +101,9 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
protected void scheduleUpdatesInAffectedArea() { protected void scheduleUpdatesInAffectedArea() {
World world = getWorld(); World world = getWorld();
affectedArea = new MutableBoundingBox(affectedArea.minX - 1, affectedArea.minY - 1, affectedArea.minZ - 1, BlockPos.getAllInBox(new BlockPos(affectedArea.minX - 1, affectedArea.minY - 1, affectedArea.minZ - 1), new BlockPos(affectedArea.maxX + 1, affectedArea.maxY + 1, affectedArea.maxZ + 1))
affectedArea.maxX + 1, affectedArea.maxY + 1, affectedArea.maxZ + 1);
BlockPos.func_229383_a_(affectedArea)
.forEach(pos -> { .forEach(pos -> {
IFluidState nextFluidState = world.getFluidState(pos); FluidState nextFluidState = world.getFluidState(pos);
if (nextFluidState.isEmpty()) if (nextFluidState.isEmpty())
return; return;
world.getPendingFluidTicks() world.getPendingFluidTicks()
@ -115,7 +113,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
} }
protected int comparePositions(BlockPosEntry e1, BlockPosEntry e2) { protected int comparePositions(BlockPosEntry e1, BlockPosEntry e2) {
Vec3d centerOfRoot = VecHelper.getCenterOf(rootPos); Vector3d centerOfRoot = VecHelper.getCenterOf(rootPos);
BlockPos pos2 = e2.pos; BlockPos pos2 = e2.pos;
BlockPos pos1 = e1.pos; BlockPos pos1 = e1.pos;
if (pos1.getY() != pos2.getY()) if (pos1.getY() != pos2.getY())
@ -144,7 +142,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
continue; continue;
visited.add(currentPos); visited.add(currentPos);
IFluidState fluidState = world.getFluidState(currentPos); FluidState fluidState = world.getFluidState(currentPos);
if (fluidState.isEmpty()) if (fluidState.isEmpty())
continue; continue;
@ -166,7 +164,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
if (offsetPos.distanceSq(rootPos) > maxRangeSq) if (offsetPos.distanceSq(rootPos) > maxRangeSq)
continue; continue;
IFluidState nextFluidState = world.getFluidState(offsetPos); FluidState nextFluidState = world.getFluidState(offsetPos);
if (nextFluidState.isEmpty()) if (nextFluidState.isEmpty())
continue; continue;
Fluid nextFluid = nextFluidState.getFluid(); Fluid nextFluid = nextFluidState.getFluid();

View File

@ -8,7 +8,7 @@ import com.simibubi.create.foundation.networking.SimplePacketBase;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
@ -37,8 +37,8 @@ public class FluidSplashPacket extends SimplePacketBase {
public void handle(Supplier<Context> ctx) { public void handle(Supplier<Context> ctx) {
ctx.get() ctx.get()
.enqueueWork(() -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { .enqueueWork(() -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
if (Minecraft.getInstance().player.getPositionVector() if (Minecraft.getInstance().player.getPositionVec()
.distanceTo(new Vec3d(pos)) > 100) .distanceTo(new Vector3d(pos.getX(), pos.getY(), pos.getZ())) > 100)
return; return;
FluidFX.splash(pos, fluid); FluidFX.splash(pos, fluid);
})); }));

View File

@ -8,6 +8,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.LerpedFloat; import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.ServerSpeedProvider; import com.simibubi.create.foundation.utility.ServerSpeedProvider;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -137,10 +138,10 @@ public class HosePulleyTileEntity extends KineticTileEntity {
} }
@Override @Override
protected void read(CompoundNBT compound, boolean clientPacket) { protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
offset.readNBT(compound.getCompound("Offset"), clientPacket); offset.readNBT(compound.getCompound("Offset"), clientPacket);
internalTank.readFromNBT(compound.getCompound("Tank")); internalTank.readFromNBT(compound.getCompound("Tank"));
super.read(compound, clientPacket); super.fromTag(state, compound, clientPacket);
} }
@Override @Override

View File

@ -97,8 +97,7 @@ public enum AllPackets {
public static void sendToNear(World world, BlockPos pos, int range, Object message) { public static void sendToNear(World world, BlockPos pos, int range, Object message) {
channel.send( channel.send(
PacketDistributor.NEAR.with(TargetPoint.p(pos.getX(), pos.getY(), pos.getZ(), range, world.getDimension() PacketDistributor.NEAR.with(TargetPoint.p(pos.getX(), pos.getY(), pos.getZ(), range, world.getRegistryKey())),
.getType())),
message); message);
} }