Jump to content

HarryTechReviews

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by HarryTechReviews

  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
  14. I have one, still doesn't recognize my mod.
  15. Despite my mod having the Mod annotation, the launcher isn't finding it and it's just booting into the game ignoring my mod. Any idea why? ---------------------------------------------------------------------------------------------------------------------- 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.
  16. Block Class package harry.mods.tutorialmod.blocks; import java.util.Random; import harry.mods.tutorialmod.Main; import harry.mods.tutorialmod.Reference; import harry.mods.tutorialmod.blocks.tileentity.TileEntitySinteringFurnace; import harry.mods.tutorialmod.init.BlockInit; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockElectricSinteringFurnace extends BlockBase { public static final PropertyDirection FACING = BlockHorizontal.FACING; public static final PropertyBool BURNING = PropertyBool.create("burning"); public BlockElectricSinteringFurnace(String name) { super(name, Material.IRON, Main.TUTORIAL); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(BURNING, false)); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(BlockInit.ELECTRIC_SINTERING_FURNACE); } @Override public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return new ItemStack(BlockInit.ELECTRIC_SINTERING_FURNACE); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { playerIn.openGui(Main.instance, Reference.GUI_ELECTRIC_SINTERING_FURNACE, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); IBlockState east = worldIn.getBlockState(pos.east()); EnumFacing face = (EnumFacing)state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) face = EnumFacing.SOUTH; else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) face = EnumFacing.NORTH; else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) face = EnumFacing.EAST; else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) face = EnumFacing.WEST; worldIn.setBlockState(pos, state.withProperty(FACING, face), 2); } } public static void setState(boolean active, World worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); TileEntity tileentity = worldIn.getTileEntity(pos); if(active) worldIn.setBlockState(pos, BlockInit.ELECTRIC_SINTERING_FURNACE.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, true), 3); else worldIn.setBlockState(pos, BlockInit.ELECTRIC_SINTERING_FURNACE.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, false), 3); if(tileentity != null) { tileentity.validate(); worldIn.setTileEntity(pos, tileentity); } } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityElectricSinteringFurnace(); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntitySinteringFurnace tileentity = (TileEntitySinteringFurnace)worldIn.getTileEntity(pos); worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), tileentity.getStackInSlot(0))); worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), tileentity.getStackInSlot(1))); worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), tileentity.getStackInSlot(2))); worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), tileentity.getStackInSlot(3))); super.breakBlock(worldIn, pos, state); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {BURNING,FACING}); } @Override public IBlockState getStateFromMeta(int meta) { EnumFacing facing = EnumFacing.getFront(meta); if(facing.getAxis() == EnumFacing.Axis.Y) facing = EnumFacing.NORTH; return this.getDefaultState().withProperty(FACING, facing); } @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } } GUI Class package harry.mods.tutorialmod.blocks.gui; import harry.mods.tutorialmod.Reference; import harry.mods.tutorialmod.blocks.TileEntityElectricSinteringFurnace; import harry.mods.tutorialmod.blocks.container.ContainerElectricSinteringFurnace; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; public class GuiElectricSinteringFurnace extends GuiContainer { private static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MODID + ":textures/gui/electric_sintering_furnace.png"); private final InventoryPlayer player; private final TileEntityElectricSinteringFurnace tileentity; public GuiElectricSinteringFurnace(InventoryPlayer player, TileEntityElectricSinteringFurnace tileentity) { super(new ContainerElectricSinteringFurnace(player, tileentity)); this.player = player; this.tileentity = tileentity; } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String tileName = this.tileentity.getDisplayName().getUnformattedText(); this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) -5, 6, 4210752); this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 7, this.ySize - 96 + 2, 4210752); this.fontRenderer.drawString(Integer.toString(this.tileentity.getEnergyStored()), 125, 72, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); this.mc.getTextureManager().bindTexture(TEXTURES); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); int l = this.getCookProgressScaled(24); this.drawTexturedModalRect(this.guiLeft + 44, this.guiTop + 36, 176, 14, l + 1, 16); int k = this.getEnergyStoredScaled(75); this.drawTexturedModalRect(this.guiLeft + 152, this.guiTop + 7, 176, 32, 16, 75 - k); } private int getCookProgressScaled(int pixels) { int i = this.tileentity.cookTime; return i != 0 ? i * pixels / 100 : 0; } private int getEnergyStoredScaled(int pixels) { int i = this.tileentity.getEnergyStored(); int j = this.tileentity.getMaxEnergyStored(); return i != 0 && j != 0 ? i * pixels / j : 0; } } GUIHandler package harry.mods.tutorialmod.handlers; import harry.mods.tutorialmod.Reference; import harry.mods.tutorialmod.blocks.TileEntityElectricSinteringFurnace; import harry.mods.tutorialmod.blocks.container.ContainerCopperChest; import harry.mods.tutorialmod.blocks.container.ContainerElectricSinteringFurnace; import harry.mods.tutorialmod.blocks.container.ContainerSinteringFurnace; import harry.mods.tutorialmod.blocks.gui.GuiCopperChest; import harry.mods.tutorialmod.blocks.gui.GuiElectricSinteringFurnace; import harry.mods.tutorialmod.blocks.gui.GuiSinteringFurnace; import harry.mods.tutorialmod.blocks.tileentity.TileEntityCopperChest; import harry.mods.tutorialmod.blocks.tileentity.TileEntitySinteringFurnace; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == Reference.GUI_SINTERING_FURNACE) return new ContainerSinteringFurnace(player.inventory, (TileEntitySinteringFurnace)world.getTileEntity(new BlockPos(x,y,z))); if(ID == Reference.GUI_COPPER_CHEST) return new ContainerCopperChest(player.inventory, (TileEntityCopperChest)world.getTileEntity(new BlockPos(x,y,z)), player); if(ID == Reference.GUI_ELECTRIC_SINTERING_FURNACE) return new ContainerElectricSinteringFurnace(player.inventory, (TileEntityElectricSinteringFurnace)world.getTileEntity(new BlockPos(x,y,z))); return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == Reference.GUI_SINTERING_FURNACE) return new GuiSinteringFurnace(player.inventory, (TileEntitySinteringFurnace)world.getTileEntity(new BlockPos(x,y,z))); if(ID == Reference.GUI_COPPER_CHEST) return new GuiCopperChest(player.inventory, (TileEntityCopperChest)world.getTileEntity(new BlockPos(x,y,z)), player); if(ID == Reference.GUI_ELECTRIC_SINTERING_FURNACE) return new GuiElectricSinteringFurnace(player.inventory, (TileEntityElectricSinteringFurnace)world.getTileEntity(new BlockPos(x,y,z))); return null; } }
  17. Yep, all other tile entities are the same but this one doesn't work
  18. Same code for the other two gui and containers and they dont return null
  19. I'm not, here it is in gui handler. if(ID == Reference.GUI_ELECTRIC_SINTERING_FURNACE) return new ContainerElectricSinteringFurnace(player.inventory, (TileEntityElectricSinteringFurnace)world.getTileEntity(new BlockPos(x,y,z))); if(ID == Reference.GUI_ELECTRIC_SINTERING_FURNACE) return new ContainerElectricSinteringFurnace(player.inventory, (TileEntityElectricSinteringFurnace)world.getTileEntity(new BlockPos(x,y,z)));
  20. Still same error, I tried something & it didn't work so I reversed it
  21. Might be wrong phrasing I don't know. Didnt work anyway
  22. Oh my god ffs. You were right, I was using the local te instead of the global te variable. So frustrating. Thanks Still doesn't work
×
×
  • Create New...

Important Information

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