Fix some load order/registration issues

This commit is contained in:
Sollace 2020-04-24 14:14:25 +02:00
parent baafbbfd96
commit 50923f4015
3 changed files with 17 additions and 13 deletions

View file

@ -24,6 +24,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
public interface UBlocks { public interface UBlocks {
CloudFarmlandBlock cloud_farmland = register(new CloudFarmlandBlock(FabricBlockSettings.of(UMaterials.CLOUD).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.WOOL).build()), "cloud_farmland");
CloudBlock normal_cloud = register(new CloudBlock(CloudType.NORMAL), "cloud_block"); CloudBlock normal_cloud = register(new CloudBlock(CloudType.NORMAL), "cloud_block");
CloudBlock enchanted_cloud = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block"); CloudBlock enchanted_cloud = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block");
CloudBlock packed_cloud = register(new CloudBlock(CloudType.PACKED), "packed_cloud_block"); CloudBlock packed_cloud = register(new CloudBlock(CloudType.PACKED), "packed_cloud_block");
@ -50,8 +51,6 @@ public interface UBlocks {
StickBlock stick = register(new StickBlock(), "stick"); StickBlock stick = register(new StickBlock(), "stick");
TomatoPlantBlock tomato_plant = register(new TomatoPlantBlock(), "tomato_plant"); TomatoPlantBlock tomato_plant = register(new TomatoPlantBlock(), "tomato_plant");
CloudFarmlandBlock cloud_farmland = register(new CloudFarmlandBlock(FabricBlockSettings.of(UMaterials.CLOUD).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.WOOL).build()), "cloud_farmland");
HiveWallBlock hive = register(new HiveWallBlock(), "hive"); HiveWallBlock hive = register(new HiveWallBlock(), "hive");
ChitinBlock chitin_block = register(new ChitinBlock(), "chitin_block"); ChitinBlock chitin_block = register(new ChitinBlock(), "chitin_block");
Block chissled_chitin = register(new ChiselledChitinBlock(), "chissled_chitin"); Block chissled_chitin = register(new ChiselledChitinBlock(), "chissled_chitin");
@ -60,17 +59,17 @@ public interface UBlocks {
SlimeLayerBlock slime_layer = register(new SlimeLayerBlock(), "slime_layer"); SlimeLayerBlock slime_layer = register(new SlimeLayerBlock(), "slime_layer");
Block sugar_block = register(new SugarBlock(), "sugar_block"); Block sugar_block = register(new SugarBlock(), "sugar_block");
SaplingBlock apple_tree = register(new SaplingBlock(
new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), UBlocks.apple_leaves.getDefaultState()),
FabricBlockSettings.of(Material.WOOD).build()
) {}, "apple_sapling");
Block apple_leaves = register(new FruitLeavesBlock() Block apple_leaves = register(new FruitLeavesBlock()
.growthChance(1200) .growthChance(1200)
.tint(0xFFEE81) .tint(0xFFEE81)
.fruit(W -> TreeType.OAK.pickRandomStack()) .fruit(W -> TreeType.OAK.pickRandomStack())
.compost(w -> new ItemStack(UItems.rotten_apple)), "apple_leaves"); .compost(w -> new ItemStack(UItems.rotten_apple)), "apple_leaves");
SaplingBlock apple_tree = register(new SaplingBlock(
new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), apple_leaves.getDefaultState()),
FabricBlockSettings.of(Material.WOOD).build()
) {}, "apple_sapling");
static <T extends Block> T register(T block, String name) { static <T extends Block> T register(T block, String name) {
return Registry.BLOCK.add(new Identifier(Unicopia.MODID, name), block); return Registry.BLOCK.add(new Identifier(Unicopia.MODID, name), block);

View file

@ -2,9 +2,11 @@ package com.minelittlepony.unicopia.entity;
import java.util.List; import java.util.List;
import com.minelittlepony.unicopia.Unicopia;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory; import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.EndBiome; import net.minecraft.world.biome.EndBiome;
import net.minecraft.world.biome.ForestBiome; import net.minecraft.world.biome.ForestBiome;
@ -38,7 +40,8 @@ public interface UEntities {
// builder.projectile(SpearEntity.class, "spear", 100, 10) // builder.projectile(SpearEntity.class, "spear", 100, 10)
static <T extends Entity> EntityType<T> register(String name, EntityType.Builder<T> builder) { static <T extends Entity> EntityType<T> register(String name, EntityType.Builder<T> builder) {
return Registry.register(Registry.ENTITY_TYPE, name, builder.build(name)); name = Unicopia.MODID + ":" + name;
return Registry.register(Registry.ENTITY_TYPE, new Identifier(name), builder.build(name));
} }
static void bootstrap() { static void bootstrap() {

View file

@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.item;
import static com.minelittlepony.unicopia.EquinePredicates.*; import static com.minelittlepony.unicopia.EquinePredicates.*;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.magic.spell.ScorchSpell; import com.minelittlepony.unicopia.magic.spell.ScorchSpell;
@ -24,6 +25,7 @@ import net.minecraft.item.Items;
import net.minecraft.item.MusicDiscItem; import net.minecraft.item.MusicDiscItem;
import net.minecraft.item.TallBlockItem; import net.minecraft.item.TallBlockItem;
import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity; import net.minecraft.util.Rarity;
import net.minecraft.util.UseAction; import net.minecraft.util.UseAction;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
@ -148,12 +150,8 @@ public interface UItems {
Item juice = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 2, 2, UseAction.DRINK, Toxicity.SAFE), "juice"); Item juice = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 2, 2, UseAction.DRINK, Toxicity.SAFE), "juice");
Item burned_juice = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 3, 1, UseAction.DRINK, Toxicity.FAIR), "burned_juice"); Item burned_juice = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 3, 1, UseAction.DRINK, Toxicity.FAIR), "burned_juice");
static <T extends Item> T register(T newItem, Item oldItem) {
return Registry.ITEM.add(Registry.ITEM.getId(oldItem), newItem);
}
static <T extends Item> T register(T item, String name) { static <T extends Item> T register(T item, String name) {
return register(item, name); return Registry.ITEM.add(new Identifier(Unicopia.MODID, name), item);
} }
static MusicDiscItem createRecord(SoundEvent sound) { static MusicDiscItem createRecord(SoundEvent sound) {
@ -196,5 +194,9 @@ public interface UItems {
Item peony = register(new ToxicBlockItem(Blocks.PEONY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PEONY); Item peony = register(new ToxicBlockItem(Blocks.PEONY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PEONY);
Item tall_grass = register(new ToxicBlockItem(Blocks.TALL_GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.TALL_GRASS); Item tall_grass = register(new ToxicBlockItem(Blocks.TALL_GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.TALL_GRASS);
Item large_fern = register(new DynamicToxicBlockItem(Blocks.LARGE_FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.DAMAGE), Items.LARGE_FERN); Item large_fern = register(new DynamicToxicBlockItem(Blocks.LARGE_FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.DAMAGE), Items.LARGE_FERN);
static <T extends Item> T register(T newItem, Item oldItem) {
return Registry.ITEM.set(Registry.ITEM.getRawId(oldItem), Registry.ITEM.getId(oldItem), newItem);
}
} }
} }