DragonITA Posted January 16, 2020 Posted January 16, 2020 I tried spawning my entity, but it did not work and I got this error: Time: 16/01/20 18.17 Description: Unexpected error java.lang.NullPointerException: Unexpected error at net.minecraft.client.renderer.entity.EntityRendererManager.func_229086_a_(EntityRendererManager.java:232) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.func_228426_a_(WorldRenderer.java:944) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.func_228378_a_(GameRenderer.java:613) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:435) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:914) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:520) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:176) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_231] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_231] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_231] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101) [forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraft.client.renderer.entity.EntityRendererManager.func_229086_a_(EntityRendererManager.java:232) at net.minecraft.client.renderer.WorldRenderer.func_228426_a_(WorldRenderer.java:944) at net.minecraft.client.renderer.GameRenderer.func_228378_a_(GameRenderer.java:613) -- Affected level -- Details: All players: 1 total; [ClientPlayerEntity['Dev'/197, l='MpServer', x=-20.84, y=63.00, z=-15.50]] Chunk stats: Client Chunk Cache: 121, 49 Level dimension: DimensionType{minecraft:overworld} Level name: MpServer Level seed: 4545873244386871167 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: {} Level spawn location: World: (0,63,14), Chunk: (at 0,3,14 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 24962 game time, 24962 day time Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Server brand: forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:457) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:1769) at net.minecraft.client.Minecraft.run(Minecraft.java:539) at net.minecraft.client.main.Main.main(Main.java:176) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101) -- System Details -- Details: Minecraft Version: 1.15.1 Minecraft Version ID: 1.15.1 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_231, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 688031888 bytes (656 MB) / 3276275712 bytes (3124 MB) up to 7635730432 bytes (7282 MB) CPUs: 4 JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx8192M ModLauncher: 5.0.0-milestone.4+67+b1a340b ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /eventbus-2.0.0-milestone.1-service.jar eventbus PLUGINSERVICE /forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-2.0.0-milestone.1-shadowed.jar accesstransformer PLUGINSERVICE /forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE /forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE FML: 30.0 Forge: net.minecraftforge:30.0.39 FML Language Providers: [email protected] minecraft@1 Mod List: client-extra.jar Minecraft {[email protected] DONE} main Fantasy Mod {fantasymod@version DONE} forge-1.15.1-30.0.39_mapped_snapshot_20190719-1.14.3-recomp.jar Forge {[email protected] DONE} Launched Version: MOD_DEV Backend library: LWJGL version 3.2.2 build 10 Backend API: AMD Mobility Radeon HD 5570 GL version 4.5.13399 Compatibility Profile Context 15.201.1151.1008, ATI Technologies Inc. GL Caps: Using framebuffer using OpenGL 3.0 Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) CPU: 4x Intel(R) Core(TM) i3 CPU 550 @ 3.20GHz [m[32m[18:18:04] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:109]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Christian8\OneDrive - 365education\NewFantasyMod[1.15.1]\run\.\crash-reports\crash-2020-01-16_18.17.57-client.txt I don't understand much of what it says, but if I read it correctly there should be a problem when rendering my entity. Here is the code: package mod.dragonita.fantasymod.client.renders; import mod.dragonita.fantasymod.Main; import mod.dragonita.fantasymod.client.models.UnicornEntityModel; import mod.dragonita.fantasymod.entities.UnicornEntity; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber(modid = Main.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class UnicornEntityRender extends MobRenderer<UnicornEntity, UnicornEntityModel> { public UnicornEntityRender(EntityRendererManager manager) { super(manager, new UnicornEntityModel(), 0f); } public static final ResourceLocation unicorn = new ResourceLocation("fantasymod:textures/entity/unicorn_entity.png"); public static class RenderFactory implements IRenderFactory<UnicornEntity> { @Override public EntityRenderer<? super UnicornEntity> createRenderFor(EntityRendererManager manager) { return new UnicornEntityRender(manager); } } @Override public ResourceLocation getEntityTexture(UnicornEntity entity) { return unicorn; } } So I register them: package mod.dragonita.fantasymod.client.renders; import mod.dragonita.fantasymod.Main; import mod.dragonita.fantasymod.init.ModEntityTypes; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber(modid = Main.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class FantasyRenderRegistry { public void registryEntityRenders() { RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.UNICORN, new UnicornEntityRender.RenderFactory()); } } And here is how I register my SpawnEgg, but there I have to post all the code, here: package mod.dragonita.fantasymod; import javax.annotation.Nonnull; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.common.base.Preconditions; import mod.dragonita.fantasymod.block.InfuserBlock; import mod.dragonita.fantasymod.init.ModBlocks; import mod.dragonita.fantasymod.init.ModEntityTypes; import mod.dragonita.fantasymod.init.ModItemGroups; import mod.dragonita.fantasymod.tileentity.InfuserTileEntity; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.SpawnEggItem; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ToolType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; @EventBusSubscriber(modid = Main.MODID, bus = EventBusSubscriber.Bus.MOD) public final class ModEventSubscriber { private static final Logger LOGGER = LogManager.getLogger(Main.MODID + " Mod Event Subscriber"); @SubscribeEvent public static void onRegisterBlocks(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll ( setup(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2)), "rainbow_ore"), setup(new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestTool(ToolType.PICKAXE).harvestLevel(2)), "rainbow_block"), setup(new InfuserBlock(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.5F)), "infuser") ); } @SubscribeEvent public static void onRegisterItems(RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); event.getRegistry().registerAll ( setup(new Item(new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP)), "rainbow_ingot"), setup(new SpawnEggItem(ModEntityTypes.UNICORN, 0xf0f0f0, 0xdf51f5, new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP)), "unicorn_entity_egg") ); // Automatically register BlockItems for all our Blocks // (We need to go over the entire registry so that we include any potential Registry Overrides) ForgeRegistries.BLOCKS.getValues().parallelStream() // Filter out blocks that aren't from our mod .filter(block -> block.getRegistryName().getNamespace().equals(Main.MODID)) // You can do extra filtering here if you don't want some blocks to have an BlockItem automatically registered for them // Register the BlockItem for the block .forEach(block -> { // Make the properties, and make it so that the item will be on our ItemGroup (CreativeTab) final Item.Properties properties = new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP); // Create the new BlockItem with the block and it's properties final BlockItem blockItem = new BlockItem(block, properties); // Setup the new BlockItem with the block's registry name and register it registry.register(setup(blockItem, block.getRegistryName())); }); LOGGER.debug("Registered Items"); } @SubscribeEvent public static void onRegisterTileEntityTypes(@Nonnull final RegistryEvent.Register<TileEntityType<?>> event) { // Register your TileEntityTypes here if you have them event.getRegistry().registerAll( // We don't have a datafixer for our TileEntity, so we pass null into build setup(TileEntityType.Builder.create(InfuserTileEntity::new, ModBlocks.INFUSER).build(null), "infuser") ); LOGGER.debug("Registered TileEntityTypes"); } //@SubscribeEvent //public static void onRegisterEntitieTypes(RegistryEvent.Register<EntityType<?>> event) //{ //final IForgeRegistry<EntityType<?>> registry = event.getRegistry(); //event.getRegistry().registerAll( //EntityType.Builder.create(UnicornEntity::new, EntityClassification.CREATURE).build(null).setRegistryName(Main.MODID, "unicorn") //FantasyModEntities.UNICORN_ENTITY.setRegistryName(Main.MODID, "unicorn_entity") //); //} /** * Performs setup on a registry entry * * @param name The path of the entry's name. Used to make a name who's domain is our mod's modid */ @Nonnull private static <T extends IForgeRegistryEntry<T>> T setup(@Nonnull final T entry, @Nonnull final String name) { Preconditions.checkNotNull(name, "Name to assign to entry cannot be null!"); return setup(entry, new ResourceLocation(Main.MODID, name)); } /** * Performs setup on a registry entry * * @param registryName The full registry name of the entry */ @Nonnull private static <T extends IForgeRegistryEntry<T>> T setup(@Nonnull final T entry, @Nonnull final ResourceLocation registryName) { Preconditions.checkNotNull(entry, "Entry cannot be null!"); Preconditions.checkNotNull(registryName, "Registry name to assign to entry cannot be null!"); entry.setRegistryName(registryName); return entry; } } But as it is unreadable I will show the parts that are really important: @SubscribeEvent public static void onRegisterItems(RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); event.getRegistry().registerAll ( setup(new Item(new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP)), "rainbow_ingot"), setup(new SpawnEggItem(ModEntityTypes.UNICORN, 0xf0f0f0, 0xdf51f5, new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP)), "unicorn_entity_egg") ); @Nonnull private static <T extends IForgeRegistryEntry<T>> T setup(@Nonnull final T entry, @Nonnull final String name) { Preconditions.checkNotNull(name, "Name to assign to entry cannot be null!"); return setup(entry, new ResourceLocation(Main.MODID, name)); } /** * Performs setup on a registry entry * * @param registryName The full registry name of the entry */ @Nonnull private static <T extends IForgeRegistryEntry<T>> T setup(@Nonnull final T entry, @Nonnull final ResourceLocation registryName) { Preconditions.checkNotNull(entry, "Entry cannot be null!"); Preconditions.checkNotNull(registryName, "Registry name to assign to entry cannot be null!"); entry.setRegistryName(registryName); return entry; } LOGGER.debug("Registered Items"); } If anyone is wondering how to register my EntityType, this is what I do: package mod.dragonita.fantasymod.init; import mod.dragonita.fantasymod.entities.UnicornEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.util.registry.Registry; public class ModEntityTypes extends net.minecraftforge.registries.ForgeRegistryEntry<EntityType<?>>{ public static EntityType<UnicornEntity> UNICORN = register("unicorn_entity", EntityType.Builder.create(UnicornEntity::new, EntityClassification.CREATURE)); @SuppressWarnings("deprecation") private static <T extends Entity> EntityType<T> register(String key, EntityType.Builder<T> builder) { return Registry.register(Registry.ENTITY_TYPE, key, builder.build(key)); } } If it has something to do with my EntityModel, dqnn I have to sqgen dqss I first wanted to see if my code would work, and then add it to my Custom EntityModel, for that I tried the Vanilla Bat Model first, but I would be surprised if that was the problem, but here is the model (I just adapted it a bit): package mod.dragonita.fantasymod.client.models; import com.google.common.collect.ImmutableList; import mod.dragonita.fantasymod.entities.UnicornEntity; import net.minecraft.client.renderer.entity.model.SegmentedModel; import net.minecraft.client.renderer.model.ModelRenderer; public class UnicornEntityModel extends SegmentedModel<UnicornEntity> { private final ModelRenderer batHead; private final ModelRenderer batBody; private final ModelRenderer batRightWing; private final ModelRenderer batLeftWing; private final ModelRenderer batOuterRightWing; private final ModelRenderer batOuterLeftWing; public UnicornEntityModel() { this.textureWidth = 64; this.textureHeight = 64; this.batHead = new ModelRenderer(this, 0, 0); this.batHead.func_228300_a_(-3.0F, -3.0F, -3.0F, 6.0F, 6.0F, 6.0F); ModelRenderer modelrenderer = new ModelRenderer(this, 24, 0); modelrenderer.func_228300_a_(-4.0F, -6.0F, -2.0F, 3.0F, 4.0F, 1.0F); this.batHead.addChild(modelrenderer); ModelRenderer modelrenderer1 = new ModelRenderer(this, 24, 0); modelrenderer1.mirror = true; modelrenderer1.func_228300_a_(1.0F, -6.0F, -2.0F, 3.0F, 4.0F, 1.0F); this.batHead.addChild(modelrenderer1); this.batBody = new ModelRenderer(this, 0, 16); this.batBody.func_228300_a_(-3.0F, 4.0F, -3.0F, 6.0F, 12.0F, 6.0F); this.batBody.setTextureOffset(0, 34).func_228300_a_(-5.0F, 16.0F, 0.0F, 10.0F, 6.0F, 1.0F); this.batRightWing = new ModelRenderer(this, 42, 0); this.batRightWing.func_228300_a_(-12.0F, 1.0F, 1.5F, 10.0F, 16.0F, 1.0F); this.batOuterRightWing = new ModelRenderer(this, 24, 16); this.batOuterRightWing.setRotationPoint(-12.0F, 1.0F, 1.5F); this.batOuterRightWing.func_228300_a_(-8.0F, 1.0F, 0.0F, 8.0F, 12.0F, 1.0F); this.batLeftWing = new ModelRenderer(this, 42, 0); this.batLeftWing.mirror = true; this.batLeftWing.func_228300_a_(2.0F, 1.0F, 1.5F, 10.0F, 16.0F, 1.0F); this.batOuterLeftWing = new ModelRenderer(this, 24, 16); this.batOuterLeftWing.mirror = true; this.batOuterLeftWing.setRotationPoint(12.0F, 1.0F, 1.5F); this.batOuterLeftWing.func_228300_a_(0.0F, 1.0F, 0.0F, 8.0F, 12.0F, 1.0F); this.batBody.addChild(this.batRightWing); this.batBody.addChild(this.batLeftWing); this.batRightWing.addChild(this.batOuterRightWing); this.batLeftWing.addChild(this.batOuterLeftWing); } @Override public Iterable<ModelRenderer> func_225601_a_() { return ImmutableList.of(this.batHead, this.batBody); } @Override public void func_225597_a_(UnicornEntity p_225597_1_, float p_225597_2_, float p_225597_3_, float p_225597_4_, float p_225597_5_, float p_225597_6_) { this.batHead.rotateAngleX = p_225597_6_ * ((float)Math.PI / 180F); this.batHead.rotateAngleY = (float)Math.PI - p_225597_5_ * ((float)Math.PI / 180F); this.batHead.rotateAngleZ = (float)Math.PI; this.batHead.setRotationPoint(0.0F, -2.0F, 0.0F); this.batRightWing.setRotationPoint(-3.0F, 0.0F, 3.0F); this.batLeftWing.setRotationPoint(3.0F, 0.0F, 3.0F); this.batBody.rotateAngleX = (float)Math.PI; this.batRightWing.rotateAngleX = -0.15707964F; this.batRightWing.rotateAngleY = -1.2566371F; this.batOuterRightWing.rotateAngleY = -1.7278761F; this.batLeftWing.rotateAngleX = this.batRightWing.rotateAngleX; this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; this.batOuterLeftWing.rotateAngleY = -this.batOuterRightWing.rotateAngleY; } } If it is my entity class that is the cause of the problem, then here it is: package mod.dragonita.fantasymod.entities; import net.minecraft.entity.EntityType; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.goal.LookAtGoal; import net.minecraft.entity.ai.goal.LookRandomlyGoal; import net.minecraft.entity.ai.goal.PanicGoal; import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal; import net.minecraft.entity.passive.horse.HorseEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Hand; import net.minecraft.world.World; public class UnicornEntity extends HorseEntity{ public UnicornEntity(EntityType<? extends UnicornEntity> type, World worldIn) { super(type, worldIn); } protected void registerGoals() { this.goalSelector.addGoal(1, new PanicGoal(this, 1.2D)); this.goalSelector.addGoal(6, new WaterAvoidingRandomWalkingGoal(this, 0.7D)); this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 6.0F)); this.goalSelector.addGoal(8, new LookRandomlyGoal(this)); } protected void registerAttributes() { super.registerAttributes(); this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0d); this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(5.0d); } @Override public boolean processInteract(PlayerEntity player, Hand hand) { return super.processInteract(player, hand); } } So, but really, I can't give more information than that, thanks for any help I get. Quote New in Modding? == Still learning!
Ugdhar Posted January 16, 2020 Posted January 16, 2020 (edited) I read somewhere on here (I'll try to find the post) that you need to create (not register) your EntityType during Item registration, because Items register before EntityTypes, so if you create the EntityType during its registration, when the Item tries to register (before the EntityType), the resulting EntityType passed to the spawn egg is null. edit: Found the post: https://www.minecraftforge.net/forum/topic/75045-solved1144-entities-and-spawneggs/?tab=comments#comment-359588 Edited January 16, 2020 by Ugdhar add link to info 1 Quote
DragonITA Posted January 17, 2020 Author Posted January 17, 2020 This dont work, I don't know if it's my fault or if I just can't do it. i tried to register it in the same time, but i have got a error, then i tried to register the EntityType before the Item, but it still dont work and if i try to spawn the entity, then the game crashes out and write: Description: Unexpected error But thanks for the Link Quote New in Modding? == Still learning!
Cadiboo Posted January 18, 2020 Posted January 18, 2020 1 hour ago, DragonITA said: i tried to register it in the same time 1 hour ago, DragonITA said: i tried to register the EntityType before the Item Well... On 1/17/2020 at 5:21 AM, Ugdhar said: You need to create (not register) your EntityType during Item registration 1 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
DragonITA Posted January 18, 2020 Author Posted January 18, 2020 I've tried it too, I have to say that (certainly in an unclear way), but I don't know if I'm doing it wrong or anything else, but it crashes the game. Quote New in Modding? == Still learning!
DragonITA Posted January 18, 2020 Author Posted January 18, 2020 Here is my Code: Here I created my entity types: package mod.dragonita.fantasymod.init; import mod.dragonita.fantasymod.Main; import mod.dragonita.fantasymod.entities.UnicornEntity; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraftforge.registries.ObjectHolder; @ObjectHolder(Main.MODID) public class ModEntityTypes{ public static EntityType<UnicornEntity> UNICORN = EntityType.Builder .create(UnicornEntity::new, EntityClassification.CREATURE) .size(5F, 7F) .build("unicorn_entity"); } And here I register them: package mod.dragonita.fantasymod; import javax.annotation.Nonnull; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.common.base.Preconditions; import mod.dragonita.fantasymod.block.InfuserBlock; import mod.dragonita.fantasymod.init.ModBlocks; import mod.dragonita.fantasymod.init.ModEntityTypes; import mod.dragonita.fantasymod.init.ModItemGroups; import mod.dragonita.fantasymod.tileentity.InfuserTileEntity; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.SpawnEggItem; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ToolType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; @EventBusSubscriber(modid = Main.MODID, bus = EventBusSubscriber.Bus.MOD) public final class ModEventSubscriber { private static final Logger LOGGER = LogManager.getLogger(Main.MODID + " Mod Event Subscriber"); @SubscribeEvent public static void onRegisterBlocks(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll ( setup(new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2)), "rainbow_ore"), setup(new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestTool(ToolType.PICKAXE).harvestLevel(2)), "rainbow_block"), setup(new InfuserBlock(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.5F)), "infuser") ); } @SubscribeEvent public static void onRegisterItems(RegistryEvent.Register<Item> itemevent) { final IForgeRegistry<Item> registry = itemevent.getRegistry(); //RegistryEvent.Register<EntityType<?>> entityevent = null; //entityevent.getRegistry().registerAll( // ModEntitieTypes.UNICORN_ENTITY_TYPE.setRegistryName(Main.MODID, "unicorn_entity") //); itemevent.getRegistry().registerAll ( setup(new Item(new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP)), "rainbow_ingot") ); // Automatically register BlockItems for all our Blocks // (We need to go over the entire registry so that we include any potential Registry Overrides) ForgeRegistries.BLOCKS.getValues().parallelStream() // Filter out blocks that aren't from our mod .filter(block -> block.getRegistryName().getNamespace().equals(Main.MODID)) // You can do extra filtering here if you don't want some blocks to have an BlockItem automatically registered for them // Register the BlockItem for the block .forEach(block -> { // Make the properties, and make it so that the item will be on our ItemGroup (CreativeTab) final Item.Properties properties = new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP); // Create the new BlockItem with the block and it's properties final BlockItem blockItem = new BlockItem(block, properties); // Setup the new BlockItem with the block's registry name and register it registry.register(setup(blockItem, block.getRegistryName())); }); LOGGER.debug("Registered Items"); } @SubscribeEvent public static void onRegisterTileEntityTypes(@Nonnull final RegistryEvent.Register<TileEntityType<?>> event) { // Register your TileEntityTypes here if you have them event.getRegistry().registerAll( // We don't have a datafixer for our TileEntity, so we pass null into build setup(TileEntityType.Builder.create(InfuserTileEntity::new, ModBlocks.INFUSER).build(null), "infuser") ); LOGGER.debug("Registered TileEntityTypes"); } @SubscribeEvent public static void onRegisterEntityTypes(RegistryEvent.Register<EntityType<?>> event) { event.getRegistry().registerAll( ModEntityTypes.UNICORN.setRegistryName(Main.MODID, "unicorn_entity") ); } @SubscribeEvent public static void onRegisterSpawnEggs(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( setup(new SpawnEggItem(ModEntityTypes.UNICORN, 0xf0f0f0, 0xdf51f5, new Item.Properties().group(ModItemGroups.RAINBOW_MOD_GROUP)), "unicorn_entity_egg") ); } /** * Performs setup on a registry entry * * @param name The path of the entry's name. Used to make a name who's domain is our mod's modid */ @Nonnull private static <T extends IForgeRegistryEntry<T>> T setup(@Nonnull final T entry, @Nonnull final String name) { Preconditions.checkNotNull(name, "Name to assign to entry cannot be null!"); return setup(entry, new ResourceLocation(Main.MODID, name)); } /** * Performs setup on a registry entry * * @param registryName The full registry name of the entry */ @Nonnull private static <T extends IForgeRegistryEntry<T>> T setup(@Nonnull final T entry, @Nonnull final ResourceLocation registryName) { Preconditions.checkNotNull(entry, "Entry cannot be null!"); Preconditions.checkNotNull(registryName, "Registry name to assign to entry cannot be null!"); entry.setRegistryName(registryName); return entry; } //@SuppressWarnings("deprecation") //private static <T extends Entity> EntityType<T> register(String key, EntityType.Builder<T> builder) { //return Registry.register(Registry.ENTITY_TYPE, key, builder.build(key)); //} } Quote New in Modding? == Still learning!
Ugdhar Posted January 18, 2020 Posted January 18, 2020 (edited) @ObjectHolder(Main.MODID) public class ModEntityTypes{ public static EntityType<UnicornEntity> UNICORN = EntityType.Builder .create(UnicornEntity::new, EntityClassification.CREATURE) .size(5F, 7F) .build("unicorn_entity"); } Do not create your registerable stuff with static initializers. Honestly not 100% sure the reasoning, but everyone that knows what they're doing on here says not to, so I'm sure it's a good reason! You want to build/create your EntityType in the Item registration event, like I had previously said. DO NOT register it. Just create it, and assign it to ModEntityTypes.UNICORN. Then after it has been created, you can create/register your spawn egg within the Item registration event. Then register (no need to build/create) your UNICORN in the EntityType registration event, since it has already been created. If you get a crash after this, post updated code, as well as the crash report. Don't assume the crash report is the same as your original post. Also, please use spoiler tags or an external site (github gist, pastebin, etc) to post your logs so it's not a mile of scrolling to get to the bottom Edited January 18, 2020 by Ugdhar 1 Quote
Cadiboo Posted January 18, 2020 Posted January 18, 2020 (edited) On 1/18/2020 at 11:09 PM, Ugdhar said: Honestly not 100% sure the reasoning, but everyone that knows what they're doing on here says not to What: Not using static initialisers. Why: Using static initialisers does not allow you to control when your objects are created or the order in which your objects are created. Consequences: Using static initialisers prevents other mods from overriding your objects, prevents forge from being able to dynamically load/unload mods and can cause weird, unreproducible crashes. How: Use the @ObjectHolder annotation if you need static references to your objects and create & register your objects in the appropriate registry event. (Note: before registry events Modders created and registered their items in preInit. This practice became out of date in 1.7 with the introduction of registry events, and is no longer possible in 1.13). If you have a creative tab that uses an item for its icon & that item references that creative tab in its constructor, and both use static initialisers, they both depend on the other being loaded first to function properly. So whichever one actually gets loaded first will cause the other one to get loaded & the other one will use a null reference to the initial one. Since you don’t control the order in which classes are initialised this means that either the item or the creative tab will have a null creative tab/icon and you don’t know which it will be. This causes hard to track down bugs (if you don’t know about this behaviour as it will compile fine). Related: (trying to find SO article about how 3 classes that depend on eachother for a value will have the runtime value depend on the order in which they are loaded, will edit this to add the article if I find it) Edited January 20, 2020 by Cadiboo 1 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
Ugdhar Posted January 18, 2020 Posted January 18, 2020 Thanks for the primer @Cadiboo, your txt is very very dark in the dark theme tho, hard to read without highlighting it Quote
Cadiboo Posted January 18, 2020 Posted January 18, 2020 Sorry, copy paste formatting strikes again Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
DragonITA Posted January 18, 2020 Author Posted January 18, 2020 10 hours ago, Ugdhar said: DO NOT register it. Just create it 10 hours ago, Ugdhar said: Then register (no need to build/create) your UNICORN in the EntityType registration event I don't understand anything now, register or not? Quote New in Modding? == Still learning!
Ugdhar Posted January 18, 2020 Posted January 18, 2020 11 hours ago, Ugdhar said: You want to build/create your EntityType in the Item registration event, like I had previously said. DO NOT register it. Just create it, and assign it to ModEntityTypes.UNICORN. 11 hours ago, Ugdhar said: Then register (no need to build/create) your UNICORN in the EntityType registration event, since it has already been created. I don't know how to be more clear than the instructions I gave Quote
DragonITA Posted January 20, 2020 Author Posted January 20, 2020 (edited) On 1/18/2020 at 1:09 PM, Ugdhar said: Do not create your registerable stuff with static initializers. Given what you said, I tried to change using the DeferredRegister, but I got this error, I think it's coming from my entity type, but I don't know why. The Log: Github Link. Edited January 20, 2020 by DragonITA Quote New in Modding? == Still learning!
Ugdhar Posted January 20, 2020 Posted January 20, 2020 (edited) Since you already have a github, you should post your code there. Much easier to read on there than pasted here, and as long as you keep updating it, no need to post updated code here. Making a guess based on the crash without seeing code, you're trying to register something that has not been initialized, so it's trying to register something that is null. *edit: Pretty sure it's an item, since the crash looks to be coming from ModItems. Edited January 20, 2020 by Ugdhar 1 Quote
DragonITA Posted January 21, 2020 Author Posted January 21, 2020 9 hours ago, Ugdhar said: Since you already have a github I only made it yesterday, and I have to admit I should have made it earlier. I'm going to try and get my mod onto Github. Quote New in Modding? == Still learning!
Cadiboo Posted January 21, 2020 Posted January 21, 2020 Use a git client. GitHub desktop is good if you have limited experience in git/the command line 1 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
DragonITA Posted January 21, 2020 Author Posted January 21, 2020 Uh, what is git client and how do you use it? Quote New in Modding? == Still learning!
mc_jojo3 Posted January 21, 2020 Posted January 21, 2020 (edited) Its Github for the desktop: https://desktop.github.com/ or if you mean git it's a software that helps developers and makes different instalations easier for an example: https://git-scm.com/downloads Edited January 21, 2020 by mc_jojo3 Added an explanation for git 1 Quote
DragonITA Posted January 21, 2020 Author Posted January 21, 2020 (edited) https://github.com/DragonGamerDevelopers/NewFantasyMod-1.15.1 here is the link. Edit: I dont have right imported it, wait a bit. Edited January 21, 2020 by DragonITA Quote New in Modding? == Still learning!
DragonITA Posted January 21, 2020 Author Posted January 21, 2020 I think you think the error comes from there, because my entity type doesn't work, and because Spawnegg needs it, the whole Mod crashes. Quote New in Modding? == Still learning!
Cadiboo Posted January 21, 2020 Posted January 21, 2020 Your repo is empty. Did you push your commits? Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
DragonITA Posted January 22, 2020 Author Posted January 22, 2020 I had imported it wrong, I will now leave it empty, after school I will import it. Quote New in Modding? == Still learning!
DragonITA Posted January 22, 2020 Author Posted January 22, 2020 I had imported it wrong, but you can now read at least my files. It was hard to import it correctly, and i get error logs. Quote New in Modding? == Still learning!
Cadiboo Posted January 22, 2020 Posted January 22, 2020 You set up the repository one folder too low. It needs to be in your project folder, the one above your src folder. Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
Cadiboo Posted January 22, 2020 Posted January 22, 2020 Any reason you have both ModEntityTypes and FantasyModEntities? I would guess that your EntityType doesn't exist when you try to use it, however, since you haven't set up your repo correctly I can't clone it and debug it locally (Technically I still can but I would have to use my own configuration files (build.gradle, gradle.properties etc.) which you may have customised, so I may not get the same results as you) 1 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.