Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
    }
}

 

 

 

  • Author

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.

  • Author

still nothing. I know that its calling the constructor that I'm working in cause I added Logs. But still no entity brought into the world.

  • Author

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.