Skip to content

Commit

Permalink
Improved Laputa shard double plant block handling
Browse files Browse the repository at this point in the history
Mostly fixes #2128, in that both parts of 2-block plants (and doors) are transported when the lower half is supposed to be moved. Some blocks (single and double) that need support may still not survive neighboring blocks being placed later, but the result should still be a lot more consistent.
  • Loading branch information
TheRealWormbo committed Jun 5, 2024
1 parent 2e7ccf3 commit aef4f44
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.HitResult;

Expand Down Expand Up @@ -138,6 +139,9 @@ private static boolean canMove(BlockState state, Level world, BlockPos pos) {
return !state.isAir()
&& !isFlowingFluid
&& !(block instanceof FallingBlock)
&& (!state.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF)
|| state.is(BotaniaTags.Blocks.LAPUTA_NO_DOUBLE_BLOCK)
|| state.getValue(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.LOWER)
&& !state.is(BotaniaTags.Blocks.LAPUTA_IMMOBILE)
&& state.getDestroySpeed(world, pos) != -1;
}
Expand Down Expand Up @@ -301,6 +305,14 @@ public void updateBurst(ManaBurst burst, ItemStack stack) {
tile = BlockEntity.loadStatic(pos, placeState, tilecmp);
}

if (placeState.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF)
&& !placeState.is(BotaniaTags.Blocks.LAPUTA_NO_DOUBLE_BLOCK)
&& placeState.getValue(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.LOWER) {
// place upper half, which was previously broken implicitly when the bottom was picked up
entity.level().setBlock(pos.above(),
placeState.setValue(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.UPPER),
Block.UPDATE_CLIENTS);
}
entity.level().setBlockAndUpdate(pos, placeState);
entity.level().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(placeState));
if (tile != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ public static class Blocks {
* Blocks in this tag cannot be moved by the Laputa Shard
*/
public static final TagKey<Block> LAPUTA_IMMOBILE = tag("laputa_immobile");
/**
* Blocks in this tag should not be treated like a 2-high double block by the Laputa Shard, even though they
* have the {@link net.minecraft.world.level.block.state.properties.BlockStateProperties#DOUBLE_BLOCK_HALF}
* property.
*/
public static final TagKey<Block> LAPUTA_NO_DOUBLE_BLOCK = tag("laputa_no_double_block");

/**
* Blocks in this tag can be removed by the Rod of Terra Firma
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ protected void addTags(HolderLookup.Provider provider) {
tag(BotaniaTags.Blocks.MAGNET_RING_BLACKLIST).add(BotaniaBlocks.manaPool, BotaniaBlocks.creativePool, BotaniaBlocks.dilutedPool,
BotaniaBlocks.fabulousPool, BotaniaBlocks.terraPlate, BotaniaBlocks.runeAltar);
tag(BotaniaTags.Blocks.LAPUTA_IMMOBILE);
tag(BotaniaTags.Blocks.LAPUTA_NO_DOUBLE_BLOCK);

tag(BotaniaTags.Blocks.TERRA_PLATE_BASE).add(BotaniaBlocks.livingrock, BotaniaBlocks.shimmerrock);

Expand Down

0 comments on commit aef4f44

Please sign in to comment.