Jump to content

[1.14.4] Game crash on entity spawn


byTiny

Recommended Posts

Hey, so I want to spawn an entity when the player joins the world but I get a crash every time I join the world:

Spoiler
 
 
 
 
Spoiler

---- Minecraft Crash Report ----
// Shall we play a game?

Time: 3/8/20 2:19 PM
Description: Ticking memory connection

java.lang.NullPointerException: Ticking memory connection
	at net.minecraft.entity.Entity.<init>(Entity.java:205) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:192) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.MobEntity.<init>(MobEntity.java:99) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.CreatureEntity.<init>(CreatureEntity.java:13) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.AgeableEntity.<init>(AgeableEntity.java:23) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.passive.AnimalEntity.<init>(AnimalEntity.java:30) ~[forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
	at tk.bytiny.epicmod.entitys.testmob.<init>(testmob.java:13) ~[main/:?] {re:classloading}
	at tk.bytiny.epicmod.listener.p_replacer.plogin(p_replacer.java:25) ~[main/:?] {re:classloading}
	at net.minecraftforge.eventbus.ASMEventHandler_7_p_replacer_plogin_PlayerLoggedInEvent.invoke(.dynamic) ~[?:?] {}
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) ~[eventbus-1.0.0-service.jar:?] {}
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-1.0.0-service.jar:?] {}
	at net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerLoggedIn(BasicEventHooks.java:43) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:206) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:119) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:63) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:241) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:148) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:882) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_191] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
	at net.minecraft.entity.Entity.<init>(Entity.java:205)
	at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:192)
	at net.minecraft.entity.MobEntity.<init>(MobEntity.java:99)
	at net.minecraft.entity.CreatureEntity.<init>(CreatureEntity.java:13)
	at net.minecraft.entity.AgeableEntity.<init>(AgeableEntity.java:23)
	at net.minecraft.entity.passive.AnimalEntity.<init>(AnimalEntity.java:30)
	at tk.bytiny.epicmod.entitys.testmob.<init>(testmob.java:13)
	at tk.bytiny.epicmod.listener.p_replacer.plogin(p_replacer.java:25)
	at net.minecraftforge.eventbus.ASMEventHandler_7_p_replacer_plogin_PlayerLoggedInEvent.invoke(.dynamic)
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
	at net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerLoggedIn(BasicEventHooks.java:43)
	at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:206)
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:119)
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:63)
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:241)

-- Ticking connection --
Details:
	Connection: net.minecraft.network.NetworkManager@6a6d93d6
Stacktrace:
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:148)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:882)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646)
	at java.lang.Thread.run(Unknown Source)

-- System Details --
Details:
	Minecraft Version: 1.14.4
	Minecraft Version ID: 1.14.4
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_191, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 567013392 bytes (540 MB) / 1816657920 bytes (1732 MB) up to 3806855168 bytes (3630 MB)
	CPUs: 16
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 4.1.0+62+5bfa59b
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/eventbus-1.0.0-service.jar eventbus PLUGINSERVICE 
		/forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-1.0.1-milestone.0.1+94458e7-shadowed.jar accesstransformer PLUGINSERVICE 
		/forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 28.2
	Forge: net.minecraftforge:28.2.0
	FML Language Providers: 
		[email protected]
		minecraft@1
	Mod List: 
		client-extra.jar Minecraft {[email protected] DONE}
		forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar Forge {[email protected] DONE}
		main Epic Mod {em@NONE DONE}
	Player Count: 1 / 8; [ServerPlayerEntity['Dev'/95, l='test', x=0.00, y=5.00, z=0.00]]
	Data Packs: vanilla, mod:em, mod:forge
	Type: Integrated Server (map_client.txt)
	Is Modded: Definitely; Client brand changed to 'forge'

 

I tried figuring out what the problem might be but all I could find out was that it might have to do something with getting the world.

 

This is the class where I'm spawning the entity. I tested this with a Minecraft villager and it worked:

Spoiler
 
 
 
 
 
 
 
 
Spoiler

package tk.bytiny.epicmod.listener;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import tk.bytiny.epicmod.main;
import tk.bytiny.epicmod.entitys.mobentity;
import tk.bytiny.epicmod.entitys.testmob;

@EventBusSubscriber(modid = main.MODID, bus = Bus.FORGE)
public class p_replacer {

	public static EntityType<testmob> entity2 = mobentity.TESTMOB;
	public static testmob person2;
	public static PlayerEntity p;
	
	@SubscribeEvent
	public static void plogin(PlayerLoggedInEvent event) {
		if(event.getEntity() instanceof PlayerEntity)
		{
			p = (PlayerEntity) event.getEntity();			
			person2 = new testmob(entity2, p.world);
			p.world.addEntity(person2);
			person2.setPosition(p.getPosition().getX(), p.getPosition().getY(), p.getPosition().getZ());
		}
	}
}

 

 

For the entity I followed the tutorial of Jorrit Tyberghein:

Spoiler
 
 
 
 
Spoiler

 

 

And those are my entity classes:

Spoiler
 
 
 
 
Spoiler

package tk.bytiny.epicmod.entitys;

import javax.annotation.Nullable;

import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.world.World;

public class testmob extends AnimalEntity {

	public testmob(EntityType<? extends AnimalEntity> type, World worldIn) {
		super(type, worldIn);
	}
	
	@Nullable
	@Override
	public AgeableEntity createChild(AgeableEntity ageable) {
		return null;
	}

}

package tk.bytiny.epicmod.entitys;

import net.minecraft.entity.EntityType;
import net.minecraftforge.registries.ObjectHolder;

public class mobentity {

	@ObjectHolder("em:testmob")
	public static EntityType<testmob> TESTMOB;
	
}

package tk.bytiny.epicmod.entitys;

import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.model.RendererModel;

public class TestmobModel extends EntityModel<testmob> {

	public RendererModel body;
	
	public TestmobModel() {
		body = new RendererModel(this, 0, 0);
		body.addBox(-3, -3, -3, 6, 6, 6);
	}
	
	@Override
	public void render(testmob entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
		body.render(scale);
	}
	
	@Override
	public void setRotationAngles(testmob entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) {
	}
	
}

package tk.bytiny.epicmod.entitys;

import javax.annotation.Nullable;

import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.util.ResourceLocation;
import tk.bytiny.epicmod.main;

public class TestmobRenderer extends MobRenderer<testmob, TestmobModel>{
	
	public TestmobRenderer(EntityRendererManager manager) {
		super(manager, new TestmobModel(), 0.5f);
	}

	@Nullable
	@Override
	protected ResourceLocation getEntityTexture(testmob entity) {
		return new ResourceLocation(main.MODID, "textures/entity/testmob.png");
	}

}

package tk.bytiny.epicmod.init;

import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import tk.bytiny.epicmod.main;
import tk.bytiny.epicmod.entitys.TestmobRenderer;
import tk.bytiny.epicmod.entitys.testmob;
import tk.bytiny.epicmod.item.BasicItem;

@EventBusSubscriber(modid = main.MODID, bus = Bus.MOD)
public class Epicmobs{

	public static final BasicItem BASIC_ITEM = new BasicItem();
	
	@SubscribeEvent
	public static void registerEntity(Register<EntityType<?>> event) {
		event.getRegistry().register(EntityType.Builder.create(testmob::new, EntityClassification.CREATURE).size(1, 1).setShouldReceiveVelocityUpdates(false).build("testmob").setRegistryName(main.MODID, "testmob"));
		RenderingRegistry.registerEntityRenderingHandler(testmob.class, TestmobRenderer::new);
	}
}

 

I tried my best to find out what the problem is and this is the first time I ask online for help. I hope I didn't overlock something stupid and that you guys can maybe help me.

Edited by byTiny
Edited title to fit better.
Link to comment
Share on other sites

Thanks very much for the reply it helped me a lot and I fixed the problem now and I'm sorry that you had to look at the terrible code I wrote.

I tried addressing the problems you mentioned. I now added comments to everything so it's not confusing anymore. I cleaned the code from all unused code, for example, the BASICI_ITEM line which wasn't supposed to be there.

But I still have a question: I'm currently using this project for testing code and then copy it into my real project. There my ModID is "gamechanger" and the reason why the other project has the short ModID "em" is that it is faster to type. So my question is: is there a specific reason why the ModID has to be long?

Link to comment
Share on other sites

3 hours ago, byTiny said:

is there a specific reason why the ModID has to be long?

Imagine if everyone used 2 character mod IDs. That means there would be a lot of conflicts, as there are only 26² possible combinations, but some would be more popular than others.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Try deliting feur builder  It caused this issue in my modpack
    • I am not using hardcoded recipes, I'm using Vanilla's already existing code for leather armor dying. (via extending and implementing DyeableArmorItem / DyeableLeatherItem respectively) I have actually figured out that it's something to do with registering item colors to the ItemColors instance, but I'm trying to figure out where exactly in my mod's code I would be placing a call to the required event handler. Unfortunately the tutorial is criminally undescriptive. The most I've found is that it has to be done during client initialization. I'm currently trying to do the necessary setup via hijacking the item registry since trying to modify the item classes directly (via using SubscribeEvent in the item's constructor didn't work. Class so far: // mrrp mrow - mcmod item painter v1.0 - catzrule ch package catzadvitems.init; import net.minecraft.client.color.item.ItemColors; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.client.event.ColorHandlerEvent; import catzadvitems.item.DyeableWoolArmorItem; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Painter { @ObjectHolder("cai:dyeable_wool_chestplate") public static final Item W_CHEST = null; @ObjectHolder("cai:dyeable_wool_leggings") public static final Item W_LEGS = null; @ObjectHolder("cai:dyeable_wool_boots") public static final Item W_SOCKS = null; public Painter() { // left blank, idk if forge throws a fit if constructors are missing, not taking the chance of it happening. } @SubscribeEvent public static void init(FMLClientSetupEvent event) { new Painter(); } @Mod.EventBusSubscriber private static class ForgeBusEvents { @SubscribeEvent public static void registerItemColors(ColorHandlerEvent.Item event) { ItemColors col = event.getItemColors(); col.register(DyeableUnderArmorItem::getItemDyedColor, W_CHEST, W_LEGS, W_SOCKS); //placeholder for other dye-able items here later.. } } } (for those wondering, i couldn't think of a creative wool helmet name)
    • nvm found out it was because i had create h and not f
    • Maybe there's something happening in the 'leather armor + dye' recipe itself that would be updating the held item texture?
    • @SubscribeEvent public static void onRenderPlayer(RenderPlayerEvent.Pre e) { e.setCanceled(true); model.renderToBuffer(e.getPoseStack(), pBuffer, e.getPackedLight(), 0f, 0f, 0f, 0f, 0f); //ToaPlayerRenderer.render(); } Since getting the render method from a separate class is proving to be bit of a brick wall for me (but seems to be the solution in older versions of minecraft/forge) I've decided to try and pursue using the renderToBuffer method directly from the model itself. I've tried this route before but can't figure out what variables to feed it for the vertexConsumer and still can't seem to figure it out; if this is even a path to pursue.  The vanilla model files do not include any form of render methods, and seem to be fully constructed from their layer definitions? Their renderer files seem to take their layers which are used by the render method in the vanilla MobRenderer class. But for modded entities we @Override this function and don't have to feed the method variables because of that? I assume that the render method in the extended renderer takes the layer definitions from the renderer classes which take those from the model files. Or maybe instead of trying to use a render method I should be calling the super from the renderer like   new ToaPlayerRenderer(context, false); Except I'm not sure what I would provide for context? There's a context method in the vanilla EntityRendererProvider class which doesn't look especially helpful. I've been trying something like <e.getEntity(), model<e.getEntity()>> since that generally seems to be what is provided to the renderers for context, but I don't know if it's THE context I'm looking for? Especially since the method being called doesn't want to take this or variations of this.   In short; I feel like I'm super super close but I have to be missing something obvious? Maybe this insane inane ramble post will provide some insight into this puzzle?
  • Topics

×
×
  • Create New...

Important Information

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