From 7ac09095e5e34c3dd060ac674220820cd8eb77b2 Mon Sep 17 00:00:00 2001 From: Andrew-71 Date: Mon, 25 Sep 2023 22:19:40 +0300 Subject: [PATCH] Add dice statistic, begin re-adding stairs and slabs --- TODO.md | 7 ++-- .../java/su/a71/new_soviet/NewSoviet.java | 2 + .../new_soviet/datagen/ModelGenerator.java | 35 ++++++++---------- .../su/a71/new_soviet/items/DiceItem.java | 7 +++- .../new_soviet/registration/NSE_Stats.java | 17 +++++++++ .../assets/new_soviet/lang/en_us.json | 1 + .../doors/chiseled_birch_door_bottom.png | Bin 0 -> 371 bytes 7 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 src/main/java/su/a71/new_soviet/registration/NSE_Stats.java create mode 100644 src/main/resources/assets/new_soviet/textures/block/doors/chiseled_birch_door_bottom.png diff --git a/TODO.md b/TODO.md index 9c8fd49..32abcb3 100644 --- a/TODO.md +++ b/TODO.md @@ -3,15 +3,14 @@ * Make good README.md stuff === STUFF TO ADD/FIX === -* Add slab and stair variations * Add fences * Add windows * Add (with functionality) present appliance/furniture/electronics textures -* Add achievement criterion for dice and advancements -* PO2 wall (fix) +* Add advancements (with datagen) * What's switch type 2? -* All the lamps (lamp posts too!) * Cigarette and handrail are BROKEN and the code is a MESS sorry, but it needs CLEANUP +* Concrete with bars should have proper hitbox, placeable upside down, and act like dripstone +* Fix post lamp hitboxes === ACHIEVEMENTS === Kolkhoz warrior - kill a zombie, skeleton, creeper and spider with a sickle \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/NewSoviet.java b/src/main/java/su/a71/new_soviet/NewSoviet.java index 3fab95f..568f1c8 100644 --- a/src/main/java/su/a71/new_soviet/NewSoviet.java +++ b/src/main/java/su/a71/new_soviet/NewSoviet.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; 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.registration.NSE_Stats; public class NewSoviet implements ModInitializer { public static final String MOD_ID = "new_soviet"; @@ -31,5 +32,6 @@ public class NewSoviet implements ModInitializer { NSE_Blocks.init(); NSE_Items.init(); NSE_Custom.init(); + NSE_Stats.init(); } } \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/datagen/ModelGenerator.java b/src/main/java/su/a71/new_soviet/datagen/ModelGenerator.java index 15f838c..557eaf4 100644 --- a/src/main/java/su/a71/new_soviet/datagen/ModelGenerator.java +++ b/src/main/java/su/a71/new_soviet/datagen/ModelGenerator.java @@ -42,21 +42,20 @@ public class ModelGenerator extends FabricModelProvider { blockStateModelGenerator.blockStateCollector.accept(BlockStateModelGenerator.createSingletonBlockState(block, model_id)); } - public void registerSlabStairs(BlockStateModelGenerator blockStateModelGenerator, Block parent, StairsBlock stairs, SlabBlock slab, String texturePath) { + public void registerCubeWithSlabStairs(BlockStateModelGenerator blockStateModelGenerator, Block parent, StairsBlock stairs, SlabBlock slab, String texturePath) { TextureMap textureMap = TextureMap.all(Registries.BLOCK.getId(parent).withPath((path) -> "block/" + texturePath + "/" + path)); + Identifier cube_model = Models.CUBE_ALL.upload(parent, textureMap, blockStateModelGenerator.modelCollector); + blockStateModelGenerator.blockStateCollector.accept(BlockStateModelGenerator.createSingletonBlockState(parent, cube_model)); -// Identifier slab_model = Models.SLAB.upload(slab, textureMap, blockStateModelGenerator.modelCollector); -// Identifier slab_model_top = Models.SLAB_TOP.upload(slab, textureMap, blockStateModelGenerator.modelCollector); -// Identifier slab_model_full = Models.CUBE_ALL.upload(slab, textureMap, blockStateModelGenerator.modelCollector); + Identifier slab_model = Models.SLAB.upload(slab, textureMap, blockStateModelGenerator.modelCollector); + Identifier slab_model_top = Models.SLAB_TOP.upload(slab, textureMap, blockStateModelGenerator.modelCollector); Identifier stairs_model = Models.STAIRS.upload(stairs, textureMap, blockStateModelGenerator.modelCollector); Identifier stairs_model_outer = Models.OUTER_STAIRS.upload(stairs, textureMap, blockStateModelGenerator.modelCollector); Identifier stairs_model_inner = Models.INNER_STAIRS.upload(stairs, textureMap, blockStateModelGenerator.modelCollector); -// blockStateModelGenerator.registerItemModel(doorBlock.asItem()); -// BlockStateModelGenerator.createSlabBlockState(slab) -// blockStateModelGenerator.blockStateCollector.accept(BlockStateModelGenerator.createSlabBlockState(slab, slab_model, slab_model_top, slab_model_full)); - blockStateModelGenerator.blockStateCollector.accept(BlockStateModelGenerator.createStairsBlockState(slab, stairs_model_inner, stairs_model, stairs_model_outer)); + blockStateModelGenerator.blockStateCollector.accept(BlockStateModelGenerator.createSlabBlockState(slab, slab_model, slab_model_top, cube_model)); + blockStateModelGenerator.blockStateCollector.accept(BlockStateModelGenerator.createStairsBlockState(stairs, stairs_model_inner, stairs_model, stairs_model_outer)); } @Override @@ -66,18 +65,18 @@ public class ModelGenerator extends FabricModelProvider { registerDoor(blockStateModelGenerator, NSE_Blocks.CHISELED_OAK_DOOR); registerDoor(blockStateModelGenerator, NSE_Blocks.CHISELED_MANGROVE_DOOR); - registerCube(blockStateModelGenerator, NSE_Blocks.SAND_TILES, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.CRACKED_SAND_TILES, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.MOSSY_SAND_TILES, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.SAND_TILES, NSE_Blocks.SAND_TILES_STAIRS, NSE_Blocks.SAND_TILES_SLAB, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.CRACKED_SAND_TILES, NSE_Blocks.CRACKED_SAND_TILES_STAIRS, NSE_Blocks.CRACKED_SAND_TILES_SLAB, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.MOSSY_SAND_TILES, NSE_Blocks.MOSSY_SAND_TILES_STAIRS, NSE_Blocks.MOSSY_SAND_TILES_SLAB, "sand"); registerCube(blockStateModelGenerator, NSE_Blocks.SMALL_SAND_TILES, "sand"); registerCube(blockStateModelGenerator, NSE_Blocks.SMALL_CRACKED_SAND_TILES, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.HERRINGBONE_SAND_TILES, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.CROSS_SAND_TILES, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.HERRINGBONE_SAND_TILES, NSE_Blocks.HERRINGBONE_SAND_TILES_STAIRS, NSE_Blocks.HERRINGBONE_SAND_TILES_SLAB, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.CROSS_SAND_TILES, NSE_Blocks.CROSS_SAND_TILES_STAIRS, NSE_Blocks.CROSS_SAND_TILES_SLAB, "sand"); registerCube(blockStateModelGenerator, NSE_Blocks.BIG_SAND_TILES, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.SAND_BRICKS, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.CRACKED_SAND_BRICKS, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.MOSSY_SAND_BRICKS, "sand"); - registerCube(blockStateModelGenerator, NSE_Blocks.BIG_SAND_BRICKS, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.SAND_BRICKS, NSE_Blocks.SAND_BRICKS_STAIRS, NSE_Blocks.SAND_BRICKS_SLAB, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.CRACKED_SAND_BRICKS, NSE_Blocks.CRACKED_SAND_BRICKS_STAIRS, NSE_Blocks.CRACKED_SAND_BRICKS_SLAB, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.MOSSY_SAND_BRICKS, NSE_Blocks.MOSSY_SAND_BRICKS_STAIRS, NSE_Blocks.MOSSY_SAND_BRICKS_SLAB, "sand"); + registerCubeWithSlabStairs(blockStateModelGenerator, NSE_Blocks.BIG_SAND_BRICKS, NSE_Blocks.BIG_SAND_BRICKS_STAIRS, NSE_Blocks.BIG_SAND_BRICKS_SLAB, "sand"); registerCube(blockStateModelGenerator, NSE_Blocks.BRICK_TILES, "brick"); registerCube(blockStateModelGenerator, NSE_Blocks.CRACKED_BRICK_TILES, "brick"); registerCube(blockStateModelGenerator, NSE_Blocks.MOSSY_BRICK_TILES, "brick"); @@ -229,8 +228,6 @@ public class ModelGenerator extends FabricModelProvider { registerCube(blockStateModelGenerator, NSE_Blocks.GREEN_WALLPAPER, "wallpapers"); registerCube(blockStateModelGenerator, NSE_Blocks.BROWN_WALLPAPER, "wallpapers"); registerCube(blockStateModelGenerator, NSE_Blocks.BEIGE_WALLPAPER, "wallpapers"); - -// registerSlabStairs(blockStateModelGenerator, NSE_Blocks.SAND_TILES, NSE_Blocks.SAND_TILES_STAIRS, NSE_Blocks.SAND_TILES_SLAB, "sand"); } @Override diff --git a/src/main/java/su/a71/new_soviet/items/DiceItem.java b/src/main/java/su/a71/new_soviet/items/DiceItem.java index b9325c6..60fa342 100644 --- a/src/main/java/su/a71/new_soviet/items/DiceItem.java +++ b/src/main/java/su/a71/new_soviet/items/DiceItem.java @@ -17,6 +17,7 @@ import java.util.List; import su.a71.new_soviet.Config; import su.a71.new_soviet.NewSoviet; import su.a71.new_soviet.registration.NSE_Sounds; +import su.a71.new_soviet.registration.NSE_Stats; public class DiceItem extends Item { private final int sides; @@ -34,8 +35,12 @@ public class DiceItem extends Item { if (!world.isClient) { StringBuilder output = new StringBuilder(); for (var i = 0; i < itemStack.getCount(); i++) { + int result = NewSoviet.RANDOM.nextBetween(1, this.getSides()); + if (result == this.getSides()) { + user.incrementStat(NSE_Stats.ROLL_PERFECT_DICE); + } world.playSound(null, user.getX(), user.getY(), user.getZ(), NSE_Sounds.DICE_SOUND, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); - output.append(NewSoviet.RANDOM.nextBetween(1, this.getSides())).append(", "); + output.append(result).append(", "); } if (Config.INSTANCE.shouldAnnounceDice()) { world.getPlayers().forEach(player -> player.sendMessage(Text.translatable(itemStack.getCount() == 1 ? "item.new_soviet.dice.thrown_announce" : "item.new_soviet.dice.thrown_multiple_announce", user.getDisplayName()).append(" " + output.subSequence(0, output.length() - 2)), false)); diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Stats.java b/src/main/java/su/a71/new_soviet/registration/NSE_Stats.java new file mode 100644 index 0000000..446958b --- /dev/null +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Stats.java @@ -0,0 +1,17 @@ +package su.a71.new_soviet.registration; + +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.stat.StatFormatter; +import net.minecraft.stat.Stats; +import net.minecraft.util.Identifier; +import su.a71.new_soviet.NewSoviet; + +public class NSE_Stats extends NSE_BaseRegistration { + public static final Identifier ROLL_PERFECT_DICE = new Identifier(NewSoviet.MOD_ID, "roll_perfect_dice"); + + public static void init() { + Registry.register(Registries.CUSTOM_STAT, "roll_perfect_dice", ROLL_PERFECT_DICE); + Stats.CUSTOM.getOrCreateStat(ROLL_PERFECT_DICE, StatFormatter.DEFAULT); + } +} \ No newline at end of file diff --git a/src/main/resources/assets/new_soviet/lang/en_us.json b/src/main/resources/assets/new_soviet/lang/en_us.json index 160be07..3128797 100644 --- a/src/main/resources/assets/new_soviet/lang/en_us.json +++ b/src/main/resources/assets/new_soviet/lang/en_us.json @@ -161,6 +161,7 @@ "item.new_soviet.dice.thrown_announce": "Dice was thrown by %s with result:", "item.new_soviet.dice.thrown_multiple_announce": "Dice were thrown by %s with result:", "subtitles.new_soviet.dice_throw": "Dice thrown", + "stat.new_soviet.roll_perfect_dice": "Perfect Dice Throws", "block.new_soviet.landmine": "AP Landmine", "block.new_soviet.chiseled_mangrove_door": "Chiseled Mangrove Door", "block.new_soviet.chiseled_oak_door": "Chiseled Oak Door", diff --git a/src/main/resources/assets/new_soviet/textures/block/doors/chiseled_birch_door_bottom.png b/src/main/resources/assets/new_soviet/textures/block/doors/chiseled_birch_door_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..b62b6e58e96cf1e2e7f9f93d24d5689704681bd6 GIT binary patch literal 371 zcmV-(0gV2MP)Px$ElET{R49>!Qn5Z80r(#Ki$uak?pP`}18m1H1_t+XRHg7jP zOIZ;1Z$tyn(ub#atEr2!5