From 5675524d5df1efcca64cb7e783fdf11347945fc6 Mon Sep 17 00:00:00 2001 From: Halbear Date: Mon, 3 Aug 2026 20:42:54 +0100 Subject: [PATCH] Olive Planks --- .../PineTreeTrunkPlacer.java | 140 ++++++++++++++++++ .../halbear/aotg/registries/ModBlocks.java | 11 +- .../net/halbear/aotg/registries/ModItems.java | 1 + .../net/halbear/aotg/registries/ModTabs.java | 1 + .../ageofthegods/Items/olive_planks.json | 6 + .../blockstates/olive_planks.json | 9 ++ .../assets/ageofthegods/lang/en_us.json | 7 + .../models/block/olive/olive_planks.json | 6 + .../textures/block/olive/olive_planks.png | Bin 0 -> 385 bytes .../data/ageofthegods/recipe/xiphos.json | 17 +++ .../data/ageofthegods/recipe/xiphos2.json | 17 +++ .../data/ageofthegods/recipe/xiphos3.json | 17 +++ 12 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/halbear/aotg/custom/WorldGen/GenerationFeatures/PineTreeTrunkPlacer.java create mode 100644 src/main/resources/assets/ageofthegods/Items/olive_planks.json create mode 100644 src/main/resources/assets/ageofthegods/blockstates/olive_planks.json create mode 100644 src/main/resources/assets/ageofthegods/models/block/olive/olive_planks.json create mode 100644 src/main/resources/assets/ageofthegods/textures/block/olive/olive_planks.png create mode 100644 src/main/resources/data/ageofthegods/recipe/xiphos.json create mode 100644 src/main/resources/data/ageofthegods/recipe/xiphos2.json create mode 100644 src/main/resources/data/ageofthegods/recipe/xiphos3.json diff --git a/src/main/java/net/halbear/aotg/custom/WorldGen/GenerationFeatures/PineTreeTrunkPlacer.java b/src/main/java/net/halbear/aotg/custom/WorldGen/GenerationFeatures/PineTreeTrunkPlacer.java new file mode 100644 index 0000000..d170e9b --- /dev/null +++ b/src/main/java/net/halbear/aotg/custom/WorldGen/GenerationFeatures/PineTreeTrunkPlacer.java @@ -0,0 +1,140 @@ +package net.halbear.aotg.custom.WorldGen.GenerationFeatures; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.halbear.aotg.registries.ModTreeGen; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.BiConsumer; + +public class PineTreeTrunkPlacer extends TrunkPlacer { + + public PineTreeTrunkPlacer(int baseHeight, int heightRandA, int heightRandB) { + super(baseHeight, heightRandA, heightRandB); + } + + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + trunkPlacerParts(instance).apply(instance, PineTreeTrunkPlacer::new) + ); + + @Override + protected TrunkPlacerType type() { + return ModTreeGen.TALL_TWISTY_TRUNK_PLACER.get(); + } + + @Override + public List placeTrunk(WorldGenLevel worldGenLevel, BiConsumer biConsumer, RandomSource randomSource, int freeSpace, BlockPos blockPos, TreeConfiguration treeConfiguration) { + int TRUNK_WIDTH = 3; + List leafNodes = new ArrayList<>(); + int mainHeight = this.getTreeHeight(randomSource); + BlockPos currentPos = blockPos; + + for (int i = 0; i < mainHeight; i++) { + TRUNK_WIDTH = (int)Math.max(3 * (1.0-((i*0.75)/(double)mainHeight)),1); + for (int xOffset = 0; xOffset < TRUNK_WIDTH; xOffset++) { + for (int zOffset = 0; zOffset < TRUNK_WIDTH; zOffset++) { + BlockPos thickLogPos = currentPos.offset(xOffset, 0, zOffset); + if(i < 2 && randomSource.nextFloat() < 0.40f){ + generateRoots(worldGenLevel, biConsumer, randomSource, thickLogPos, treeConfiguration); + } + if ((randomSource.nextInt(10) < 9) || TRUNK_WIDTH < 3) + this.placeLog(worldGenLevel, biConsumer, randomSource, thickLogPos, treeConfiguration); + else if (randomSource.nextDouble() < 0.1) + leafNodes.add(new FoliagePlacer.FoliageAttachment(thickLogPos, randomSource.nextInt(2), false)); + } + } + if (randomSource.nextFloat() < 0.6f && i > 1) { + currentPos = currentPos.offset(randomSource.nextInt(3) - 1, 0, randomSource.nextInt(3) - 1); + this.placeLog(worldGenLevel, biConsumer, randomSource, currentPos.below(), treeConfiguration); + } + + if (i > 2 && randomSource.nextFloat() < 0.65) { + BlockPos branchStart = currentPos.offset(randomSource.nextInt(TRUNK_WIDTH), 0, randomSource.nextInt(TRUNK_WIDTH)); + BlockPos branchEnd = generateBranch(worldGenLevel, biConsumer, randomSource, branchStart, treeConfiguration,i, leafNodes); + + leafNodes.add(new FoliagePlacer.FoliageAttachment(branchEnd, randomSource.nextInt(2) + (Math.max((int)(i/(double)(mainHeight/1.25))*2,1)), false)); + } else if(i > 2 && i == mainHeight - 1){ + for(int l = 0; l < 2 + randomSource.nextInt(3); l++){ + BlockPos branchStart = currentPos.offset(randomSource.nextInt(TRUNK_WIDTH), 0, randomSource.nextInt(TRUNK_WIDTH)); + BlockPos branchEnd = generateBranch(worldGenLevel, biConsumer, randomSource, branchStart, treeConfiguration,i, leafNodes); + this.placeLog(worldGenLevel, biConsumer, randomSource, branchStart, treeConfiguration); + + leafNodes.add(new FoliagePlacer.FoliageAttachment(branchEnd, randomSource.nextInt(2) + (Math.max((int)(i/(double)(mainHeight/1.25))*2,1)), false)); + } + } + + currentPos = currentPos.above(); + } + + for (int xOffset = 0; xOffset < TRUNK_WIDTH; xOffset++) { + for (int zOffset = 0; zOffset < TRUNK_WIDTH; zOffset++) { + leafNodes.add(new FoliagePlacer.FoliageAttachment(currentPos.offset(xOffset, 0, zOffset), 0, false)); + } + } + return leafNodes; + } + + private BlockPos generateRoots(WorldGenLevel level, BiConsumer blockSetter, + RandomSource random, BlockPos branchStart, TreeConfiguration config) { + int dirX = random.nextBoolean() ? 1 : -1; + int dirZ = random.nextBoolean() ? 1 : -1; + int branchLength = 2 + random.nextInt(6); + + BlockPos bPos = branchStart; + for (int b = 0; b < branchLength; b++) { + int stepX = random.nextFloat() < 0.7f ? dirX : 0; + int stepZ = random.nextFloat() < 0.7f ? dirZ : 0; + int stepY = random.nextFloat() < 0.4f ? -1 : 0; + bPos = bPos.offset(stepX, stepY, stepZ); + this.placeLog(level, blockSetter, random, bPos, config); + } + return bPos; + } + + private BlockPos generateBranch(WorldGenLevel level, BiConsumer blockSetter, + RandomSource random, BlockPos branchStart, TreeConfiguration config, int CurrentTreeHeight,List leafNodes) { + int dirX = random.nextBoolean() ? 1 : -1; + int dirZ = random.nextBoolean() ? 1 : -1; + int branchLength = 3 + random.nextInt(Math.min(CurrentTreeHeight,12)); + + BlockPos bPos = branchStart; + for (int b = 0; b < branchLength; b++) { + int stepX = random.nextFloat() < 0.7f ? dirX : 0; + int stepZ = random.nextFloat() < 0.7f ? dirZ : 0; + int stepY = random.nextFloat() < 0.4f ? 1 : 0; + bPos = bPos.offset(stepX, stepY, stepZ); + if(stepY == 1) this.placeLog(level, blockSetter, random, bPos.below(), config); + this.placeLog(level, blockSetter, random, bPos, config); + if (random.nextDouble() < 0.25) { + leafNodes.add(new FoliagePlacer.FoliageAttachment(bPos, random.nextInt(2), false)); + } + } + return bPos; + } + + public static int checkPointPosition(double xp, double yp, double xc, double yc, double r) { + double dx = xp - xc; + double dy = yp - yc; + double squaredDistance = (dx * dx) + (dy * dy); + + double squaredRadius = r * r * 1.25; + + if (squaredDistance < squaredRadius) { + return -1; + } else if (squaredDistance == squaredRadius) { + return 0; + } else { + return 1; + } + } +} diff --git a/src/main/java/net/halbear/aotg/registries/ModBlocks.java b/src/main/java/net/halbear/aotg/registries/ModBlocks.java index 254e44a..759282b 100644 --- a/src/main/java/net/halbear/aotg/registries/ModBlocks.java +++ b/src/main/java/net/halbear/aotg/registries/ModBlocks.java @@ -54,7 +54,7 @@ public class ModBlocks { )); public static final DeferredBlock OLIVE_LOG = RegisterBlock("olive_log", - properties -> new RotatedPillarBlock(properties.strength(0.5f) + properties -> new RotatedPillarBlock(properties.strength(0.35f) .requiresCorrectToolForDrops() .explosionResistance(1.0f) .sound(SoundType.WOOD) @@ -63,13 +63,20 @@ public class ModBlocks { public static final DeferredBlock OLIVE_LEAVES = RegisterBlock("olive_leaves", - properties -> new RockCoveredGrassBlock(properties.strength(0.15f) + properties -> new Block(properties.strength(0.15f) .requiresCorrectToolForDrops() .explosionResistance(0.5f) .sound(SoundType.GRASS) .lightLevel(state -> 0) .noOcclusion() )); + public static final DeferredBlock OLIVE_PLANKS = RegisterBlock("olive_planks", + properties -> new Block(properties.strength(0.35f) + .requiresCorrectToolForDrops() + .explosionResistance(1.0f) + .sound(SoundType.WOOD) + .lightLevel(state -> 0) + )); public static final DeferredBlock SHALE_BLOCK = RegisterBlock("shale_block", properties -> new RockCoveredGrassBlock(properties.strength(1.5f) diff --git a/src/main/java/net/halbear/aotg/registries/ModItems.java b/src/main/java/net/halbear/aotg/registries/ModItems.java index a13a9a1..04a2366 100644 --- a/src/main/java/net/halbear/aotg/registries/ModItems.java +++ b/src/main/java/net/halbear/aotg/registries/ModItems.java @@ -27,6 +27,7 @@ public class ModItems { public static final DeferredItem OLIVE_LOG_ITEM = ITEMS.registerSimpleBlockItem("olive_log", OLIVE_LOG); public static final DeferredItem ALLOY_FURNACE_ITEM = ITEMS.registerSimpleBlockItem("alloy_furnace", ALLOY_FURNACE); public static final DeferredItem FORGE_WORKBENCH_ITEM = ITEMS.registerSimpleBlockItem("forge", FORGE_WORKBENCH); + public static final DeferredItem OLIVE_PLANKS_ITEM = ITEMS.registerSimpleBlockItem("olive_planks", OLIVE_PLANKS); public static final DeferredItem FLUID_INDICATOR_ITEM = RegisterItem("fluid_indicator_debug_item", properties -> new Item(properties .fireResistant() diff --git a/src/main/java/net/halbear/aotg/registries/ModTabs.java b/src/main/java/net/halbear/aotg/registries/ModTabs.java index 8830477..9ac80ab 100644 --- a/src/main/java/net/halbear/aotg/registries/ModTabs.java +++ b/src/main/java/net/halbear/aotg/registries/ModTabs.java @@ -54,6 +54,7 @@ public class ModTabs { output.accept(ELECTRUM_INGOT.get()); output.accept(HEPATIZON_INGOT.get()); output.accept(ORICHALCUM_INGOT.get()); + output.accept(OLIVE_PLANKS_ITEM.get()); output.accept(HARDENED_SLAG.get()); output.accept(XIPHOS_SWORD.get()); }).build()); diff --git a/src/main/resources/assets/ageofthegods/Items/olive_planks.json b/src/main/resources/assets/ageofthegods/Items/olive_planks.json new file mode 100644 index 0000000..0e1aae2 --- /dev/null +++ b/src/main/resources/assets/ageofthegods/Items/olive_planks.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "ageofthegods:block/olive/olive_planks" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ageofthegods/blockstates/olive_planks.json b/src/main/resources/assets/ageofthegods/blockstates/olive_planks.json new file mode 100644 index 0000000..6a783fe --- /dev/null +++ b/src/main/resources/assets/ageofthegods/blockstates/olive_planks.json @@ -0,0 +1,9 @@ +{ + "variants": { + "": [ + { + "model": "ageofthegods:block/olive/olive_planks", "weight": 3 + } + ] + } +} diff --git a/src/main/resources/assets/ageofthegods/lang/en_us.json b/src/main/resources/assets/ageofthegods/lang/en_us.json index 6bc347b..6dfb1fd 100644 --- a/src/main/resources/assets/ageofthegods/lang/en_us.json +++ b/src/main/resources/assets/ageofthegods/lang/en_us.json @@ -7,14 +7,21 @@ "block.ageofthegods.shale_grass_block": "Grassy Shale", "block.ageofthegods.olive_leaves": "Olive Leaves", "block.ageofthegods.olive_log": "Olive Log", + "block.ageofthegods.olive_planks": "Olive Planks", "block.ageofthegods.alloy_furnace": "Alloy Furnace Segment", "block.ageofthegods.forge": "Forge", + "block.ageofthegods.silver_ore": "Silver Ore", + "block.ageofthegods.zinc_ore": "Zinc Ore", + "block.ageofthegods.tin_ore": "Tin Ore", "gui.ageofthegods.alloy_furnace_gui.title": "Alloy Furnace", "gui.ageofthegods.forge_workbench.title": "Forge", "item.ageofthegods.xiphos": "Xiphos", "item.ageofthegods.zinc_ingot": "Zinc Ingot", + "item.ageofthegods.raw_zinc": "Raw Zinc", + "item.ageofthegods.raw_tin": "Raw Tin", + "item.ageofthegods.raw_silver": "Raw Silver", "item.ageofthegods.tin_ingot": "Tin Ingot", "item.ageofthegods.silver_ingot": "Silver Ingot", "item.ageofthegods.bronze_ingot": "Bronze Ingot", diff --git a/src/main/resources/assets/ageofthegods/models/block/olive/olive_planks.json b/src/main/resources/assets/ageofthegods/models/block/olive/olive_planks.json new file mode 100644 index 0000000..619c241 --- /dev/null +++ b/src/main/resources/assets/ageofthegods/models/block/olive/olive_planks.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "ageofthegods:block/olive/olive_planks" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ageofthegods/textures/block/olive/olive_planks.png b/src/main/resources/assets/ageofthegods/textures/block/olive/olive_planks.png new file mode 100644 index 0000000000000000000000000000000000000000..52feab4b1e3d18bd4b505390c1ac921a1cb0cbec GIT binary patch literal 385 zcmV-{0e=38P)Px$J4r-AR5*==Q?W_|K@fchn`_Krv&RuQ2qN1^5J4-OKoG=FNSW`+C-@;ESc+8& z`z4655RN^NBVLmfXAx(aUH8oEZgytgyf<^naxv@j(-ZW;Hf=OcHDW%UKpP7H_^iJ% zmP4pA2LKF;kt;|u={4AG>q7%7CbqF0x`rxXO*4tzw#L5NxR@X|Z7jGHRp!wN(oDKW z0FW#fvyN*zragqXIWPV&#`Ny14YaXXtt-r@6F0S>ByFsxnVRro0ud?T(BMCI`c}** zGEp1b??LE8-+S`)`q=T+yu5$l;r`Z3}3*wN2|464FdUkbz`U fm_VSs@W6fmnlGom$VIOB00000NkvXXu0mjf literal 0 HcmV?d00001 diff --git a/src/main/resources/data/ageofthegods/recipe/xiphos.json b/src/main/resources/data/ageofthegods/recipe/xiphos.json new file mode 100644 index 0000000..420600d --- /dev/null +++ b/src/main/resources/data/ageofthegods/recipe/xiphos.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "pattern": [ + " a ", + " a ", + " b " + ], + "key": { + "a": "ageofthegods:bronze_ingot", + "c": "minecraft:stick" + }, + "result": { + "id": "ageofthegods:xiphos", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/ageofthegods/recipe/xiphos2.json b/src/main/resources/data/ageofthegods/recipe/xiphos2.json new file mode 100644 index 0000000..87fe1b8 --- /dev/null +++ b/src/main/resources/data/ageofthegods/recipe/xiphos2.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "pattern": [ + "a ", + "a ", + "b " + ], + "key": { + "a": "ageofthegods:bronze_ingot", + "c": "minecraft:stick" + }, + "result": { + "id": "ageofthegods:xiphos", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/ageofthegods/recipe/xiphos3.json b/src/main/resources/data/ageofthegods/recipe/xiphos3.json new file mode 100644 index 0000000..4509e7f --- /dev/null +++ b/src/main/resources/data/ageofthegods/recipe/xiphos3.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "pattern": [ + " a", + " a", + " b" + ], + "key": { + "a": "ageofthegods:bronze_ingot", + "c": "minecraft:stick" + }, + "result": { + "id": "ageofthegods:xiphos", + "count": 1 + } +} \ No newline at end of file