Jump to content

[1.11]Spawning ItemEntity


Thaun_

Recommended Posts

I am trying to make so when a MagmaBlock hits water it will turn into MagmaIngot (Selfmade) but when i try to spawn it i get an error.

 

EntityJoinWorldEventHandler Class:

 

[embed=425,349]package thaun.thaunsmod.handler;

 

import net.minecraft.entity.item.EntityItem;

import net.minecraft.init.Blocks;

import net.minecraft.item.Item;

import net.minecraftforge.event.entity.EntityJoinWorldEvent;

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import thaun.thaunsmod.Blocks.MagmaEntity;

 

public class EntityJoinWorldEventHandler {

 

@SubscribeEvent

    public void onEntityJoinWorld(EntityJoinWorldEvent event)

    {

        if(event.getEntity() instanceof EntityItem)

        {

            if(((EntityItem)event.getEntity()).getEntityItem().getItem() == Item.getItemFromBlock(Blocks.MAGMA))

            {

                event.setCanceled(true);

                MagmaEntity entityItem = new MagmaEntity(event.getEntity().worldObj, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, ((EntityItem)event.getEntity()).getEntityItem());

                if (!event.getWorld().isRemote) {

                System.out.println("Sending out signal: 1");

                event.getEntity().getEntityWorld().spawnEntityInWorld(entityItem);

                }

             

            }

        }

    }

}

[/embed]

 

 

MagmaBlock class:

 

[embed=425,349]package thaun.thaunsmod.Blocks;

 

import net.minecraft.entity.item.EntityItem;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.world.World;

import thaun.thaunsmod.Items.ItemInit;

 

public class MagmaEntity extends EntityItem{

 

public MagmaEntity(World worldIn, double x, double y, double z, ItemStack stack) {

        super(worldIn, x, y, z, stack);

    }

 

    @Override

    public void onUpdate()

    {

   

        if(this.isWet())

        {

            EntityItem entity = new EntityItem(worldObj, this.posX, this.posY, this.posZ, new ItemStack(ItemInit.magmaIngot));

            worldObj.spawnEntityInWorld(entity);

        System.out.println("Sending out signal: 2");

         

        }

    }

 

}[/embed]

 

 

I have

[embed=425,349]MinecraftForge.EVENT_BUS.register(new EntityJoinWorldEventHandler());[/embed]

in Post-Init

 

What i get as output is alot of "Sending out signal: 1" and this error that is huge...

http://pastebin.com/dWQcyCqe

Link to comment
Share on other sites

My guess is that you haven't registered your entity.

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

Did this:

 

[embed=425,349]

EntityRegistry.registerModEntity(Blocks.MAGMA.getRegistryName(), MagmaEntity.class, "magma", 1899, this, 1, 1, false);[/embed]

 

Seems i get the same error... I dont really know how to use this stuff really well...

Link to comment
Share on other sites

Yes, we know. Diesieben07 has pointed out the problems with your current code. You need to fix those.

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

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.