From a71bd7762cb2ba6dd9570d38c34e54e398c9e406 Mon Sep 17 00:00:00 2001 From: Andrew-71 Date: Sun, 6 Aug 2023 23:55:57 +0300 Subject: [PATCH] Fix sirens and begin figuring out stairs --- .../building_blocks/sand_tiles_stairs.json | 35 +++++++++++++++++++ .../recipes/decorations/light_bulb.json | 35 +++++++++++++++++++ .../data/new_soviet/recipes/light_bulb.json | 24 +++++++++++++ .../new_soviet/recipes/sand_tiles_stairs.json | 19 ++++++++++ .../su/a71/new_soviet/DataGeneration.java | 8 ++++- .../su/a71/new_soviet/blocks/SirenBlock.java | 28 ++++++++++++--- .../assets/new_soviet/sounds/LICENSE | 2 +- 7 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 src/main/generated/data/new_soviet/advancements/recipes/building_blocks/sand_tiles_stairs.json create mode 100644 src/main/generated/data/new_soviet/advancements/recipes/decorations/light_bulb.json create mode 100644 src/main/generated/data/new_soviet/recipes/light_bulb.json create mode 100644 src/main/generated/data/new_soviet/recipes/sand_tiles_stairs.json diff --git a/src/main/generated/data/new_soviet/advancements/recipes/building_blocks/sand_tiles_stairs.json b/src/main/generated/data/new_soviet/advancements/recipes/building_blocks/sand_tiles_stairs.json new file mode 100644 index 0000000..d5625b7 --- /dev/null +++ b/src/main/generated/data/new_soviet/advancements/recipes/building_blocks/sand_tiles_stairs.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_sand_tiles": { + "conditions": { + "items": [ + { + "items": [ + "new_soviet:sand_tiles" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "new_soviet:sand_tiles_stairs" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_sand_tiles", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "new_soviet:sand_tiles_stairs" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/advancements/recipes/decorations/light_bulb.json b/src/main/generated/data/new_soviet/advancements/recipes/decorations/light_bulb.json new file mode 100644 index 0000000..676446a --- /dev/null +++ b/src/main/generated/data/new_soviet/advancements/recipes/decorations/light_bulb.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_light_bulb_item": { + "conditions": { + "items": [ + { + "items": [ + "new_soviet:light_bulb_item" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "new_soviet:light_bulb" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_light_bulb_item", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "new_soviet:light_bulb" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/recipes/light_bulb.json b/src/main/generated/data/new_soviet/recipes/light_bulb.json new file mode 100644 index 0000000..c3a87c7 --- /dev/null +++ b/src/main/generated/data/new_soviet/recipes/light_bulb.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "X": { + "item": "minecraft:iron_ingot" + }, + "Y": { + "item": "minecraft:iron_nugget" + }, + "Z": { + "item": "new_soviet:light_bulb_item" + } + }, + "pattern": [ + " X ", + " Y ", + " Z " + ], + "result": { + "item": "new_soviet:light_bulb" + }, + "show_notification": true +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/recipes/sand_tiles_stairs.json b/src/main/generated/data/new_soviet/recipes/sand_tiles_stairs.json new file mode 100644 index 0000000..e581dae --- /dev/null +++ b/src/main/generated/data/new_soviet/recipes/sand_tiles_stairs.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "key": { + "#": { + "item": "new_soviet:sand_tiles" + } + }, + "pattern": [ + "# ", + "## ", + "###" + ], + "result": { + "count": 4, + "item": "new_soviet:sand_tiles_stairs" + }, + "show_notification": true +} \ 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 27d1912..56ce225 100644 --- a/src/main/java/su/a71/new_soviet/DataGeneration.java +++ b/src/main/java/su/a71/new_soviet/DataGeneration.java @@ -671,7 +671,13 @@ public class DataGeneration implements DataGeneratorEntrypoint { offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, NSE_Blocks.CHISELED_SPRUCE_DOOR, Blocks.SPRUCE_DOOR); offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, NSE_Blocks.CHISELED_BIRCH_DOOR, Blocks.BIRCH_DOOR); - createStairsRecipe(NSE_Blocks.SAND_TILES_STAIRS, Ingredient.ofItems(NSE_Blocks.SAND_TILES)); + createStairsRecipe(NSE_Blocks.SAND_TILES_STAIRS, Ingredient.ofItems(NSE_Blocks.SAND_TILES)) + .criterion(hasItem(NSE_Blocks.SAND_TILES), conditionsFromItem(NSE_Blocks.SAND_TILES)).offerTo(exporter); + + ShapedRecipeJsonBuilder.create(RecipeCategory.DECORATIONS, NSE_Custom.LIGHT_BULB, 1) + .input('X', Items.IRON_INGOT).input('Y', Items.IRON_NUGGET).input('Z', NSE_Items.LIGHT_BULB) + .pattern(" X ").pattern(" Y ").pattern(" Z ") + .criterion(hasItem(NSE_Items.LIGHT_BULB), conditionsFromItem(NSE_Items.LIGHT_BULB)).offerTo(exporter); } } diff --git a/src/main/java/su/a71/new_soviet/blocks/SirenBlock.java b/src/main/java/su/a71/new_soviet/blocks/SirenBlock.java index 9d87d0d..9368d05 100644 --- a/src/main/java/su/a71/new_soviet/blocks/SirenBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/SirenBlock.java @@ -4,6 +4,8 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.*; import net.minecraft.block.piston.PistonBehavior; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; @@ -19,20 +21,22 @@ import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldView; import su.a71.new_soviet.registration.NSE_Custom; -public class SirenBlock extends HorizontalFacingBlock { +public class SirenBlock extends HorizontalFacingBlock implements Waterloggable { public static final BooleanProperty ON; + public static final BooleanProperty WATERLOGGED; public SirenBlock() { super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY).strength(1f, 2f)); - setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH).with(ON, false)); + setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH).with(ON, false).with(WATERLOGGED, false)); } @Override protected void appendProperties(StateManager.Builder builder) { - builder.add(Properties.HORIZONTAL_FACING, ON); + builder.add(Properties.HORIZONTAL_FACING, ON, WATERLOGGED); } public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { @@ -69,7 +73,10 @@ public class SirenBlock extends HorizontalFacingBlock { @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()).with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos())); + return super.getPlacementState(ctx) + .with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()) + .with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos())) + .with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER); } public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { @@ -98,7 +105,20 @@ public class SirenBlock extends HorizontalFacingBlock { }; } + @Override + 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.get(FACING).getOpposite() == direction && !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); + } + + public FluidState getFluidState(BlockState state) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + static { ON = RedstoneTorchBlock.LIT; + WATERLOGGED = Properties.WATERLOGGED; } } \ No newline at end of file diff --git a/src/main/resources/assets/new_soviet/sounds/LICENSE b/src/main/resources/assets/new_soviet/sounds/LICENSE index b48b276..5767cda 100644 --- a/src/main/resources/assets/new_soviet/sounds/LICENSE +++ b/src/main/resources/assets/new_soviet/sounds/LICENSE @@ -1 +1 @@ -File light_bulb_broken.ogg is converted .mp3 file made by Mike Koenig, which is licensed under CC Attribution 3.0 (https://creativecommons.org/licenses/by/3.0/). Original file is available at https://soundbible.com/105-Light-Bulb-Breaking.html \ No newline at end of file +File light_bulb_broken.ogg is converted .mp3 file which was made by Mike Koenig and licensed under CC Attribution 3.0 (https://creativecommons.org/licenses/by/3.0/). Original file is available at https://soundbible.com/105-Light-Bulb-Breaking.html \ No newline at end of file