diff --git a/src/main/java/com/simibubi/create/foundation/world/OreGeneration.java b/src/main/java/com/simibubi/create/foundation/world/OreGeneration.java index 8cefa7072..203234673 100644 --- a/src/main/java/com/simibubi/create/foundation/world/OreGeneration.java +++ b/src/main/java/com/simibubi/create/foundation/world/OreGeneration.java @@ -7,22 +7,29 @@ import java.util.List; import com.simibubi.create.AllBlocks; import net.minecraft.block.Block; -import net.minecraft.block.Blocks; import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biomes; import net.minecraft.world.gen.GenerationStage; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.OreFeatureConfig; +import net.minecraft.world.gen.placement.ChanceRangeConfig; import net.minecraft.world.gen.placement.CountRangeConfig; import net.minecraft.world.gen.placement.Placement; import net.minecraftforge.registries.ForgeRegistries; public enum OreGeneration { - TEST_BLOB_1(new BasicOreGenConfig(Blocks.EMERALD_BLOCK, 25, 2, 128)), - TEST_BLOB_2(new BasicOreGenConfig(Blocks.QUARTZ_BLOCK, 41, 3, 25)), - TEST_BLOB_3(new OnlyInBiomes(new BasicOreGenConfig(Blocks.BLUE_GLAZED_TERRACOTTA, 5, 10, 30), Biome.Category.OCEAN)), - TEST_BLOB_4(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.GABBRO.get(), 31, 2, 128), Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS)), + COPPER_ORE_GENERAL(new BasicOreGenConfig(AllBlocks.COPPER_ORE.get(), 21, 3, 40, 96)), + COPPER_ORE_OCEAN(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.COPPER_ORE.get(), 15, 3, 20, 55), Biome.Category.OCEAN)), + + ZINC_ORE_GENERAL(new BasicOreGenConfig(AllBlocks.ZINC_ORE.get(), 17, 1, 55, 80)), + ZINC_ORE_DESERT(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.ZINC_ORE.get(), 17, 5, 50, 85),Biome.Category.DESERT)), + + BASALT_ROCK(new BasicOreGenConfig(AllBlocks.VOLCANIC_ROCK.get(), 39, 0.2f, 0, 10)), + + //TEST_BLOB_1(new BasicOreGenConfig(Blocks.EMERALD_BLOCK, 25, 2, 0, 128)), + //TEST_BLOB_2(new BasicOreGenConfig(Blocks.QUARTZ_BLOCK, 41, 3, 0, 25)), + //TEST_BLOB_3(new OnlyInBiomes(new BasicOreGenConfig(Blocks.BLUE_GLAZED_TERRACOTTA, 5, 10, 0, 30), Biome.Category.OCEAN)), + //TEST_BLOB_4(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.GABBRO.get(), 31, 2, 0, 128), Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS)), ; @@ -45,22 +52,42 @@ public enum OreGeneration { Block block; //im not 100% certain that these names are accurate but at least they seem that way - int clusterSize, clusterCount/*per chunk*/, maxHeight; + private int clusterSize, clusterCount, minHeight, maxHeight; + private float clusterChance; - private BasicOreGenConfig(Block block, int clusterSize, int clusterCount, int maxHeight) { + private BasicOreGenConfig(Block block, int clusterSize, int clusterCount, int minHeight, int maxHeight) { this.block = block; this.clusterSize = clusterSize; this.clusterCount = clusterCount; + this.clusterChance = 1.0f; + this.minHeight = minHeight; + this.maxHeight = maxHeight; + } + + private BasicOreGenConfig(Block block, int clusterSize, float clusterChance, int minHeight, int maxHeight) { + this.block = block; + this.clusterSize = clusterSize; + this.clusterCount = 0; + this.clusterChance = clusterChance; + this.minHeight = minHeight; this.maxHeight = maxHeight; } @Override public void addFeature(Biome biome) { - biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, - Biome.createDecoratedFeature(Feature.ORE, - new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, - block.getDefaultState(), clusterSize), - Placement.COUNT_RANGE, new CountRangeConfig(clusterCount, 0, 0, maxHeight))); + if (clusterCount > 0) { + biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, + Biome.createDecoratedFeature(Feature.ORE, + new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, + block.getDefaultState(), clusterSize), + Placement.COUNT_RANGE, new CountRangeConfig(clusterCount, minHeight, 0, maxHeight))); + } else { + biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, + Biome.createDecoratedFeature(Feature.ORE, + new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, + block.getDefaultState(), clusterSize), + Placement.CHANCE_RANGE, new ChanceRangeConfig(clusterChance, minHeight, 0, maxHeight))); + } } } diff --git a/src/main/java/com/simibubi/create/foundation/world/OxidizingBlock.java b/src/main/java/com/simibubi/create/foundation/world/OxidizingBlock.java index a8ea4d7bc..be85f0595 100644 --- a/src/main/java/com/simibubi/create/foundation/world/OxidizingBlock.java +++ b/src/main/java/com/simibubi/create/foundation/world/OxidizingBlock.java @@ -1,49 +1,69 @@ package com.simibubi.create.foundation.world; +import java.util.LinkedList; +import java.util.OptionalDouble; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.state.BooleanProperty; +import net.minecraft.state.IntegerProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; public class OxidizingBlock extends Block { - public static final BooleanProperty OXIDIZED = BooleanProperty.create("oxidized"); + public static final IntegerProperty OXIDIZATION = IntegerProperty.create("oxidization", 0, 7); private float chance; public OxidizingBlock(Properties properties, float chance) { super(properties); this.chance = chance; - setDefaultState(getDefaultState().with(OXIDIZED, false)); + setDefaultState(getDefaultState().with(OXIDIZATION, 0)); } @Override protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(OXIDIZED)); + super.fillStateContainer(builder.add(OXIDIZATION)); } @Override public boolean ticksRandomly(BlockState state) { - return super.ticksRandomly(state) || !state.get(OXIDIZED); + return super.ticksRandomly(state) || state.get(OXIDIZATION) < 7; } - + @Override public void randomTick(BlockState state, World worldIn, BlockPos pos, Random random) { - if (worldIn.getRandom().nextFloat() <= chance) + if (worldIn.getRandom().nextFloat() <= chance) { + int currentState = state.get(OXIDIZATION); + boolean canIncrease = false; + LinkedList neighbors = new LinkedList<>(); for (Direction facing : Direction.values()) { BlockPos neighbourPos = pos.offset(facing); if (!worldIn.isBlockPresent(neighbourPos)) continue; - if (!Block.hasSolidSide(worldIn.getBlockState(neighbourPos), worldIn, neighbourPos, - facing.getOpposite())) + BlockState neighborState = worldIn.getBlockState(neighbourPos); + if (neighborState.has(OXIDIZATION)) { + neighbors.add(neighborState.get(OXIDIZATION)); + } + if (Block.hasSolidSide(neighborState, worldIn, neighbourPos, + facing.getOpposite())) { continue; - worldIn.setBlockState(pos, state.with(OXIDIZED, true)); - break; + } + canIncrease = true; } + if (canIncrease) { + OptionalDouble average = neighbors.stream().mapToInt(v -> v).average(); + if (average.orElse(7d) >= currentState) + worldIn.setBlockState(pos, state.with(OXIDIZATION, Math.min(currentState + 1, 7))); + } + } } + @Override + public float getBlockHardness(BlockState blockState, IBlockReader worldIn, BlockPos pos) { + return this.blockHardness - 0.2f * blockState.get(OXIDIZATION); + } } diff --git a/src/main/resources/assets/create/blockstates/copper_ore.json b/src/main/resources/assets/create/blockstates/copper_ore.json index 4a2d71196..05a62ab54 100644 --- a/src/main/resources/assets/create/blockstates/copper_ore.json +++ b/src/main/resources/assets/create/blockstates/copper_ore.json @@ -1,6 +1,12 @@ { "variants": { - "oxidized=true": { "model": "create:block/copper_ore_oxidized" }, - "oxidized=false": { "model": "create:block/copper_ore" } + "oxidization=0": { "model": "create:block/copper_ore_oxidization0" }, + "oxidization=1": { "model": "create:block/copper_ore_oxidization1" }, + "oxidization=2": { "model": "create:block/copper_ore_oxidization2" }, + "oxidization=3": { "model": "create:block/copper_ore_oxidization3" }, + "oxidization=4": { "model": "create:block/copper_ore_oxidization4" }, + "oxidization=5": { "model": "create:block/copper_ore_oxidization5" }, + "oxidization=6": { "model": "create:block/copper_ore_oxidization6" }, + "oxidization=7": { "model": "create:block/copper_ore_oxidization7" } } } \ No newline at end of file diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index d828418b8..aeb283fdf 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -506,6 +506,11 @@ "create.command.killTPSCommand.status.usage.1": "[Create]: use /killtps start to artificially slow down the server tick", "create.command.killTPSCommand.argument.tickTime": "tickTime", + "advancement.create:root": "Create Advancements", + "advancement.create:root.desc": "~ todo", + "advancement.create:test": "test advancement", + "advancement.create:test.desc": "test advancement description", + "_comment": "-------------------------] ITEM DESCRIPTIONS [------------------------------------------------", "item.create.example_item.tooltip": "EXAMPLE ITEM (just a marker that this tooltip exists)", diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization0.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization0.json new file mode 100644 index 000000000..ca2cd845d --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization0.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization0" + } +} diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization1.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization1.json new file mode 100644 index 000000000..057bd9a02 --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization1.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization1" + } +} diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization2.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization2.json new file mode 100644 index 000000000..8c4c6270e --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization2.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization2" + } +} diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization3.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization3.json new file mode 100644 index 000000000..c59aa7c25 --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization3.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization3" + } +} diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization4.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization4.json new file mode 100644 index 000000000..d76e8a2b4 --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization4.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization4" + } +} diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization5.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization5.json new file mode 100644 index 000000000..d653db79f --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization5.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization5" + } +} diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization6.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization6.json new file mode 100644 index 000000000..9cce4f3ce --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization6.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization6" + } +} diff --git a/src/main/resources/assets/create/models/block/copper_ore_oxidization7.json b/src/main/resources/assets/create/models/block/copper_ore_oxidization7.json new file mode 100644 index 000000000..714e43b97 --- /dev/null +++ b/src/main/resources/assets/create/models/block/copper_ore_oxidization7.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/copper_ore_oxidization7" + } +} diff --git a/src/main/resources/assets/create/models/item/copper_ore.json b/src/main/resources/assets/create/models/item/copper_ore.json index 0ed008141..5f162f594 100644 --- a/src/main/resources/assets/create/models/item/copper_ore.json +++ b/src/main/resources/assets/create/models/item/copper_ore.json @@ -1,3 +1,3 @@ { - "parent": "create:block/copper_ore" + "parent": "create:block/copper_ore_oxidization0" } \ No newline at end of file diff --git a/src/main/resources/assets/create/textures/block/copper_ore.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization0.png similarity index 100% rename from src/main/resources/assets/create/textures/block/copper_ore.png rename to src/main/resources/assets/create/textures/block/copper_ore_oxidization0.png diff --git a/src/main/resources/assets/create/textures/block/copper_ore_oxidization1.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization1.png new file mode 100644 index 000000000..38b2cee6a Binary files /dev/null and b/src/main/resources/assets/create/textures/block/copper_ore_oxidization1.png differ diff --git a/src/main/resources/assets/create/textures/block/copper_ore_oxidization2.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization2.png new file mode 100644 index 000000000..920e1cbb8 Binary files /dev/null and b/src/main/resources/assets/create/textures/block/copper_ore_oxidization2.png differ diff --git a/src/main/resources/assets/create/textures/block/copper_ore_oxidization3.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization3.png new file mode 100644 index 000000000..3378f6b07 Binary files /dev/null and b/src/main/resources/assets/create/textures/block/copper_ore_oxidization3.png differ diff --git a/src/main/resources/assets/create/textures/block/copper_ore_oxidization4.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization4.png new file mode 100644 index 000000000..d3a1b9f8f Binary files /dev/null and b/src/main/resources/assets/create/textures/block/copper_ore_oxidization4.png differ diff --git a/src/main/resources/assets/create/textures/block/copper_ore_oxidization5.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization5.png new file mode 100644 index 000000000..6fc4e5712 Binary files /dev/null and b/src/main/resources/assets/create/textures/block/copper_ore_oxidization5.png differ diff --git a/src/main/resources/assets/create/textures/block/copper_ore_oxidization6.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization6.png new file mode 100644 index 000000000..8e8b0caf0 Binary files /dev/null and b/src/main/resources/assets/create/textures/block/copper_ore_oxidization6.png differ diff --git a/src/main/resources/assets/create/textures/block/copper_ore_oxidized.png b/src/main/resources/assets/create/textures/block/copper_ore_oxidization7.png similarity index 100% rename from src/main/resources/assets/create/textures/block/copper_ore_oxidized.png rename to src/main/resources/assets/create/textures/block/copper_ore_oxidization7.png diff --git a/src/main/resources/data/create/advancements/root.json b/src/main/resources/data/create/advancements/root.json new file mode 100644 index 000000000..8a4479c08 --- /dev/null +++ b/src/main/resources/data/create/advancements/root.json @@ -0,0 +1,21 @@ +{ + "display": { + "icon": { + "item": "create:cogwheel" + }, + "title": { + "translate": "advancement.create:root" + }, + "description": { + "translate": "advancement.create:root.desc" + }, + "background": "create:textures/block/brass_casing_side.png", + "show_toast": false, + "announce_to_chat": false + }, + "criteria": { + "flower": { + "trigger": "minecraft:inventory_changed" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/create/advancements/test.json b/src/main/resources/data/create/advancements/test.json new file mode 100644 index 000000000..bf5f5bb6f --- /dev/null +++ b/src/main/resources/data/create/advancements/test.json @@ -0,0 +1,26 @@ +{ + "display": { + "icon": { + "item": "create:wrench" + }, + "title": { + "translate": "advancement.create:test" + }, + "description": { + "translate": "advancement.create:test.desc" + } + }, + "parent": "create:root", + "criteria": { + "flower": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:wrench" + } + ] + } + } + } +} \ No newline at end of file