diff --git a/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlock.java b/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlock.java index 4926cb4b6..ba3937ded 100644 --- a/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlock.java +++ b/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlock.java @@ -10,6 +10,7 @@ import com.github.elenterius.biomancy.styles.TextStyles; import com.github.elenterius.biomancy.util.ComponentUtil; import com.github.elenterius.biomancy.util.SoundUtil; +import com.github.elenterius.biomancy.world.RegionManager; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; @@ -107,6 +108,16 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return ModBlockEntities.PRIMORDIAL_CRADLE.get().create(pos, state); } + @Override + public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) { + if (!state.is(newState.getBlock())) { + if (level instanceof ServerLevel serverLevel) { + RegionManager.remove(serverLevel, pos); //removes mound shape from level + } + super.onRemove(state, level, pos, newState, isMoving); + } + } + @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { diff --git a/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java b/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java index b8d152b03..67fe58c8d 100644 --- a/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java +++ b/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java @@ -79,27 +79,24 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Primo @Override public void onLoad() { super.onLoad(); - if (level instanceof ServerLevel serverLevel && !serverLevel.isClientSide) { + if (level instanceof ServerLevel serverLevel) { Shape shape = RegionManager.getOrCreateShapeRegion(serverLevel, worldPosition, () -> { if (procGenValues != null) { return MoundGenerator.constructShape(worldPosition, procGenValues); } return MoundGenerator.constructShape(level, worldPosition, level.random.nextLong()); }); + if (shape instanceof MoundShape moundShape) { - procGenValues = moundShape.getProcGenValues(); + MoundShape.ProcGenValues values = moundShape.getProcGenValues(); + if (!values.equals(procGenValues)) { + procGenValues = values; + setChangedSilent(); + } } } } - @Override - public void setRemoved() { - if (level instanceof ServerLevel serverLevel && !serverLevel.isClientSide) { - RegionManager.remove(serverLevel, worldPosition); - } - super.setRemoved(); - } - /** * modifies the stack */