Jump to content

Recommended Posts

Posted

Im making a security camera, that has to be an entity since I'm going to implement a feature to spectate it. I'm extending entityHanging since paintings are similar, but I am getting a crash when I try placing it down.

ModSecurityCamera:

package com.leomelonseeds.moarstuff.items;

import javax.annotation.Nullable;

import com.leomelonseeds.moarstuff.entity.EntityCamera;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityHanging;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class ModSecurityCamera extends Item
{
    private final Class <? extends EntityHanging > hangingEntityClass;

    public ModSecurityCamera(Class <? extends EntityHanging > entityClass)
    {
        this.hangingEntityClass = entityClass;
        this.setCreativeTab(Moditems.moarStuff);
        this.setUnlocalizedName("security_camera");
    }

    /**
     * Called when a Block is right-clicked with this Item
     */
    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        BlockPos blockpos = pos.offset(facing);

        if (facing != EnumFacing.DOWN && facing != EnumFacing.UP && playerIn.canPlayerEdit(blockpos, facing, stack))
        {
            EntityHanging entityhanging = this.createEntity(worldIn, blockpos, facing);

            if (entityhanging != null && entityhanging.onValidSurface())
            {
                if (!worldIn.isRemote)
                {
                    entityhanging.playPlaceSound();
                    worldIn.spawnEntityInWorld(entityhanging);
                }

                --stack.stackSize;
            }

            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }

    @Nullable
    private EntityHanging createEntity(World worldIn, BlockPos pos, EnumFacing clickedSide)
    {
        return (EntityHanging)(this.hangingEntityClass == EntityCamera.class ? new EntityCamera(worldIn, pos, clickedSide): null);  
        }
}

Error:

[20:11:16] [Server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_25]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_25]
	at net.minecraft.util.Util.runTask(Util.java:26) [Util.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:742) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]
Caused by: java.lang.NullPointerException
	at net.minecraft.entity.EntityHanging.onValidSurface(EntityHanging.java:147) ~[EntityHanging.class:?]
	at com.leomelonseeds.moarstuff.items.ModSecurityCamera.onItemUse(ModSecurityCamera.java:42) ~[ModSecurityCamera.class:?]
	at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:780) ~[ForgeHooks.class:?]
	at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:158) ~[ItemStack.class:?]
	at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:509) ~[PlayerInteractionManager.class:?]
	at net.minecraft.network.NetHandlerPlayServer.processRightClickBlock(NetHandlerPlayServer.java:706) ~[NetHandlerPlayServer.class:?]
	at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) ~[CPacketPlayerTryUseItemOnBlock.class:?]
	at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[CPacketPlayerTryUseItemOnBlock.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$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:?]
	... 5 more

 

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.

Posted

You called EntityHanging#onValidSurface without setting EntityHanging#hangingPosition to a non-null value. which probably means that you're calling the EntityHanging(World) constructor instead of the EntityHanging(World, BlockPos) constructor.

 

If this isn't the case, post the ModSecurityCamera class.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Well I already have the ModSecurityCamera up there.

If you want the entity class, here:

package com.leomelonseeds.moarstuff.entity;

import javax.annotation.Nullable;

import com.leomelonseeds.moarstuff.items.Moditems;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityHanging;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class EntityCamera extends EntityHanging {

	public EntityCamera(World worldIn) {
		super(worldIn);
		
	}
	
	 public EntityCamera(World worldIn, BlockPos pos, EnumFacing facing)
	    {
	        super(worldIn, pos);
	    }
	 
	 @SideOnly(Side.CLIENT)
	    public EntityCamera(World worldIn, BlockPos pos, EnumFacing facing, String title)
	    {
	        this(worldIn, pos, facing);

	      
	        this.updateFacingWithBoundingBox(facing);
	    }

	@Override
	public int getWidthPixels() {
		
		return 12;
	}

	@Override
	public int getHeightPixels() {
		
		return 12;
	}

	@Override
	public void onBroken(@Nullable Entity brokenEntity) {
		
		if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
        {
            this.playSound(SoundEvents.BLOCK_STONE_BREAK, 1.0F, 1.0F);

            if (brokenEntity instanceof EntityPlayer)
            {
                EntityPlayer entityplayer = (EntityPlayer)brokenEntity;

                if (entityplayer.capabilities.isCreativeMode)
                {
                    return;
                }
            }

            this.entityDropItem(new ItemStack(Moditems.camera), 0.0F);
        }
	
		
		
		
	}

	@Override
	public void playPlaceSound() {
		
		this.playSound(SoundEvents.BLOCK_STONE_HIT, 1.0F, 1.0F);
		
	}
	
	 public void setLocationAndAngles(double x, double y, double z, float yaw, float pitch)
	    {
	        this.setPosition(x, y, z);
	    }

	    /**
	     * Set the position and rotation values directly without any clamping.
	     */
	    @SideOnly(Side.CLIENT)
	    public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport)
	    {
	        BlockPos blockpos = this.hangingPosition.add(x - this.posX, y - this.posY, z - this.posZ);
	        this.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
	    }

}

 

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.

Posted

I meant EntityCamera, yes.

 

It's actually the EntityHanging#facingDirection field that's null rather than EntityHanging#hangingPosition as I initially suspected; this is because the EntityCamera(World, BlockPos, EnumFacing) constructor doesn't call EntityHanging#updateFacingWithBoundingBox.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

OK it works now. A few problems: I know my entity is invisible right now, but when I tried to destroy it, it also destroys the block behind it, and after a few seconds drops the block. How would I set a break time, and what is wrong with it?

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.

Posted
37 minutes ago, TheSunCat said:

Paintings don't have a break time. They have 1HP, drop a painting item (which is actually a spawn egg ^_^). Same with item frames.

Actually they don't.  Entities that aren't living don't even have an HP field. When they take any damage at all, even if that damage is 0, they die.

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.

Posted
43 minutes ago, TheSunCat said:

Also, is it possible to add a custom painting without replacing the actual painting file?

Hell if I know. Probably not.

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.

Posted
14 minutes ago, TheSunCat said:

Ok. What is the h*** for?

Because I'm an abrasive jerk and I don't actually know everything, despite appearances on this forum.

I've never touched paintings and don't feel like doing the research for you.

  • Like 1

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.

Posted

I've added custom paintings, creating new item and entity classes for them. I added a bunch of texture files and left the existing one alone. Because my custom painting class is not identical to EntityPainting, the client-side message handler would not cooperate. The message was ok, but I needed to jump through some hoops on the client side to spawn my entity.

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.

Posted

@TheSunCatPlease turn signatures on and read Draco18s'. Its nice. 

So how about my problems?

19 hours ago, Leomelonseeds said:

t when I tried to destroy it, it also destroys the block behind it, and after a few seconds drops the block

 

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.

Posted

Why isint it working?

On 2/20/2017 at 11:27 AM, jeffryfisher said:

The message was ok, but I needed to jump through some hoops on the client side to spawn my entity.

Well how would I do that?

 

Code:

package com.leomelonseeds.moarstuff.entity;

import javax.annotation.Nullable;

import com.leomelonseeds.moarstuff.items.Moditems;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityHanging;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class EntityCamera extends EntityHanging {

	public EntityCamera(World worldIn) {
		super(worldIn);
		
	}
	
	 public EntityCamera(World worldIn, BlockPos pos, EnumFacing facing)
	    {
	        super(worldIn, pos);
	        
	        this.updateFacingWithBoundingBox(facing);
	    }
	 
	 @SideOnly(Side.CLIENT)
	    public EntityCamera(World worldIn, BlockPos pos, EnumFacing facing, String title)
	    {
	        this(worldIn, pos, facing);

	      
	        this.updateFacingWithBoundingBox(facing);
	    }

	@Override
	public int getWidthPixels() {
		
		return 12;
	}

	@Override
	public int getHeightPixels() {
		
		return 12;
	}

	@Override
	public void onBroken(@Nullable Entity brokenEntity) {
		
		if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
        {
            this.playSound(SoundEvents.BLOCK_STONE_BREAK, 1.0F, 1.0F);

            if (brokenEntity instanceof EntityPlayer)
            {
                EntityPlayer entityplayer = (EntityPlayer)brokenEntity;

                if (entityplayer.capabilities.isCreativeMode)
                {
                    return;
                }
            }

            this.entityDropItem(new ItemStack(Moditems.camera), 0.0F);
        }
	
		
		
		
	}

	@Override
	public void playPlaceSound() {
		
		this.playSound(SoundEvents.BLOCK_STONE_HIT, 1.0F, 1.0F);
		
	}
	
	 public void setLocationAndAngles(double x, double y, double z, float yaw, float pitch)
	    {
	        this.setPosition(x, y, z);
	    }

	    /**
	     * Set the position and rotation values directly without any clamping.
	     */
	    @SideOnly(Side.CLIENT)
	    public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport)
	    {
	        BlockPos blockpos = this.hangingPosition.add(x - this.posX, y - this.posY, z - this.posZ);
	        this.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
	    }

}

 

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.

Posted

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.

 

Client Proxy line in init:

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

 

Excerpt from Callback Class:

import com.google.common.base.Function;

@SideOnly(Side.CLIENT)
public class SomeSpawnCallback implements Function<EntitySpawnMessage, Entity> {
  
  ...
  
  @Override
  public Entity apply(EntitySpawnMessage m) {
    // read message and call your hanging entity's client-side constructor
  }
}

 

Forge reflection will call your "apply" method.

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.

Posted (edited)
35 minutes ago, jeffryfisher said:

// read message

So... What is that?

And also which package shouold I put that class in?

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.

Posted

Ok so the ClientRegistry line is saying that it can not make a static reference to the non static method of setCustomSpawning. When I try to store an instance of the EntityRegistration class in my clientproxy, what things should I put in the constructor? Nothing seems to be working right now.

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.

Posted

Ok now what values should I put in the constructor EntityCamera(client-side) when creating an instance of my Entity in SomeSpawnCallback to use in the apply method? null does not work apparently, and this either:

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> {
	  
	private World worldIn;
	private BlockPos pos;
	private EnumFacing facing;
	private String title;
	EntityCamera entityC = new EntityCamera(worldIn, pos, facing, title);
	  
	  @Override
	  public Entity apply(EntitySpawnMessage m) {
		
	
	    return entityC;
		  
	  }
	  
	}

 

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.

Posted

The apply method gets parameter m (message). See what that gives you.

 

When I make a mod, I put everything in one package.

 

You might want to replace "Some" with a word pertaining to what you're working on (e.g. "Camera").

 

Sorry 'bout the local "registration" variable. Here's what I used in 1.8 - 1.10.2:

 

    container = Loader.instance ().getIndexedModList ().get (modId);
    EntityRegistration registration = EntityRegistry.instance ().lookupModSpawn (container, 0);

 

I think you want to instantiate each new camera inside the callback. Then return a new entity every time. The parameters for the constructor are whatever your camera needs plus what HangingEntity needs. If you're lucky, you'll find what you need inside the message 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.

Posted
8 hours ago, jeffryfisher said:

When I make a mod, I put everything in one package.

Gosh, that's so... unorganized!

 

 

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.

Posted

I make simple mods that don't need lots of compartmentalization.

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.

Posted
12 hours ago, jeffryfisher said:

The parameters for the constructor are whatever your camera needs plus what HangingEntity needs. If you're lucky, you'll find what you need inside the message m.

Well, some examples please? Like, what do I put for worldIn?

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

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



×
×
  • Create New...

Important Information

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