Jump to content

HarryTechReviews

Members
  • Posts

    55
  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

HarryTechReviews's Achievements

Stone Miner

Stone Miner (3/8)

4

Reputation

  1. Sorry but how would I initialize it without registering it?
  2. My entity works in game through world spawns and /summon but the spawn egg returns null for the entity not existing. I think it is to do with the spawn egg item being registered too early but my entity is registered before my spawn egg so I don't see why this is an issue. Any help is much appreciated Entity Registry Class public static EntityType<?> GIANT_SQUIRREL; public static void registerEntityWorldSpawns() { registerEntityWorldSpawn(GIANT_SQUIRREL, EntityClassification.CREATURE, 10, 1, 3, Biomes.BIRCH_FOREST, Biomes.DARK_FOREST, Biomes.FOREST); } public static void registerEntityWorldSpawn(EntityType<?> entity, EntityClassification type, int weight, int minGroupSize, int maxGroupSize, Biome... biomes) { for(Biome biome : biomes) { if(biome != null) { biome.getSpawns(type).add(new Biome.SpawnListEntry(entity, weight, minGroupSize, maxGroupSize)); } } } public static void registerEntitySpawnEggs(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( TutorialItems.giant_squrrel_egg = registerEntitySpawnEgg(GIANT_SQUIRREL, 0x000000, 0xffffff, "giant_squirrel_egg") ); } public static SpawnEggItem registerEntitySpawnEgg(EntityType<?> entityType, int color1, int color2, String name) { SpawnEggItem item = new SpawnEggItem(entityType, color1, color2, new Item.Properties().group(TutorialModRegistries.TUTORIAL)); item.setRegistryName(new ResourceLocation(TutorialModRegistries.MODID, name)); return item; } Mod Event Subscriber Class @SubscribeEvent public static void regiserEntities(final RegistryEvent.Register<EntityType<?>> event) { event.getRegistry().registerAll ( TutorialEntities.GIANT_SQUIRREL = EntityType.Builder.create(EntityGiantSquirrel::new, EntityClassification.CREATURE).build(MODID + ":giant_squirrel").setRegistryName(location("giant_squirrel")) ); TutorialEntities.registerEntityWorldSpawns(); } @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( TutorialItems.tutorial_item = new Item(new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_item")), TutorialItems.tutorial_axe = new CustomAxeItem(TutorialToolMaterials.tutorial, -1.0f, 6.0f, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_axe")), TutorialItems.tutorial_hoe = new HoeItem(TutorialToolMaterials.tutorial, 6.0f, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_hoe")), TutorialItems.tutorial_pickaxe = new CustomPickaxeItem(TutorialToolMaterials.tutorial, -2, 6.0f, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_pickaxe")), TutorialItems.tutorial_shovel = new ShovelItem(TutorialToolMaterials.tutorial, -3.0f, 6.0f, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_shovel")), TutorialItems.tutorial_sword = new SwordItem(TutorialToolMaterials.tutorial, 0, 6.0f, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_sword")), TutorialItems.tutorial_helmet = new ArmorItem(TutorialArmorMaterials.tutorial, EquipmentSlotType.HEAD, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_helmet")), TutorialItems.tutorial_chestplate = new ArmorItem(TutorialArmorMaterials.tutorial, EquipmentSlotType.CHEST, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_chestplate")), TutorialItems.tutorial_leggings = new ArmorItem(TutorialArmorMaterials.tutorial, EquipmentSlotType.LEGS, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_leggings")), TutorialItems.tutorial_boots = new ArmorItem(TutorialArmorMaterials.tutorial, EquipmentSlotType.FEET, new Item.Properties().group(TUTORIAL)).setRegistryName(location("tutorial_boots")), TutorialItems.tutorial_block = new BlockItem(TutorialBlocks.tutorial_block, new Item.Properties().group(TUTORIAL)).setRegistryName(TutorialBlocks.tutorial_block.getRegistryName()), TutorialItems.tutorial_ore = new BlockItem(TutorialBlocks.tutorial_ore, new Item.Properties().group(TUTORIAL)).setRegistryName(TutorialBlocks.tutorial_ore.getRegistryName()), TutorialItems.tutorial_ore_nether = new BlockItem(TutorialBlocks.tutorial_ore_nether, new Item.Properties().group(TUTORIAL)).setRegistryName(TutorialBlocks.tutorial_ore_nether.getRegistryName()), TutorialItems.tutorial_ore_end = new BlockItem(TutorialBlocks.tutorial_ore_end, new Item.Properties().group(TUTORIAL)).setRegistryName(TutorialBlocks.tutorial_ore_end.getRegistryName()) ); /*TODO FIX SPAWN EGGS */ TutorialEntities.registerEntitySpawnEggs(event); LOGGER.info("Items registered."); } public static ResourceLocation location(String name) { return new ResourceLocation(MODID, name); }
  3. Any chance this will be added to the Block.Properties as it seems a bit redundant to create a class for a block just to set a harvest level?
  4. I can't figure out which functions to use to register placement types in 1.14. From what I can see in the class, the function vanilla uses is private and examples I've seen call a register method which doesn't exist any more. Thanks EntitySpawnPlacementType Class package net.minecraft.entity; import com.google.common.collect.Maps; import java.util.Map; import java.util.Random; import javax.annotation.Nullable; import net.minecraft.entity.monster.DrownedEntity; import net.minecraft.entity.monster.EndermiteEntity; import net.minecraft.entity.monster.GhastEntity; import net.minecraft.entity.monster.GuardianEntity; import net.minecraft.entity.monster.HuskEntity; import net.minecraft.entity.monster.MagmaCubeEntity; import net.minecraft.entity.monster.MonsterEntity; import net.minecraft.entity.monster.PatrollerEntity; import net.minecraft.entity.monster.SilverfishEntity; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.entity.monster.StrayEntity; import net.minecraft.entity.monster.ZombiePigmanEntity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.BatEntity; import net.minecraft.entity.passive.DolphinEntity; import net.minecraft.entity.passive.MooshroomEntity; import net.minecraft.entity.passive.OcelotEntity; import net.minecraft.entity.passive.ParrotEntity; import net.minecraft.entity.passive.PolarBearEntity; import net.minecraft.entity.passive.RabbitEntity; import net.minecraft.entity.passive.SquidEntity; import net.minecraft.entity.passive.TurtleEntity; import net.minecraft.entity.passive.fish.AbstractFishEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.Registry; import net.minecraft.world.IWorld; import net.minecraft.world.gen.Heightmap; public class EntitySpawnPlacementRegistry { private static final Map<EntityType<?>, EntitySpawnPlacementRegistry.Entry> REGISTRY = Maps.newHashMap(); private static <T extends MobEntity> void register(EntityType<T> entityTypeIn, EntitySpawnPlacementRegistry.PlacementType placementType, Heightmap.Type heightMapType, EntitySpawnPlacementRegistry.IPlacementPredicate<T> p_209343_3_) { EntitySpawnPlacementRegistry.Entry entityspawnplacementregistry$entry = REGISTRY.put(entityTypeIn, new EntitySpawnPlacementRegistry.Entry(heightMapType, placementType, p_209343_3_)); if (entityspawnplacementregistry$entry != null) { throw new IllegalStateException("Duplicate registration for type " + Registry.ENTITY_TYPE.getKey(entityTypeIn)); } } public static EntitySpawnPlacementRegistry.PlacementType getPlacementType(EntityType<?> entityTypeIn) { EntitySpawnPlacementRegistry.Entry entityspawnplacementregistry$entry = REGISTRY.get(entityTypeIn); return entityspawnplacementregistry$entry == null ? EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS : entityspawnplacementregistry$entry.placementType; } public static Heightmap.Type func_209342_b(@Nullable EntityType<?> entityTypeIn) { EntitySpawnPlacementRegistry.Entry entityspawnplacementregistry$entry = REGISTRY.get(entityTypeIn); return entityspawnplacementregistry$entry == null ? Heightmap.Type.MOTION_BLOCKING_NO_LEAVES : entityspawnplacementregistry$entry.type; } public static <T extends Entity> boolean func_223515_a(EntityType<T> p_223515_0_, IWorld p_223515_1_, SpawnReason p_223515_2_, BlockPos p_223515_3_, Random p_223515_4_) { EntitySpawnPlacementRegistry.Entry entityspawnplacementregistry$entry = REGISTRY.get(p_223515_0_); return entityspawnplacementregistry$entry == null || entityspawnplacementregistry$entry.field_223513_c.test((EntityType)p_223515_0_, p_223515_1_, p_223515_2_, p_223515_3_, p_223515_4_); } static { register(EntityType.COD, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AbstractFishEntity::func_223363_b); register(EntityType.DOLPHIN, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, DolphinEntity::func_223364_b); register(EntityType.DROWNED, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, DrownedEntity::func_223332_b); register(EntityType.GUARDIAN, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, GuardianEntity::func_223329_b); register(EntityType.PUFFERFISH, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AbstractFishEntity::func_223363_b); register(EntityType.SALMON, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AbstractFishEntity::func_223363_b); register(EntityType.SQUID, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SquidEntity::func_223365_b); register(EntityType.TROPICAL_FISH, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AbstractFishEntity::func_223363_b); register(EntityType.BAT, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, BatEntity::func_223369_b); register(EntityType.BLAZE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223324_d); register(EntityType.CAVE_SPIDER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.CHICKEN, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.COW, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.CREEPER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.DONKEY, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.ENDERMAN, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.ENDERMITE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, EndermiteEntity::func_223328_b); register(EntityType.ENDER_DRAGON, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::func_223315_a); register(EntityType.GHAST, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, GhastEntity::func_223368_b); register(EntityType.GIANT, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.HORSE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.HUSK, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, HuskEntity::func_223334_b); register(EntityType.IRON_GOLEM, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::func_223315_a); register(EntityType.LLAMA, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.MAGMA_CUBE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MagmaCubeEntity::func_223367_b); register(EntityType.MOOSHROOM, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MooshroomEntity::func_223318_c); register(EntityType.MULE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.OCELOT, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, OcelotEntity::func_223319_c); register(EntityType.PARROT, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, ParrotEntity::func_223317_c); register(EntityType.PIG, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.PILLAGER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, PatrollerEntity::func_223330_b); register(EntityType.POLAR_BEAR, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, PolarBearEntity::func_223320_c); register(EntityType.RABBIT, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, RabbitEntity::func_223321_c); register(EntityType.SHEEP, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.SILVERFISH, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SilverfishEntity::func_223331_b); register(EntityType.SKELETON, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.SKELETON_HORSE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.SLIME, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SlimeEntity::func_223366_c); register(EntityType.SNOW_GOLEM, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::func_223315_a); register(EntityType.SPIDER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.STRAY, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, StrayEntity::func_223327_b); register(EntityType.TURTLE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, TurtleEntity::func_223322_c); register(EntityType.VILLAGER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::func_223315_a); register(EntityType.WITCH, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.WITHER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.WITHER_SKELETON, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.WOLF, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.ZOMBIE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.ZOMBIE_HORSE, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.ZOMBIE_PIGMAN, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, ZombiePigmanEntity::func_223337_b); register(EntityType.ZOMBIE_VILLAGER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.CAT, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.ELDER_GUARDIAN, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, GuardianEntity::func_223329_b); register(EntityType.EVOKER, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.FOX, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.ILLUSIONER, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.PANDA, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.PHANTOM, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::func_223315_a); register(EntityType.RAVAGER, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.SHULKER, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::func_223315_a); register(EntityType.TRADER_LLAMA, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::func_223316_b); register(EntityType.VEX, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.VINDICATOR, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c); register(EntityType.WANDERING_TRADER, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::func_223315_a); } static class Entry { private final Heightmap.Type type; private final EntitySpawnPlacementRegistry.PlacementType placementType; private final EntitySpawnPlacementRegistry.IPlacementPredicate<?> field_223513_c; public Entry(Heightmap.Type p_i51522_1_, EntitySpawnPlacementRegistry.PlacementType p_i51522_2_, EntitySpawnPlacementRegistry.IPlacementPredicate<?> p_i51522_3_) { this.type = p_i51522_1_; this.placementType = p_i51522_2_; this.field_223513_c = p_i51522_3_; } } @FunctionalInterface public interface IPlacementPredicate<T extends Entity> { boolean test(EntityType<T> p_test_1_, IWorld p_test_2_, SpawnReason p_test_3_, BlockPos p_test_4_, Random p_test_5_); } public static enum PlacementType implements net.minecraftforge.common.IExtensibleEnum { ON_GROUND, IN_WATER, NO_RESTRICTIONS; public static PlacementType create(String name, net.minecraftforge.common.util.TriPredicate<net.minecraft.world.IWorldReader, BlockPos, EntityType<? extends MobEntity>> predicate) { throw new IllegalStateException("Enum not extended"); } private net.minecraftforge.common.util.TriPredicate<net.minecraft.world.IWorldReader, BlockPos, EntityType<?>> predicate; private PlacementType() { this(null); } private PlacementType(net.minecraftforge.common.util.TriPredicate<net.minecraft.world.IWorldReader, BlockPos, EntityType<?>> predicate) { this.predicate = predicate; } public boolean canSpawnAt(net.minecraft.world.IWorldReader world, BlockPos pos, EntityType<?> type) { if (this == NO_RESTRICTIONS) return true; if (predicate == null) return net.minecraft.world.spawner.WorldEntitySpawner.canSpawnAtBody(this, world, pos, type); return predicate.test(world, pos, type); } } }
  5. Are you doing the Item.BLOCK_TO_ITEM thing?
  6. Yeah unfortunately. If you create a new text file called RunClient.bat and put 'gradlew runClient' in it, then put it in your mod folder, you can just double click it to run the game
  7. No matter what I set my tool material's attack damage value to, it loads into the game as over 700 attack damage. Any ideas why or is this a bug? ToolMaterialList class public enum ToolMaterialList implements IItemTier { TUTORIAL(1.7f, 5.0f, 25, 700, 3, ItemList.tutorial_item); private float attackDamage, efficiency; private int enchantability, durability, harvestLevel; private Item repairMaterial; private ToolMaterialList(float attackDamage, float efficiency, int enchantability, int durability, int harvestLevel, Item repairMaterial) { this.attackDamage = attackDamage; this.efficiency = efficiency; this.enchantability = enchantability; this.durability = durability; this.harvestLevel = harvestLevel; this.repairMaterial = repairMaterial; } @Override public float getAttackDamage() { return this.attackDamage; } @Override public float getEfficiency() { return this.efficiency; } @Override public int getEnchantability() { return this.enchantability; } @Override public int getHarvestLevel() { return this.harvestLevel; } @Override public int getMaxUses() { return this.durability; } @Override public Ingredient getRepairMaterial() { return Ingredient.fromItems(repairMaterial); } } Example of a tool class (they are all the same) public class ItemTutorialAxe extends ItemAxe { public ItemTutorialAxe(IItemTier tier, Item.Properties properties) { super(tier, tier.getMaxUses(), 0, properties); } }
  8. Seems to be a bug with eclipse. This is a workaround for now. Run this in the command prompt in your mod directory
  9. SOLUTION At least for now, you can boot the game using 'gradlew runClient' in the command prompt. This seems to be a bug and will probably be fixed soon though.
  10. Here is my item block code. This loads into my tab @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( ItemList.tutorial_block = new ItemBlock(BlockList.tutorial_block, new Item.Properties().group(tutorial)).setRegistryName(BlockList.tutorial_block.getRegistryName()) ); Item.BLOCK_TO_ITEM.put(BlockList.tutorial_block, ItemList.tutorial_block); }
  11. Thanks for your help with the error. What's wrong with ItemBase? It's just a class that I can use to make all of my items do something, rather than having to individually do it for every item. Thanks for the help with the static stuff though, I'll change that now
  12. No idea why but I have a ResourceLocationException when registering my item. Any help is appreciated Stacktrace [18:51:09.439] [Client thread/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Caught exception during event RegistryEvent.Register<minecraft:items> dispatch for modid tutorialmod java.lang.ExceptionInInitializerError: null at harry.tutorialmod.TutorialMod$RegistryEvents.registerItems(TutorialMod.java:46) ~[main/:?] at net.minecraftforge.eventbus.ASMEventHandler_1_RegistryEvents_registerItems_Register.invoke(.dynamic) ~[?:?] at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:79) ~[eventbus-0.6.0-service.jar:?] at net.minecraftforge.eventbus.EventBus.post(EventBus.java:249) ~[eventbus-0.6.0-service.jar:?] at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:105) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:25.0] at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_201] at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_201] at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:100) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.fml.ModList.lambda$dispatchSynchronousEvent$4(ModList.java:111) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_201] at net.minecraftforge.fml.ModList.dispatchSynchronousEvent(ModList.java:111) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.fml.ModList.lambda$static$0(ModList.java:82) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.fml.LifecycleEventProvider.dispatch(LifecycleEventProvider.java:72) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:146) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:814) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.fml.ModLoader.loadMods(ModLoader.java:134) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:52) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraft.client.Minecraft.init(Minecraft.java:411) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraft.client.Minecraft.run(Minecraft.java:344) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraft.client.main.Main.main(SourceFile:144) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_201] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_201] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201] at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:19) [modlauncher-0.9.4.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:35) [modlauncher-0.9.4.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-0.9.4.jar:?] at cpw.mods.modlauncher.Launcher.run(Launcher.java:58) [modlauncher-0.9.4.jar:?] at cpw.mods.modlauncher.Launcher.main(Launcher.java:44) [modlauncher-0.9.4.jar:?] at net.minecraftforge.userdev.UserdevLauncher.main(UserdevLauncher.java:77) [forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] Caused by: net.minecraft.util.ResourceLocationException: Non [a-z0-9/._-] character in path of location: tutorialmod:tutorialItem at net.minecraft.util.ResourceLocation.<init>(SourceFile:38) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraft.util.ResourceLocation.<init>(SourceFile:47) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.registries.GameData.checkPrefix(GameData.java:833) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?] at net.minecraftforge.registries.ForgeRegistryEntry.setRegistryName(ForgeRegistryEntry.java:45) ~[?:?] at net.minecraftforge.registries.ForgeRegistryEntry.setRegistryName(ForgeRegistryEntry.java:52) ~[?:?] at harry.tutorialmod.items.ItemBase.<init>(ItemBase.java:13) ~[?:?] at harry.tutorialmod.init.ItemInit.<clinit>(ItemInit.java:14) ~[?:?] ... 31 more ItemBase public class ItemBase extends Item { public ItemBase(String name) { super(new Item.Properties()); setRegistryName(new ResourceLocation(ModConfig.MODID, name)); ItemInit.ITEMS.add(this); } } ItemInit public class ItemInit { public static final List<Item> ITEMS = new ArrayList<Item>(); public static final Item tutorialItem = new ItemBase("tutorialItem"); } Main Class @Mod(ModConfig.MODID) public class TutorialMod { private static final Logger LOGGER = LogManager.getLogger(ModConfig.MODID); public TutorialMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { LOGGER.info("Setup method registered. (This is what used to be preInit)"); } private void clientRegistries(final FMLClientSetupEvent event) { LOGGER.info("Client registries registered. This is for all things that are client side only."); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll((Item[]) ItemInit.ITEMS.toArray()); LOGGER.info("Items registered."); } @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { LOGGER.info("Blocks registered."); } } }
  13. https://github.com/HarryTechRevs/MinecraftModding1.13
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.