From b68cb9114b0f5922aea50929309369f15d38ed7f Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Thu, 6 May 2021 17:15:07 +0800 Subject: [PATCH] finish terrain generation --- scripts/ore_manager/block_gen.py | 166 ++++++++++++ scripts/ore_manager/en.txt | 7 + scripts/ore_manager/stone.png | Bin 0 -> 215 bytes scripts/ore_manager/zh.txt | 7 + scripts/plant_manager/block_gen.py | 239 ++++++++++++++++++ scripts/plant_manager/en.txt | 18 ++ scripts/plant_manager/flower.png | Bin 0 -> 139 bytes scripts/plant_manager/prop.txt | 18 ++ .../plant_manager/sweet_berry_bush_stage0.png | Bin 0 -> 162 bytes .../plant_manager/sweet_berry_bush_stage1.png | Bin 0 -> 255 bytes .../plant_manager/sweet_berry_bush_stage2.png | Bin 0 -> 280 bytes .../plant_manager/sweet_berry_bush_stage3.png | Bin 0 -> 294 bytes scripts/plant_manager/zh.txt | 18 ++ .../teyvatcraft/init/TerrainsManager.java | 230 +++++++++++++---- .../teyvatcraft/mixin/FlowerForestAccess.java | 20 ++ .../blockstates/cor_lapis_ore.json | 7 + .../blockstates/noctilucous_jade_ore.json | 7 + .../assets/teyvatcraft/lang/en_us.json | 2 + .../assets/teyvatcraft/lang/zh_cn.json | 2 + .../models/block/cor_lapis_ore.json | 6 + .../models/block/noctilucous_jade_ore.json | 6 + .../models/item/cor_lapis_ore.json | 3 + .../models/item/noctilucous_jade_ore.json | 3 + .../textures/block/cor_lapis_ore.png | Bin 0 -> 617 bytes .../textures/block/noctilucous_jade_ore.png | Bin 0 -> 629 bytes .../loot_tables/blocks/cor_lapis_ore.json | 6 +- .../blocks/noctilucous_jade_ore.json | 6 +- src/main/resources/teyvatcraft.mixins.json | 3 +- 28 files changed, 715 insertions(+), 59 deletions(-) create mode 100644 scripts/ore_manager/block_gen.py create mode 100644 scripts/ore_manager/en.txt create mode 100644 scripts/ore_manager/stone.png create mode 100644 scripts/ore_manager/zh.txt create mode 100644 scripts/plant_manager/block_gen.py create mode 100644 scripts/plant_manager/en.txt create mode 100644 scripts/plant_manager/flower.png create mode 100644 scripts/plant_manager/prop.txt create mode 100644 scripts/plant_manager/sweet_berry_bush_stage0.png create mode 100644 scripts/plant_manager/sweet_berry_bush_stage1.png create mode 100644 scripts/plant_manager/sweet_berry_bush_stage2.png create mode 100644 scripts/plant_manager/sweet_berry_bush_stage3.png create mode 100644 scripts/plant_manager/zh.txt create mode 100644 src/main/java/net/yyc12345/teyvatcraft/mixin/FlowerForestAccess.java create mode 100644 src/main/resources/assets/teyvatcraft/blockstates/cor_lapis_ore.json create mode 100644 src/main/resources/assets/teyvatcraft/blockstates/noctilucous_jade_ore.json create mode 100644 src/main/resources/assets/teyvatcraft/models/block/cor_lapis_ore.json create mode 100644 src/main/resources/assets/teyvatcraft/models/block/noctilucous_jade_ore.json create mode 100644 src/main/resources/assets/teyvatcraft/models/item/cor_lapis_ore.json create mode 100644 src/main/resources/assets/teyvatcraft/models/item/noctilucous_jade_ore.json create mode 100644 src/main/resources/assets/teyvatcraft/textures/block/cor_lapis_ore.png create mode 100644 src/main/resources/assets/teyvatcraft/textures/block/noctilucous_jade_ore.png diff --git a/scripts/ore_manager/block_gen.py b/scripts/ore_manager/block_gen.py new file mode 100644 index 0000000..be1ac7a --- /dev/null +++ b/scripts/ore_manager/block_gen.py @@ -0,0 +1,166 @@ +import sys +import os +import shutil + +def ReadListFromFile(filename, listInstance): + f = open(filename, 'r', encoding='utf-8') + while True: + cache = f.readline() + if cache == '': + break; + cache = cache.strip() + if cache == '': + listInstance.append('') + continue + if cache.startswith('//'): + continue + listInstance.append(cache) + f.close() + +def GetUnderlineName(strl): + return strl.lower().replace(',', '').replace('& ', '').replace('é', 'e').replace('-', '_').replace("'", '').replace('"', '').replace(' ', '_') + +# folder creation +if not os.path.isdir('data/teyvatcraft/loot_tables/blocks'): + os.makedirs('data/teyvatcraft/loot_tables/blocks') +if not os.path.isdir('assets/teyvatcraft/models/block'): + os.makedirs('assets/teyvatcraft/models/block') +if not os.path.isdir('assets/teyvatcraft/models/item'): + os.makedirs('assets/teyvatcraft/models/item') +if not os.path.isdir('assets/teyvatcraft/blockstates'): + os.makedirs('assets/teyvatcraft/blockstates') +if not os.path.isdir('assets/teyvatcraft/textures/block'): + os.makedirs('assets/teyvatcraft/textures/block') + + +# read file +enList = [] +zhList = [] + +ReadListFromFile('zh.txt', zhList) +ReadListFromFile('en.txt', enList) + +if len(zhList) != len(enList): + print('2 files item is not matched') + sys.exit(0) + +javaDeclareFile = open('declare.block.java', 'w', encoding='utf-8') +javaRegisterFile = open('register.block.java', 'w', encoding='utf-8') +langZhFile = open('zh_cn.block.json', 'w', encoding='utf-8') +langEnFile = open('en_us.block.json', 'w', encoding='utf-8') +for index in range(len(enList)): + if enList[index] == '': + # keep blank line in register & declare + javaDeclareFile.write('\n') + javaRegisterFile.write('\n') + langZhFile.write('\n') + langEnFile.write('\n') + continue + + (droppedName, oreName) = enList[index].split('#') + dropped_underlineName = GetUnderlineName(droppedName) + ore_underlineName = GetUnderlineName(oreName) + ore_upperName = ore_underlineName.upper() + + flootTables = open('data/teyvatcraft/loot_tables/blocks/' + ore_underlineName + '.json', 'w', encoding='utf-8') + fblockstates = open('assets/teyvatcraft/blockstates/' + ore_underlineName + '.json', 'w', encoding='utf-8') + fmodel = open('assets/teyvatcraft/models/block/{}.json'.format(ore_underlineName), 'w', encoding='utf-8') + fmodelItem = open('assets/teyvatcraft/models/item/{}.json'.format(ore_underlineName), 'w', encoding='utf-8') + + flootTables.write('''{{ + "type": "minecraft:block", + "pools": [ + {{ + "rolls": 1, + "entries": [ + {{ + "type": "minecraft:alternatives", + "children": [ + {{ + "type": "minecraft:item", + "conditions": [ + {{ + "condition": "minecraft:match_tool", + "predicate": {{ + "enchantments": [ + {{ + "enchantment": "minecraft:silk_touch", + "levels": {{ + "min": 1 + }} + }} + ] + }} + }} + ], + "name": "teyvatcraft:{}" + }}, + {{ + "type": "minecraft:item", + "functions": [ + {{ + "function": "minecraft:set_count", + "count": {{ + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + }} + }}, + {{ + "function": "minecraft:apply_bonus", + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "parameters": {{ + "bonusMultiplier": 1 + }} + }}, + {{ + "function": "minecraft:explosion_decay" + }} + ], + "name": "teyvatcraft:{}" + }} + ] + }} + ] + }} + ] +}}'''.format(ore_underlineName, dropped_underlineName)) + + fblockstates.write('''{{ + "variants": {{ + "": {{ + "model": "teyvatcraft:block/{}" + }} + }} +}}'''.format(ore_underlineName)) + + fmodel.write('''{{ + "parent": "minecraft:block/cube_all", + "textures": {{ + "all": "teyvatcraft:block/{}" + }} +}}'''.format(ore_underlineName)) + + fmodelItem.write('''{{ + "parent": "teyvatcraft:block/{}" +}}'''.format(ore_underlineName)) + + flootTables.close() + fblockstates.close() + fmodel.close() + fmodelItem.close() + + javaDeclareFile.write('public static final Block {} = new OreBlock(getOreBlockSettings(1, 3.0f));\n'.format(ore_upperName)) + javaRegisterFile.write('Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "{}"), {});\n'.format(ore_underlineName, ore_upperName)) + + langZhFile.write('"block.teyvatcraft.{}": "{}",\n'.format(ore_underlineName, zhList[index].split('#')[1])) + langEnFile.write('"block.teyvatcraft.{}": "{}",\n'.format(ore_underlineName, enList[index].split('#')[1].replace('"', ''))) + + shutil.copyfile('stone.png', 'assets/teyvatcraft/textures/block/{}.png'.format(ore_underlineName)) + + +javaDeclareFile.close() +javaRegisterFile.close() +langZhFile.close() +langEnFile.close() diff --git a/scripts/ore_manager/en.txt b/scripts/ore_manager/en.txt new file mode 100644 index 0000000..ed4d93e --- /dev/null +++ b/scripts/ore_manager/en.txt @@ -0,0 +1,7 @@ +//Magical Crystal Chunk#Magical Crystal Chunk Ore +//Crystal Chunk#Crystal Chunk Ore +//White Iron Chunk#White Iron Chunk Ore +//Iron Chunk#Iron Chunk Ore +//Starsilver#Starsilver Ore +Cor Lapis#Cor Lapis Ore +Noctilucous Jade#Noctilucous Jade Ore diff --git a/scripts/ore_manager/stone.png b/scripts/ore_manager/stone.png new file mode 100644 index 0000000000000000000000000000000000000000..2665baef2a32e0e8ae787419f3e5c87c6acc2e72 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`^E_P~Lo80W20IEd7_xkh;V*bE zY_qdE>5|DV_QNxTl(wF^laakvR?u3>s_eURdzxqhqrFz~_q?!t-avuQiOY}KGOi1l z_t_$MW@5UV_IaDcUc*I3aVu-m<_Q~c9eXUg!CHCGwbyKG7+oK1Ntz${aY5JA7iaG3 zD}MCS+3>h0Ys>W;d)8?-U74StIeq&}Vc#>!?`AzvUDoOGJ9z#hmVgL{O=s|Q^>bP0l+XkK9o{gC literal 0 HcmV?d00001 diff --git a/scripts/plant_manager/prop.txt b/scripts/plant_manager/prop.txt new file mode 100644 index 0000000..b403f3e --- /dev/null +++ b/scripts/plant_manager/prop.txt @@ -0,0 +1,18 @@ +flower +flower +sweet_berry_bush +flower +flower +flower +sweet_berry_bush +flower +flower +flower +flower +flower +flower +sweet_berry_bush +sweet_berry_bush +flower +sweet_berry_bush +flower diff --git a/scripts/plant_manager/sweet_berry_bush_stage0.png b/scripts/plant_manager/sweet_berry_bush_stage0.png new file mode 100644 index 0000000000000000000000000000000000000000..6b5854dad976baf59a73bb79c0ce47fe49d1689f GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`nVv3=Ar_~T6C_v{Gw@&FG5W#3 zC{=gLzibuDKk8A+K877^nQa><{$$~0NbIkwH{dPe^iV$Is&bR>Qi~3o(Ub++4znD% z63q_BFfDSNq4E51j{A2upLr`TwBPJ_$Ga$rDNXv!eg&!N_ZffvkG^~P^6CJfr3{{~ KelF{r5}E)C_c#pz literal 0 HcmV?d00001 diff --git a/scripts/plant_manager/sweet_berry_bush_stage1.png b/scripts/plant_manager/sweet_berry_bush_stage1.png new file mode 100644 index 0000000000000000000000000000000000000000..216269ca02a131c539f2670b4331b32270eeec73 GIT binary patch literal 255 zcmV3p5JdMPCPtbWZeSorf`Q->Jb+j5=p!XOdCYGchUuBQ6R{fx6PotK~r!#WThxw1I()Ltg<0Y5rC}Sy8n~p4Li2h^-p*5?4E(i z8s9uxew2_;hw08C0pJ`UGwWKwdscF*vYM`Z6ad5uz+q=dvZok;Ns{M&^Jnt#*vUEn z?B3Uw$o@Py?jVC?7#?E%1*~EUW>^dn@U*kT-`p1Kx-Zn;_Oeh!4gCNB002ovPDHLk FV1f&{axnk^ literal 0 HcmV?d00001 diff --git a/scripts/plant_manager/sweet_berry_bush_stage2.png b/scripts/plant_manager/sweet_berry_bush_stage2.png new file mode 100644 index 0000000000000000000000000000000000000000..4254cc09f4ca242f0642eff6ddef0ad66d9a185a GIT binary patch literal 280 zcmV+z0q6dSP)K6+0_uQ=|_A z#AFnJ>^JX#k`dGOP|SYwGP!uH#ITWG@+ufT{4{hkDJE}@;iBay0ITMEpfjuh{CrIL eky5}%%=128fdoL-u8m*-00000oneEP)Q%G+v@y(Z5b^E!I8zb}zW6jC(ys@{95GU$-w%PZf7qM##Cek4$D s3_=Q9(ND4+_AN+GLnGdK{4?dg4`;?6Ie=3qR{#J207*qoM6N<$g6~OsLI3~& literal 0 HcmV?d00001 diff --git a/scripts/plant_manager/zh.txt b/scripts/plant_manager/zh.txt new file mode 100644 index 0000000..710f796 --- /dev/null +++ b/scripts/plant_manager/zh.txt @@ -0,0 +1,18 @@ +嘟嘟莲 +蒲公英籽 +绝云椒椒 +小灯草 +薄荷 +甜甜花 +树莓 +金鱼草 +松茸 +马尾 +塞西莉亚花 +琉璃百合 +慕风蘑菇 +霓裳花 +落落莓 +风车菊 +钩钩果 +清心 diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java index fe02644..442e722 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java +++ b/src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java @@ -3,78 +3,204 @@ package net.yyc12345.teyvatcraft.init; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; +import java.util.function.Predicate; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; + +import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.util.Identifier; +import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.decorator.Decorator; -import net.minecraft.world.gen.decorator.RangeDecoratorConfig; import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.OreFeatureConfig; +import net.minecraft.world.gen.feature.RandomPatchFeatureConfig; +import net.minecraft.world.gen.feature.ConfiguredFeatures.Decorators; +import net.minecraft.world.gen.placer.BlockPlacer; +import net.minecraft.world.gen.placer.SimpleBlockPlacer; +import net.minecraft.world.gen.stateprovider.BlockStateProvider; +import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; +import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; +import net.yyc12345.teyvatcraft.mixin.FlowerForestAccess; public class TerrainsManager { + private static final Block[] NORMAL__FLOWERS = new Block[] { + BlocksManager.DANDELION_SEED, + BlocksManager.SMALL_LAMP_GRASS, + BlocksManager.MINT, + BlocksManager.SWEET_FLOWER, + BlocksManager.MATSUTAKE, + BlocksManager.GLAZE_LILY, + BlocksManager.PHILANEMO_MUSHROOM, + BlocksManager.WINDWHEEL_ASTER + }; + private static final Block[] SWAMP__FLOWERS = new Block[] { + BlocksManager.CALLA_LILY, + BlocksManager.SNAPDRAGON, + BlocksManager.HORSETAIL + }; + private static final Block[] MOUNTAINS__FLOWERS = new Block[] { + BlocksManager.CECILIA, + BlocksManager.QINGXIN + }; + + private static final Block[] NORMAL__SWEET_BERRY_BUSH = new Block[] { + BlocksManager.JUEYUN_CHILI, + BlocksManager.BERRY, + BlocksManager.SILK_FLOWER, + BlocksManager.VALBERRY, + BlocksManager.WOLFHOOK, + }; + // ==================== ore gen - private static ConfiguredFeature OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - BlocksManager.MAGICAL_CRYSTAL_CHUNK_ORE.getDefaultState(), - 1)) // vein size - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 12))) - .spreadHorizontally() - .repeat(5); // number of veins per chunk + private static ConfiguredFeature OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE = generateOreFreature(2, 12, 5, BlocksManager.MAGICAL_CRYSTAL_CHUNK_ORE); + private static ConfiguredFeature OREGEN_CRYSTAL_CHUNK_ORE = generateOreFreature(4, 32, 12, BlocksManager.CRYSTAL_CHUNK_ORE); + private static ConfiguredFeature OREGEN_WHITE_IRON_CHUNK_ORE = generateOreFreature(4, 64, 24, BlocksManager.WHITE_IRON_CHUNK_ORE); + private static ConfiguredFeature OREGEN_IRON_CHUNK_ORE = generateOreFreature(8, 64, 24, BlocksManager.IRON_CHUNK_ORE); + private static ConfiguredFeature OREGEN_STARSILVER_ORE = generateOreFreature(4, 64, 24, BlocksManager.STARSILVER_ORE); + private static ConfiguredFeature OREGEN_NOCTILUCOUS_JADE_ORE = generateOreFreature(4, 64, 24, BlocksManager.NOCTILUCOUS_JADE_ORE); + private static ConfiguredFeature OREGEN_COR_LAPIS_ORE = generateOreFreature(4, 64, 24, BlocksManager.COR_LAPIS_ORE); - private static ConfiguredFeature OREGEN_CRYSTAL_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - BlocksManager.CRYSTAL_CHUNK_ORE.getDefaultState(), - 4)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 32))) - .spreadHorizontally() - .repeat(12); + private static ConfiguredFeature FLOWERGEN_NORMAL = generateFlowerLikePlantFreature(NORMAL__FLOWERS); + private static ConfiguredFeature FLOWERGEN_SWAMP = generateFlowerLikePlantFreature(SWAMP__FLOWERS); + private static ConfiguredFeature FLOWERGEN_MOUNTAINS = generateFlowerLikePlantFreature(MOUNTAINS__FLOWERS); + private static ConfiguredFeature SBBGEN_NORMAL = generateSweetBerryBushLikePlantFreature(NORMAL__SWEET_BERRY_BUSH); - private static ConfiguredFeature OREGEN_WHITE_IRON_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - BlocksManager.WHITE_IRON_CHUNK_ORE.getDefaultState(), - 4)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 64))) - .spreadHorizontally() - .repeat(24); + // ================ feature generator + private static ConfiguredFeature generateOreFreature(int veinSize, int maxY, int repeat, Block blk) { + return Feature.ORE + .configure(new OreFeatureConfig( + OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, + blk.getDefaultState(), + veinSize)) + .rangeOf(maxY) + .spreadHorizontally() + .repeat(repeat); + } + private static ConfiguredFeature generateFlowerLikePlantFreature(Block[] flowerBlks) { + WeightedBlockStateProvider provider = new WeightedBlockStateProvider(); + for(Block item : flowerBlks) { + provider.addState(item.getDefaultState(), 1); + } - private static ConfiguredFeature OREGEN_IRON_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - BlocksManager.IRON_CHUNK_ORE.getDefaultState(), - 8)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 64))) - .spreadHorizontally() - .repeat(24); + return Feature.FLOWER + .configure((new RandomPatchFeatureConfig.Builder( + (BlockStateProvider)provider, + (BlockPlacer)SimpleBlockPlacer.INSTANCE)) + .tries(64) + .build()) + .decorate(Decorators.SPREAD_32_ABOVE) + .decorate(Decorators.SQUARE_HEIGHTMAP) + .repeat(2); + } + private static ConfiguredFeature generateSweetBerryBushLikePlantFreature(Block[] plantBlks) { + WeightedBlockStateProvider provider = new WeightedBlockStateProvider(); + for(Block item : plantBlks) { + provider.addState(item.getDefaultState(), 1); + } - private static ConfiguredFeature OREGEN_STARSILVER_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - BlocksManager.IRON_CHUNK_ORE.getDefaultState(), - 4)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 64))) - .spreadHorizontally() - .repeat(24); + return Feature.RANDOM_PATCH + .configure((new RandomPatchFeatureConfig.Builder( + (BlockStateProvider)provider, + (BlockPlacer)SimpleBlockPlacer.INSTANCE)) + .tries(64) + .whitelist((Set)ImmutableSet.of(Blocks.GRASS_BLOCK)) + .cannotProject() + .build()); + } - private static void registerOreGeneration(String mIdentifier, ConfiguredFeature genStasticas) { + // ================ biome register + private static Predicate getAllBiomeSelector() { + return BiomeSelectors.foundInOverworld(); + } + private static Predicate getMountainsBiomeSelector() { + return BiomeSelectors.includeByKey( + BiomeKeys.MOUNTAINS, + BiomeKeys.GRAVELLY_MOUNTAINS, + BiomeKeys.WOODED_MOUNTAINS, + BiomeKeys.MODIFIED_GRAVELLY_MOUNTAINS + ); + } + private static Predicate getSwampBiomeSelector() { + return BiomeSelectors.includeByKey( + BiomeKeys.SWAMP, + BiomeKeys.SWAMP_HILLS + ); + } + private static Predicate getBadlandsBiomeSelector() { + return BiomeSelectors.includeByKey( + BiomeKeys.BADLANDS, + BiomeKeys.ERODED_BADLANDS, + BiomeKeys.WOODED_BADLANDS_PLATEAU, + BiomeKeys.MODIFIED_BADLANDS_PLATEAU, + BiomeKeys.BADLANDS_PLATEAU + ); + } + private static Predicate getFrozenBiomeSelector() { + return BiomeSelectors.includeByKey( + BiomeKeys.SNOWY_TUNDRA, + BiomeKeys.ICE_SPIKES, + BiomeKeys.SNOWY_TAIGA, + BiomeKeys.SNOWY_TAIGA_MOUNTAINS, + BiomeKeys.FROZEN_RIVER, + BiomeKeys.SNOWY_BEACH, + BiomeKeys.SNOWY_MOUNTAINS + ); + } + + private static void registerOreGeneration(String mIdentifier, ConfiguredFeature genFeature, Predicate biomeSelector) { RegistryKey> regKey = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("teyvatcraft", mIdentifier)); - Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, regKey.getValue(), genStasticas); - BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Feature.UNDERGROUND_ORES, regKey); + Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, regKey.getValue(), genFeature); + BiomeModifications.addFeature(biomeSelector, GenerationStep.Feature.UNDERGROUND_ORES, regKey); + } + + private static void registerPlantGeneration(String mIdentifier, ConfiguredFeature genFeature, Predicate biomeSelector) { + RegistryKey> regKey = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, + new Identifier("teyvatcraft", mIdentifier)); + Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, regKey.getValue(), genFeature); + BiomeModifications.addFeature(biomeSelector, GenerationStep.Feature.VEGETAL_DECORATION, regKey); } public static void RegisterAll() { // ore gen - registerOreGeneration("oregen_magical_crystal_ore", OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE); - registerOreGeneration("oregen_crystal_ore", OREGEN_CRYSTAL_CHUNK_ORE); - registerOreGeneration("oregen_white_iron_ore", OREGEN_WHITE_IRON_CHUNK_ORE); - registerOreGeneration("oregen_iron_ore", OREGEN_IRON_CHUNK_ORE); - registerOreGeneration("oregen_starsilver_ore", OREGEN_STARSILVER_ORE); + registerOreGeneration("oregen_magical_crystal_ore", OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE, getAllBiomeSelector()); + registerOreGeneration("oregen_crystal_ore", OREGEN_CRYSTAL_CHUNK_ORE, getAllBiomeSelector()); + registerOreGeneration("oregen_white_iron_ore", OREGEN_WHITE_IRON_CHUNK_ORE, getAllBiomeSelector()); + registerOreGeneration("oregen_iron_ore", OREGEN_IRON_CHUNK_ORE, getAllBiomeSelector()); + registerOreGeneration("oregen_starsilver_ore", OREGEN_STARSILVER_ORE, getFrozenBiomeSelector()); + registerOreGeneration("oregen_noctilucous_jade_ore", OREGEN_NOCTILUCOUS_JADE_ORE, getBadlandsBiomeSelector()); + registerOreGeneration("oregen_cor_lapis_ore", OREGEN_COR_LAPIS_ORE, getBadlandsBiomeSelector()); + + // flower gen + registerPlantGeneration("flowergen_normal", FLOWERGEN_NORMAL, getAllBiomeSelector()); + registerPlantGeneration("flowergen_swamp", FLOWERGEN_SWAMP, getSwampBiomeSelector()); + registerPlantGeneration("flowergen_mountains", FLOWERGEN_MOUNTAINS, getMountainsBiomeSelector()); + + registerPlantGeneration("sbbgen_normal", SBBGEN_NORMAL, getAllBiomeSelector()); + + // patch flower forest + BlockState[] flowerForestArray = FlowerForestAccess.getFlowers(); + List flowerForestList = new ArrayList(); + for(BlockState item : flowerForestArray) { + flowerForestList.add(item); + } + for(Block item : NORMAL__FLOWERS) { + flowerForestList.add(item.getDefaultState()); + } + BlockState[] newFlowerForestArray = flowerForestList.toArray(new BlockState[flowerForestList.size()]); + FlowerForestAccess.setFlowers(newFlowerForestArray); + } } diff --git a/src/main/java/net/yyc12345/teyvatcraft/mixin/FlowerForestAccess.java b/src/main/java/net/yyc12345/teyvatcraft/mixin/FlowerForestAccess.java new file mode 100644 index 0000000..0d0dd07 --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/mixin/FlowerForestAccess.java @@ -0,0 +1,20 @@ +package net.yyc12345.teyvatcraft.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import net.minecraft.block.BlockState; +import net.minecraft.world.gen.stateprovider.ForestFlowerBlockStateProvider; + +@Mixin(ForestFlowerBlockStateProvider.class) +public interface FlowerForestAccess { + @Accessor("FLOWERS") + static BlockState[] getFlowers() { + throw new AssertionError(); + } + + @Accessor("FLOWERS") + static void setFlowers(BlockState[] items) { + throw new AssertionError(); + } +} diff --git a/src/main/resources/assets/teyvatcraft/blockstates/cor_lapis_ore.json b/src/main/resources/assets/teyvatcraft/blockstates/cor_lapis_ore.json new file mode 100644 index 0000000..42b6bea --- /dev/null +++ b/src/main/resources/assets/teyvatcraft/blockstates/cor_lapis_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "teyvatcraft:block/cor_lapis_ore" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/teyvatcraft/blockstates/noctilucous_jade_ore.json b/src/main/resources/assets/teyvatcraft/blockstates/noctilucous_jade_ore.json new file mode 100644 index 0000000..01f9d06 --- /dev/null +++ b/src/main/resources/assets/teyvatcraft/blockstates/noctilucous_jade_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "teyvatcraft:block/noctilucous_jade_ore" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/teyvatcraft/lang/en_us.json b/src/main/resources/assets/teyvatcraft/lang/en_us.json index 95ca02f..4862eb1 100644 --- a/src/main/resources/assets/teyvatcraft/lang/en_us.json +++ b/src/main/resources/assets/teyvatcraft/lang/en_us.json @@ -34,6 +34,8 @@ "block.teyvatcraft.white_iron_chunk_ore": "White Iron Chunk Ore", "block.teyvatcraft.iron_chunk_ore": "Iron Chunk Ore", "block.teyvatcraft.starsilver_ore": "Starsilver Ore", + "block.teyvatcraft.cor_lapis_ore": "Cor Lapis Ore", + "block.teyvatcraft.noctilucous_jade_ore": "Noctilucous Jade Ore", "block.teyvatcraft.rice": "Rice", "block.teyvatcraft.tomato": "Tomato", diff --git a/src/main/resources/assets/teyvatcraft/lang/zh_cn.json b/src/main/resources/assets/teyvatcraft/lang/zh_cn.json index c7783fc..ee37cfd 100644 --- a/src/main/resources/assets/teyvatcraft/lang/zh_cn.json +++ b/src/main/resources/assets/teyvatcraft/lang/zh_cn.json @@ -34,6 +34,8 @@ "block.teyvatcraft.white_iron_chunk_ore": "白铁块原矿", "block.teyvatcraft.iron_chunk_ore": "铁块原矿", "block.teyvatcraft.starsilver_ore": "星银矿石原矿", + "block.teyvatcraft.cor_lapis_ore": "石珀原矿", + "block.teyvatcraft.noctilucous_jade_ore": "夜泊石原矿", "block.teyvatcraft.rice": "稻米", "block.teyvatcraft.tomato": "番茄", diff --git a/src/main/resources/assets/teyvatcraft/models/block/cor_lapis_ore.json b/src/main/resources/assets/teyvatcraft/models/block/cor_lapis_ore.json new file mode 100644 index 0000000..a98b1b8 --- /dev/null +++ b/src/main/resources/assets/teyvatcraft/models/block/cor_lapis_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "teyvatcraft:block/cor_lapis_ore" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/teyvatcraft/models/block/noctilucous_jade_ore.json b/src/main/resources/assets/teyvatcraft/models/block/noctilucous_jade_ore.json new file mode 100644 index 0000000..5a3dfbc --- /dev/null +++ b/src/main/resources/assets/teyvatcraft/models/block/noctilucous_jade_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "teyvatcraft:block/noctilucous_jade_ore" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/teyvatcraft/models/item/cor_lapis_ore.json b/src/main/resources/assets/teyvatcraft/models/item/cor_lapis_ore.json new file mode 100644 index 0000000..0476f18 --- /dev/null +++ b/src/main/resources/assets/teyvatcraft/models/item/cor_lapis_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "teyvatcraft:block/cor_lapis_ore" +} \ No newline at end of file diff --git a/src/main/resources/assets/teyvatcraft/models/item/noctilucous_jade_ore.json b/src/main/resources/assets/teyvatcraft/models/item/noctilucous_jade_ore.json new file mode 100644 index 0000000..c49f625 --- /dev/null +++ b/src/main/resources/assets/teyvatcraft/models/item/noctilucous_jade_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "teyvatcraft:block/noctilucous_jade_ore" +} \ No newline at end of file diff --git a/src/main/resources/assets/teyvatcraft/textures/block/cor_lapis_ore.png b/src/main/resources/assets/teyvatcraft/textures/block/cor_lapis_ore.png new file mode 100644 index 0000000000000000000000000000000000000000..a3c90d5f4e2f576d089728efeb4a485fbe1fb7f1 GIT binary patch literal 617 zcmV-v0+#)WP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0scuuK~y+TWl~K~ z6HydB^PEy(`XvR5OfV9OT_7Ke#(;?~FocEf*qQhP*plwMchjH1(v60-No_FEooihOywkZ?tO3GIq%;4u2n9V+lavPJOn`?vEw)r`@WAvA`$LI zVUsX5@)h@|E4Vy(gyyd#UVd7{{vj}EA7BS}LQWfYZo~)10 zhENMu@a^Q5tn2l9C}@o;W8Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0t!h)K~y+TjZ!gh z(_j#NcAUi6PGyxwE=pUf5Q(ZCDj~8|1vV-qRwictK{kf)4o%n@xFw>$=!Hw}=HIi!B!pMNE({9KRP)yWJM%b6JeK zT)kd@kR%C~;yt-+AW0i@b}%p9RkSYM!@KD#m@r1DKwr-_}uA(x4_=DhGm zDqLH5h)2_R*DU!AjKm-Lur#KZA?G z*)AOHV9Q%UE$HC(r*%Zffe5&PyvS;*^Zx0yi18i}Va|dRf0yh;cJ>N07BDsV0zbAf zoV=JeJ%yUThLlgMP|WiWrFm@5uAyg?EF#z}lLfZK*Dn2Uw P00000NkvXXu0mjf-`pMO literal 0 HcmV?d00001 diff --git a/src/main/resources/data/teyvatcraft/loot_tables/blocks/cor_lapis_ore.json b/src/main/resources/data/teyvatcraft/loot_tables/blocks/cor_lapis_ore.json index 3529feb..b7c5d11 100644 --- a/src/main/resources/data/teyvatcraft/loot_tables/blocks/cor_lapis_ore.json +++ b/src/main/resources/data/teyvatcraft/loot_tables/blocks/cor_lapis_ore.json @@ -32,8 +32,8 @@ { "function": "minecraft:set_count", "count": { - "min": 4.0, - "max": 5.0, + "min": 1.0, + "max": 2.0, "type": "minecraft:uniform" } }, @@ -56,4 +56,4 @@ ] } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/resources/data/teyvatcraft/loot_tables/blocks/noctilucous_jade_ore.json b/src/main/resources/data/teyvatcraft/loot_tables/blocks/noctilucous_jade_ore.json index f629257..29328a6 100644 --- a/src/main/resources/data/teyvatcraft/loot_tables/blocks/noctilucous_jade_ore.json +++ b/src/main/resources/data/teyvatcraft/loot_tables/blocks/noctilucous_jade_ore.json @@ -32,8 +32,8 @@ { "function": "minecraft:set_count", "count": { - "min": 4.0, - "max": 5.0, + "min": 1.0, + "max": 2.0, "type": "minecraft:uniform" } }, @@ -56,4 +56,4 @@ ] } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/resources/teyvatcraft.mixins.json b/src/main/resources/teyvatcraft.mixins.json index c0db0ca..f41cbfa 100644 --- a/src/main/resources/teyvatcraft.mixins.json +++ b/src/main/resources/teyvatcraft.mixins.json @@ -7,7 +7,8 @@ ], "client": [ "TeyvatCraftMixin", - "VillagerAccess" + "VillagerAccess", + "FlowerForestAccess" ], "injectors": { "defaultRequire": 1