Skip to content

Commit

Permalink
fix dupe with turbine
Browse files Browse the repository at this point in the history
  • Loading branch information
skiprocks999 committed Dec 17, 2023
1 parent 8528430 commit 5b1534a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
26 changes: 3 additions & 23 deletions src/main/java/nuclearscience/common/block/BlockTurbine.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

public class BlockTurbine extends GenericEntityBlockWaterloggable {

private static final VoxelShape SHAPE = Shapes.or(Block.box(1.25, 2.5, 6, 14.75, 13.5, 10), Block.box(6, 2.5, 1.25, 10, 13.5, 14.75), Block.box(2, 2.5, 4, 14, 13.5, 12), Block.box(4, 2.5, 2, 12, 13.5, 14), Block.box(3, 2.5, 3, 13, 13.5, 13), Block.box(4.65, 0.75, 4.65, 11.35, 2.5, 11.35), Block.box(4.3, 13.5, 4.3, 11.7, 15, 11.7), Block.box(5.7, 15, 5.7, 10.3, 16, 10.3));

public static final BooleanProperty RENDER = BooleanProperty.create("render");

public BlockTurbine() {
Expand Down Expand Up @@ -54,17 +56,6 @@ public void onRotate(ItemStack stack, BlockPos pos, Player player) {
}
}

@Override
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (state.getBlock() != newState.getBlock() && !worldIn.isClientSide) {
TileTurbine turbine = (TileTurbine) worldIn.getBlockEntity(pos);
if (turbine != null) {
turbine.deconstructStructure();
}
}
super.onRemove(state, worldIn, pos, newState, isMoving);
}

@Override
public RenderShape getRenderShape(BlockState state) {
if (!state.getValue(RENDER)) {
Expand Down Expand Up @@ -101,18 +92,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
if (state.getValue(RENDER)) {
VoxelShape turbine = Block.box(1.25, 2.5, 6, 14.75, 13.5, 10);
turbine = Shapes.or(turbine, Block.box(6, 2.5, 1.25, 10, 13.5, 14.75));

turbine = Shapes.or(turbine, Block.box(2, 2.5, 4, 14, 13.5, 12));
turbine = Shapes.or(turbine, Block.box(4, 2.5, 2, 12, 13.5, 14));
turbine = Shapes.or(turbine, Block.box(3, 2.5, 3, 13, 13.5, 13));

turbine = Shapes.or(turbine, Block.box(4.65, 0.75, 4.65, 11.35, 2.5, 11.35));
turbine = Shapes.or(turbine, Block.box(4.3, 13.5, 4.3, 11.7, 15, 11.7));
turbine = Shapes.or(turbine, Block.box(5.7, 15, 5.7, 10.3, 16, 10.3));

return turbine;
return SHAPE;
}

return Shapes.block();
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/nuclearscience/common/tile/TileTurbine.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class TileTurbine extends GenericTile implements ITickableSound, ISteamRe

private boolean isSoundPlaying = false;

private boolean destroyed = false;

@Override
public AABB getRenderBoundingBox() {
return isCore.get() ? super.getRenderBoundingBox().inflate(1, 0, 1) : super.getRenderBoundingBox();
Expand Down Expand Up @@ -99,7 +101,7 @@ public void deconstructStructure() {
hasCore.set(false);
coreLocation.set(TileQuarry.OUT_OF_REACH);
BlockState state = getBlockState();
if (state.hasProperty(BlockTurbine.RENDER)) {
if (state.hasProperty(BlockTurbine.RENDER) && !destroyed) {
level.setBlockAndUpdate(worldPosition, getBlockState().setValue(BlockTurbine.RENDER, true));
}
} else if (hasCore.get()) {
Expand Down Expand Up @@ -192,4 +194,15 @@ public double receiveSteam(double temperature, double amount) {
public boolean isStillValid() {
return isRemoved();
}

@Override
public void onBlockDestroyed() {
super.onBlockDestroyed();
if (level.isClientSide) {
return;
}
destroyed = true;
deconstructStructure();

}
}

0 comments on commit 5b1534a

Please sign in to comment.