From d2631b77140709e101398b823d3537c09e121ae9 Mon Sep 17 00:00:00 2001 From: Andrew-71 Date: Mon, 4 Sep 2023 22:32:39 +0300 Subject: [PATCH] Various minor improvements --- .../data/new_soviet/tags/blocks/tv.json | 8 ++++ .../su/a71/new_soviet/DataGeneration.java | 7 +++- .../blocks/lamps/LightBulbLampBlock.java | 4 +- .../lamps/lamp_post/LampPostBaseBlock.java | 37 ++++++++++--------- .../su/a71/new_soviet/items/RakeItem.java | 2 +- .../registration/NSE_BaseRegistration.java | 6 +++ .../a71/new_soviet/registration/NSE_Tags.java | 15 ++++++++ .../java/su/a71/new_soviet/util/NSE_Tags.java | 17 --------- 8 files changed, 58 insertions(+), 38 deletions(-) create mode 100644 src/main/generated/data/new_soviet/tags/blocks/tv.json create mode 100644 src/main/java/su/a71/new_soviet/registration/NSE_Tags.java delete mode 100644 src/main/java/su/a71/new_soviet/util/NSE_Tags.java diff --git a/src/main/generated/data/new_soviet/tags/blocks/tv.json b/src/main/generated/data/new_soviet/tags/blocks/tv.json new file mode 100644 index 0000000..9651641 --- /dev/null +++ b/src/main/generated/data/new_soviet/tags/blocks/tv.json @@ -0,0 +1,8 @@ +{ + "replace": false, + "values": [ + "new_soviet:tv", + "new_soviet:red_tv", + "new_soviet:brown_tv" + ] +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/DataGeneration.java b/src/main/java/su/a71/new_soviet/DataGeneration.java index 5533ab5..0643e65 100644 --- a/src/main/java/su/a71/new_soviet/DataGeneration.java +++ b/src/main/java/su/a71/new_soviet/DataGeneration.java @@ -27,7 +27,7 @@ import net.minecraft.util.Util; import su.a71.new_soviet.registration.NSE_Blocks; import su.a71.new_soviet.registration.NSE_Custom; import su.a71.new_soviet.registration.NSE_Items; -import su.a71.new_soviet.util.NSE_Tags; +import su.a71.new_soviet.registration.NSE_Tags; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -820,6 +820,11 @@ public class DataGeneration implements DataGeneratorEntrypoint { .add(NSE_Blocks.MEAT_TEETH) .add(NSE_Blocks.PURPLE_GOO); + getOrCreateTagBuilder(NSE_Tags.Blocks.TV) + .add(NSE_Custom.TV) + .add(NSE_Custom.RED_TV) + .add(NSE_Custom.BROWN_TV); + getOrCreateTagBuilder(BlockTags.DOORS) .add(NSE_Blocks.CHISELED_BIRCH_DOOR) .add(NSE_Blocks.CHISELED_OAK_DOOR) diff --git a/src/main/java/su/a71/new_soviet/blocks/lamps/LightBulbLampBlock.java b/src/main/java/su/a71/new_soviet/blocks/lamps/LightBulbLampBlock.java index 3cb3338..3c5a1a4 100644 --- a/src/main/java/su/a71/new_soviet/blocks/lamps/LightBulbLampBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/lamps/LightBulbLampBlock.java @@ -11,6 +11,7 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; import net.minecraft.state.property.Property; import net.minecraft.util.ActionResult; +import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -60,7 +61,7 @@ public class LightBulbLampBlock extends LampBlock { return ActionResult.SUCCESS; } else { player.getItemCooldownManager().set(NSE_Items.LIGHT_BULB, 10); - player.sendMessage(Text.translatable("block.new_soviet.light_bulb_block.energized"), true); + player.sendMessage(Text.translatable("block.new_soviet.light_bulb_block.energized").formatted(Formatting.YELLOW), true); world.playSound((PlayerEntity)null, pos.getX(), pos.getY(), pos.getZ(), NSE_Sounds.ELECTRIC_HIT, SoundCategory.AMBIENT, 0.8f, 1f); if (!player.isCreative()) { player.damage(world.getDamageSources().lightningBolt(), NewSoviet.RANDOM.nextBetween(1, 4)); @@ -71,7 +72,6 @@ public class LightBulbLampBlock extends LampBlock { return ActionResult.PASS; } else { return super.onUse(state, world, pos, player, hand, hit); - } } diff --git a/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostBaseBlock.java b/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostBaseBlock.java index 61a03e7..8b08cd2 100644 --- a/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostBaseBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostBaseBlock.java @@ -1,9 +1,7 @@ package su.a71.new_soviet.blocks.lamps.lamp_post; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; +import net.minecraft.block.*; +import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; @@ -16,19 +14,22 @@ import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.WorldAccess; -public class LampPostBaseBlock extends Block { -// public BooleanProperty is_extension = Properties.ATTACHED; +public class LampPostBaseBlock extends Block implements Waterloggable { protected static final VoxelShape SHAPE_BASE; protected static final VoxelShape SHAPE_ATTACHED; + public static final BooleanProperty WATERLOGGED; + public LampPostBaseBlock(Settings settings) { super(settings); - this.setDefaultState(this.stateManager.getDefaultState().with(Properties.ATTACHED, false)); + this.setDefaultState(this.stateManager.getDefaultState() + .with(Properties.ATTACHED, false) + .with(WATERLOGGED, false)); } @Override protected void appendProperties(StateManager.Builder builder) { - builder.add(Properties.ATTACHED); + builder.add(Properties.ATTACHED, WATERLOGGED); } @Override @@ -37,23 +38,20 @@ public class LampPostBaseBlock extends Block { return SHAPE_ATTACHED; }; return SHAPE_BASE; -// Direction dir = state.get(FACING); -// return switch (dir) { -// case NORTH -> SHAPE.north(); -// case SOUTH -> SHAPE.south(); -// case EAST -> SHAPE.east(); -// case WEST -> SHAPE.west(); -// default -> VoxelShapes.fullCube(); -// }; } public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + if (state.get(WATERLOGGED)) { + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state.with(Properties.ATTACHED, world.getBlockState(pos.down()).getBlock() instanceof LampPostBaseBlock), direction, neighborState, world, pos, neighborPos); } @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - return super.getPlacementState(ctx).with(Properties.ATTACHED, ctx.getWorld().getBlockState(ctx.getBlockPos().down()).getBlock() instanceof LampPostBaseBlock); + return super.getPlacementState(ctx) + .with(Properties.ATTACHED, ctx.getWorld().getBlockState(ctx.getBlockPos().down()).getBlock() instanceof LampPostBaseBlock) + .with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER); } public static VoxelShape getBaseShape(){ @@ -65,8 +63,13 @@ public class LampPostBaseBlock extends Block { return shape; } + public FluidState getFluidState(BlockState state) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + static { SHAPE_ATTACHED = VoxelShapes.cuboid(0.4375, 0, 0.4375, 0.5625, 1, 0.5625); SHAPE_BASE = getBaseShape(); + WATERLOGGED = Properties.WATERLOGGED; } } diff --git a/src/main/java/su/a71/new_soviet/items/RakeItem.java b/src/main/java/su/a71/new_soviet/items/RakeItem.java index 5063726..6b9db54 100644 --- a/src/main/java/su/a71/new_soviet/items/RakeItem.java +++ b/src/main/java/su/a71/new_soviet/items/RakeItem.java @@ -15,7 +15,7 @@ import net.minecraft.util.math.Direction; import net.minecraft.world.World; import net.minecraft.world.event.GameEvent; import su.a71.new_soviet.registration.NSE_Sounds; -import su.a71.new_soviet.util.NSE_Tags; +import su.a71.new_soviet.registration.NSE_Tags; import java.util.Map; import java.util.function.Consumer; diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_BaseRegistration.java b/src/main/java/su/a71/new_soviet/registration/NSE_BaseRegistration.java index 690295c..d27224f 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_BaseRegistration.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_BaseRegistration.java @@ -12,6 +12,8 @@ import net.minecraft.item.ItemGroup; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; @@ -49,5 +51,9 @@ public class NSE_BaseRegistration { FabricBlockEntityTypeBuilder.create(factory, blocks).build()); } + public static TagKey createTag(String name) { + return TagKey.of(RegistryKeys.BLOCK, new Identifier(NewSoviet.MOD_ID, name)); + } + public static void init() {} } diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Tags.java b/src/main/java/su/a71/new_soviet/registration/NSE_Tags.java new file mode 100644 index 0000000..f66073b --- /dev/null +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Tags.java @@ -0,0 +1,15 @@ +package su.a71.new_soviet.registration; + +import net.minecraft.block.Block; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; +import net.minecraft.util.Identifier; +import su.a71.new_soviet.NewSoviet; + +public class NSE_Tags extends NSE_BaseRegistration{ + public static class Blocks { + public static final TagKey RAKE_MINEABLE = createTag("rake"); + + public static final TagKey TV = createTag("tv"); + } +} diff --git a/src/main/java/su/a71/new_soviet/util/NSE_Tags.java b/src/main/java/su/a71/new_soviet/util/NSE_Tags.java deleted file mode 100644 index 986a478..0000000 --- a/src/main/java/su/a71/new_soviet/util/NSE_Tags.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.a71.new_soviet.util; - -import net.minecraft.block.Block; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.Identifier; -import su.a71.new_soviet.NewSoviet; - -public class NSE_Tags { - public class Blocks { - public static final TagKey RAKE_MINEABLE = - createTag("rake"); - private static TagKey createTag(String name) { - return TagKey.of(RegistryKeys.BLOCK, new Identifier(NewSoviet.MOD_ID, name)); - } - } -}