diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 5fe449130..6056b8170 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -49,7 +49,7 @@ b59324f051f21d8ce1a48a08f4721a61a3c414d6 assets/create/blockstates/chute.json e5e3757e99c139d67b2a70288466d8a74d818841 assets/create/blockstates/cogwheel.json 36f54136a7756c97f71bc6b47ef4e8e575e72879 assets/create/blockstates/content_observer.json 7d11142092c89ccba3e74e0a3bdd0ccb446d63b5 assets/create/blockstates/controller_rail.json -f292ffa3bc036947b655c0a0ce26a91615c3d40b assets/create/blockstates/controls.json +641de13967ee1e2f3cc238eee4baa93b3324bb2f assets/create/blockstates/controls.json 961b615124ea9a5a5735e8a79f81a702de7da2cf assets/create/blockstates/copper_backtank.json cabf6b8c59eb0e3d56a0a5a856ca058bb3200882 assets/create/blockstates/copper_casing.json b3d0dee8f6e14fa6c637e98cc1c6f1ea55b5f0d5 assets/create/blockstates/copper_shingle_slab.json @@ -237,7 +237,7 @@ be3bef7e091d8b50bfc1c6b7275946d1f636aefd assets/create/blockstates/horizontal_fr 10ef455fd61ed1ca831d27bf2b533d05dec9c67d assets/create/blockstates/item_vault.json 5d851c90d23de5087ce546d4bbe509e112b84c49 assets/create/blockstates/jungle_window.json b15bea757ef981e0ca60f740ca234ee2014eb7b7 assets/create/blockstates/jungle_window_pane.json -f8982f0241f33b2cd55d6261ab6ee38cb83b6d8d assets/create/blockstates/large_bogey.json +a922b31bc4a91f5825b643ba5fa2c9a836d612cd assets/create/blockstates/large_bogey.json f651091db216b009b3379b2f48d56d03481c8675 assets/create/blockstates/large_cogwheel.json a38184e035c2ebca7471e1714494fea213af259e assets/create/blockstates/layered_andesite.json 2409f04042380a8ad086f9c4f98032e85771c3f3 assets/create/blockstates/layered_asurine.json @@ -423,7 +423,7 @@ e05f2e98984127aa6b601c4e4909e4c8207b5407 assets/create/blockstates/small_asurine 636028cb348cf9a0f060b4232cdb5dc4d26a4d40 assets/create/blockstates/small_asurine_brick_stairs.json d9b5e23652ca70b29a9142ff8f2efd33dfe74904 assets/create/blockstates/small_asurine_brick_wall.json 6fc5be0d465faa59aebe016d4ecb4d5284507bef assets/create/blockstates/small_asurine_bricks.json -f8982f0241f33b2cd55d6261ab6ee38cb83b6d8d assets/create/blockstates/small_bogey.json +a922b31bc4a91f5825b643ba5fa2c9a836d612cd assets/create/blockstates/small_bogey.json 2371c092ecbefa9a844889e0a471714d070569dd assets/create/blockstates/small_calcite_brick_slab.json 134ba0452fc721333177695882c8cef3cb7eca8e assets/create/blockstates/small_calcite_brick_stairs.json 7112ac7498acdd196b05af977e7e12cbab29df14 assets/create/blockstates/small_calcite_brick_wall.json @@ -487,7 +487,7 @@ f385988cb6fa9c48b5d59a6942ec50ed2b60c8bf assets/create/blockstates/stockpile_swi e815bfd854c2653f10828bb11950f7fb991d7efc assets/create/blockstates/stressometer.json 8b0c2c7ac72529565b3339aa8df7565858100afa assets/create/blockstates/tiled_glass.json a2454400b1cf9889f70aebdc89c52a1be25f543c assets/create/blockstates/tiled_glass_pane.json -a64fcf2bee9b49f1448d1ff691bd92d7590a59b0 assets/create/blockstates/track.json +96c45abe7a5d9273feaf5f747d14cee8e04b58da assets/create/blockstates/track.json 408ae1009ee8bb2f2b83753d5909c53744f7865f assets/create/blockstates/track_signal.json 60609cfbcc9be6f7e41fb493ef3147beb9750b60 assets/create/blockstates/track_station.json 29af21c8d82891139d48d69f0393f612f2b6f8f1 assets/create/blockstates/tuff_pillar.json diff --git a/src/generated/resources/assets/create/blockstates/controls.json b/src/generated/resources/assets/create/blockstates/controls.json index d1e6fccff..aaa070173 100644 --- a/src/generated/resources/assets/create/blockstates/controls.json +++ b/src/generated/resources/assets/create/blockstates/controls.json @@ -1,32 +1,62 @@ { "variants": { - "facing=north,open=false": { + "facing=north,open=false,waterlogged=false": { "model": "create:block/controls/block_closed" }, - "facing=south,open=false": { + "facing=south,open=false,waterlogged=false": { "model": "create:block/controls/block_closed", "y": 180 }, - "facing=west,open=false": { + "facing=west,open=false,waterlogged=false": { "model": "create:block/controls/block_closed", "y": 270 }, - "facing=east,open=false": { + "facing=east,open=false,waterlogged=false": { "model": "create:block/controls/block_closed", "y": 90 }, - "facing=north,open=true": { + "facing=north,open=true,waterlogged=false": { "model": "create:block/controls/block_open" }, - "facing=south,open=true": { + "facing=south,open=true,waterlogged=false": { "model": "create:block/controls/block_open", "y": 180 }, - "facing=west,open=true": { + "facing=west,open=true,waterlogged=false": { "model": "create:block/controls/block_open", "y": 270 }, - "facing=east,open=true": { + "facing=east,open=true,waterlogged=false": { + "model": "create:block/controls/block_open", + "y": 90 + }, + "facing=north,open=false,waterlogged=true": { + "model": "create:block/controls/block_closed" + }, + "facing=south,open=false,waterlogged=true": { + "model": "create:block/controls/block_closed", + "y": 180 + }, + "facing=west,open=false,waterlogged=true": { + "model": "create:block/controls/block_closed", + "y": 270 + }, + "facing=east,open=false,waterlogged=true": { + "model": "create:block/controls/block_closed", + "y": 90 + }, + "facing=north,open=true,waterlogged=true": { + "model": "create:block/controls/block_open" + }, + "facing=south,open=true,waterlogged=true": { + "model": "create:block/controls/block_open", + "y": 180 + }, + "facing=west,open=true,waterlogged=true": { + "model": "create:block/controls/block_open", + "y": 270 + }, + "facing=east,open=true,waterlogged=true": { "model": "create:block/controls/block_open", "y": 90 } diff --git a/src/generated/resources/assets/create/blockstates/large_bogey.json b/src/generated/resources/assets/create/blockstates/large_bogey.json index f78f19c47..64d662e09 100644 --- a/src/generated/resources/assets/create/blockstates/large_bogey.json +++ b/src/generated/resources/assets/create/blockstates/large_bogey.json @@ -1,10 +1,17 @@ { "variants": { - "axis=x": { + "axis=x,waterlogged=false": { "model": "create:block/track/bogey/top", "y": 90 }, - "axis=z": { + "axis=z,waterlogged=false": { + "model": "create:block/track/bogey/top" + }, + "axis=x,waterlogged=true": { + "model": "create:block/track/bogey/top", + "y": 90 + }, + "axis=z,waterlogged=true": { "model": "create:block/track/bogey/top" } } diff --git a/src/generated/resources/assets/create/blockstates/small_bogey.json b/src/generated/resources/assets/create/blockstates/small_bogey.json index f78f19c47..64d662e09 100644 --- a/src/generated/resources/assets/create/blockstates/small_bogey.json +++ b/src/generated/resources/assets/create/blockstates/small_bogey.json @@ -1,10 +1,17 @@ { "variants": { - "axis=x": { + "axis=x,waterlogged=false": { "model": "create:block/track/bogey/top", "y": 90 }, - "axis=z": { + "axis=z,waterlogged=false": { + "model": "create:block/track/bogey/top" + }, + "axis=x,waterlogged=true": { + "model": "create:block/track/bogey/top", + "y": 90 + }, + "axis=z,waterlogged=true": { "model": "create:block/track/bogey/top" } } diff --git a/src/generated/resources/assets/create/blockstates/track.json b/src/generated/resources/assets/create/blockstates/track.json index 904650424..c97222554 100644 --- a/src/generated/resources/assets/create/blockstates/track.json +++ b/src/generated/resources/assets/create/blockstates/track.json @@ -1,129 +1,255 @@ { "variants": { - "shape=none,turn=false": { + "shape=none,turn=false,waterlogged=false": { "model": "minecraft:block/air" }, - "shape=zo,turn=false": { + "shape=zo,turn=false,waterlogged=false": { "model": "create:block/track/z_ortho" }, - "shape=xo,turn=false": { + "shape=xo,turn=false,waterlogged=false": { "model": "create:block/track/x_ortho" }, - "shape=pd,turn=false": { + "shape=pd,turn=false,waterlogged=false": { "model": "create:block/track/diag" }, - "shape=nd,turn=false": { + "shape=nd,turn=false,waterlogged=false": { "model": "create:block/track/diag_2" }, - "shape=an,turn=false": { + "shape=an,turn=false,waterlogged=false": { "model": "create:block/track/ascending", "y": 180 }, - "shape=as,turn=false": { + "shape=as,turn=false,waterlogged=false": { "model": "create:block/track/ascending" }, - "shape=ae,turn=false": { + "shape=ae,turn=false,waterlogged=false": { "model": "create:block/track/ascending", "y": 270 }, - "shape=aw,turn=false": { + "shape=aw,turn=false,waterlogged=false": { "model": "create:block/track/ascending", "y": 90 }, - "shape=tn,turn=false": { + "shape=tn,turn=false,waterlogged=false": { "model": "create:block/track/teleport", "y": 180 }, - "shape=ts,turn=false": { + "shape=ts,turn=false,waterlogged=false": { "model": "create:block/track/teleport" }, - "shape=te,turn=false": { + "shape=te,turn=false,waterlogged=false": { "model": "create:block/track/teleport", "y": 270 }, - "shape=tw,turn=false": { + "shape=tw,turn=false,waterlogged=false": { "model": "create:block/track/teleport", "y": 90 }, - "shape=cr_o,turn=false": { + "shape=cr_o,turn=false,waterlogged=false": { "model": "create:block/track/cross_ortho" }, - "shape=cr_d,turn=false": { + "shape=cr_d,turn=false,waterlogged=false": { "model": "create:block/track/cross_diag" }, - "shape=cr_pdx,turn=false": { + "shape=cr_pdx,turn=false,waterlogged=false": { "model": "create:block/track/cross_d1_xo" }, - "shape=cr_pdz,turn=false": { + "shape=cr_pdz,turn=false,waterlogged=false": { "model": "create:block/track/cross_d1_zo" }, - "shape=cr_ndx,turn=false": { + "shape=cr_ndx,turn=false,waterlogged=false": { "model": "create:block/track/cross_d2_xo" }, - "shape=cr_ndz,turn=false": { + "shape=cr_ndz,turn=false,waterlogged=false": { "model": "create:block/track/cross_d2_zo" }, - "shape=none,turn=true": { + "shape=none,turn=true,waterlogged=false": { "model": "minecraft:block/air" }, - "shape=zo,turn=true": { + "shape=zo,turn=true,waterlogged=false": { "model": "create:block/track/z_ortho" }, - "shape=xo,turn=true": { + "shape=xo,turn=true,waterlogged=false": { "model": "create:block/track/x_ortho" }, - "shape=pd,turn=true": { + "shape=pd,turn=true,waterlogged=false": { "model": "create:block/track/diag" }, - "shape=nd,turn=true": { + "shape=nd,turn=true,waterlogged=false": { "model": "create:block/track/diag_2" }, - "shape=an,turn=true": { + "shape=an,turn=true,waterlogged=false": { "model": "create:block/track/ascending", "y": 180 }, - "shape=as,turn=true": { + "shape=as,turn=true,waterlogged=false": { "model": "create:block/track/ascending" }, - "shape=ae,turn=true": { + "shape=ae,turn=true,waterlogged=false": { "model": "create:block/track/ascending", "y": 270 }, - "shape=aw,turn=true": { + "shape=aw,turn=true,waterlogged=false": { "model": "create:block/track/ascending", "y": 90 }, - "shape=tn,turn=true": { + "shape=tn,turn=true,waterlogged=false": { "model": "create:block/track/teleport", "y": 180 }, - "shape=ts,turn=true": { + "shape=ts,turn=true,waterlogged=false": { "model": "create:block/track/teleport" }, - "shape=te,turn=true": { + "shape=te,turn=true,waterlogged=false": { "model": "create:block/track/teleport", "y": 270 }, - "shape=tw,turn=true": { + "shape=tw,turn=true,waterlogged=false": { "model": "create:block/track/teleport", "y": 90 }, - "shape=cr_o,turn=true": { + "shape=cr_o,turn=true,waterlogged=false": { "model": "create:block/track/cross_ortho" }, - "shape=cr_d,turn=true": { + "shape=cr_d,turn=true,waterlogged=false": { "model": "create:block/track/cross_diag" }, - "shape=cr_pdx,turn=true": { + "shape=cr_pdx,turn=true,waterlogged=false": { "model": "create:block/track/cross_d1_xo" }, - "shape=cr_pdz,turn=true": { + "shape=cr_pdz,turn=true,waterlogged=false": { "model": "create:block/track/cross_d1_zo" }, - "shape=cr_ndx,turn=true": { + "shape=cr_ndx,turn=true,waterlogged=false": { "model": "create:block/track/cross_d2_xo" }, - "shape=cr_ndz,turn=true": { + "shape=cr_ndz,turn=true,waterlogged=false": { + "model": "create:block/track/cross_d2_zo" + }, + "shape=none,turn=false,waterlogged=true": { + "model": "minecraft:block/air" + }, + "shape=zo,turn=false,waterlogged=true": { + "model": "create:block/track/z_ortho" + }, + "shape=xo,turn=false,waterlogged=true": { + "model": "create:block/track/x_ortho" + }, + "shape=pd,turn=false,waterlogged=true": { + "model": "create:block/track/diag" + }, + "shape=nd,turn=false,waterlogged=true": { + "model": "create:block/track/diag_2" + }, + "shape=an,turn=false,waterlogged=true": { + "model": "create:block/track/ascending", + "y": 180 + }, + "shape=as,turn=false,waterlogged=true": { + "model": "create:block/track/ascending" + }, + "shape=ae,turn=false,waterlogged=true": { + "model": "create:block/track/ascending", + "y": 270 + }, + "shape=aw,turn=false,waterlogged=true": { + "model": "create:block/track/ascending", + "y": 90 + }, + "shape=tn,turn=false,waterlogged=true": { + "model": "create:block/track/teleport", + "y": 180 + }, + "shape=ts,turn=false,waterlogged=true": { + "model": "create:block/track/teleport" + }, + "shape=te,turn=false,waterlogged=true": { + "model": "create:block/track/teleport", + "y": 270 + }, + "shape=tw,turn=false,waterlogged=true": { + "model": "create:block/track/teleport", + "y": 90 + }, + "shape=cr_o,turn=false,waterlogged=true": { + "model": "create:block/track/cross_ortho" + }, + "shape=cr_d,turn=false,waterlogged=true": { + "model": "create:block/track/cross_diag" + }, + "shape=cr_pdx,turn=false,waterlogged=true": { + "model": "create:block/track/cross_d1_xo" + }, + "shape=cr_pdz,turn=false,waterlogged=true": { + "model": "create:block/track/cross_d1_zo" + }, + "shape=cr_ndx,turn=false,waterlogged=true": { + "model": "create:block/track/cross_d2_xo" + }, + "shape=cr_ndz,turn=false,waterlogged=true": { + "model": "create:block/track/cross_d2_zo" + }, + "shape=none,turn=true,waterlogged=true": { + "model": "minecraft:block/air" + }, + "shape=zo,turn=true,waterlogged=true": { + "model": "create:block/track/z_ortho" + }, + "shape=xo,turn=true,waterlogged=true": { + "model": "create:block/track/x_ortho" + }, + "shape=pd,turn=true,waterlogged=true": { + "model": "create:block/track/diag" + }, + "shape=nd,turn=true,waterlogged=true": { + "model": "create:block/track/diag_2" + }, + "shape=an,turn=true,waterlogged=true": { + "model": "create:block/track/ascending", + "y": 180 + }, + "shape=as,turn=true,waterlogged=true": { + "model": "create:block/track/ascending" + }, + "shape=ae,turn=true,waterlogged=true": { + "model": "create:block/track/ascending", + "y": 270 + }, + "shape=aw,turn=true,waterlogged=true": { + "model": "create:block/track/ascending", + "y": 90 + }, + "shape=tn,turn=true,waterlogged=true": { + "model": "create:block/track/teleport", + "y": 180 + }, + "shape=ts,turn=true,waterlogged=true": { + "model": "create:block/track/teleport" + }, + "shape=te,turn=true,waterlogged=true": { + "model": "create:block/track/teleport", + "y": 270 + }, + "shape=tw,turn=true,waterlogged=true": { + "model": "create:block/track/teleport", + "y": 90 + }, + "shape=cr_o,turn=true,waterlogged=true": { + "model": "create:block/track/cross_ortho" + }, + "shape=cr_d,turn=true,waterlogged=true": { + "model": "create:block/track/cross_diag" + }, + "shape=cr_pdx,turn=true,waterlogged=true": { + "model": "create:block/track/cross_d1_xo" + }, + "shape=cr_pdz,turn=true,waterlogged=true": { + "model": "create:block/track/cross_d1_zo" + }, + "shape=cr_ndx,turn=true,waterlogged=true": { + "model": "create:block/track/cross_d2_xo" + }, + "shape=cr_ndz,turn=true,waterlogged=true": { "model": "create:block/track/cross_d2_zo" } } diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 8b05eb431..14d006c72 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -1438,9 +1438,9 @@ public class AllBlocks { .register(); public static final BlockEntry TRACK = REGISTRATE.block("track", TrackBlock::new) - .initialProperties(Material.DECORATION) - .properties(p -> p.color(MaterialColor.NONE)) - .properties(p -> p.strength(0.8F) + .initialProperties(Material.STONE) + .properties(p -> p.color(MaterialColor.NONE) + .strength(0.8F) .sound(SoundType.METAL) .noOcclusion()) .addLayer(() -> RenderType::cutoutMipped) @@ -1477,7 +1477,6 @@ public class AllBlocks { .initialProperties(SharedProperties::softMetal) .properties(p -> p.color(MaterialColor.PODZOL)) .properties(p -> p.sound(SoundType.NETHERITE_BLOCK)) - .properties(BlockBehaviour.Properties::noOcclusion) .transform(pickaxeOnly()) .blockstate((c, p) -> p.getVariantBuilder(c.get()) .forAllStates(state -> ConfiguredModel.builder() diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java index edb929582..83e2efb8d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java @@ -8,10 +8,12 @@ import javax.annotation.ParametersAreNonnullByDefault; import com.google.common.base.Optional; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.utility.BlockHelper; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -23,10 +25,14 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.AABB; @@ -37,7 +43,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class SeatBlock extends Block { +public class SeatBlock extends Block implements ProperWaterloggedBlock { protected final DyeColor color; protected final boolean inCreativeTab; @@ -46,6 +52,29 @@ public class SeatBlock extends Block { super(properties); this.color = color; this.inCreativeTab = inCreativeTab; + registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false)); + } + + @Override + protected void createBlockStateDefinition(Builder pBuilder) { + super.createBlockStateDefinition(pBuilder.add(WATERLOGGED)); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext pContext) { + return withWater(super.getStateForPlacement(pContext), pContext); + } + + @Override + public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState, + LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) { + updateWater(pLevel, pState, pCurrentPos); + return pState; + } + + @Override + public FluidState getFluidState(BlockState pState) { + return fluidState(pState); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsBlock.java index 8da8bca4b..80f2e3468 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsBlock.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.in import com.simibubi.create.AllShapes; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionWorld; import com.simibubi.create.content.contraptions.wrench.IWrenchable; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -15,32 +16,40 @@ import net.minecraft.world.level.block.HorizontalDirectionalBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -public class ControlsBlock extends HorizontalDirectionalBlock implements IWrenchable { +public class ControlsBlock extends HorizontalDirectionalBlock implements IWrenchable, ProperWaterloggedBlock { public static final BooleanProperty OPEN = BooleanProperty.create("open"); public ControlsBlock(Properties p_54120_) { super(p_54120_); - registerDefaultState(defaultBlockState().setValue(OPEN, false)); + registerDefaultState(defaultBlockState().setValue(OPEN, false) + .setValue(WATERLOGGED, false)); } @Override protected void createBlockStateDefinition(Builder pBuilder) { - super.createBlockStateDefinition(pBuilder.add(FACING, OPEN)); + super.createBlockStateDefinition(pBuilder.add(FACING, OPEN, WATERLOGGED)); } @Override public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState, LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) { + updateWater(pLevel, pState, pCurrentPos); return pState.setValue(OPEN, pLevel instanceof ContraptionWorld); } + + @Override + public FluidState getFluidState(BlockState pState) { + return fluidState(pState); + } @Override public BlockState getStateForPlacement(BlockPlaceContext pContext) { - BlockState state = super.getStateForPlacement(pContext); + BlockState state = withWater(super.getStateForPlacement(pContext), pContext); Direction horizontalDirection = pContext.getHorizontalDirection(); Player player = pContext.getPlayer(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java index c8cde9367..653f819f7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java @@ -45,6 +45,8 @@ import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.common.util.ForgeSoundType; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidAttributes; @@ -111,6 +113,16 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE ComparatorUtil.fractionToRedstoneLevel(te.getFillState())) .orElse(0); } - + public static void updateBoilerState(BlockState pState, Level pLevel, BlockPos tankPos) { BlockState tankState = pLevel.getBlockState(tankPos); if (!(tankState.getBlock() instanceof FluidTankBlock tank)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java index 47be6d5c1..a24d12d78 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.relays.elementary; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -12,16 +13,14 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SimpleWaterloggedBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.pathfinder.PathComputationType; public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock - implements ITE, SimpleWaterloggedBlock { + implements ITE, ProperWaterloggedBlock { public AbstractShaftBlock(Properties properties) { super(properties); @@ -50,30 +49,24 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock @Override public FluidState getFluidState(BlockState state) { - return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) - : Fluids.EMPTY.defaultFluidState(); + return fluidState(state); } @Override protected void createBlockStateDefinition(Builder builder) { - builder.add(BlockStateProperties.WATERLOGGED); - super.createBlockStateDefinition(builder); + super.createBlockStateDefinition(builder.add(BlockStateProperties.WATERLOGGED)); } @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { - if (state.getValue(BlockStateProperties.WATERLOGGED)) - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + updateWater(world, state, pos); return state; } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { - FluidState ifluidstate = context.getLevel() - .getFluidState(context.getClickedPos()); - return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, - Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)); + return withWater(super.getStateForPlacement(context), context); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/IBogeyBlock.java b/src/main/java/com/simibubi/create/content/logistics/trains/IBogeyBlock.java index 4959593c9..b71df10de 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/IBogeyBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/IBogeyBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.logistics.trains; +import static net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED; + import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @@ -75,7 +77,9 @@ public interface IBogeyBlock extends IWrenchable { if (newBlock instanceof IBogeyBlock bogey) { BlockState matchingBogey = bogey.getMatchingBogey(bogeyUpDirection, trackAxisAlongFirstCoordinate); if (matchingBogey != null) - return matchingBogey; + return matchingBogey.hasProperty(WATERLOGGED) + ? matchingBogey.setValue(WATERLOGGED, state.getValue(WATERLOGGED)) + : matchingBogey; } index = (index + 1) % BOGEYS.size(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/AbstractStationScreen.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/AbstractStationScreen.java index 3e80a5fe2..104f74c1f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/AbstractStationScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/AbstractStationScreen.java @@ -17,6 +17,7 @@ import com.simibubi.create.foundation.gui.element.GuiGameElement; import com.simibubi.create.foundation.gui.widget.IconButton; import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; public abstract class AbstractStationScreen extends AbstractSimiScreen { @@ -65,7 +66,7 @@ public abstract class AbstractStationScreen extends AbstractSimiScreen { Carriage carriage = carriages.get(i); w += icon.getIconWidth(carriage.bogeySpacing) + 1; } - + return w; } @@ -83,11 +84,12 @@ public abstract class AbstractStationScreen extends AbstractSimiScreen { .scale(40) .rotateX(-22) .rotateY(63); - GuiGameElement.of(te.getBlockState()) + GuiGameElement.of(te.getBlockState() + .setValue(BlockStateProperties.WATERLOGGED, false)) .render(ms); if (te.resolveFlagAngle()) { - msr.translate(1 / 16f, -9 / 16f, -11 / 16f); + msr.translate(1 / 16f, -19 / 16f, -12 / 16f); StationRenderer.transformFlag(msr, te, partialTicks, 180, false); GuiGameElement.of(getFlag(partialTicks)) .render(ms); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationBlock.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationBlock.java index 8bd96a7cc..f6c5b8480 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationBlock.java @@ -7,10 +7,12 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.content.logistics.block.depot.SharedDepotBlockMethods; import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.gui.ScreenOpener; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -18,13 +20,16 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; @@ -33,18 +38,36 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; -public class StationBlock extends Block implements ITE, IWrenchable { +public class StationBlock extends Block implements ITE, IWrenchable, ProperWaterloggedBlock { public static final BooleanProperty ASSEMBLING = BooleanProperty.create("assembling"); public StationBlock(Properties p_54120_) { super(p_54120_); - registerDefaultState(defaultBlockState().setValue(ASSEMBLING, false)); + registerDefaultState(defaultBlockState().setValue(ASSEMBLING, false) + .setValue(WATERLOGGED, false)); } @Override protected void createBlockStateDefinition(Builder pBuilder) { - super.createBlockStateDefinition(pBuilder.add(ASSEMBLING)); + super.createBlockStateDefinition(pBuilder.add(ASSEMBLING, WATERLOGGED)); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext pContext) { + return withWater(super.getStateForPlacement(pContext), pContext); + } + + @Override + public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState, + LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) { + updateWater(pLevel, pState, pCurrentPos); + return pState; + } + + @Override + public FluidState getFluidState(BlockState pState) { + return fluidState(pState); } @Override @@ -74,7 +97,7 @@ public class StationBlock extends Block implements ITE, IWren super.updateEntityAfterFallOn(worldIn, entityIn); SharedDepotBlockMethods.onLanded(worldIn, entityIn); } - + @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationTileEntity.java index 32ea101f7..a1cc87a0f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationTileEntity.java @@ -37,6 +37,7 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgePoi import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour; import com.simibubi.create.content.logistics.trains.management.schedule.Schedule; import com.simibubi.create.content.logistics.trains.management.schedule.ScheduleItem; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; @@ -251,7 +252,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable BlockPos bogeyPos = pos.relative(assemblyDirection, i) .offset(up); BlockState blockState = level.getBlockState(bogeyPos); - if (blockState.getBlock()instanceof IBogeyBlock bogey) { + if (blockState.getBlock() instanceof IBogeyBlock bogey) { level.setBlock(bogeyPos, bogey.getRotatedBlockState(blockState, Direction.DOWN), 3); bogey.playRotateSound(level, bogeyPos); return true; @@ -267,21 +268,21 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable return false; } - BlockState bogeyAnchor = track.getBogeyAnchor(level, pos, state); + BlockState bogeyAnchor = ProperWaterloggedBlock.withWater(level, track.getBogeyAnchor(level, pos, state), pos); level.setBlock(pos.offset(up), bogeyAnchor, 3); player.displayClientMessage(Lang.translate("train_assembly.bogey_created"), true); SoundType soundtype = bogeyAnchor.getBlock() .getSoundType(state, level, pos, player); level.playSound(null, pos, soundtype.getPlaceSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); - + if (!player.isCreative()) { ItemStack itemInHand = player.getItemInHand(hand); itemInHand.shrink(1); if (itemInHand.isEmpty()) player.setItemInHand(hand, ItemStack.EMPTY); } - + return true; } @@ -354,7 +355,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable } BlockState potentialBogeyState = level.getBlockState(bogeyOffset.offset(currentPos)); - if (potentialBogeyState.getBlock()instanceof IBogeyBlock bogey && bogeyIndex < bogeyLocations.length) { + if (potentialBogeyState.getBlock() instanceof IBogeyBlock bogey && bogeyIndex < bogeyLocations.length) { bogeyTypes[bogeyIndex] = bogey; bogeyLocations[bogeyIndex] = i; bogeyIndex++; @@ -677,7 +678,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable return true; BlockState target = edgePoint.getTrackBlockState(); - if (!(target.getBlock()instanceof ITrackBlock def)) + if (!(target.getBlock() instanceof ITrackBlock def)) return false; Vec3 axis = null; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleEditPacket.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleEditPacket.java index ddd6537a2..c609feeca 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleEditPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleEditPacket.java @@ -5,6 +5,7 @@ import java.util.function.Supplier; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.networking.SimplePacketBase; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; @@ -36,8 +37,15 @@ public class ScheduleEditPacket extends SimplePacketBase { ItemStack mainHandItem = sender.getMainHandItem(); if (!AllItems.SCHEDULE.isIn(mainHandItem)) return; - mainHandItem.getOrCreateTag() - .put("Schedule", schedule.write()); + + CompoundTag tag = mainHandItem.getOrCreateTag(); + if (schedule.entries.isEmpty()) { + tag.remove("Schedule"); + if (tag.isEmpty()) + mainHandItem.setTag(null); + } else + tag.put("Schedule", schedule.write()); + sender.getCooldowns() .addCooldown(mainHandItem.getItem(), 5); }); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java index 2ef47f778..76a8bb429 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java @@ -14,6 +14,7 @@ import com.simibubi.create.content.logistics.trains.IBogeyBlock; import com.simibubi.create.content.logistics.trains.entity.BogeyInstance; import com.simibubi.create.content.logistics.trains.entity.CarriageBogey; import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; @@ -26,6 +27,7 @@ import net.minecraft.core.Direction.Axis; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Rotation; @@ -34,12 +36,14 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class StandardBogeyBlock extends Block implements IBogeyBlock, ITE { +public class StandardBogeyBlock extends Block + implements IBogeyBlock, ITE, ProperWaterloggedBlock { public static final EnumProperty AXIS = BlockStateProperties.HORIZONTAL_AXIS; private final boolean large; @@ -47,11 +51,12 @@ public class StandardBogeyBlock extends Block implements IBogeyBlock, ITE builder) { - builder.add(AXIS); + builder.add(AXIS, WATERLOGGED); super.createBlockStateDefinition(builder); } @@ -63,6 +68,18 @@ public class StandardBogeyBlock extends Block implements IBogeyBlock, ITE SHAPE = EnumProperty.create("shape", TrackShape.class); public static final BooleanProperty HAS_TE = BooleanProperty.create("turn"); @@ -106,12 +109,18 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac public TrackBlock(Properties p_49795_) { super(p_49795_); registerDefaultState(defaultBlockState().setValue(SHAPE, TrackShape.ZO) - .setValue(HAS_TE, false)); + .setValue(HAS_TE, false) + .setValue(WATERLOGGED, false)); } @Override protected void createBlockStateDefinition(Builder p_49915_) { - super.createBlockStateDefinition(p_49915_.add(SHAPE, HAS_TE)); + super.createBlockStateDefinition(p_49915_.add(SHAPE, HAS_TE, WATERLOGGED)); + } + + @Override + public FluidState getFluidState(BlockState state) { + return fluidState(state); } @OnlyIn(Dist.CLIENT) @@ -121,7 +130,8 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac @Override public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState stateForPlacement = super.getStateForPlacement(ctx); + BlockState stateForPlacement = withWater(super.getStateForPlacement(ctx), ctx); + if (ctx.getPlayer() == null) return stateForPlacement; @@ -298,6 +308,7 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac @Override public BlockState updateShape(BlockState state, Direction pDirection, BlockState pNeighborState, LevelAccessor level, BlockPos pCurrentPos, BlockPos pNeighborPos) { + updateWater(level, state, pCurrentPos); TrackShape shape = state.getValue(SHAPE); if (!shape.isPortal()) return state; @@ -424,7 +435,7 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac if (!entry.getValue() .isInside(pos)) continue; - if (world.getBlockEntity(entry.getKey())instanceof StationTileEntity station) + if (world.getBlockEntity(entry.getKey()) instanceof StationTileEntity station) if (station.trackClicked(player, hand, this, state, pos)) return InteractionResult.SUCCESS; } @@ -440,7 +451,7 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac BlockPos girderPos = pPos.below() .offset(vec3.z * side, 0, vec3.x * side); BlockState girderState = pLevel.getBlockState(girderPos); - if (girderState.getBlock()instanceof GirderBlock girderBlock + if (girderState.getBlock() instanceof GirderBlock girderBlock && !blockTicks.hasScheduledTick(girderPos, girderBlock)) pLevel.scheduleTick(girderPos, girderBlock, 1); } @@ -635,7 +646,7 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac Vec3 normal = null; Vec3 offset = null; - if (bezierPoint != null && world.getBlockEntity(pos)instanceof TrackTileEntity trackTE) { + if (bezierPoint != null && world.getBlockEntity(pos) instanceof TrackTileEntity trackTE) { BezierConnection bc = trackTE.connections.get(bezierPoint.curveTarget()); if (bc != null) { double length = Mth.floor(bc.getLength() * 2); @@ -698,7 +709,8 @@ public class TrackBlock extends Block implements EntityBlock, IWrenchable, ITrac int girderAmount = 0; if (te instanceof TrackTileEntity track) { - for (BezierConnection bezierConnection : track.getConnections().values()) { + for (BezierConnection bezierConnection : track.getConnections() + .values()) { if (!bezierConnection.isPrimary()) continue; trackAmount += bezierConnection.getTrackItemCost(); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPaver.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPaver.java index 5fb7a96ef..717a9401e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPaver.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPaver.java @@ -9,6 +9,7 @@ import java.util.Set; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.curiosities.girder.GirderBlock; import com.simibubi.create.content.logistics.trains.BezierConnection; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; @@ -182,7 +183,7 @@ public class TrackPaver { if (stateAtPos.getBlock() != state.getBlock() && stateAtPos.getMaterial() .isReplaceable()) { if (!simulate) - level.setBlock(pos, state, 3); + level.setBlock(pos, ProperWaterloggedBlock.withWater(level, state, pos), 3); return true; } return false; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPlacement.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPlacement.java index beee442b3..dddf75263 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPlacement.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackPlacement.java @@ -13,6 +13,7 @@ import com.simibubi.create.CreateClient; import com.simibubi.create.content.curiosities.tools.BlueprintOverlayRenderer; import com.simibubi.create.content.logistics.trains.BezierConnection; import com.simibubi.create.content.logistics.trains.ITrackBlock; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; @@ -504,7 +505,7 @@ public class TrackPlacement { } if (canPlace) - level.setBlock(offsetPos, toPlace, 3); + level.setBlock(offsetPos, ProperWaterloggedBlock.withWater(level, toPlace, offsetPos), 3); } } @@ -513,14 +514,14 @@ public class TrackPlacement { if (!simulate) { BlockState stateAtPos = level.getBlockState(targetPos1); - level.setBlock(targetPos1, + level.setBlock(targetPos1, ProperWaterloggedBlock.withWater(level, (stateAtPos.getBlock() == state1.getBlock() ? stateAtPos : state1).setValue(TrackBlock.HAS_TE, true), - 3); + targetPos1), 3); stateAtPos = level.getBlockState(targetPos2); - level.setBlock(targetPos2, + level.setBlock(targetPos2, ProperWaterloggedBlock.withWater(level, (stateAtPos.getBlock() == state2.getBlock() ? stateAtPos : state2).setValue(TrackBlock.HAS_TE, true), - 3); + targetPos2), 3); } BlockEntity te1 = level.getBlockEntity(targetPos1); diff --git a/src/main/java/com/simibubi/create/foundation/block/ProperWaterloggedBlock.java b/src/main/java/com/simibubi/create/foundation/block/ProperWaterloggedBlock.java new file mode 100644 index 000000000..e6d98c12d --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/block/ProperWaterloggedBlock.java @@ -0,0 +1,48 @@ +package com.simibubi.create.foundation.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +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.BooleanProperty; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; + +/** + * Waterlog checklist:
+ * 1. createBlockStateDefinition -> add WATERLOGGED
+ * 2. constructor -> default WATERLOGGED to false
+ * 3. getFluidState -> return fluidState
+ * 4. getStateForPlacement -> call withWater
+ * 5. updateShape -> call updateWater + */ +public interface ProperWaterloggedBlock extends SimpleWaterloggedBlock { + + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + default FluidState fluidState(BlockState state) { + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); + } + + default void updateWater(LevelAccessor level, BlockState state, BlockPos pos) { + if (state.getValue(BlockStateProperties.WATERLOGGED)) + level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + + default BlockState withWater(BlockState placementState, BlockPlaceContext ctx) { + return withWater(ctx.getLevel(), placementState, ctx.getClickedPos()); + } + + public static BlockState withWater(LevelAccessor level, BlockState placementState, BlockPos pos) { + if (placementState == null) + return null; + if (!(placementState.getBlock() instanceof SimpleWaterloggedBlock)) + return null; + FluidState ifluidstate = level.getFluidState(pos); + return placementState.setValue(BlockStateProperties.WATERLOGGED, + Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)); + } + +}