From 5908788ab0456966cba6e3317e91053fd7bd6072 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sat, 24 Apr 2021 21:28:06 +0800 Subject: [PATCH] add some garbage --- README.md | 6 +- helps/ResourcesMapping.md | 57 ++-- scripts/Genshin Impact Data dump.js | 44 ++++ scripts/item_generator.py | 66 +++++ .../yyc12345/teyvatcraft/RegisterManager.java | 243 ------------------ .../net/yyc12345/teyvatcraft/TeyvatCraft.java | 12 +- .../blocks/TeyvatHarvestablePlantBlock.java | 49 ++++ .../teyvatcraft/init/BlocksManager.java | 60 +++++ .../teyvatcraft/init/DungeonManager.java | 7 + .../teyvatcraft/init/ItemsManager.java | 102 ++++++++ .../teyvatcraft/init/TerrainsManager.java | 80 ++++++ .../teyvatcraft/init/VillagerManager.java | 31 +++ .../teyvatcraft/items/gnosis/GnosisAnemo.java | 11 - .../teyvatcraft/items/gnosis/GnosisCryo.java | 11 - .../items/gnosis/GnosisDendro.java | 11 - .../items/gnosis/GnosisElectro.java | 11 - .../teyvatcraft/items/gnosis/GnosisGeo.java | 11 - .../teyvatcraft/items/gnosis/GnosisHydro.java | 11 - .../items/gnosis/GnosisPrototype.java | 1 - .../teyvatcraft/items/gnosis/GnosisPyro.java | 11 - .../items/vision/VisionPrototype.java | 1 - .../teyvatcraft/mixin/TeyvatCraftMixin.java | 2 +- .../teyvatcraft/mixin/VillagerAccess.java | 34 +++ src/main/resources/teyvatcraft.mixins.json | 3 +- 24 files changed, 520 insertions(+), 355 deletions(-) create mode 100644 scripts/Genshin Impact Data dump.js create mode 100644 scripts/item_generator.py delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/RegisterManager.java create mode 100644 src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatHarvestablePlantBlock.java create mode 100644 src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java create mode 100644 src/main/java/net/yyc12345/teyvatcraft/init/DungeonManager.java create mode 100644 src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java create mode 100644 src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java create mode 100644 src/main/java/net/yyc12345/teyvatcraft/init/VillagerManager.java delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisAnemo.java delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisCryo.java delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisDendro.java delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisElectro.java delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisGeo.java delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisHydro.java delete mode 100644 src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPyro.java create mode 100644 src/main/java/net/yyc12345/teyvatcraft/mixin/VillagerAccess.java diff --git a/README.md b/README.md index 3ae6283..187c834 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # TeyvatCraft -All code are under MIT LICENSE. But all assets, such as image, belong to miHoyo and miHoyo hold its copyright. +All code are under MIT LICENSE. But all assets, such as image, belong to miHoyo and miHoYo hold its copyright. + +This mod will **not** add Homeworld system into Minecraft. Minecraft has been a openworld game now. Minecraft player can use various block to create what they want. Add Homeworld system is entirely useless and if you still want Furniture, you can add other Minecraft mods to implement it. + +And, this mod is not designed to implement Genshin Impact in Minecraft entirely. Some features has been adapted to Minecraft self. If you need full Genshin Impact experiences, you can leave now. diff --git a/helps/ResourcesMapping.md b/helps/ResourcesMapping.md index 0431441..ab5f3c0 100644 --- a/helps/ResourcesMapping.md +++ b/helps/ResourcesMapping.md @@ -1,68 +1,68 @@ |**材料**|可种植|用原版代替|和村民交易|可由加工得来|野外采集|矿物|未映射| |:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:| -|嘟嘟莲|||||√||| +|嘟嘟莲|||||一次性,沼泽||| |石珀||||||√|| -|蒲公英籽|||||√||| -|绝云椒椒|||||√||| -|小灯草|||||√||| -|琉璃袋|||||√||| +|蒲公英籽|||||可反复||| +|绝云椒椒|||||可反复||| +|小灯草|||||一次性||| +|琉璃袋||兰花|||||| |蘑菇||棕色蘑菇|||||| |禽肉||生鸡肉|||||| |鸟蛋||鸡蛋|||||| |兽肉||猪肉|||||| |白萝卜|√||||||| -|薄荷|||||√||| +|薄荷|||||一次性||| |鱼肉||原版可食用鱼肉|||||| -|胡椒|||√||||| +|胡椒|||屠夫||||| |番茄|√||||||| |面粉||||√|||| -|甜甜花|||||√||| +|甜甜花|||||一次性||| |洋葱|√||||||| |熏禽肉|||||||√| |卷心菜|√||||||| -|树莓|||||√||| +|树莓|||||可反复||| |土豆||√|||||| |牛奶||√|||||| |糖||√|||||| -|杏仁|||√||||| -|金鱼草|||||√||| -|豆腐|||√||||| +|杏仁|||农民||||| +|金鱼草|||||一次性,沼泽||| +|豆腐|||农民||||| |莲蓬||荷叶|||||| -|松茸|||||√||| +|松茸|||||一次性||| |稻米|√||||||| -|虾仁|||√||||| +|虾仁|||渔夫||||| |胡萝卜||√|||||| |奶油||||√|||| -|螃蟹|||||√||| +|螃蟹|||渔夫||||| |奶酪||||√|||| -|松果|||||√||| +|松果|||||云杉树叶掉落||| |果酱||||√|||| -|盐|||√||||| +|盐|||屠夫||||| |黄油||||√|||| -|火腿|||√||||| -|培根|||√||||| -|香肠|||√||||| -|青蛙|||||√||| +|火腿||||√|||| +|培根||||√|||| +|香肠||||√|||| +|青蛙|||渔夫||||| |电气水晶||||||√|| -|蜥蜴尾巴|||||||√| +|蜥蜴尾巴|||牧师||||| |冰雾花花朵|||||||√| |烈焰花花蕊|||||||√| -|蝴蝶翅膀|||||||√| -|晶核|||||||√| +|蝴蝶翅膀|||牧师||||| +|晶核|||牧师||||| |铁块||||||√|| |白铁块||||||√|| |水晶块||||||√|| |蟹黄||||√|||| |小麦||√|||||| |魔晶块||||||√|| -|鳅鳅宝玉|||||√||| +|鳅鳅宝玉|||牧师||||| |竹笋|||||||√| |发光髓|||||||√| |「冷鲜肉」|||||||√| |星银矿石||||||√|| |奇异的「牙齿」|||||||√| |汲取了生命力的龙牙|||||||√| -|马尾|||||√||| +|马尾|||||一次性,沼泽||| |嬗变之尘|||||||√| |北陆单手剑原胚|||||||√| |北陆双手剑原胚|||||||√| @@ -70,6 +70,7 @@ |北陆弓原胚|||||||√| |北陆法器原胚|||||||√| |苹果||√|||||| -|日落果|||||√||| +|日落果|||||白桦树叶掉落||| -所有可种植物品,加入农民一级收购列表,尝试将这些作物设为农民可接受的作物,就像原版作物一样,如果不行就将作物种子设定为流浪商人贩卖 \ No newline at end of file +* 所有可种植物品,加入农民一级收购列表,尝试将这些作物设为农民可接受的作物,就像原版作物一样,如果不行就将作物种子设定为流浪商人贩卖 +* 野外采集的,一次性表示类似于花的处理方式,采完就没了,可用刷花机量产。可反复表示类似于浆果丛的处理方式,可以反复采摘,但是只能在原地采摘,不能重新集中化种植。树叶掉落的,按照类似橡木树叶掉落苹果的方式处理掉落。后面标识沼泽的,按类似于兰花的生成方式,即只在沼泽生成,其他未标识的,按普通花的生成方式生成。 \ No newline at end of file diff --git a/scripts/Genshin Impact Data dump.js b/scripts/Genshin Impact Data dump.js new file mode 100644 index 0000000..efca613 --- /dev/null +++ b/scripts/Genshin Impact Data dump.js @@ -0,0 +1,44 @@ +// ==UserScript== +// @name Genshin Impact Data dump +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match https://genshin.honeyhunterworld.com/db/item/* +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + var dataButton = document.createElement("button"); + dataButton.innerText = "Get Data"; + dataButton.setAttribute("style", "height: 3em; padding: 0.5em;background: #1e90ff;color: white; border: solid 1px gray;border-radius: 5px;"); + dataButton.addEventListener("click", function() { + let listdiv = document.querySelector('div.items_wrap'); + let itemlist = listdiv.querySelectorAll('span.itemname'); + let outList = []; + for (let i = 0; i < itemlist.length; i++) { + outList.push(itemlist[i].innerText); + } + console.log(outList.join('\n')); + }); + + var urlButton = document.createElement("button"); + urlButton.innerText = "Get URL"; + urlButton.setAttribute("style", "height: 3em; padding: 0.5em;background: #1e90ff;color: white; border: solid 1px gray;border-radius: 5px;"); + urlButton.addEventListener("click", function() { + let listdiv = document.querySelector('div.items_wrap'); + let itemlist = listdiv.querySelectorAll('div.itemcont > a > div > div.itempic_cont > img.itempic'); + let outList = []; + for (let i = 0; i < itemlist.length; i++) { + outList.push("https://genshin.honeyhunterworld.com" + itemlist[i].getAttribute("src")); + } + console.log(outList.join('\n')); + }); + + var dataList = document.querySelector('div.items_wrap'); + dataList.parentNode.insertBefore(dataButton, dataList); + dataList.parentNode.insertBefore(urlButton, dataList); + +})(); \ No newline at end of file diff --git a/scripts/item_generator.py b/scripts/item_generator.py new file mode 100644 index 0000000..c412f59 --- /dev/null +++ b/scripts/item_generator.py @@ -0,0 +1,66 @@ +import sys +import os + +def ReadListFromFile(filename, listInstance): + f = open(filename, 'r', encoding='utf-8') + while True: + cache = f.readline() + if cache == '': + break; + cache = cache.strip() + if cache == '': + continue + listInstance.append(cache) + f.close() + +# folder creation +if not os.path.isdir('models/item'): + os.makedirs('models/item') +if not os.path.isdir('textures/item'): + os.makedirs('textures/item') + + +# read file +enList = [] +zhList = [] +urlList = [] + +ReadListFromFile('zhcn.txt', zhList) +ReadListFromFile('enus.txt', enList) +ReadListFromFile('url.txt', urlList) + +if len(zhList) != len(enList) or len(urlList) != len(enList): + print('3 files item is not matched') + sys.exit(0) + +javaDeclareFile = open('declare.java', 'w', encoding='utf-8') +javaRegisterFile = open('register.java', 'w', encoding='utf-8') +langZhFile = open('zh_cn.json', 'w', encoding='utf-8') +langEnFile = open('en_us.json', 'w', encoding='utf-8') +shFile = open('downloadImage.sh', 'w', encoding='utf-8') +for index in range(len(enList)): + underlineName = enList[index].lower().replace(' ', '_').replace('-', '').replace("'", '') + upperName = underlineName.upper() + + fmodels = open('models/item/' + underlineName + '.json', 'w', encoding='utf-8') + fmodels.write('''{{ + "parent": "minecraft:item/generated", + "textures": {{ + "layer0": "teyvatcraft:item/{}" + }} +}}'''.format(underlineName)) + fmodels.close() + + javaDeclareFile.write('public static final Item {} = new Item(new FabricItemSettings().group(ITEM_GROUP));\n'.format(upperName)) + javaRegisterFile.write('Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "{}"), {});\n'.format(underlineName, upperName)) + + langZhFile.write('"item.teyvatcraft.{}": "{}",\n'.format(underlineName, zhList[index])) + langEnFile.write('"item.teyvatcraft.{}": "{}",\n'.format(underlineName, enList[index])) + + shFile.write('curl -o textures/item/{}.png {}\n'.format(underlineName, urlList[index])) + +javaDeclareFile.close() +javaRegisterFile.close() +langZhFile.close() +langEnFile.close() +shFile.close() diff --git a/src/main/java/net/yyc12345/teyvatcraft/RegisterManager.java b/src/main/java/net/yyc12345/teyvatcraft/RegisterManager.java deleted file mode 100644 index 7e2f988..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/RegisterManager.java +++ /dev/null @@ -1,243 +0,0 @@ -package net.yyc12345.teyvatcraft; - - -import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; -import net.fabricmc.fabric.api.item.v1.FabricItemSettings; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; -import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; - -import net.minecraft.util.Identifier; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.block.Blocks; -import net.minecraft.util.Rarity; -import net.minecraft.block.Block; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.OreBlock; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.item.AliasedBlockItem; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -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.Feature; -import net.minecraft.world.gen.feature.OreFeatureConfig; - -import net.yyc12345.teyvatcraft.blocks.*; -import net.yyc12345.teyvatcraft.items.SeedItem; -import net.yyc12345.teyvatcraft.items.gnosis.*; - -public class RegisterManager { - public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build( - new Identifier("teyvatcraft", "general"), - () -> new ItemStack(Blocks.COBBLESTONE)); - - // ==================== gnosis - public static final GnosisDendro GNOSIS_DENDRO = new GnosisDendro( - new FabricItemSettings() - .group(ITEM_GROUP) - .maxCount(1) - .rarity(Rarity.EPIC) - ); - public static final GnosisHydro GNOSIS_HYDRO = new GnosisHydro( - new FabricItemSettings() - .group(ITEM_GROUP) - .maxCount(1) - .rarity(Rarity.EPIC) - ); - public static final GnosisPyro GNOSIS_PYRO = new GnosisPyro( - new FabricItemSettings() - .group(ITEM_GROUP) - .maxCount(1) - .rarity(Rarity.EPIC) - ); - public static final GnosisGeo GNOSIS_GEO = new GnosisGeo( - new FabricItemSettings() - .group(ITEM_GROUP) - .maxCount(1) - .rarity(Rarity.EPIC) - ); - public static final GnosisElectro GNOSIS_ELECTRO = new GnosisElectro( - new FabricItemSettings() - .group(ITEM_GROUP) - .maxCount(1) - .rarity(Rarity.EPIC) - ); - public static final GnosisAnemo GNOSIS_ANEMO = new GnosisAnemo( - new FabricItemSettings() - .group(ITEM_GROUP) - .maxCount(1) - .rarity(Rarity.EPIC) - ); - public static final GnosisCryo GNOSIS_CRYO = new GnosisCryo( - new FabricItemSettings() - .group(ITEM_GROUP) - .maxCount(1) - .rarity(Rarity.EPIC) - ); - - // ==================== ore - public static final Block MAGICAL_CRYSTAL_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 4).requiresTool().strength(4.0F, 4.0F)); - public static final Block CRYSTAL_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 3).requiresTool().strength(4.0F, 4.0F)); - public static final Block WHITE_IRON_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 2).requiresTool().strength(3.0F, 3.0F)); - public static final Block IRON_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 1).requiresTool().strength(3.0F, 3.0F)); - public static final Block STARSILVER_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 1).requiresTool().strength(2.0F, 2.0F)); - - public static final Item MAGICAL_CRYSTAL_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); - public static final Item CRYSTAL_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); - public static final Item WHITE_IRON_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); - public static final Item IRON_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); - public static final Item STARSILVER = new Item(new FabricItemSettings().group(ITEM_GROUP)); - - public static final Item MYSTIC_ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP)); - public static final Item FINE_ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP)); - public static final Item ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP)); - - // ==================== crops - public static final Block RICE_block = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).nonOpaque()); - public static final Block TOMATO_block = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); - public static final Block ONION_block = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); - public static final Block CABBAGE_block = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); - public static final Block RADDISH_block = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); - - public static final Item RICE_item = new Item(new FabricItemSettings().group(ITEM_GROUP)); - public static final Item TOMATO_item = new SeedItem(TOMATO_block, new FabricItemSettings().group(ITEM_GROUP)); - public static final Item ONION_item = new SeedItem(ONION_block, new FabricItemSettings().group(ITEM_GROUP)); - public static final Item CABBAGE_item = new SeedItem(CABBAGE_block, new FabricItemSettings().group(ITEM_GROUP)); - public static final Item RADDISH_item = new SeedItem(RADDISH_block, new FabricItemSettings().group(ITEM_GROUP)); - public static final Item RICE_SEED_item = new SeedItem(RICE_block, new FabricItemSettings().group(ITEM_GROUP)); - - // ==================== ore gen - private static ConfiguredFeature OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - 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_CRYSTAL_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - CRYSTAL_CHUNK_ORE.getDefaultState(), - 4)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 32))) - .spreadHorizontally() - .repeat(12); - - private static ConfiguredFeature OREGEN_WHITE_IRON_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - WHITE_IRON_CHUNK_ORE.getDefaultState(), - 4)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 64))) - .spreadHorizontally() - .repeat(24); - - private static ConfiguredFeature OREGEN_IRON_CHUNK_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - IRON_CHUNK_ORE.getDefaultState(), - 8)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 64))) - .spreadHorizontally() - .repeat(24); - - private static ConfiguredFeature OREGEN_STARSILVER_ORE = Feature.ORE - .configure(new OreFeatureConfig( - OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, - IRON_CHUNK_ORE.getDefaultState(), - 4)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 64))) - .spreadHorizontally() - .repeat(24); - - private static void RegisterOreGeneration(String mIdentifier, ConfiguredFeature genStasticas) { - 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); - } - - public static void RegisterAll() { - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_dendro"), GNOSIS_DENDRO); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_hydro"), GNOSIS_HYDRO); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_pyro"), GNOSIS_PYRO); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_geo"), GNOSIS_GEO); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_electro"), GNOSIS_ELECTRO); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_anemo"), GNOSIS_ANEMO); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_cryo"), GNOSIS_CRYO); - - // ore - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "magical_crystal_chunk"), MAGICAL_CRYSTAL_CHUNK); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "crystal_chunk"), CRYSTAL_CHUNK); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "white_iron_chunk"), WHITE_IRON_CHUNK); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "iron_chunk"), IRON_CHUNK); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starsilver"), STARSILVER); - - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "mystic_enhancement_ore"), MYSTIC_ENHANCEMENT_ORE); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "fine_enhancement_ore"), FINE_ENHANCEMENT_ORE); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "enhancement_ore"), ENHANCEMENT_ORE); - - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "magical_crystal_chunk_ore"), MAGICAL_CRYSTAL_CHUNK_ORE); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "crystal_chunk_ore"), CRYSTAL_CHUNK_ORE); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "white_iron_chunk_ore"), WHITE_IRON_CHUNK_ORE); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "iron_chunk_ore"), IRON_CHUNK_ORE); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "starsilver_ore"), STARSILVER_ORE); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "magical_crystal_chunk_ore"), - new BlockItem(MAGICAL_CRYSTAL_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "crystal_chunk_ore"), - new BlockItem(CRYSTAL_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "white_iron_chunk_ore"), - new BlockItem(WHITE_IRON_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "iron_chunk_ore"), - new BlockItem(IRON_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starsilver_ore"), - new BlockItem(STARSILVER_ORE, new Item.Settings().group(ITEM_GROUP))); - - // crops - ((TeyvatCropBlock)RICE_block).setSeedsItem(RICE_SEED_item); - ((TeyvatCropBlock)TOMATO_block).setSeedsItem(TOMATO_item); - ((TeyvatCropBlock)ONION_block).setSeedsItem(ONION_item); - ((TeyvatCropBlock)CABBAGE_block).setSeedsItem(CABBAGE_item); - ((TeyvatCropBlock)RADDISH_block).setSeedsItem(RADDISH_item); - - BlockRenderLayerMap.INSTANCE.putBlock(RICE_block, RenderLayer.getCutoutMipped()); - BlockRenderLayerMap.INSTANCE.putBlock(TOMATO_block, RenderLayer.getCutoutMipped()); - BlockRenderLayerMap.INSTANCE.putBlock(ONION_block, RenderLayer.getCutoutMipped()); - BlockRenderLayerMap.INSTANCE.putBlock(CABBAGE_block, RenderLayer.getCutoutMipped()); - BlockRenderLayerMap.INSTANCE.putBlock(RADDISH_block, RenderLayer.getCutoutMipped()); - - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "rice"), RICE_item); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "tomato"), TOMATO_item); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "onion"), ONION_item); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "cabbage"), CABBAGE_item); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "raddish"), RADDISH_item); - Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "rice_seed"), RICE_SEED_item); - - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "rice"), RICE_block); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "tomato"), TOMATO_block); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "onion"), ONION_block); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "cabbage"), CABBAGE_block); - Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "raddish"), RADDISH_block); - - // 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); - } -} diff --git a/src/main/java/net/yyc12345/teyvatcraft/TeyvatCraft.java b/src/main/java/net/yyc12345/teyvatcraft/TeyvatCraft.java index a4baec0..be157b1 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/TeyvatCraft.java +++ b/src/main/java/net/yyc12345/teyvatcraft/TeyvatCraft.java @@ -1,11 +1,19 @@ package net.yyc12345.teyvatcraft; import net.fabricmc.api.ModInitializer; -import net.yyc12345.teyvatcraft.RegisterManager; +import net.yyc12345.teyvatcraft.init.BlocksManager; +import net.yyc12345.teyvatcraft.init.DungeonManager; +import net.yyc12345.teyvatcraft.init.ItemsManager; +import net.yyc12345.teyvatcraft.init.TerrainsManager; +import net.yyc12345.teyvatcraft.init.VillagerManager; public class TeyvatCraft implements ModInitializer { @Override public void onInitialize() { - RegisterManager.RegisterAll(); + BlocksManager.RegisterAll(); + ItemsManager.RegisterAll(); + TerrainsManager.RegisterAll(); + VillagerManager.RegisterAll(); + DungeonManager.RegisterAll(); } } diff --git a/src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatHarvestablePlantBlock.java b/src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatHarvestablePlantBlock.java new file mode 100644 index 0000000..106b412 --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/blocks/TeyvatHarvestablePlantBlock.java @@ -0,0 +1,49 @@ +package net.yyc12345.teyvatcraft.blocks; + +import net.minecraft.block.BlockState; +import net.minecraft.block.SweetBerryBushBlock; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemConvertible; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class TeyvatHarvestablePlantBlock extends SweetBerryBushBlock { + + private Item droppedItem; + + public TeyvatHarvestablePlantBlock(Settings settings, Item droppedItem) { + super(settings); + this.droppedItem = droppedItem; + } + + @Override + public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { + // revoke sweet berry bush default operation + return; + } + + @Override + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + int i = ((Integer)state.get(AGE)).intValue(); + boolean bl = (i == 3); + if (!bl && player.getStackInHand(hand).getItem() == Items.BONE_MEAL) + return ActionResult.PASS; + if (i > 1) { + int j = 1 + world.random.nextInt(2); + dropStack(world, pos, new ItemStack((ItemConvertible)droppedItem, j + (bl ? 1 : 0))); + world.playSound(null, pos, SoundEvents.ITEM_SWEET_BERRIES_PICK_FROM_BUSH, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F); + world.setBlockState(pos, (BlockState)state.with(AGE, Integer.valueOf(1)), 2); + return ActionResult.success(world.isClient); + } + return super.onUse(state, world, pos, player, hand, hit); + } +} diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java new file mode 100644 index 0000000..8c1788b --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/init/BlocksManager.java @@ -0,0 +1,60 @@ +package net.yyc12345.teyvatcraft.init; + +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder; +import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; +import net.minecraft.block.Block; +import net.minecraft.block.Material; +import net.minecraft.block.MaterialColor; +import net.minecraft.block.OreBlock; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.yyc12345.teyvatcraft.blocks.TeyvatCropBlock; + +public class BlocksManager { + + // ==================== ore + public static final Block MAGICAL_CRYSTAL_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 4).requiresTool().strength(4.0F, 4.0F)); + public static final Block CRYSTAL_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 3).requiresTool().strength(4.0F, 4.0F)); + public static final Block WHITE_IRON_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 2).requiresTool().strength(3.0F, 3.0F)); + public static final Block IRON_CHUNK_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 1).requiresTool().strength(3.0F, 3.0F)); + public static final Block STARSILVER_ORE = new OreBlock(FabricBlockSettings.of(new FabricMaterialBuilder(MaterialColor.STONE).build()).breakByTool(FabricToolTags.PICKAXES, 1).requiresTool().strength(2.0F, 2.0F)); + + // ==================== crops + public static final Block RICE = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).nonOpaque()); + public static final Block TOMATO = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); + public static final Block ONION = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); + public static final Block CABBAGE = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); + public static final Block RADDISH = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)); + + + public static void RegisterAll() { + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "magical_crystal_chunk_ore"), MAGICAL_CRYSTAL_CHUNK_ORE); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "crystal_chunk_ore"), CRYSTAL_CHUNK_ORE); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "white_iron_chunk_ore"), WHITE_IRON_CHUNK_ORE); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "iron_chunk_ore"), IRON_CHUNK_ORE); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "starsilver_ore"), STARSILVER_ORE); + + // crops + ((TeyvatCropBlock)RICE).setSeedsItem(ItemsManager.RICE_SEED); + ((TeyvatCropBlock)TOMATO).setSeedsItem(ItemsManager.TOMATO); + ((TeyvatCropBlock)ONION).setSeedsItem(ItemsManager.ONION); + ((TeyvatCropBlock)CABBAGE).setSeedsItem(ItemsManager.CABBAGE); + ((TeyvatCropBlock)RADDISH).setSeedsItem(ItemsManager.RADDISH); + + BlockRenderLayerMap.INSTANCE.putBlock(RICE, RenderLayer.getCutoutMipped()); + BlockRenderLayerMap.INSTANCE.putBlock(TOMATO, RenderLayer.getCutoutMipped()); + BlockRenderLayerMap.INSTANCE.putBlock(ONION, RenderLayer.getCutoutMipped()); + BlockRenderLayerMap.INSTANCE.putBlock(CABBAGE, RenderLayer.getCutoutMipped()); + BlockRenderLayerMap.INSTANCE.putBlock(RADDISH, RenderLayer.getCutoutMipped()); + + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "rice"), RICE); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "tomato"), TOMATO); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "onion"), ONION); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "cabbage"), CABBAGE); + Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "raddish"), RADDISH); + } +} diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/DungeonManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/DungeonManager.java new file mode 100644 index 0000000..1665988 --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/init/DungeonManager.java @@ -0,0 +1,7 @@ +package net.yyc12345.teyvatcraft.init; + +public class DungeonManager { + public static void RegisterAll() { + + } +} diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java new file mode 100644 index 0000000..da8a49c --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/init/ItemsManager.java @@ -0,0 +1,102 @@ +package net.yyc12345.teyvatcraft.init; + +import net.minecraft.util.registry.Registry; +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; + +import net.minecraft.util.Identifier; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.Rarity; +import net.minecraft.item.BlockItem; +import net.minecraft.item.FoodComponent; +import net.minecraft.item.Item; +import net.minecraft.item.ItemConvertible; +import static net.minecraft.block.ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE; +import net.yyc12345.teyvatcraft.items.SeedItem; + +public class ItemsManager { + public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build( + new Identifier("teyvatcraft", "general"), + () -> new ItemStack(Items.NETHER_STAR)); + + // ==================== gnosis + public static final Item GNOSIS_DENDRO = new Item(new FabricItemSettings().group(ITEM_GROUP).maxCount(1).rarity(Rarity.EPIC).fireproof()); + public static final Item GNOSIS_HYDRO = new Item(new FabricItemSettings().group(ITEM_GROUP).maxCount(1).rarity(Rarity.EPIC).fireproof()); + public static final Item GNOSIS_PYRO = new Item(new FabricItemSettings().group(ITEM_GROUP).maxCount(1).rarity(Rarity.EPIC).fireproof()); + public static final Item GNOSIS_GEO = new Item(new FabricItemSettings().group(ITEM_GROUP).maxCount(1).rarity(Rarity.EPIC).fireproof()); + public static final Item GNOSIS_ELECTRO = new Item(new FabricItemSettings().group(ITEM_GROUP).maxCount(1).rarity(Rarity.EPIC).fireproof()); + public static final Item GNOSIS_ANEMO = new Item(new FabricItemSettings().group(ITEM_GROUP).maxCount(1).rarity(Rarity.EPIC).fireproof()); + public static final Item GNOSIS_CRYO = new Item(new FabricItemSettings().group(ITEM_GROUP).maxCount(1).rarity(Rarity.EPIC).fireproof()); + + // ==================== ore + public static final Item MAGICAL_CRYSTAL_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); + public static final Item CRYSTAL_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); + public static final Item WHITE_IRON_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); + public static final Item IRON_CHUNK = new Item(new FabricItemSettings().group(ITEM_GROUP)); + public static final Item STARSILVER = new Item(new FabricItemSettings().group(ITEM_GROUP)); + + // ==================== weapon enhancement + public static final Item MYSTIC_ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP)); + public static final Item FINE_ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP)); + public static final Item ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP)); + + // ==================== crops + public static final Item RICE = new Item(new FabricItemSettings().group(ITEM_GROUP).food((new FoodComponent.Builder()).hunger(1).saturationModifier(0.3F).build())); + public static final Item TOMATO = new SeedItem(BlocksManager.TOMATO, new FabricItemSettings().group(ITEM_GROUP).food((new FoodComponent.Builder()).hunger(1).saturationModifier(0.3F).build())); + public static final Item ONION = new SeedItem(BlocksManager.ONION, new FabricItemSettings().group(ITEM_GROUP).food((new FoodComponent.Builder()).hunger(1).saturationModifier(0.3F).build())); + public static final Item CABBAGE = new SeedItem(BlocksManager.CABBAGE, new FabricItemSettings().group(ITEM_GROUP).food((new FoodComponent.Builder()).hunger(1).saturationModifier(0.3F).build())); + public static final Item RADDISH = new SeedItem(BlocksManager.RADDISH, new FabricItemSettings().group(ITEM_GROUP).food((new FoodComponent.Builder()).hunger(1).saturationModifier(0.3F).build())); + public static final Item RICE_SEED = new SeedItem(BlocksManager.RICE, new FabricItemSettings().group(ITEM_GROUP)); + + public static void registerCompostableItem(float levelIncreaseChance, ItemConvertible item) { + ITEM_TO_LEVEL_INCREASE_CHANCE.put(item.asItem(), levelIncreaseChance); + } + + public static void RegisterAll() { + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_dendro"), GNOSIS_DENDRO); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_hydro"), GNOSIS_HYDRO); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_pyro"), GNOSIS_PYRO); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_geo"), GNOSIS_GEO); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_electro"), GNOSIS_ELECTRO); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_anemo"), GNOSIS_ANEMO); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "gnosis_cryo"), GNOSIS_CRYO); + + // ore + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "magical_crystal_chunk"), MAGICAL_CRYSTAL_CHUNK); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "crystal_chunk"), CRYSTAL_CHUNK); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "white_iron_chunk"), WHITE_IRON_CHUNK); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "iron_chunk"), IRON_CHUNK); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starsilver"), STARSILVER); + + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "mystic_enhancement_ore"), MYSTIC_ENHANCEMENT_ORE); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "fine_enhancement_ore"), FINE_ENHANCEMENT_ORE); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "enhancement_ore"), ENHANCEMENT_ORE); + + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "magical_crystal_chunk_ore"), + new BlockItem(BlocksManager.MAGICAL_CRYSTAL_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "crystal_chunk_ore"), + new BlockItem(BlocksManager.CRYSTAL_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "white_iron_chunk_ore"), + new BlockItem(BlocksManager.WHITE_IRON_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "iron_chunk_ore"), + new BlockItem(BlocksManager.IRON_CHUNK_ORE, new Item.Settings().group(ITEM_GROUP))); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starsilver_ore"), + new BlockItem(BlocksManager.STARSILVER_ORE, new Item.Settings().group(ITEM_GROUP))); + + // crops + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "rice"), RICE); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "tomato"), TOMATO); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "onion"), ONION); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "cabbage"), CABBAGE); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "raddish"), RADDISH); + Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "rice_seed"), RICE_SEED); + registerCompostableItem(0.65f, RICE); + registerCompostableItem(0.65f, TOMATO); + registerCompostableItem(0.65f, ONION); + registerCompostableItem(0.65f, CABBAGE); + registerCompostableItem(0.65f, RADDISH); + registerCompostableItem(0.3f, RICE_SEED); + } +} diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java new file mode 100644 index 0000000..ea878b6 --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/init/TerrainsManager.java @@ -0,0 +1,80 @@ +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 net.minecraft.util.Identifier; +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.Feature; +import net.minecraft.world.gen.feature.OreFeatureConfig; + +public class TerrainsManager { + + // ==================== 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_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 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); + + 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); + + 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); + + private static void RegisterOreGeneration(String mIdentifier, ConfiguredFeature genStasticas) { + 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); + } + + 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); + } +} diff --git a/src/main/java/net/yyc12345/teyvatcraft/init/VillagerManager.java b/src/main/java/net/yyc12345/teyvatcraft/init/VillagerManager.java new file mode 100644 index 0000000..ea3fbea --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/init/VillagerManager.java @@ -0,0 +1,31 @@ +package net.yyc12345.teyvatcraft.init; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +import net.minecraft.item.Item; +import net.yyc12345.teyvatcraft.mixin.VillagerAccess; + +public class VillagerManager { + + public static void RegisterAll() { + // register villager food + ImmutableMap.Builder villagerFoodItems = new ImmutableMap.Builder().putAll(VillagerAccess.getItemFoodValues()); + villagerFoodItems.put(ItemsManager.RICE, ItemsManager.RICE.getFoodComponent().getHunger()); + villagerFoodItems.put(ItemsManager.TOMATO, ItemsManager.TOMATO.getFoodComponent().getHunger()); + villagerFoodItems.put(ItemsManager.ONION, ItemsManager.ONION.getFoodComponent().getHunger()); + villagerFoodItems.put(ItemsManager.CABBAGE, ItemsManager.CABBAGE.getFoodComponent().getHunger()); + villagerFoodItems.put(ItemsManager.RADDISH, ItemsManager.RADDISH.getFoodComponent().getHunger()); + VillagerAccess.setItemFoodValues(villagerFoodItems.build()); + + // register villager gatherables + ImmutableSet.Builder villagerGatherables= new ImmutableSet.Builder().addAll(VillagerAccess.getGatherableItems()); + villagerGatherables.add(ItemsManager.RICE); + villagerGatherables.add(ItemsManager.TOMATO); + villagerGatherables.add(ItemsManager.ONION); + villagerGatherables.add(ItemsManager.CABBAGE); + villagerGatherables.add(ItemsManager.RADDISH); + VillagerAccess.setGatherableItems(villagerGatherables.build()); + + } +} diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisAnemo.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisAnemo.java deleted file mode 100644 index 850e95c..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisAnemo.java +++ /dev/null @@ -1,11 +0,0 @@ - -package net.yyc12345.teyvatcraft.items.gnosis; - -import net.yyc12345.teyvatcraft.items.gnosis.GnosisPrototype; -import net.minecraft.item.Item.Settings; - -public class GnosisAnemo extends GnosisPrototype { - public GnosisAnemo(Settings settings) { - super(settings); - } -} \ No newline at end of file diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisCryo.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisCryo.java deleted file mode 100644 index 0d0acfa..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisCryo.java +++ /dev/null @@ -1,11 +0,0 @@ - -package net.yyc12345.teyvatcraft.items.gnosis; - -import net.yyc12345.teyvatcraft.items.gnosis.GnosisPrototype; -import net.minecraft.item.Item.Settings; - -public class GnosisCryo extends GnosisPrototype { - public GnosisCryo(Settings settings) { - super(settings); - } -} \ No newline at end of file diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisDendro.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisDendro.java deleted file mode 100644 index f95f2f9..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisDendro.java +++ /dev/null @@ -1,11 +0,0 @@ - -package net.yyc12345.teyvatcraft.items.gnosis; - -import net.yyc12345.teyvatcraft.items.gnosis.GnosisPrototype; -import net.minecraft.item.Item.Settings; - -public class GnosisDendro extends GnosisPrototype { - public GnosisDendro(Settings settings) { - super(settings); - } -} \ No newline at end of file diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisElectro.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisElectro.java deleted file mode 100644 index 28f3f58..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisElectro.java +++ /dev/null @@ -1,11 +0,0 @@ - -package net.yyc12345.teyvatcraft.items.gnosis; - -import net.yyc12345.teyvatcraft.items.gnosis.GnosisPrototype; -import net.minecraft.item.Item.Settings; - -public class GnosisElectro extends GnosisPrototype { - public GnosisElectro(Settings settings) { - super(settings); - } -} \ No newline at end of file diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisGeo.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisGeo.java deleted file mode 100644 index 3f4a19a..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisGeo.java +++ /dev/null @@ -1,11 +0,0 @@ - -package net.yyc12345.teyvatcraft.items.gnosis; - -import net.yyc12345.teyvatcraft.items.gnosis.GnosisPrototype; -import net.minecraft.item.Item.Settings; - -public class GnosisGeo extends GnosisPrototype { - public GnosisGeo(Settings settings) { - super(settings); - } -} \ No newline at end of file diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisHydro.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisHydro.java deleted file mode 100644 index b27fb29..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisHydro.java +++ /dev/null @@ -1,11 +0,0 @@ - -package net.yyc12345.teyvatcraft.items.gnosis; - -import net.yyc12345.teyvatcraft.items.gnosis.GnosisPrototype; -import net.minecraft.item.Item.Settings; - -public class GnosisHydro extends GnosisPrototype { - public GnosisHydro(Settings settings) { - super(settings); - } -} \ No newline at end of file diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPrototype.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPrototype.java index f156456..c887fc7 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPrototype.java +++ b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPrototype.java @@ -1,7 +1,6 @@ package net.yyc12345.teyvatcraft.items.gnosis; import net.minecraft.item.Item; -import net.minecraft.item.Item.Settings; public class GnosisPrototype extends Item { public GnosisPrototype(Settings settings) { diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPyro.java b/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPyro.java deleted file mode 100644 index 6ffdad9..0000000 --- a/src/main/java/net/yyc12345/teyvatcraft/items/gnosis/GnosisPyro.java +++ /dev/null @@ -1,11 +0,0 @@ - -package net.yyc12345.teyvatcraft.items.gnosis; - -import net.yyc12345.teyvatcraft.items.gnosis.GnosisPrototype; -import net.minecraft.item.Item.Settings; - -public class GnosisPyro extends GnosisPrototype { - public GnosisPyro(Settings settings) { - super(settings); - } -} \ No newline at end of file diff --git a/src/main/java/net/yyc12345/teyvatcraft/items/vision/VisionPrototype.java b/src/main/java/net/yyc12345/teyvatcraft/items/vision/VisionPrototype.java index b146158..d83af8d 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/items/vision/VisionPrototype.java +++ b/src/main/java/net/yyc12345/teyvatcraft/items/vision/VisionPrototype.java @@ -1,7 +1,6 @@ package net.yyc12345.teyvatcraft.items.vision; import net.minecraft.item.Item; -import net.minecraft.item.Item.Settings; public class VisionPrototype extends Item { public VisionPrototype(Settings settings) { diff --git a/src/main/java/net/yyc12345/teyvatcraft/mixin/TeyvatCraftMixin.java b/src/main/java/net/yyc12345/teyvatcraft/mixin/TeyvatCraftMixin.java index 281b160..a9955bb 100644 --- a/src/main/java/net/yyc12345/teyvatcraft/mixin/TeyvatCraftMixin.java +++ b/src/main/java/net/yyc12345/teyvatcraft/mixin/TeyvatCraftMixin.java @@ -10,6 +10,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class TeyvatCraftMixin { @Inject(at = @At("HEAD"), method = "init()V") private void init(CallbackInfo info) { - System.out.println("This line is printed by an example mod mixin!"); + //System.out.println("This line is printed by an example mod mixin!"); } } diff --git a/src/main/java/net/yyc12345/teyvatcraft/mixin/VillagerAccess.java b/src/main/java/net/yyc12345/teyvatcraft/mixin/VillagerAccess.java new file mode 100644 index 0000000..003631e --- /dev/null +++ b/src/main/java/net/yyc12345/teyvatcraft/mixin/VillagerAccess.java @@ -0,0 +1,34 @@ +package net.yyc12345.teyvatcraft.mixin; + +import net.minecraft.entity.passive.VillagerEntity; +import net.minecraft.item.Item; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Map; +import java.util.Set; + +@Mixin(VillagerEntity.class) +public interface VillagerAccess { + + @Accessor("GATHERABLE_ITEMS") + static Set getGatherableItems() { + throw new AssertionError(); + } + + @Accessor("GATHERABLE_ITEMS") + static void setGatherableItems(Set items) { + throw new AssertionError(); + } + + + @Accessor("ITEM_FOOD_VALUES") + static Map getItemFoodValues() { + throw new AssertionError(); + } + + @Accessor("ITEM_FOOD_VALUES") + static void setItemFoodValues(Map food) { + throw new AssertionError(); + } +} diff --git a/src/main/resources/teyvatcraft.mixins.json b/src/main/resources/teyvatcraft.mixins.json index 7fb07a6..c0db0ca 100644 --- a/src/main/resources/teyvatcraft.mixins.json +++ b/src/main/resources/teyvatcraft.mixins.json @@ -6,7 +6,8 @@ "mixins": [ ], "client": [ - "TeyvatCraftMixin" + "TeyvatCraftMixin", + "VillagerAccess" ], "injectors": { "defaultRequire": 1