Fix sirens and begin figuring out stairs

This commit is contained in:
Andrew-71 2023-08-06 23:55:57 +03:00
parent 74a4a3d64d
commit a71bd7762c
7 changed files with 145 additions and 6 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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_SPRUCE_DOOR, Blocks.SPRUCE_DOOR);
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, NSE_Blocks.CHISELED_BIRCH_DOOR, Blocks.BIRCH_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);
} }
} }

View file

@ -4,6 +4,8 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.piston.PistonBehavior; import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
@ -19,20 +21,22 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import su.a71.new_soviet.registration.NSE_Custom; 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 ON;
public static final BooleanProperty WATERLOGGED;
public SirenBlock() { public SirenBlock() {
super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY).strength(1f, 2f)); 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 @Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { protected void appendProperties(StateManager.Builder<Block, BlockState> 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) { 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 @Override
public BlockState getPlacementState(ItemPlacementContext ctx) { 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) { 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 { static {
ON = RedstoneTorchBlock.LIT; ON = RedstoneTorchBlock.LIT;
WATERLOGGED = Properties.WATERLOGGED;
} }
} }

View file

@ -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 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