diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index e86c6bfd..6f867deb 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -11,10 +11,12 @@ import com.minelittlepony.unicopia.block.cloud.CloudStairsBlock; import com.minelittlepony.unicopia.block.cloud.CompactedCloudBlock; import com.minelittlepony.unicopia.block.cloud.NaturalCloudBlock; import com.minelittlepony.unicopia.block.cloud.OrientedCloudBlock; +import com.minelittlepony.unicopia.block.cloud.PoreousCloudStairsBlock; import com.minelittlepony.unicopia.block.cloud.CloudBedBlock; import com.minelittlepony.unicopia.block.cloud.CloudBlock; import com.minelittlepony.unicopia.block.cloud.SoggyCloudBlock; import com.minelittlepony.unicopia.block.cloud.SoggyCloudSlabBlock; +import com.minelittlepony.unicopia.block.cloud.SoggyCloudStairsBlock; import com.minelittlepony.unicopia.block.cloud.UnstableCloudBlock; import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.cloud.CloudBlockItem; @@ -147,29 +149,29 @@ public interface UBlocks { () -> UBlocks.COMPACTED_CLOUD), ItemGroups.NATURAL); Block COMPACTED_CLOUD = register("compacted_cloud", new CompactedCloudBlock(Settings.copy(CLOUD))); Block CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock(Settings.copy(CLOUD), true, () -> UBlocks.SOGGY_CLOUD_SLAB), ItemGroups.NATURAL); - Block CLOUD_STAIRS = register("cloud_stairs", new CloudStairsBlock(CLOUD.getDefaultState(), Settings.copy(CLOUD), () -> UBlocks.SOGGY_CLOUD_STAIRS), ItemGroups.NATURAL); + PoreousCloudStairsBlock CLOUD_STAIRS = register("cloud_stairs", new PoreousCloudStairsBlock(CLOUD.getDefaultState(), Settings.copy(CLOUD), () -> UBlocks.SOGGY_CLOUD_STAIRS), ItemGroups.NATURAL); Block CLOUD_PLANKS = register("cloud_planks", new NaturalCloudBlock(Settings.copy(CLOUD).hardness(0.4F).requiresTool(), false, null, () -> UBlocks.COMPACTED_CLOUD_PLANKS), ItemGroups.BUILDING_BLOCKS); Block COMPACTED_CLOUD_PLANKS = register("compacted_cloud_planks", new CompactedCloudBlock(Settings.copy(CLOUD_PLANKS))); Block CLOUD_PLANK_SLAB = register("cloud_plank_slab", new CloudSlabBlock(Settings.copy(CLOUD_PLANKS), false, null), ItemGroups.BUILDING_BLOCKS); - Block CLOUD_PLANK_STAIRS = register("cloud_plank_stairs", new CloudStairsBlock(CLOUD_PLANKS.getDefaultState(), Settings.copy(CLOUD_PLANKS), null), ItemGroups.BUILDING_BLOCKS); + Block CLOUD_PLANK_STAIRS = register("cloud_plank_stairs", new CloudStairsBlock(CLOUD_PLANKS.getDefaultState(), Settings.copy(CLOUD_PLANKS)), ItemGroups.BUILDING_BLOCKS); Block CLOUD_BRICKS = register("cloud_bricks", new NaturalCloudBlock(Settings.copy(CLOUD).hardness(0.6F).requiresTool(), false, null, () -> UBlocks.COMPACTED_CLOUD_BRICKS), ItemGroups.BUILDING_BLOCKS); Block COMPACTED_CLOUD_BRICKS = register("compacted_cloud_bricks", new CompactedCloudBlock(Settings.copy(CLOUD_BRICKS))); Block CLOUD_BRICK_SLAB = register("cloud_brick_slab", new CloudSlabBlock(Settings.copy(CLOUD_BRICKS), false, null), ItemGroups.BUILDING_BLOCKS); - Block CLOUD_BRICK_STAIRS = register("cloud_brick_stairs", new CloudStairsBlock(CLOUD_BRICKS.getDefaultState(), Settings.copy(CLOUD_PLANKS), null), ItemGroups.BUILDING_BLOCKS); + Block CLOUD_BRICK_STAIRS = register("cloud_brick_stairs", new CloudStairsBlock(CLOUD_BRICKS.getDefaultState(), Settings.copy(CLOUD_PLANKS)), ItemGroups.BUILDING_BLOCKS); SoggyCloudBlock SOGGY_CLOUD = register("soggy_cloud", new SoggyCloudBlock(Settings.copy(CLOUD).hardness(0.7F), () -> UBlocks.CLOUD)); SoggyCloudSlabBlock SOGGY_CLOUD_SLAB = register("soggy_cloud_slab", new SoggyCloudSlabBlock(Settings.copy(SOGGY_CLOUD), () -> UBlocks.CLOUD_SLAB)); - CloudStairsBlock SOGGY_CLOUD_STAIRS = register("soggy_cloud_stairs", new CloudStairsBlock(SOGGY_CLOUD.getDefaultState(), Settings.copy(CLOUD), null)); + SoggyCloudStairsBlock SOGGY_CLOUD_STAIRS = register("soggy_cloud_stairs", new SoggyCloudStairsBlock(SOGGY_CLOUD.getDefaultState(), Settings.copy(CLOUD), () -> UBlocks.CLOUD_STAIRS)); Block DENSE_CLOUD = register("dense_cloud", new CloudBlock(Settings.create().mapColor(MapColor.GRAY).hardness(0.5F).resistance(0).sounds(BlockSoundGroup.WOOL), false), ItemGroups.NATURAL); Block DENSE_CLOUD_SLAB = register("dense_cloud_slab", new CloudSlabBlock(Settings.copy(DENSE_CLOUD), false, null), ItemGroups.NATURAL); - Block DENSE_CLOUD_STAIRS = register("dense_cloud_stairs", new CloudStairsBlock(DENSE_CLOUD.getDefaultState(), Settings.copy(DENSE_CLOUD), null), ItemGroups.NATURAL); + Block DENSE_CLOUD_STAIRS = register("dense_cloud_stairs", new CloudStairsBlock(DENSE_CLOUD.getDefaultState(), Settings.copy(DENSE_CLOUD)), ItemGroups.NATURAL); Block CARVED_CLOUD = register("carved_cloud", new OrientedCloudBlock(Settings.copy(CLOUD).hardness(0.4F).requiresTool(), false), ItemGroups.BUILDING_BLOCKS); Block UNSTABLE_CLOUD = register("unstable_cloud", new UnstableCloudBlock(Settings.copy(CLOUD)), ItemGroups.NATURAL); diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java index c599ba70..51027fe7 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudStairsBlock.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.block.cloud; -import java.util.function.Supplier; - import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.EquineContext; @@ -18,15 +16,13 @@ import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.World; -public class CloudStairsBlock extends StairsBlock implements Soakable { +public class CloudStairsBlock extends StairsBlock { private final CloudBlock baseBlock; - private final @Nullable Supplier soggyBlock; - public CloudStairsBlock(BlockState baseState, Settings settings, @Nullable Supplier soggyBlock) { + public CloudStairsBlock(BlockState baseState, Settings settings) { super(baseState, settings); this.baseBlock = (CloudBlock)baseState.getBlock(); - this.soggyBlock = soggyBlock; } @Override @@ -92,15 +88,4 @@ public class CloudStairsBlock extends StairsBlock implements Soakable { public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) { return true; } - - @Nullable - @Override - public BlockState getSoggyState(int moisture) { - return soggyBlock == null ? (baseBlock instanceof Soakable s ? s.getSoggyState(moisture) : null) : soggyBlock.get().getSoggyState(moisture); - } - - @Override - public int getMoisture(BlockState state) { - return baseBlock instanceof Soakable s ? s.getMoisture(state) : 0; - } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/PoreousCloudBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/PoreousCloudBlock.java index 591ea39e..5e17ca06 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/PoreousCloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/PoreousCloudBlock.java @@ -20,20 +20,22 @@ public class PoreousCloudBlock extends CloudBlock implements Soakable { @Nullable @Override - public BlockState getSoggyState(int moisture) { - return soggyBlock == null ? null : soggyBlock.get().getSoggyState(moisture); - } - - @Override - public int getMoisture(BlockState state) { - return 0; + public BlockState getStateWithMoisture(BlockState state, int moisture) { + if (moisture <= 0) { + return Soakable.copyProperties(state, getDefaultState()); + } + return soggyBlock == null ? null : soggyBlock.get().getStateWithMoisture(state, moisture); } @Override public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (soggyBlock != null && world.hasRain(pos) && world.isAir(pos.up())) { - world.setBlockState(pos, Soakable.copyProperties(state, soggyBlock.get().getSoggyState(random.nextBetween(1, 5)))); - return; + if (state.getBlock() instanceof Soakable soakable && world.hasRain(pos) && world.isAir(pos.up())) { + @Nullable + BlockState soggyState = soakable.getStateWithMoisture(state, random.nextBetween(1, 5)); + if (soggyState != null) { + world.setBlockState(pos, soggyState); + return; + } } super.randomTick(state, world, pos, random); diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/PoreousCloudStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/PoreousCloudStairsBlock.java new file mode 100644 index 00000000..6733ee2d --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/PoreousCloudStairsBlock.java @@ -0,0 +1,26 @@ +package com.minelittlepony.unicopia.block.cloud; + +import java.util.function.Supplier; + +import org.jetbrains.annotations.Nullable; + +import net.minecraft.block.BlockState; + +public class PoreousCloudStairsBlock extends CloudStairsBlock implements Soakable { + + protected final Supplier soggyBlock; + + public PoreousCloudStairsBlock(BlockState baseState, Settings settings, Supplier soggyBlock) { + super(baseState, settings); + this.soggyBlock = soggyBlock; + } + + @Nullable + @Override + public BlockState getStateWithMoisture(BlockState state, int moisture) { + if (moisture <= 0) { + return Soakable.copyProperties(state, getDefaultState()); + } + return soggyBlock.get().getStateWithMoisture(state, moisture); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/Soakable.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/Soakable.java index 4623e92a..e800bbf8 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/Soakable.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/Soakable.java @@ -6,7 +6,6 @@ import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.USounds; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -31,9 +30,12 @@ public interface Soakable { IntProperty MOISTURE = IntProperty.of("moisture", 1, 7); Direction[] DIRECTIONS = Arrays.stream(Direction.values()).filter(d -> d != Direction.UP).toArray(Direction[]::new); - BlockState getSoggyState(int moisture); + @Nullable + BlockState getStateWithMoisture(BlockState state, int moisture); - int getMoisture(BlockState state); + default int getMoisture(BlockState state) { + return state.getOrEmpty(MOISTURE).orElse(0); + } static void addMoistureParticles(BlockState state, World world, BlockPos pos, Random random) { if (random.nextInt(5) == 0) { @@ -46,69 +48,71 @@ public interface Soakable { } } - static ActionResult tryCollectMoisture(Block dryBlock, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - ItemStack stack = player.getStackInHand(hand); - if (stack.getItem() == Items.GLASS_BOTTLE) { - if (!player.isCreative()) { - stack.split(1); - } - if (stack.isEmpty()) { - player.setStackInHand(hand, Items.POTION.getDefaultStack()); - } else { - player.giveItemStack(Items.POTION.getDefaultStack()); - } - world.playSound(player, player.getX(), player.getY(), player.getZ(), USounds.Vanilla.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1, 1); - world.emitGameEvent(player, GameEvent.FLUID_PICKUP, pos); - updateMoisture(dryBlock, state, world, pos, state.get(MOISTURE) - 1); + static ActionResult tryCollectMoisture(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + if (state.getBlock() instanceof Soakable soakable) { + ItemStack stack = player.getStackInHand(hand); + if (stack.getItem() == Items.GLASS_BOTTLE) { + if (!player.isCreative()) { + stack.split(1); + } + if (stack.isEmpty()) { + player.setStackInHand(hand, Items.POTION.getDefaultStack()); + } else { + player.giveItemStack(Items.POTION.getDefaultStack()); + } + world.playSound(player, player.getX(), player.getY(), player.getZ(), USounds.Vanilla.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1, 1); + world.emitGameEvent(player, GameEvent.FLUID_PICKUP, pos); + updateMoisture(soakable, state, world, pos, soakable.getMoisture(state) - 1); - return ActionResult.SUCCESS; + return ActionResult.SUCCESS; + } } return ActionResult.PASS; } - static void tickMoisture(Block dryBlock, BlockState state, ServerWorld world, BlockPos pos, Random random) { - int moisture = state.get(MOISTURE); + static void tickMoisture(BlockState state, ServerWorld world, BlockPos pos, Random random) { + if (state.getBlock() instanceof Soakable soakable) { + int moisture = soakable.getMoisture(state); - if (world.hasRain(pos) && world.isAir(pos.up())) { - if (moisture < 7) { - world.setBlockState(pos, state.with(MOISTURE, moisture + 1)); - } - } else { - if (moisture > 1) { - BlockPos neighborPos = pos.offset(Util.getRandom(Soakable.DIRECTIONS, random)); - BlockState neighborState = world.getBlockState(neighborPos); + if (world.hasRain(pos) && world.isAir(pos.up())) { + if (moisture < 7) { + world.setBlockState(pos, soakable.getStateWithMoisture(state, moisture + 1)); + } + } else { + if (moisture > 1) { + BlockPos neighborPos = pos.offset(Util.getRandom(Soakable.DIRECTIONS, random)); + BlockState neighborState = world.getBlockState(neighborPos); - if (neighborState.getBlock() instanceof Soakable soakable && soakable.getMoisture(neighborState) < moisture) { - int half = Math.max(1, moisture / 2); - @Nullable - BlockState newNeighborState = soakable.getSoggyState(half); - if (newNeighborState != null) { - updateMoisture(dryBlock, state, world, pos, moisture - half); - world.setBlockState(neighborPos, soakable.getSoggyState(half)); - world.emitGameEvent(null, GameEvent.BLOCK_CHANGE, neighborPos); - return; + if (neighborState.getBlock() instanceof Soakable neighborSoakable && neighborSoakable.getMoisture(neighborState) < moisture) { + int half = Math.max(1, moisture / 2); + @Nullable + BlockState newNeighborState = neighborSoakable.getStateWithMoisture(neighborState, half); + if (newNeighborState != null) { + updateMoisture(soakable, state, world, pos, moisture - half); + world.setBlockState(neighborPos, soakable.getStateWithMoisture(state, half)); + world.emitGameEvent(null, GameEvent.BLOCK_CHANGE, neighborPos); + return; + } } } + updateMoisture(soakable, state, world, pos, moisture - 1); } - updateMoisture(dryBlock, state, world, pos, moisture - 1); } } - private static void updateMoisture(Block dryBlock, BlockState state, World world, BlockPos pos, int newMoisture) { - if (newMoisture <= 0) { - world.setBlockState(pos, copyProperties(state, dryBlock.getDefaultState())); - } else { - world.setBlockState(pos, state.with(MOISTURE, newMoisture)); - } + private static void updateMoisture(Soakable soakable, BlockState state, World world, BlockPos pos, int newMoisture) { + world.setBlockState(pos, soakable.getStateWithMoisture(state, newMoisture)); world.playSound(null, pos, SoundEvents.ENTITY_SALMON_FLOP, SoundCategory.BLOCKS, 1, (float)world.random.nextTriangular(0.5, 0.3F)); } - + @Nullable @SuppressWarnings({ "rawtypes", "unchecked" }) - static BlockState copyProperties(BlockState from, BlockState to) { - for (Property property : from.getProperties()) { - to = to.withIfExists(property, from.get(property)); + static BlockState copyProperties(BlockState from, @Nullable BlockState to) { + if (to != null) { + for (Property property : from.getProperties()) { + to = to.withIfExists(property, from.get(property)); + } } return to; } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudBlock.java index 36124dbc..e508b96a 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudBlock.java @@ -2,9 +2,12 @@ package com.minelittlepony.unicopia.block.cloud; import java.util.function.Supplier; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.util.ActionResult; @@ -12,6 +15,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; +import net.minecraft.world.BlockView; import net.minecraft.world.World; public class SoggyCloudBlock extends CloudBlock implements Soakable { @@ -24,25 +28,30 @@ public class SoggyCloudBlock extends CloudBlock implements Soakable { this.dryBlock = dryBlock; } - @Override - public BlockState getSoggyState(int moisture) { - return getDefaultState().with(MOISTURE, moisture); - } - - @Override - public int getMoisture(BlockState state) { - return state.get(MOISTURE); - } - @Override protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); builder.add(MOISTURE); } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return dryBlock.get().getPickStack(world, pos, state); + } + + @Nullable + @Override + public BlockState getStateWithMoisture(BlockState state, int moisture) { + if (moisture <= 0) { + return Soakable.copyProperties(state, dryBlock.get().getDefaultState()); + } + return Soakable.copyProperties(state, getDefaultState()).with(MOISTURE, moisture); + } + @Override @Deprecated public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - return Soakable.tryCollectMoisture(dryBlock.get(), state, world, pos, player, hand, hit); + return Soakable.tryCollectMoisture(state, world, pos, player, hand, hit); } @Override @@ -53,6 +62,6 @@ public class SoggyCloudBlock extends CloudBlock implements Soakable { @Override public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - Soakable.tickMoisture(dryBlock.get(), state, world, pos, random); + Soakable.tickMoisture(state, world, pos, random); } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudSlabBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudSlabBlock.java index d9f604fe..d074b2cb 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudSlabBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudSlabBlock.java @@ -2,9 +2,12 @@ package com.minelittlepony.unicopia.block.cloud; import java.util.function.Supplier; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.util.ActionResult; @@ -12,6 +15,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; +import net.minecraft.world.BlockView; import net.minecraft.world.World; public class SoggyCloudSlabBlock extends CloudSlabBlock { @@ -24,26 +28,30 @@ public class SoggyCloudSlabBlock extends CloudSlabBlock { this.dryBlock = dryBlock; } - @Override - public BlockState getSoggyState(int moisture) { - return getDefaultState().with(MOISTURE, moisture); - } - - @Override - public int getMoisture(BlockState state) { - return state.get(MOISTURE); - } - @Override protected void appendProperties(StateManager.Builder builder) { super.appendProperties(builder); builder.add(MOISTURE); } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return dryBlock.get().getPickStack(world, pos, state); + } + + @Nullable + @Override + public BlockState getStateWithMoisture(BlockState state, int moisture) { + if (moisture <= 0) { + return Soakable.copyProperties(state, dryBlock.get().getDefaultState()); + } + return Soakable.copyProperties(state, getDefaultState()).with(MOISTURE, moisture); + } + @Override @Deprecated public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - return Soakable.tryCollectMoisture(dryBlock.get(), state, world, pos, player, hand, hit); + return Soakable.tryCollectMoisture(state, world, pos, player, hand, hit); } @Override @@ -54,6 +62,6 @@ public class SoggyCloudSlabBlock extends CloudSlabBlock { @Override public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - Soakable.tickMoisture(dryBlock.get(), state, world, pos, random); + Soakable.tickMoisture(state, world, pos, random); } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudStairsBlock.java new file mode 100644 index 00000000..495c0f37 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/SoggyCloudStairsBlock.java @@ -0,0 +1,43 @@ +package com.minelittlepony.unicopia.block.cloud; + +import java.util.function.Supplier; + +import org.jetbrains.annotations.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.state.StateManager; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; + +public class SoggyCloudStairsBlock extends CloudStairsBlock implements Soakable { + + private final Supplier dryBlock; + + public SoggyCloudStairsBlock(BlockState baseState, Settings settings, Supplier dryBlock) { + super(baseState, settings); + setDefaultState(getDefaultState().with(MOISTURE, 7)); + this.dryBlock = dryBlock; + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(MOISTURE); + } + + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return dryBlock.get().getPickStack(world, pos, state); + } + + @Nullable + @Override + public BlockState getStateWithMoisture(BlockState state, int moisture) { + if (moisture <= 0) { + return Soakable.copyProperties(state, dryBlock.get().getDefaultState()); + } + return Soakable.copyProperties(state, getDefaultState()).with(MOISTURE, moisture); + } +}