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 have a custom entity that opens a gui when the player right clicks on it. This works all fine but if you try to right click it again after the player died, you can't click the entity anymore. If you reopen the world, it works again. I'm I doing something wrong?

 

int entityId = EntityRegistry.findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(EntityCorpse.class, "Corpse", entityId, 2342, 3246);
EntityRegistry.registerModEntity(EntityCorpse.class, "Corpse", entityId, PXYMain.instance, 64, 1, true);

public class EntityCorpse extends EntityLivingBase
{
    public InventoryCorpse inventory = new InventoryCorpse();

    public EntityCorpse(World world)
    {
        super(world);
        setHealth(getMaxHealth());
        this.setSize(0.9F, 2F);
    }

    @Override
    public void readEntityFromNBT(NBTTagCompound nbt)
    {
        super.readEntityFromNBT(nbt);
        inventory.readFromNBT(nbt);
    }

    @Override
    public ItemStack getHeldItem()
    {
        return null;
    }

    @Override
    public ItemStack getEquipmentInSlot(int p_71124_1_)
    {
        return null;
    }

    @Override
    public void setCurrentItemOrArmor(int p_70062_1_, ItemStack p_70062_2_)
    {

    }

    @Override
    public ItemStack[] getLastActiveItems()
    {
        return new ItemStack[0];
    }

    @Override
    public void writeEntityToNBT(NBTTagCompound nbt)
    {
        super.writeEntityToNBT(nbt);
        inventory.writeToNBT(nbt);
    }

    @Override
    public boolean interactFirst(EntityPlayer player)
    {
        if (!player.worldObj.isRemote)
        {
            new PacketOpenCorpseGuiServer.Handler().handleMessage(new PacketOpenCorpseGuiServer(this), (EntityPlayerMP) player);
        }
        return true;
    }
}

  • Author

The packet is not important. I could replace that with a simple println. The problem is interactFirst isn't even called. I also noticed that the raytrace goes right through the entity.

  • Author

This seems to happen to vanilla creatures as well. Pushing them away a couple times fixes it but that's no solution as my entity will be uncollidable.

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.