diff --git a/src/main/java/gregtech/api/pipenet/block/BlockPipe.java b/src/main/java/gregtech/api/pipenet/block/BlockPipe.java index 667b67fcf52..119075cd5ee 100644 --- a/src/main/java/gregtech/api/pipenet/block/BlockPipe.java +++ b/src/main/java/gregtech/api/pipenet/block/BlockPipe.java @@ -564,9 +564,9 @@ public BlockFaceShape getBlockFaceShape(@NotNull IBlockAccess worldIn, @NotNull } @Override - public boolean recolorBlock(World world, @NotNull BlockPos pos, @NotNull EnumFacing side, + public boolean recolorBlock(@NotNull World world, @NotNull BlockPos pos, @NotNull EnumFacing side, @NotNull EnumDyeColor color) { - IPipeTile tileEntityPipe = (IPipeTile) world.getTileEntity(pos); + IPipeTile tileEntityPipe = getPipeTileEntity(world, pos); if (tileEntityPipe != null && tileEntityPipe.getPipeType() != null && tileEntityPipe.getPipeType().isPaintable() && tileEntityPipe.getPaintingColor() != color.colorValue) { @@ -588,6 +588,7 @@ public IPipeTile getPipeTileEntity(IBlockAccess world, B return getPipeTileEntity(tileEntityAtPos); } + @Nullable public IPipeTile getPipeTileEntity(TileEntity tileEntityAtPos) { if (tileEntityAtPos instanceof IPipeTile && isThisPipeBlock(((IPipeTile) tileEntityAtPos).getPipeBlock())) { diff --git a/src/main/java/gregtech/common/pipelike/cable/BlockCable.java b/src/main/java/gregtech/common/pipelike/cable/BlockCable.java index 204010ed522..98be62d35b1 100644 --- a/src/main/java/gregtech/common/pipelike/cable/BlockCable.java +++ b/src/main/java/gregtech/common/pipelike/cable/BlockCable.java @@ -114,8 +114,7 @@ protected boolean isPipeTool(@NotNull ItemStack stack) { @Override public int getLightValue(@NotNull IBlockState state, IBlockAccess world, @NotNull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityCable) { - TileEntityCable cable = (TileEntityCable) tile; + if (tile instanceof TileEntityCable cable) { int temp = cable.getTemperature(); // max light at 5000 K // min light at 500 K @@ -132,7 +131,9 @@ public int getLightValue(@NotNull IBlockState state, IBlockAccess world, @NotNul @Override public void breakBlock(@NotNull World worldIn, @NotNull BlockPos pos, @NotNull IBlockState state) { if (worldIn.isRemote) { - TileEntityCable cable = (TileEntityCable) getPipeTileEntity(worldIn, pos); + IPipeTile pipeTile = getPipeTileEntity(worldIn, pos); + if (pipeTile == null) return; + TileEntityCable cable = (TileEntityCable) pipeTile; cable.killParticle(); } super.breakBlock(worldIn, pos, state); @@ -165,11 +166,12 @@ public void onEntityCollision(World worldIn, @NotNull BlockPos pos, @NotNull IBl @NotNull Entity entityIn) { super.onEntityCollision(worldIn, pos, state, entityIn); if (worldIn.isRemote) return; - Insulation insulation = getPipeTileEntity(worldIn, pos).getPipeType(); - if (insulation.insulationLevel == -1 && entityIn instanceof EntityLivingBase) { - EntityLivingBase entityLiving = (EntityLivingBase) entityIn; - TileEntityCable cable = (TileEntityCable) getPipeTileEntity(worldIn, pos); - if (cable != null && cable.getFrameMaterial() == null && cable.getNodeData().getLossPerBlock() > 0) { + IPipeTile pipeTile = getPipeTileEntity(worldIn, pos); + if (pipeTile == null) return; + Insulation insulation = pipeTile.getPipeType(); + if (insulation.insulationLevel == -1 && entityIn instanceof EntityLivingBase entityLiving) { + TileEntityCable cable = (TileEntityCable) pipeTile; + if (cable.getFrameMaterial() == null && cable.getNodeData().getLossPerBlock() > 0) { long voltage = cable.getCurrentMaxVoltage(); double amperage = cable.getAverageAmperage(); if (voltage > 0L && amperage > 0L) { diff --git a/src/main/java/gregtech/common/pipelike/fluidpipe/BlockFluidPipe.java b/src/main/java/gregtech/common/pipelike/fluidpipe/BlockFluidPipe.java index 20ac0640a0f..d94dc304bdf 100644 --- a/src/main/java/gregtech/common/pipelike/fluidpipe/BlockFluidPipe.java +++ b/src/main/java/gregtech/common/pipelike/fluidpipe/BlockFluidPipe.java @@ -131,7 +131,9 @@ public void onEntityCollision(@NotNull World worldIn, @NotNull BlockPos pos, @No @NotNull Entity entityIn) { super.onEntityCollision(worldIn, pos, state, entityIn); if (worldIn.isRemote) return; - TileEntityFluidPipe pipe = (TileEntityFluidPipe) getPipeTileEntity(worldIn, pos); + IPipeTile pipeTile = getPipeTileEntity(worldIn, pos); + if (pipeTile == null) return; + TileEntityFluidPipe pipe = (TileEntityFluidPipe) pipeTile; if (pipe instanceof TileEntityFluidPipeTickable && pipe.getFrameMaterial() == null && ((TileEntityFluidPipeTickable) pipe).getOffsetTimer() % 10 == 0) { if (entityIn instanceof EntityLivingBase) {