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 0000000..2665bae Binary files /dev/null and b/scripts/ore_manager/stone.png differ diff --git a/scripts/ore_manager/zh.txt b/scripts/ore_manager/zh.txt new file mode 100644 index 0000000..9bda2ae --- /dev/null +++ b/scripts/ore_manager/zh.txt @@ -0,0 +1,7 @@ +//魔晶块#魔晶块原矿 +//水晶块#水晶块原矿 +//白铁块#白铁块原矿 +//铁块#铁块原矿 +//星银矿石#星银矿石原矿 +石珀#石珀原矿 +夜泊石#夜泊石原矿 diff --git a/scripts/plant_manager/block_gen.py b/scripts/plant_manager/block_gen.py new file mode 100644 index 0000000..86d50de --- /dev/null +++ b/scripts/plant_manager/block_gen.py @@ -0,0 +1,239 @@ +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 GenerateSweetBerryBushStageModel(name, stage): + f = open('assets/teyvatcraft/models/block/{}_stage{}.json'.format(name, stage), 'w', encoding='utf-8') + f.write('''{{ + "parent": "minecraft:block/cross", + "textures": {{ + "cross": "teyvatcraft:block/{}_stage{}" + }} +}}'''.format(name, stage)) + f.close() + +# 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/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 = [] +propList = [] + +ReadListFromFile('zh.txt', zhList) +ReadListFromFile('en.txt', enList) +ReadListFromFile('prop.txt', propList) + +if len(zhList) != len(enList) or len(propList) != len(enList): + print('3 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)): + underlineName = enList[index].lower().replace(',', '').replace('& ', '').replace('é', 'e').replace('-', '_').replace("'", '').replace('"', '').replace(' ', '_') + upperName = underlineName.upper() + + if propList[index] == '': + # keep blank line in register & declare + javaDeclareFile.write('\n') + javaRegisterFile.write('\n') + langZhFile.write('\n') + langEnFile.write('\n') + continue + + flootTables = open('data/teyvatcraft/loot_tables/blocks/' + underlineName + '.json', 'w', encoding='utf-8') + fblockstates = open('assets/teyvatcraft/blockstates/' + underlineName + '.json', 'w', encoding='utf-8') + if propList[index] == 'sweet_berry_bush': + javaDeclareFile.write('public static final Block {} = new TeyvatSweetBerryBushLikePlantBlock(ItemsManager.{});\n'.format(upperName, upperName)) + + flootTables.write('''{{ + "type": "minecraft:block", + "pools": [ + {{ + "rolls": 1.0, + "entries": [ + {{ + "type": "minecraft:item", + "name": "teyvatcraft:{}" + }} + ], + "conditions": [ + {{ + "condition": "minecraft:block_state_property", + "block": "teyvatcraft:{}", + "properties": {{ + "age": "3" + }} + }} + ], + "functions": [ + {{ + "function": "minecraft:set_count", + "count": {{ + "min": 2.0, + "max": 3.0, + "type": "minecraft:uniform" + }} + }}, + {{ + "function": "minecraft:apply_bonus", + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "parameters": {{ + "bonusMultiplier": 1 + }} + }} + ] + }}, + {{ + "rolls": 1.0, + "entries": [ + {{ + "type": "minecraft:item", + "name": "teyvatcraft:{}" + }} + ], + "conditions": [ + {{ + "condition": "minecraft:block_state_property", + "block": "teyvatcraft:{}", + "properties": {{ + "age": "2" + }} + }} + ], + "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 + }} + }} + ] + }} + ], + "functions": [ + {{ + "function": "minecraft:explosion_decay" + }} + ] +}}'''.format(*([underlineName, ]*4))) + + fblockstates.write('''{{ + "variants": {{ + "age=0": {{ + "model": "teyvatcraft:block/{}_stage0" + }}, + "age=1": {{ + "model": "teyvatcraft:block/{}_stage1" + }}, + "age=2": {{ + "model": "teyvatcraft:block/{}_stage2" + }}, + "age=3": {{ + "model": "teyvatcraft:block/{}_stage3" + }} + }} +}}'''.format(*([underlineName, ]*4))) + + GenerateSweetBerryBushStageModel(underlineName, 0) + GenerateSweetBerryBushStageModel(underlineName, 1) + GenerateSweetBerryBushStageModel(underlineName, 2) + GenerateSweetBerryBushStageModel(underlineName, 3) + + #shutil.copyfile('sweet_berry_bush_stage0.png', 'assets/teyvatcraft/textures/block/{}_stage0.png'.format(underlineName)) + #shutil.copyfile('sweet_berry_bush_stage1.png', 'assets/teyvatcraft/textures/block/{}_stage1.png'.format(underlineName)) + #shutil.copyfile('sweet_berry_bush_stage2.png', 'assets/teyvatcraft/textures/block/{}_stage2.png'.format(underlineName)) + #shutil.copyfile('sweet_berry_bush_stage3.png', 'assets/teyvatcraft/textures/block/{}_stage3.png'.format(underlineName)) + + elif propList[index] == 'flower': + fmodel = open('assets/teyvatcraft/models/block/{}.json'.format(underlineName), 'w', encoding='utf-8') + javaDeclareFile.write('public static final Block {} = new TeyvatFlowerLikePlantBlock();\n'.format(upperName)) + + flootTables.write('''{{ + "type": "minecraft:block", + "pools": [ + {{ + "rolls": 1, + "entries": [ + {{ + "type": "minecraft:item", + "name": "teyvatcraft:{}" + }} + ], + "conditions": [ + {{ + "condition": "minecraft:survives_explosion" + }} + ] + }} + ] +}}'''.format(underlineName)) + + fblockstates.write('''{{ + "variants": {{ + "": {{ + "model": "teyvatcraft:block/{}" + }} + }} +}}'''.format(underlineName)) + + fmodel.write('''{{ + "parent": "minecraft:block/cross", + "textures": {{ + "cross": "teyvatcraft:block/{}" + }} +}}'''.format(underlineName)) + fmodel.close() + + #shutil.copyfile('flower.png', 'assets/teyvatcraft/textures/block/{}.png'.format(underlineName)) + + flootTables.close() + fblockstates.close() + + javaRegisterFile.write('registerTeyvatPlant({}, "{}");\n'.format(upperName, underlineName)) + + langZhFile.write('"block.teyvatcraft.{}": "{}",\n'.format(underlineName, zhList[index])) + langEnFile.write('"block.teyvatcraft.{}": "{}",\n'.format(underlineName, enList[index].replace('"', ''))) + + +javaDeclareFile.close() +javaRegisterFile.close() +langZhFile.close() +langEnFile.close() diff --git a/scripts/plant_manager/en.txt b/scripts/plant_manager/en.txt new file mode 100644 index 0000000..66dd807 --- /dev/null +++ b/scripts/plant_manager/en.txt @@ -0,0 +1,18 @@ +Calla Lily +Dandelion Seed +Jueyun Chili +Small Lamp Grass +Mint +Sweet Flower +Berry +Snapdragon +Matsutake +Horsetail +Cecilia +Glaze Lily +Philanemo Mushroom +Silk Flower +Valberry +Windwheel Aster +Wolfhook +Qingxin diff --git a/scripts/plant_manager/flower.png b/scripts/plant_manager/flower.png new file mode 100644 index 0000000..21b8490 Binary files /dev/null and b/scripts/plant_manager/flower.png differ 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 0000000..6b5854d Binary files /dev/null and b/scripts/plant_manager/sweet_berry_bush_stage0.png differ 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 0000000..216269c Binary files /dev/null and b/scripts/plant_manager/sweet_berry_bush_stage1.png differ 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 0000000..4254cc0 Binary files /dev/null and b/scripts/plant_manager/sweet_berry_bush_stage2.png differ diff --git a/scripts/plant_manager/sweet_berry_bush_stage3.png b/scripts/plant_manager/sweet_berry_bush_stage3.png new file mode 100644 index 0000000..755ba23 Binary files /dev/null and b/scripts/plant_manager/sweet_berry_bush_stage3.png differ 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 0000000..a3c90d5 Binary files /dev/null and b/src/main/resources/assets/teyvatcraft/textures/block/cor_lapis_ore.png differ diff --git a/src/main/resources/assets/teyvatcraft/textures/block/noctilucous_jade_ore.png b/src/main/resources/assets/teyvatcraft/textures/block/noctilucous_jade_ore.png new file mode 100644 index 0000000..8e1e0c9 Binary files /dev/null and b/src/main/resources/assets/teyvatcraft/textures/block/noctilucous_jade_ore.png differ 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