Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.10.2] Hanging Entity help


Leomelonseeds
 Share

Recommended Posts

Ok I changed my code to this:

package com.leomelonseeds.moarstuff.entity;

import com.google.common.base.Function;

import net.minecraft.entity.Entity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.internal.FMLMessage.EntitySpawnMessage;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.leomelonseeds.moarstuff.entity.EntityCamera;


	
	@SideOnly(Side.CLIENT)
	public class SomeSpawnCallBack implements Function<EntitySpawnMessage, Entity> {
	  
	public World worldIn;
	public BlockPos pos;
	public EnumFacing facing;
	public String title;
	
	  
	  @Override
	  public Entity apply(EntitySpawnMessage m) {
		System.out.println(m);
		EntityCamera entityC = new EntityCamera(worldIn, pos, facing, title);
	    return entityC;
		  
	  }
	  
	}

But now its giving me a null pointer exeption for this line:

registration.setCustomSpawning( new SomeSpawnCallBack (), false);

 

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Wait I put this:

public ModContainer container = Loader.instance ().getIndexedModList ().get (Main.MODID);
    EntityRegistration registration = EntityRegistry.instance ().lookupModSpawn (container, 0);

Does that work? Cause it errors when I copyPaste yours in there.

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

I don't know if it's the best way, but I hunted around and found a world client instance in FML:

    WorldClient wc = FMLClientHandler.instance ().getWorldClient ();

 

Everything else I needed for my constructor came out of EntitySpawnMessage m.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Its still giving me this:

[12:28:34] [Client thread/ERROR] [FML]: Caught exception from Moar Stuff (moarstuff)
java.lang.NullPointerException
	at com.leomelonseeds.moarstuff.ClientProxy.init(ClientProxy.java:65) ~[bin/:?]
	at com.leomelonseeds.moarstuff.Main.init(Main.java:33) ~[bin/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?]
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?]
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:795) [Loader.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:324) [FMLClientHandler.class:?]
	at net.minecraft.client.Minecraft.startGame(Minecraft.java:561) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]

When i try to open game.

ClientProxy:

package com.leomelonseeds.moarstuff;

import com.leomelonseeds.moarstuff.blocks.BlockMegaTNT;
import com.leomelonseeds.moarstuff.blocks.BlockNuke;
import com.leomelonseeds.moarstuff.blocks.Modblocks;
import com.leomelonseeds.moarstuff.client.render.blocks.BlockRenderRegister;
import com.leomelonseeds.moarstuff.client.render.blocks.TileGrillRenderer;
import com.leomelonseeds.moarstuff.client.render.entity.RenderMegaTNTPrimed;
import com.leomelonseeds.moarstuff.client.render.entity.RenderNukePrimed;
import com.leomelonseeds.moarstuff.client.render.items.ItemRenderRegister;
import com.leomelonseeds.moarstuff.entity.EntityCamera;
import com.leomelonseeds.moarstuff.entity.MegaTNTPrimed;
import com.leomelonseeds.moarstuff.entity.ModLivingDropsEvent;
import com.leomelonseeds.moarstuff.entity.NukePrimed;
import com.leomelonseeds.moarstuff.entity.SomeSpawnCallBack;
import com.leomelonseeds.moarstuff.tileentity.Grill;

import net.minecraft.block.properties.IProperty;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.item.Item;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration;



public class ClientProxy extends CommonProxy {
	
	
	
	ModContainer container = Loader.instance ().getIndexedModList ().get (Main.MODID);
    EntityRegistration registration = EntityRegistry.instance ().lookupModSpawn (container, 0);

	@Override
	public void preInit(FMLPreInitializationEvent e){ 
		super.preInit(e);
		
		ModelLoader.setCustomStateMapper(Modblocks.megatnt, (new StateMap.Builder()).ignore(new IProperty[] {BlockMegaTNT.EXPLODE}).build());
		ModelLoader.setCustomStateMapper(Modblocks.nuke, (new StateMap.Builder()).ignore(new IProperty[] {BlockNuke.EXPLODE}).build());
	   RenderingRegistry.registerEntityRenderingHandler(NukePrimed.class, RenderNukePrimed::new);
	    RenderingRegistry.registerEntityRenderingHandler(MegaTNTPrimed.class, RenderMegaTNTPrimed::new);
	    MinecraftForge.EVENT_BUS.register(new ModLivingDropsEvent());
        
	  
	}
	@Override
	public void init(FMLInitializationEvent e) {
		super.init(e);
		 BlockRenderRegister.registerBlockRenderer();
		 ItemRenderRegister.registerItemRenderer();
		 EntityRegistry.registerModEntity(MegaTNTPrimed.class, "megatnt", 1, Main.instance, 160, 10, true);
		 EntityRegistry.registerModEntity(NukePrimed.class, "nuke", 2, Main.instance, 160, 10, true);
		 EntityRegistry.registerModEntity(EntityCamera.class, "camera", 3, Main.instance, 100000, 30, false);
		 ClientRegistry.bindTileEntitySpecialRenderer(Grill.class, new TileGrillRenderer());
		 ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(Modblocks.grill), 0, Grill.class);
		 registration.setCustomSpawning(new SomeSpawnCallBack(), false);
		
		 
	}

	@Override
	public void postInit(FMLPostInitializationEvent e) {
		super.postInit(e);
	}

}

 

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Try moving assignments such as  "EntityRegistration registration = ..."  into methods whose timing assures that they'll get values other than null at the time of assignment.

 

You might be far enough along in this that you need more general help to understand the differences between preinit, init etc, so you might want to start a new thread.

  • Like 1

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Stupid me... Apparently changing the 

On 2/25/2017 at 5:25 PM, Leomelonseeds said:

(container, 0);

to 

container, 3(My entity id) fixed the crash... lol.

 

Ok now its giving an error:

[16:45:09] [Client thread/ERROR] [FML]: A severe problem occurred during the spawning of an entity at ( -906.96875,71.5, 151.5)
java.lang.NullPointerException: The validated object is null
	at org.apache.commons.lang3.Validate.notNull(Validate.java:222) ~[commons-lang3-3.3.2.jar:3.3.2]
	at org.apache.commons.lang3.Validate.notNull(Validate.java:203) ~[commons-lang3-3.3.2.jar:3.3.2]
	at net.minecraft.entity.EntityHanging.updateFacingWithBoundingBox(EntityHanging.java:58) ~[EntityHanging.class:?]
	at com.leomelonseeds.moarstuff.entity.EntityCamera.<init>(EntityCamera.java:31) ~[EntityCamera.class:?]
	at com.leomelonseeds.moarstuff.entity.EntityCamera.<init>(EntityCamera.java:37) ~[EntityCamera.class:?]
	at com.leomelonseeds.moarstuff.entity.SomeSpawnCallBack.apply(SomeSpawnCallBack.java:29) ~[SomeSpawnCallBack.class:?]
	at com.leomelonseeds.moarstuff.entity.SomeSpawnCallBack.apply(SomeSpawnCallBack.java:1) ~[SomeSpawnCallBack.class:?]
	at net.minecraftforge.fml.common.registry.EntityRegistry$EntityRegistration.doCustomSpawning(EntityRegistry.java:112) ~[EntityRegistry$EntityRegistration.class:?]
	at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.spawnEntity(EntitySpawnHandler.java:93) [EntitySpawnHandler.class:?]
	at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.process(EntitySpawnHandler.java:73) [EntitySpawnHandler.class:?]
	at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler.access$000(EntitySpawnHandler.java:48) [EntitySpawnHandler.class:?]
	at net.minecraftforge.fml.common.network.internal.EntitySpawnHandler$1.run(EntitySpawnHandler.java:63) [EntitySpawnHandler$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_25]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_25]
	at net.minecraft.util.Util.runTask(Util.java:25) [Util.class:?]
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1108) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:406) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]

Code:

package com.leomelonseeds.moarstuff.entity;

import com.google.common.base.Function;

import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.network.internal.FMLMessage.EntitySpawnMessage;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;


	
	@SideOnly(Side.CLIENT)
	public class SomeSpawnCallBack implements Function<EntitySpawnMessage, Entity> {
	  
	WorldClient wc = FMLClientHandler.instance ().getWorldClient ();
	public BlockPos pos;
	public EnumFacing facing;
	public String title;
	
	  
	  @Override
	  public Entity apply(EntitySpawnMessage m) {
		System.out.println(m);
		EntityCamera entityC = new EntityCamera(wc, pos, facing, title);
	    return entityC;
		  
	  }
	  
	}

For message m, im getting this:

[16:45:09] [Client thread/INFO] [STDOUT]: [com.leomelonseeds.moarstuff.entity.SomeSpawnCallBack:apply:28]: net.minecraftforge.fml.common.network.internal.FMLMessage$EntitySpawnMessage@2e04d682

 

Edited by Leomelonseeds

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

You declared fields (pos, facing & title) in a class and never gave them values. I told you above that you need to get data from the message m. What did you expect would happen when you passed uninitialized arguments to that constructor? Why are you even posting the crash here when it points directly to a face-palm level programming omission?

 

Your effort here is looking more and more like cargo-cult programming, which will leave you wondering why you stop getting help in this forum. You've left the realm of Forge learning and entered the realm of either Java ignorance or just plain laziness. Put some effort into understanding Java, and the plain English meaning of your error message, and the "logic" of your own program sequence before asking for any more help.

  • Like 1

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

3 hours ago, jeffryfisher said:

I told you above that you need to get data from the message m

 

23 hours ago, Leomelonseeds said:

For message m, im getting this:


[16:45:09] [Client thread/INFO] [STDOUT]: [com.leomelonseeds.moarstuff.entity.SomeSpawnCallBack:apply:28]: net.minecraftforge.fml.common.network.internal.FMLMessage$EntitySpawnMessage@2e04d682

 

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Congrats, you use system.out and passed in a complex object type which doesn't override ToString to return a meaningful value. You're looking at the string representation of a pointer.  Please stop Cargo Cult-ing.

 

You need to actually do something with the m in order to get any data out of it. Go look at the class (right click -> jump to declaration on the variable's Type).

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

  • 2 weeks later...

Ok I see that it uses toBytes. How would I get any data from toBytes though? (Forgive the stupid questions please I just want help)

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

So that will provide the methods I need for my constructor? Or am I getting this all wrong??

On 2/24/2017 at 0:31 PM, jeffryfisher said:

In 1.10.2, to stop MC from trying to spawn a vanilla painting, I needed to provide a callback class to a custom spawning registration that was called from client proxy init.

Sooo... That?

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Wait but what data should I put in the methods? (Sorry for more stupid questions) You told me to not use anything suggested above but mabye there is some value in that...?

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Waitt..... When I spawn the entity, there are no errors in the console tho. Can you please explain in detail why my entity doesn't spawn but a painting does? 

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

well it does spawn i think but it doesnt have a collision box. I think it does spawn cause when i break the block behind it, a few seconds later it drops as an item (the entity)

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

How many times have you stepped through the creation / spawning in the debugger? Does that number bear a remarkable resemblance to your level of understanding? Set breakpoints (in your constructors and in vanilla EntityPainting constructors) and run the debugger.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.

Guest
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.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.