fix crop block display error

This commit is contained in:
yyc12345 2021-04-23 12:48:16 +08:00
parent 01a83e5b2b
commit 1e0d9a52cd
12 changed files with 78 additions and 26 deletions

View File

@ -10,6 +10,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications; import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; 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.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -22,6 +23,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor; import net.minecraft.block.MaterialColor;
import net.minecraft.block.OreBlock; import net.minecraft.block.OreBlock;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.item.AliasedBlockItem; import net.minecraft.item.AliasedBlockItem;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -33,6 +35,7 @@ import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.yyc12345.teyvatcraft.blocks.*; import net.yyc12345.teyvatcraft.blocks.*;
import net.yyc12345.teyvatcraft.items.SeedItem;
import net.yyc12345.teyvatcraft.items.gnosis.*; import net.yyc12345.teyvatcraft.items.gnosis.*;
public class RegisterManager { public class RegisterManager {
@ -102,15 +105,18 @@ public class RegisterManager {
public static final Item ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP)); public static final Item ENHANCEMENT_ORE = new Item(new FabricItemSettings().group(ITEM_GROUP));
// ==================== crops // ==================== 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 Block RICE_block = new TeyvatCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP));
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 final Item RICE_SEED = new AliasedBlockItem(RICE_block, new FabricItemSettings().group(ITEM_GROUP));
public static final Item RICE_item = new Item(new FabricItemSettings().group(ITEM_GROUP)); 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 // ==================== ore gen
private static ConfiguredFeature<?, ?> OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE = Feature.ORE private static ConfiguredFeature<?, ?> OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE = Feature.ORE
@ -201,25 +207,31 @@ public class RegisterManager {
Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starsilver_ore"), Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "starsilver_ore"),
new BlockItem(STARSILVER_ORE, new Item.Settings().group(ITEM_GROUP))); new BlockItem(STARSILVER_ORE, new Item.Settings().group(ITEM_GROUP)));
// crops // crops
Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "rice_seed"), RICE_SEED); ((TeyvatCropBlock)RICE_block).setSeedsItem(RICE_SEED_item);
Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "rice"), RICE_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);
((TeyvatCropBlock)RICE_block).setSeedsItem(RICE_SEED);
Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "rice"), RICE_block); Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "rice"), RICE_block);
Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "tomato"), TOMATO); Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "tomato"), TOMATO_block);
Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "onion"), ONION); Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "onion"), ONION_block);
Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "cabbage"), CABBAGE); Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "cabbage"), CABBAGE_block);
Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "raddish"), RADDISH); Registry.register(Registry.BLOCK, new Identifier("teyvatcraft", "raddish"), RADDISH_block);
Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "tomato"),
new BlockItem(TOMATO, new Item.Settings().group(ITEM_GROUP)));
Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "onion"),
new BlockItem(ONION, new Item.Settings().group(ITEM_GROUP)));
Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "cabbage"),
new BlockItem(CABBAGE, new Item.Settings().group(ITEM_GROUP)));
Registry.register(Registry.ITEM, new Identifier("teyvatcraft", "raddish"),
new BlockItem(RADDISH, new Item.Settings().group(ITEM_GROUP)));
// ore gen // ore gen
RegisterOreGeneration("oregen_magical_crystal_ore", OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE); RegisterOreGeneration("oregen_magical_crystal_ore", OREGEN_MAGICAL_CRYSTAL_CHUNK_ORE);

View File

@ -0,0 +1,12 @@
package net.yyc12345.teyvatcraft.items;
import net.minecraft.block.Block;
import net.minecraft.item.AliasedBlockItem;
import net.yyc12345.teyvatcraft.blocks.TeyvatCropBlock;
public class SeedItem extends AliasedBlockItem {
public SeedItem(Block block, Settings settings) {
super(block, settings);
((TeyvatCropBlock) block).setSeedsItem(this);
}
}

View File

@ -23,5 +23,19 @@
"block.teyvatcraft.crystal_chunk_ore": "Crystal Chunk Ore", "block.teyvatcraft.crystal_chunk_ore": "Crystal Chunk Ore",
"block.teyvatcraft.white_iron_chunk_ore": "White Iron Chunk Ore", "block.teyvatcraft.white_iron_chunk_ore": "White Iron Chunk Ore",
"block.teyvatcraft.iron_chunk_ore": "Iron Chunk Ore", "block.teyvatcraft.iron_chunk_ore": "Iron Chunk Ore",
"block.teyvatcraft.starsilver_ore": "Starsilver Ore" "block.teyvatcraft.starsilver_ore": "Starsilver Ore",
"block.teyvatcraft.rice": "Rice",
"block.teyvatcraft.tomato": "Tomato",
"block.teyvatcraft.onion": "Onion",
"block.teyvatcraft.cabbage": "Cabbage",
"block.teyvatcraft.raddish": "Raddish",
"block.teyvatcraft.rice_seed": "Rice Seed",
"item.teyvatcraft.rice": "Rice",
"item.teyvatcraft.tomato": "Tomato",
"item.teyvatcraft.onion": "Onion",
"item.teyvatcraft.cabbage": "Cabbage",
"item.teyvatcraft.raddish": "Raddish",
"item.teyvatcraft.rice_seed": "Rice Seed"
} }

View File

@ -23,5 +23,19 @@
"block.teyvatcraft.crystal_chunk_ore": "水晶块原矿", "block.teyvatcraft.crystal_chunk_ore": "水晶块原矿",
"block.teyvatcraft.white_iron_chunk_ore": "白铁块原矿", "block.teyvatcraft.white_iron_chunk_ore": "白铁块原矿",
"block.teyvatcraft.iron_chunk_ore": "铁块原矿", "block.teyvatcraft.iron_chunk_ore": "铁块原矿",
"block.teyvatcraft.starsilver_ore": "星银矿石原矿" "block.teyvatcraft.starsilver_ore": "星银矿石原矿",
"block.teyvatcraft.rice": "Rice",
"block.teyvatcraft.tomato": "Tomato",
"block.teyvatcraft.onion": "Onion",
"block.teyvatcraft.cabbage": "Cabbage",
"block.teyvatcraft.raddish": "Raddish",
"block.teyvatcraft.rice_seed": "Rice Seed",
"item.teyvatcraft.rice": "Rice",
"item.teyvatcraft.tomato": "Tomato",
"item.teyvatcraft.onion": "Onion",
"item.teyvatcraft.cabbage": "Cabbage",
"item.teyvatcraft.raddish": "Raddish",
"item.teyvatcraft.rice_seed": "Rice Seed"
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 224 B