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

Entity Not Showing In World


bigbaddevil6
 Share

Recommended Posts

I understand there is a thread below this one about what may be the same issue, or same resolution needs to be made, but I read over it and didn't seem to be the same problem.

 

The issue I am currently having is I been following along with VSWE tutorials of modding and they are for 1.6. I generally don't have a problem because I know the changes that were made and how to port it over.

On the other hand this is the first time I've worked with Entities and so I'm trying to learn both at once and it seems to be my downfall. The point is that you have an Item "ItemDroid" and you right click it on the ground and it spawns a floating entity "EntityDroid". When I do it nothing happens, no errors, nothing. The item gets taken away like how its suppose to and the code order means that it had to of ran the line to spawn the entity into the world.

 

I'm probably doing something stupid such as missing a step, have something in the wrong spot, or typo.... I looked at the ItemEgg class and the only difference I could see was they used onItemRightClick where as mine is onItemUseFirst.

 

ItemDroid:

 

 

package com.bigbaddevil7.rustic.item;


import com.bigbaddevil7.rustic.test.EntityDroid;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

/**
* Created by bigbaddevil7 on 10/16/2014.
*/
public class ItemDroid extends ItemRustic{
    public ItemDroid(){
        super();
        this.setUnlocalizedName("itemdroid");
    }

    @Override
    public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ){
        if(!world.isRemote){
            world.spawnEntityInWorld(new EntityDroid(world, x + 0.5, y + 1.5, z + 0.5));
            stack.stackSize--;
            return true;
        }else{
            return false;
        }
    }
}

 

 

 

 

EntityDroid:

 

 


package com.bigbaddevil7.rustic.test;

import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

/**
* Created by bigbaddevil7 on 10/16/2014.
*/
public class EntityDroid extends Entity{

    private double startY;
    private double targetY;
    public EntityDroid(World world){
        super(world);
    }

    public EntityDroid(World world, double x, double y, double z){
        this(world);
        posX = x;
        startY = posY = y;
        posZ = z;
    }

    @Override
    protected void entityInit() {

    }

    @Override
    protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) {
        startY = nbtTagCompound.getShort("Start");
        targetY = nbtTagCompound.getShort("Target");
    }

    @Override
    protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) {
        nbtTagCompound.setShort("Start", (short)startY);
        nbtTagCompound.setShort("Target", (short)targetY);
    }

    @Override
    public void onUpdate(){
        super.onUpdate();

        if(!worldObj.isRemote){
            if(targetY == 0 || Math.abs(posY - targetY) < 0.25){
                targetY = startY + worldObj.rand.nextDouble() * 5;
            }

            if(posY < targetY){
                motionY = 0.05;
            }else{
                motionY = -0.05;
            }
        }

        setPosition(posX + motionX, posY + motionY, posZ + motionZ);
    }
}

 

 

 

Link to comment
Share on other sites

I'm not using a model yet. Its should spawn up with a grey rectangle that bobs up and down. Its not that it appears and falls through the ground. It just does not appear at all. Watching the amount of entites in the world and the number never changes. I did the F3+b and no box pops up so it is not even being made.

Link to comment
Share on other sites

Eh.... Well it was registered but never called.... *slams face on desk*. Anyways... you have been extremely helpful. I thank you for your time my dear sir. I knew it was something stupid. It always is with me. Can write the formulas all fine and dandy, but dear god give me something simple like actually calling it and all hell breaks loose.

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