diff --git a/src/client/java/su/a71/new_soviet/NewSovietClient.java b/src/client/java/su/a71/new_soviet/NewSovietClient.java index d9f090f..2509989 100644 --- a/src/client/java/su/a71/new_soviet/NewSovietClient.java +++ b/src/client/java/su/a71/new_soviet/NewSovietClient.java @@ -16,6 +16,7 @@ public class NewSovietClient implements ClientModInitializer { @Override public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(NSE_Blocks.CRATE, RenderLayer.getCutout()); + BlockRenderLayerMap.INSTANCE.putBlock(NSE_Blocks.HANDRAIL, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(NSE_Custom.LAMP, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(NSE_Custom.CEILING_FAN, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(NSE_Custom.SIREN, RenderLayer.getCutout()); diff --git a/src/main/generated/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/main/generated/data/minecraft/tags/blocks/mineable/pickaxe.json index e9caf71..ab67b35 100644 --- a/src/main/generated/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/src/main/generated/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -2,6 +2,7 @@ "replace": false, "values": [ "new_soviet:sand_tiles", + "new_soviet:handrail", "new_soviet:nii_floor", "new_soviet:big_green_tiles", "new_soviet:big_green_tiles_cracked", diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/black_bishop.json b/src/main/generated/data/new_soviet/loot_tables/blocks/black_bishop.json new file mode 100644 index 0000000..d43e969 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/black_bishop.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:black_bishop" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/black_king.json b/src/main/generated/data/new_soviet/loot_tables/blocks/black_king.json new file mode 100644 index 0000000..3a18050 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/black_king.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:black_king" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/black_knight.json b/src/main/generated/data/new_soviet/loot_tables/blocks/black_knight.json new file mode 100644 index 0000000..8e3666c --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/black_knight.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:black_knight" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/black_pawn.json b/src/main/generated/data/new_soviet/loot_tables/blocks/black_pawn.json new file mode 100644 index 0000000..42a44a7 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/black_pawn.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:black_pawn" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/black_queen.json b/src/main/generated/data/new_soviet/loot_tables/blocks/black_queen.json new file mode 100644 index 0000000..8a5bff0 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/black_queen.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:black_queen" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/black_rook.json b/src/main/generated/data/new_soviet/loot_tables/blocks/black_rook.json new file mode 100644 index 0000000..3b389dd --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/black_rook.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:black_rook" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/handrail.json b/src/main/generated/data/new_soviet/loot_tables/blocks/handrail.json new file mode 100644 index 0000000..2c391a9 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/handrail.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:handrail" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/white_bishop.json b/src/main/generated/data/new_soviet/loot_tables/blocks/white_bishop.json new file mode 100644 index 0000000..e316114 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/white_bishop.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:white_bishop" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/white_king.json b/src/main/generated/data/new_soviet/loot_tables/blocks/white_king.json new file mode 100644 index 0000000..5ca35b7 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/white_king.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:white_king" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/white_knight.json b/src/main/generated/data/new_soviet/loot_tables/blocks/white_knight.json new file mode 100644 index 0000000..e3070d7 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/white_knight.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:white_knight" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/white_pawn.json b/src/main/generated/data/new_soviet/loot_tables/blocks/white_pawn.json new file mode 100644 index 0000000..0d1f254 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/white_pawn.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:white_pawn" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/white_queen.json b/src/main/generated/data/new_soviet/loot_tables/blocks/white_queen.json new file mode 100644 index 0000000..b313989 --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/white_queen.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:white_queen" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/white_rook.json b/src/main/generated/data/new_soviet/loot_tables/blocks/white_rook.json new file mode 100644 index 0000000..9429d9a --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/white_rook.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:white_rook" + } + ], + "rolls": 1.0 + } + ] +} \ 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 c7b3684..a605f49 100644 --- a/src/main/java/su/a71/new_soviet/DataGeneration.java +++ b/src/main/java/su/a71/new_soviet/DataGeneration.java @@ -11,19 +11,32 @@ import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; import net.minecraft.block.Block; import net.minecraft.block.Blocks; +import net.minecraft.block.CandleBlock; import net.minecraft.data.client.BlockStateModelGenerator; import net.minecraft.data.client.ItemModelGenerator; import net.minecraft.data.server.recipe.RecipeJsonProvider; import net.minecraft.data.server.recipe.RecipeProvider; import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder; import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder; +import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; import net.minecraft.item.Items; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.LootTable; +import net.minecraft.loot.condition.BlockStatePropertyLootCondition; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.loot.entry.LootPoolEntry; +import net.minecraft.loot.function.ExplosionDecayLootFunction; +import net.minecraft.loot.function.LootFunctionConsumingBuilder; +import net.minecraft.loot.function.SetCountLootFunction; +import net.minecraft.loot.provider.number.ConstantLootNumberProvider; +import net.minecraft.predicate.StatePredicate; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.book.RecipeCategory; import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.Util; +import su.a71.new_soviet.blocks.CheckerBlock; import su.a71.new_soviet.registration.NSE_Blocks; import su.a71.new_soviet.registration.NSE_Custom; import su.a71.new_soviet.registration.NSE_Items; @@ -34,8 +47,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; public class DataGeneration implements DataGeneratorEntrypoint { - - private static class BlockLootTables extends FabricBlockLootTableProvider { + private class BlockLootTables extends FabricBlockLootTableProvider { public BlockLootTables(FabricDataOutput dataOutput) { super(dataOutput); } @@ -199,15 +211,29 @@ public class DataGeneration implements DataGeneratorEntrypoint { addDrop(NSE_Blocks.MEAT); addDrop(NSE_Blocks.MEAT_EYE); addDrop(NSE_Blocks.MEAT_TEETH); - addDrop(NSE_Blocks.CHISELED_BIRCH_DOOR); - addDrop(NSE_Blocks.CHISELED_MANGROVE_DOOR); - addDrop(NSE_Blocks.CHISELED_OAK_DOOR); - addDrop(NSE_Blocks.CHISELED_SPRUCE_DOOR); + addDrop(NSE_Blocks.CHISELED_BIRCH_DOOR, doorDrops(NSE_Blocks.CHISELED_BIRCH_DOOR)); + addDrop(NSE_Blocks.CHISELED_MANGROVE_DOOR, doorDrops(NSE_Blocks.CHISELED_MANGROVE_DOOR));; + addDrop(NSE_Blocks.CHISELED_OAK_DOOR, doorDrops(NSE_Blocks.CHISELED_OAK_DOOR)); + addDrop(NSE_Blocks.CHISELED_SPRUCE_DOOR, doorDrops(NSE_Blocks.CHISELED_SPRUCE_DOOR));; addDrop(NSE_Blocks.BEIGE_WALLPAPER); addDrop(NSE_Blocks.BROWN_WALLPAPER); addDrop(NSE_Blocks.GREEN_WALLPAPER); + addDrop(NSE_Blocks.HANDRAIL); // Drops for furniture/electronics/appliances + addDrop(NSE_Custom.WHITE_PAWN); + addDrop(NSE_Custom.WHITE_BISHOP); + addDrop(NSE_Custom.WHITE_KING); + addDrop(NSE_Custom.WHITE_KNIGHT); + addDrop(NSE_Custom.WHITE_QUEEN); + addDrop(NSE_Custom.WHITE_ROOK); + addDrop(NSE_Custom.BLACK_KNIGHT); + addDrop(NSE_Custom.BLACK_PAWN); + addDrop(NSE_Custom.BLACK_KING); + addDrop(NSE_Custom.BLACK_QUEEN); + addDrop(NSE_Custom.BLACK_BISHOP); + addDrop(NSE_Custom.BLACK_ROOK); + addDrop(NSE_Custom.TV); addDrop(NSE_Custom.RED_TV); addDrop(NSE_Custom.BROWN_TV); @@ -230,6 +256,7 @@ public class DataGeneration implements DataGeneratorEntrypoint { // Blocks mined with a pickaxe getOrCreateTagBuilder(BlockTags.PICKAXE_MINEABLE) .add(NSE_Blocks.SAND_TILES) + .add(NSE_Blocks.HANDRAIL) .add(NSE_Blocks.NII_FLOOR) .add(NSE_Blocks.BIG_GREEN_TILES) .add(NSE_Blocks.BIG_GREEN_TILES_CRACKED) diff --git a/src/main/java/su/a71/new_soviet/blocks/CheckerBlock.java b/src/main/java/su/a71/new_soviet/blocks/CheckerBlock.java new file mode 100644 index 0000000..2283c40 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/blocks/CheckerBlock.java @@ -0,0 +1,108 @@ +package su.a71.new_soviet.blocks; + +import net.minecraft.block.*; +import net.minecraft.entity.ai.pathing.NavigationType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.IntProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.state.property.Property; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; +import net.minecraft.world.WorldView; +import org.jetbrains.annotations.Nullable; + +public class CheckerBlock extends Block implements Waterloggable { + public static final int MAX_PICKLES = 4; + public static final IntProperty CHECKERS; + public static final BooleanProperty WATERLOGGED; + protected static final VoxelShape ONE_CHECKER; + protected static final VoxelShape TWO_CHECKER; + protected static final VoxelShape THREE_CHECKER; + protected static final VoxelShape FOUR_CHECKER; + + public CheckerBlock(AbstractBlock.Settings settings) { + super(settings); + this.setDefaultState((BlockState)((BlockState)((BlockState)this.stateManager.getDefaultState()).with(CHECKERS, 1)).with(WATERLOGGED, true)); + } + + @Nullable + public BlockState getPlacementState(ItemPlacementContext ctx) { + BlockState blockState = ctx.getWorld().getBlockState(ctx.getBlockPos()); + if (blockState.isOf(this)) { + return (BlockState)blockState.with(CHECKERS, Math.min(4, (Integer)blockState.get(CHECKERS) + 1)); + } else { + FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); + boolean bl = fluidState.getFluid() == Fluids.WATER; + return (BlockState)super.getPlacementState(ctx).with(WATERLOGGED, bl); + } + } + + protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + return !floor.getCollisionShape(world, pos).getFace(Direction.UP).isEmpty() || floor.isSideSolidFullSquare(world, pos, Direction.UP); + } + + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + BlockPos blockPos = pos.down(); + return this.canPlantOnTop(world.getBlockState(blockPos), world, blockPos); + } + + public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + if (!state.canPlaceAt(world, pos)) { + return Blocks.AIR.getDefaultState(); + } else { + if ((Boolean)state.get(WATERLOGGED)) { + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + + return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); + } + } + + public boolean canReplace(BlockState state, ItemPlacementContext context) { + return !context.shouldCancelInteraction() && context.getStack().isOf(this.asItem()) && (Integer) state.get(CHECKERS) < 4 || super.canReplace(state, context); + } + + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + switch ((Integer)state.get(CHECKERS)) { + case 1: + default: + return ONE_CHECKER; + case 2: + return TWO_CHECKER; + case 3: + return THREE_CHECKER; + case 4: + return FOUR_CHECKER; + } + } + + public FluidState getFluidState(BlockState state) { + return (Boolean)state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + + protected void appendProperties(StateManager.Builder builder) { + builder.add(new Property[]{CHECKERS, WATERLOGGED}); + } + + public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) { + return false; + } + + static { + CHECKERS = IntProperty.of("checkers", 1, 4);; + WATERLOGGED = Properties.WATERLOGGED; + ONE_CHECKER = Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 4.0, 14.0); + TWO_CHECKER = Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 8.0, 14.0); + THREE_CHECKER = Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 12.0, 14.0); + FOUR_CHECKER = Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0); + } +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/blocks/ChessBlock.java b/src/main/java/su/a71/new_soviet/blocks/ChessBlock.java new file mode 100644 index 0000000..ade8934 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/blocks/ChessBlock.java @@ -0,0 +1,50 @@ +package su.a71.new_soviet.blocks; + +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.*; +import net.minecraft.block.piston.PistonBehavior; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.Properties; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.minecraft.world.WorldView; + +public class ChessBlock extends HorizontalFacingBlock { + + private VoxelShape blockShape; + + public ChessBlock(AbstractBlock.Settings settings, VoxelShape blockShape) { + super(settings.notSolid().nonOpaque().noBlockBreakParticles().pistonBehavior(PistonBehavior.DESTROY).strength(0.1f, 2f)); + setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH)); + this.blockShape = blockShape; + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(Properties.HORIZONTAL_FACING); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) { + return VoxelShapes.union(blockShape, Block.createCuboidShape(4,0,4,12,1,12), Block.createCuboidShape(5,1,5,11,4,11), Block.createCuboidShape(6,0,6,10,13,10)); + } + + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()); + } + + protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + return !floor.getCollisionShape(world, pos).getFace(Direction.UP).isEmpty() || floor.isSideSolidFullSquare(world, pos, Direction.UP); + } + + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + BlockPos blockPos = pos.down(); + return this.canPlantOnTop(world.getBlockState(blockPos), world, blockPos); + } +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/blocks/ChessBlockKnight.java b/src/main/java/su/a71/new_soviet/blocks/ChessBlockKnight.java new file mode 100644 index 0000000..d7f4065 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/blocks/ChessBlockKnight.java @@ -0,0 +1,57 @@ +package su.a71.new_soviet.blocks; + +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.HorizontalFacingBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.piston.PistonBehavior; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.Properties; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.minecraft.world.WorldView; +import su.a71.new_soviet.util.Shapes; + +public class ChessBlockKnight extends HorizontalFacingBlock { + + public ChessBlockKnight(Settings settings) { + super(settings.notSolid().nonOpaque().noBlockBreakParticles().pistonBehavior(PistonBehavior.DESTROY).strength(0.1f, 2f)); + setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH)); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(Properties.HORIZONTAL_FACING); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) { + Direction dir = state.get(FACING); + return switch (dir) { + case NORTH -> VoxelShapes.union(Block.createCuboidShape(4,0,4,12,1,12), Block.createCuboidShape(5,1,5,11,4,11), Block.createCuboidShape(6,0,6,10,13,10), Block.createCuboidShape(5.5,9,1.5,10.5,13,9.5), Block.createCuboidShape(7.5,8,6,8.5,17,11)); + case SOUTH -> VoxelShapes.union(Block.createCuboidShape(4,0,4,12,1,12), Block.createCuboidShape(5,1,5,11,4,11), Block.createCuboidShape(6,0,6,10,13,10), Block.createCuboidShape(5.5,9,6.5,10.5,13,14.5), Block.createCuboidShape(7.5,8,5,8.5,17,10)); + case EAST -> VoxelShapes.union(Block.createCuboidShape(4,0,4,12,1,12), Block.createCuboidShape(5,1,5,11,4,11), Block.createCuboidShape(6,0,6,10,13,10), Block.createCuboidShape(6.5,9,5.5,14.5,13,10.5), Block.createCuboidShape(5,8,7.5,10,17,8.5)); + case WEST -> VoxelShapes.union(Block.createCuboidShape(4,0,4,12,1,12), Block.createCuboidShape(5,1,5,11,4,11), Block.createCuboidShape(6,0,6,10,13,10), Block.createCuboidShape(1.5,9,5.5,9.5,13,10.5), Block.createCuboidShape(6,8,7.5,11,17,8.5)); + default -> VoxelShapes.fullCube(); + }; + } + + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()); + } + + protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + return !floor.getCollisionShape(world, pos).getFace(Direction.UP).isEmpty() || floor.isSideSolidFullSquare(world, pos, Direction.UP); + } + + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + BlockPos blockPos = pos.down(); + return this.canPlantOnTop(world.getBlockState(blockPos), world, blockPos); + } +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/blocks/HandrailBlock.java b/src/main/java/su/a71/new_soviet/blocks/HandrailBlock.java new file mode 100644 index 0000000..82e879c --- /dev/null +++ b/src/main/java/su/a71/new_soviet/blocks/HandrailBlock.java @@ -0,0 +1,165 @@ +package su.a71.new_soviet.blocks; + +import net.minecraft.block.*; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.enums.BlockHalf; +import net.minecraft.block.enums.StairShape; +import net.minecraft.block.piston.PistonBehavior; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.IntProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.minecraft.world.WorldAccess; +import net.minecraft.world.gen.feature.util.CaveSurface; +import su.a71.new_soviet.entity.TVBlockEntity; +import su.a71.new_soviet.registration.NSE_Blocks; +import su.a71.new_soviet.util.Shapes; + +import java.util.List; +import java.util.Objects; + +import static net.minecraft.block.StairsBlock.HALF; +import static net.minecraft.block.StairsBlock.SHAPE; + +public class HandrailBlock extends HorizontalFacingBlock implements BlockEntityProvider { + protected static final Shapes.HorizontalShape2 SHAPE1; + protected static final Shapes.HorizontalShape2 SHAPE2; + protected static final Shapes.HorizontalShape2 SHAPE3; + public static final BooleanProperty WATERLOGGED; + + public static final IntProperty ROTATE; + + public HandrailBlock(Settings settings) { + super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.BLOCK).strength(1f, 2f)); + setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH)); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(Properties.HORIZONTAL_FACING, WATERLOGGED, ROTATE); + } + + public FluidState getFluidState(BlockState state) { + return (Boolean)state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) { + Direction dir = state.get(FACING); + int rot = state.get(ROTATE); + return switch (dir) { + case NORTH -> switch (rot) { + case 1 -> SHAPE1.north(); + case 2 -> SHAPE2.north(); + case 3 -> SHAPE3.north(); + default -> VoxelShapes.fullCube(); + }; + case SOUTH -> switch (rot) { + case 1 -> SHAPE1.south(); + case 2 -> SHAPE2.south(); + case 3 -> SHAPE3.south(); + default -> VoxelShapes.fullCube(); + }; + case EAST -> switch (rot) { + case 1 -> SHAPE1.east(); + case 2 -> SHAPE2.east(); + case 3 -> SHAPE3.east(); + default -> VoxelShapes.fullCube(); + }; + case WEST -> switch (rot) { + case 1 -> SHAPE1.west(); + case 2 -> SHAPE2.west(); + case 3 -> SHAPE3.west(); + default -> VoxelShapes.fullCube(); + }; + default -> VoxelShapes.fullCube(); + }; + } + + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); + boolean bl = fluidState.getFluid() == Fluids.WATER; + int rot = 2; + BlockPos under = new BlockPos(ctx.getBlockPos().getX(), ctx.getBlockPos().getY() - 1, ctx.getBlockPos().getZ()); + if (istruestairs1(ctx.getWorld().getBlockState(ctx.getBlockPos().down(1)), ctx)) { + rot = 1; + } else if (istruestairs2(ctx.getWorld().getBlockState(ctx.getBlockPos().down(1)), ctx)) { + rot = 3; + } + return (BlockState)this.getDefaultState() + .with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER) + .with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()) + .with(ROTATE, rot); + + } + + private boolean istruestairs1(BlockState blockState, ItemPlacementContext ctx) { + boolean output = false; + if (blockState.isIn(BlockTags.STAIRS)) { + boolean h = blockState.get(SHAPE) == StairShape.STRAIGHT; + if (h && blockState.get(HALF) == BlockHalf.BOTTOM && returnFacing(blockState.get(FACING).getName()) == ctx.getHorizontalPlayerFacing().getOpposite().getName()) { + output = true; + } + } + return output; + } + + private boolean istruestairs2(BlockState blockState, ItemPlacementContext ctx) { + boolean output = false; + if (blockState.isIn(BlockTags.STAIRS)) { + boolean h = blockState.get(SHAPE) == StairShape.STRAIGHT; + if (h && blockState.get(HALF) == BlockHalf.BOTTOM && blockState.get(FACING).getName() == returnFacing(ctx.getHorizontalPlayerFacing().getOpposite().getName())) { + output = true; + } + } + return output; + } + + private String returnFacing(String facing1) { + String facing2 = "north"; + if (facing1 == "north") { + facing2 = "west"; + } else if (facing1 == "west") { + facing2 = "south"; + } else if (facing1 == "south") { + facing2 = "east"; + } + return facing2; + } + + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return new TVBlockEntity(pos, state); + } + + public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + if (!state.canPlaceAt(world, pos)) { + return Blocks.AIR.getDefaultState(); + } else { + if ((Boolean)state.get(WATERLOGGED)) { + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + + return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); + } + } + + static { + SHAPE2 = new Shapes.HorizontalShape2(List.of(List.of(0.0, 0.0, 15.0, 16.0, 17.0, 16.0), List.of(0.0, 17.0, 14.5, 16.0, 19.0, 16.5))); + SHAPE1 = new Shapes.HorizontalShape2(List.of(List.of(0.0, 0.0, 15.0, 8.0, 18.0, 16.0), List.of(8.0, -8.0, 15.0, 16.0, 10.0, 16.0))); + SHAPE3 = new Shapes.HorizontalShape2(List.of(List.of(0.0, -8.0, 15.0, 8.0, 10.0, 16.0), List.of(8.0, 0.0, 15.0, 16.0, 18.0, 16.0))); + ROTATE = IntProperty.of("rotate", 1, 3);; + WATERLOGGED = Properties.WATERLOGGED; + } +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/blocks/TVBlock.java b/src/main/java/su/a71/new_soviet/blocks/TVBlock.java index d350e79..9afd9f0 100644 --- a/src/main/java/su/a71/new_soviet/blocks/TVBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/TVBlock.java @@ -14,8 +14,13 @@ import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import su.a71.new_soviet.entity.TVBlockEntity; +import su.a71.new_soviet.util.Shapes; + +import java.util.List; public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvider { + protected static final Shapes.HorizontalShape SHAPE; + public TVBlock(AbstractBlock.Settings settings) { super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.BLOCK).strength(1f, 2f)); setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH)); @@ -30,8 +35,10 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) { Direction dir = state.get(FACING); return switch (dir) { - case NORTH, SOUTH -> VoxelShapes.cuboid(0.0f, 0.0f, 0.1875f, 1.0f, 0.8125f, 0.8125f); - case EAST, WEST -> VoxelShapes.cuboid(0.1875f, 0.0f, 0.0f, 0.8125f, 0.8125f, 1.0f); + case NORTH -> SHAPE.north(); + case SOUTH -> SHAPE.south(); + case EAST -> SHAPE.east(); + case WEST -> SHAPE.west(); default -> VoxelShapes.fullCube(); }; } @@ -45,4 +52,8 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { return new TVBlockEntity(pos, state); } + + static { + SHAPE = new Shapes.HorizontalShape(List.of(List.of(0.0, 1.0, 3.0, 16.0, 13.0, 13.0), List.of(2.0, 0.0, 4.0, 14.0, 1.0, 12.0), List.of(6.0, 13.0, 7.0, 10.0, 14.0, 9.0))); + } } \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/items/CigaretteItem.java b/src/main/java/su/a71/new_soviet/items/CigaretteItem.java new file mode 100644 index 0000000..0a8ba95 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/items/CigaretteItem.java @@ -0,0 +1,128 @@ +package su.a71.new_soviet.items; + +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.*; +import net.minecraft.particle.DustParticleEffect; +import net.minecraft.particle.ParticleEffect; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.sound.SoundCategory; +import net.minecraft.stat.Stats; +import net.minecraft.text.Text; +import net.minecraft.util.*; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.random.Random; +import net.minecraft.world.World; + +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import org.jetbrains.annotations.Nullable; +import su.a71.new_soviet.NewSoviet; +import su.a71.new_soviet.registration.NSE_Items; +import su.a71.new_soviet.sounds.Sounds; + +import java.util.List; +import java.util.Objects; + +public class CigaretteItem + extends Item { + private final int durationInTicks; + private final Item returnedItem; + private final String local_tooltip; + + public CigaretteItem(int durationInTicks, Item returnedItem, String localTooltip, Item.Settings settings) { + super(settings.maxDamageIfAbsent(durationInTicks)); + this.durationInTicks = durationInTicks; + this.returnedItem = returnedItem; + this.local_tooltip = localTooltip; + } + + @Override + public int getMaxUseTime(ItemStack stack) { + return durationInTicks - stack.getDamage() - 1; + } + + @Override + public UseAction getUseAction(ItemStack stack) { + return UseAction.SPYGLASS; + } + + @Override + public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + ItemStack itemStack = user.getStackInHand(hand); + if (user.getInventory().getStack(40).getItem() == Items.FLINT_AND_STEEL && user.getInventory().getMainHandStack().getDamage() == 0) { + world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_START, SoundCategory.PLAYERS, 1.0f, 1.0f); + user.incrementStat(Stats.USED.getOrCreateStat(this)); + itemStack.damage(1, user, e -> e.sendEquipmentBreakStatus(EquipmentSlot.OFFHAND)); + return ItemUsage.consumeHeldItem(world, user, hand); + } else if (user.getInventory().getMainHandStack().getDamage() != 0) { + world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_RESTART, SoundCategory.PLAYERS, 1.0f, 1.0f); + user.incrementStat(Stats.USED.getOrCreateStat(this)); + return ItemUsage.consumeHeldItem(world, user, hand); + } else if (user.isCreative()) { + world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_RESTART, SoundCategory.PLAYERS, 1.0f, 1.0f); + user.incrementStat(Stats.USED.getOrCreateStat(this)); + return ItemUsage.consumeHeldItem(world, user, hand); + } + return TypedActionResult.fail(itemStack); + } + + @Override + public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) { + stack.onStoppedUsing(world, user, durationInTicks); + return stack; + } + + @Override + public void usageTick(World world, LivingEntity user, ItemStack stack, int remainingUseTicks) { + user.setMovementSpeed(1.1f); + if (stack.getDamage() < durationInTicks - 1) { + stack.damage(1, user, e -> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));} + if (NewSoviet.RANDOM.nextBetween(1, 2) == 1) { + float pitch = NewSoviet.RANDOM.nextBetween(8, 10) * 0.1f; + double d = user.getX(); + double e = user.getY() + 1.5; + double f = user.getZ(); + world.addParticle(ParticleTypes.SMOKE, d, e, f, 0, 0, 0); + world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.SMOKING, SoundCategory.PLAYERS, 1.0f, pitch); + } + if (NewSoviet.RANDOM.nextBetween(1, 6) == 1) { + double d = user.getX(); + double e = user.getY() + 1.5; + double f = user.getZ(); + world.addParticle(ParticleTypes.LARGE_SMOKE, d, e, f, 0, 0, 0); + float pitch = NewSoviet.RANDOM.nextBetween(9, 10) * 0.1f; + world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_RANDOM, SoundCategory.PLAYERS, 1.0f, pitch); + } + } + + @Override + public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) { + if (stack.getDamage() < (durationInTicks - 1)) { + stack.damage(1, user, e -> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND)); + world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_PAUSE, SoundCategory.PLAYERS, 1.0f, 1.0f); + } else if (stack.getDamage() >= (durationInTicks - 2)) { + user.equipStack(EquipmentSlot.MAINHAND, new ItemStack(returnedItem)); + world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_STOPPED, SoundCategory.PLAYERS, 1.0f, 1.0f); + } + double d = user.getX(); + double e = user.getY() + 1.5; + double f = user.getZ(); + world.addParticle(ParticleTypes.LARGE_SMOKE, d, e, f, 0, -0.03, 0); + } + + @Override + public void appendTooltip(ItemStack stack, @Nullable World world, List tooltip, TooltipContext context) { + if (!local_tooltip.isEmpty()) { + tooltip.add(Text.translatable(local_tooltip)); + super.appendTooltip(stack, world, tooltip, context); + } + } +} + diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Blocks.java b/src/main/java/su/a71/new_soviet/registration/NSE_Blocks.java index 39bcbdf..1c6b6fd 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Blocks.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Blocks.java @@ -12,8 +12,10 @@ import net.minecraft.sound.BlockSoundGroup; import net.minecraft.text.Text; import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; - +import su.a71.new_soviet.blocks.CheckerBlock; import su.a71.new_soviet.blocks.ConcreteWithBarsBlock; +import su.a71.new_soviet.blocks.HandrailBlock; +import su.a71.new_soviet.sounds.Sounds; public class NSE_Blocks extends NSE_BaseRegistration { @@ -229,6 +231,8 @@ public class NSE_Blocks extends NSE_BaseRegistration { public static final Block MEAT_TEETH = new Block(FabricBlockSettings.copy(MEAT)); public static final SnowBlock PURPLE_GOO = new SnowBlock(FabricBlockSettings.copy(MEAT).hardness(1.2f).nonOpaque()); + public static final HandrailBlock HANDRAIL = new HandrailBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.COPPER).hardness(4f).nonOpaque()); + private static final ItemGroup NSE_BUILDING_TAB = FabricItemGroup.builder() .icon(() -> new ItemStack(CALCITE_TILES)) .displayName(Text.translatable("itemGroup.new_soviet.building_blocks")) @@ -433,6 +437,7 @@ public class NSE_Blocks extends NSE_BaseRegistration { registerBlock("meat_eye", () -> MEAT_EYE, NSE_BUILDING_TAB); registerBlock("meat_teeth", () -> MEAT_TEETH, NSE_BUILDING_TAB); registerBlock("purple_goo", () -> PURPLE_GOO, NSE_BUILDING_TAB); + registerBlock("handrail", () -> HANDRAIL, NSE_BUILDING_TAB); // Flammable blocks! FlammableBlockRegistry flammableBlockRegistry = FlammableBlockRegistry.getDefaultInstance(); diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java index bd29137..bc531ef 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java @@ -2,7 +2,9 @@ package su.a71.new_soviet.registration; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; import net.minecraft.block.MapColor; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.piston.PistonBehavior; @@ -13,8 +15,11 @@ import net.minecraft.registry.Registry; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundEvent; import net.minecraft.text.Text; +import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; import su.a71.new_soviet.NewSoviet; import su.a71.new_soviet.blocks.*; import su.a71.new_soviet.entity.TVBlockEntity; @@ -38,6 +43,24 @@ public class NSE_Custom extends NSE_BaseRegistration { public static final SoundEvent ELECTRIC_HIT = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "electric_hit")); public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY).offset(AbstractBlock.OffsetType.XZ).dynamicBounds()); + //games + //checkers + public static final CheckerBlock WHITE_CHECKER = new CheckerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).hardness(0.1f).nonOpaque().mapColor(MapColor.WHITE)); + public static final CheckerBlock BLACK_CHECKER = new CheckerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).hardness(0.1f).nonOpaque().mapColor(MapColor.BLACK)); + //chess + public static final ChessBlock WHITE_BISHOP = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,8,5,11,9,11), Block.createCuboidShape(5,10,5,11,16,11), Block.createCuboidShape(7,16,7,9,19,9))); + public static final ChessBlock WHITE_KING = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,13,5,11,16,11), Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5.5,7,5.5,10.5,8,10.5))); + public static final ChessBlockKnight WHITE_KNIGHT = new ChessBlockKnight(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque()); + public static final ChessBlock WHITE_PAWN = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5,8,5,11,14,11))); + public static final ChessBlock WHITE_QUEEN = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,13,5,11,16,11), Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5.5,7,5.5,10.5,8,10.5))); + public static final ChessBlock WHITE_ROOK = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.WHITE).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,10,5,11,15,11), Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5.5,7,5.5,10.5,8,10.5))); + + public static final ChessBlock BLACK_BISHOP = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.BLACK).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,8,5,11,9,11), Block.createCuboidShape(5,10,5,11,16,11), Block.createCuboidShape(7,16,7,9,19,9))); + public static final ChessBlock BLACK_KING = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.BLACK).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,13,5,11,16,11), Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5.5,7,5.5,10.5,8,10.5))); + public static final ChessBlockKnight BLACK_KNIGHT = new ChessBlockKnight(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.BLACK).nonOpaque()); + public static final ChessBlock BLACK_PAWN = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.BLACK).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5,8,5,11,14,11))); + public static final ChessBlock BLACK_QUEEN = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.BLACK).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,13,5,11,16,11), Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5.5,7,5.5,10.5,8,10.5))); + public static final ChessBlock BLACK_ROOK = new ChessBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).mapColor(DyeColor.BLACK).nonOpaque(), VoxelShapes.union(Block.createCuboidShape(5,10,5,11,15,11), Block.createCuboidShape(5.5,5,5.5,10.5,6,10.5), Block.createCuboidShape(5.5,7,5.5,10.5,8,10.5))); private static final ItemGroup NSE_CUSTOM_TAB = FabricItemGroup.builder() .icon(() -> new ItemStack(TV)) @@ -56,5 +79,19 @@ public class NSE_Custom extends NSE_BaseRegistration { registerBlock("siren", () -> SIREN, NSE_CUSTOM_TAB); registerBlock("landmine", () -> LANDMINE, NSE_CUSTOM_TAB); registerBlock("switch", () -> SWITCH, NSE_CUSTOM_TAB); + registerBlock("white_checker", () -> WHITE_CHECKER, NSE_CUSTOM_TAB); + registerBlock("black_checker", () -> BLACK_CHECKER, NSE_CUSTOM_TAB); + registerBlock("white_pawn", () -> WHITE_PAWN, NSE_CUSTOM_TAB); + registerBlock("white_queen", () -> WHITE_QUEEN, NSE_CUSTOM_TAB); + registerBlock("white_rook", () -> WHITE_ROOK, NSE_CUSTOM_TAB); + registerBlock("white_knight", () -> WHITE_KNIGHT, NSE_CUSTOM_TAB); + registerBlock("white_bishop", () -> WHITE_BISHOP, NSE_CUSTOM_TAB); + registerBlock("white_king", () -> WHITE_KING, NSE_CUSTOM_TAB); + registerBlock("black_pawn", () -> BLACK_PAWN, NSE_CUSTOM_TAB); + registerBlock("black_queen", () -> BLACK_QUEEN, NSE_CUSTOM_TAB); + registerBlock("black_knight", () -> BLACK_KNIGHT, NSE_CUSTOM_TAB); + registerBlock("black_rook", () -> BLACK_ROOK, NSE_CUSTOM_TAB); + registerBlock("black_bishop", () -> BLACK_BISHOP, NSE_CUSTOM_TAB); + registerBlock("black_king", () -> BLACK_KING, NSE_CUSTOM_TAB); } } \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Items.java b/src/main/java/su/a71/new_soviet/registration/NSE_Items.java index 212e233..c456bcd 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Items.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Items.java @@ -11,6 +11,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; import su.a71.new_soviet.Materials.NSE_ToolMaterials; +import su.a71.new_soviet.items.CigaretteItem; import su.a71.new_soviet.items.DiceItem; import su.a71.new_soviet.items.RakeItem; @@ -30,6 +31,11 @@ public class NSE_Items extends NSE_BaseRegistration { public static final DiceItem DICE_D20 = new DiceItem(20, "item.new_soviet.dice_d20.tooltip", new Item.Settings().maxCount(6)); public static final Item LIGHT_BULB = new Item(new Item.Settings()); + public static final Item CIGARETTE_BUTT = new Item(new Item.Settings()); + + //cigarettes + public static final CigaretteItem CIGARETTE = new CigaretteItem(200, NSE_Items.CIGARETTE_BUTT, "item.new_soviet.tooltip.salute", new Item.Settings()); + // private static final ItemGroup NSE_ITEMS_TAB = FabricItemGroup.builder() .icon(() -> new ItemStack(SICKLE)) @@ -46,5 +52,7 @@ public class NSE_Items extends NSE_BaseRegistration { registerItem("dice_d4", () -> DICE_D4, NSE_ITEMS_TAB); registerItem("dice_d20", () -> DICE_D20, NSE_ITEMS_TAB); registerItem("light_bulb_item", () -> LIGHT_BULB, NSE_ITEMS_TAB); + registerItem("cigarette", ()-> CIGARETTE, NSE_ITEMS_TAB); + registerItem("cigarette_butt", ()-> CIGARETTE_BUTT, NSE_ITEMS_TAB); } } diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java b/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java index c29db12..35a3713 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java @@ -27,6 +27,13 @@ public class NSE_Sounds extends NSE_BaseRegistration { public static SoundEvent ITEM_RAKE_TILL = registerSoundEvent("item_rake_till"); + public static SoundEvent SMOKING = registerSoundEvent("smoking"); + public static SoundEvent CIGARETTE_RESTART = registerSoundEvent("cigarette_restart"); + public static SoundEvent CIGARETTE_RANDOM = registerSoundEvent("cigarette_random"); + public static SoundEvent CIGARETTE_STOPPED = registerSoundEvent("cigarette_stopped"); + public static SoundEvent CIGARETTE_START = registerSoundEvent("cigarette_start"); + public static SoundEvent CIGARETTE_PAUSE = registerSoundEvent("cigarette_pause"); + public static final SoundEvent SIREN_SOUND = registerSoundEvent("siren_sound"); public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = registerSoundEvent("light_bulb_broken_sound"); diff --git a/src/main/java/su/a71/new_soviet/sounds/Sounds.java b/src/main/java/su/a71/new_soviet/sounds/Sounds.java new file mode 100644 index 0000000..688ce23 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/sounds/Sounds.java @@ -0,0 +1,52 @@ +package su.a71.new_soviet.sounds; + +import net.minecraft.block.Blocks; +import net.minecraft.sound.SoundEvents; +import su.a71.new_soviet.NewSoviet; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.Identifier; + +public class Sounds { + //dice sound + public static SoundEvent DICE_SOUND = registerSoundEvent("dice_sound"); + //parquet sounds + public static SoundEvent PARQUET_WALK = registerSoundEvent("parquet_walk"); + public static final BlockSoundGroup PARQUET_SOUNDS = new BlockSoundGroup(1f, 1f, + BlockSoundGroup.CHERRY_WOOD.getBreakSound(), Sounds.PARQUET_WALK, BlockSoundGroup.CHERRY_WOOD.getPlaceSound(), + BlockSoundGroup.CHERRY_WOOD.getHitSound(), Sounds.PARQUET_WALK); + + //meat sounds + public static final BlockSoundGroup MEAT_SOUNDS = new BlockSoundGroup(1f, 1f, + BlockSoundGroup.MUD.getBreakSound(), BlockSoundGroup.HONEY.getStepSound(), BlockSoundGroup.MUD.getPlaceSound(), + BlockSoundGroup.MUD.getHitSound(), BlockSoundGroup.HONEY.getStepSound()); + + //switch sound + public static SoundEvent SWITCH_PRESS = registerSoundEvent("switch_press"); + + //sand tiles sounds + public static final BlockSoundGroup SAND_TILES_SOUNDS = new BlockSoundGroup(1f, 0.8f, + BlockSoundGroup.MUD_BRICKS.getBreakSound(), BlockSoundGroup.DECORATED_POT.getStepSound(), BlockSoundGroup.MUD_BRICKS.getPlaceSound(), + BlockSoundGroup.MUD_BRICKS.getHitSound(), BlockSoundGroup.DECORATED_POT.getStepSound()); + + //wallpaper block sounds + public static final BlockSoundGroup WALLPAPER_BLOCK_SOUNDS = new BlockSoundGroup(1f, 0.7f, + BlockSoundGroup.BAMBOO_WOOD.getBreakSound(), BlockSoundGroup.WOOL.getStepSound(), BlockSoundGroup.BAMBOO_WOOD.getPlaceSound(), + BlockSoundGroup.WOOL.getHitSound(), BlockSoundGroup.WOOL.getStepSound()); + //rake sound + public static SoundEvent ITEM_RAKE_TILL = registerSoundEvent("item_rake_till"); + //cigarette sounds + public static SoundEvent SMOKING = registerSoundEvent("smoking"); + public static SoundEvent CIGARETTE_RESTART = registerSoundEvent("cigarette_restart"); + public static SoundEvent CIGARETTE_RANDOM = registerSoundEvent("cigarette_random"); + public static SoundEvent CIGARETTE_STOPPED = registerSoundEvent("cigarette_stopped"); + public static SoundEvent CIGARETTE_START = registerSoundEvent("cigarette_start"); + public static SoundEvent CIGARETTE_PAUSE = registerSoundEvent("cigarette_pause"); + + private static SoundEvent registerSoundEvent(String name) { + Identifier id = new Identifier(NewSoviet.MOD_ID, name); + return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id)); + } +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/util/Shapes.java b/src/main/java/su/a71/new_soviet/util/Shapes.java new file mode 100644 index 0000000..f589d62 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/util/Shapes.java @@ -0,0 +1,199 @@ +package su.a71.new_soviet.util; + +import net.minecraft.block.Block; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; + +import java.util.ArrayList; +import java.util.List; + +public class Shapes { + public static class NHShape{ + private VoxelShape NORTH; + private VoxelShape WEST; + private VoxelShape SOUTH; + private VoxelShape EAST; + private double minX; + private double minY; + private double minZ; + private double maxX; + private double maxY; + private double maxZ; + + public NHShape(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + this.minX = minX; + this.minY = minY; + this.minZ = minZ; + this.maxX = maxX; + this.maxY = maxY; + this.maxZ = maxZ; + this.NORTH = Block.createCuboidShape(minX, minY, minZ, maxX, maxY, maxZ); + this.WEST = Block.createCuboidShape(minZ, minY, minX, maxZ, maxY, maxX); + this.SOUTH = Block.createCuboidShape(minX, minY, (16 - maxZ), maxX, maxY, (16 - minZ)); + this.EAST = Block.createCuboidShape((16 - maxZ), minY, minX, (16 - minZ), maxY, maxX); + } + + public VoxelShape north(){ + return NORTH; + } + + public VoxelShape west(){ + return WEST; + } + + public VoxelShape south(){ + return SOUTH; + } + + public VoxelShape east(){ + return EAST; + } + } + + public static class NHShape2{ + private VoxelShape NORTH; + private VoxelShape WEST; + private VoxelShape SOUTH; + private VoxelShape EAST; + private double minX; + private double minY; + private double minZ; + private double maxX; + private double maxY; + private double maxZ; + + public NHShape2(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + this.minX = minX; + this.minY = minY; + this.minZ = minZ; + this.maxX = maxX; + this.maxY = maxY; + this.maxZ = maxZ; + this.NORTH = Block.createCuboidShape((16 - maxX), minY, minZ, (16 - minX), maxY, maxZ); + this.WEST = Block.createCuboidShape(minZ, minY, minX, maxZ, maxY, maxX); + this.SOUTH = Block.createCuboidShape(minX, minY, (16 - maxZ), maxX, maxY, (16 - minZ)); + this.EAST = Block.createCuboidShape((16 - maxZ), minY, (16 - maxX), (16 - minZ), maxY, (16 - minX)); + } + + public VoxelShape north(){ + return NORTH; + } + + public VoxelShape west(){ + return WEST; + } + + public VoxelShape south(){ + return SOUTH; + } + + public VoxelShape east(){ + return EAST; + } + } + + public static class HorizontalShape{ + private List ShapesListN; + private List ShapesListS; + private List ShapesListW; + private List ShapesListE; + public HorizontalShape(List> list) { + this.ShapesListN = new ArrayList<>(); + this.ShapesListS = new ArrayList<>(); + this.ShapesListW = new ArrayList<>(); + this.ShapesListE = new ArrayList<>(); + for (List i : list) { + NHShape shape = new NHShape(i.get(0), i.get(1), i.get(2), i.get(3), i.get(4), i.get(5)); + ShapesListN.add(shape.north()); + ShapesListS.add(shape.south()); + ShapesListW.add(shape.west()); + ShapesListE.add(shape.east()); + } + } + + public VoxelShape north() { + VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0); + for (int i=0;i> list) { + this.ShapesListN = new ArrayList<>(); + this.ShapesListS = new ArrayList<>(); + this.ShapesListW = new ArrayList<>(); + this.ShapesListE = new ArrayList<>(); + for (List i : list) { + NHShape2 shape = new NHShape2(i.get(0), i.get(1), i.get(2), i.get(3), i.get(4), i.get(5)); + ShapesListN.add(shape.north()); + ShapesListS.add(shape.south()); + ShapesListW.add(shape.west()); + ShapesListE.add(shape.east()); + } + } + + public VoxelShape north() { + VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0); + for (int i=0;i