Jump to content

(1.16.5 MCP) entity.remove() or entity.setDead() doesnt work


Recommended Posts

Posted

for example i have a test item and if i look an entity and right click the item it should elimitate the entity but entity.remove() or entity.setDead() just make the entity invisible, even i can hear it

(i tried to remove the entity with !world.isremote and without it but it didnt work)

@Override
    public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand handIn) {
        double raytraceDistance = 5.0D;
        RayTraceResult entityResult = Minecraft.getInstance().objectMouseOver;
        if(entityResult.getType() == RayTraceResult.Type.ENTITY) {
            Entity lookPos = ((EntityRayTraceResult) entityResult).getEntity();
            if(lookPos.getEntity() instanceof ArmorStandEntity || lookPos.getEntity() instanceof PaintingEntity ||
                    lookPos.getEntity() instanceof ItemEntity || lookPos.getEntity() instanceof PlayerEntity) {} //this makes that it doesnt work for this entities
            else {
                if(!world.isRemote) {
                    lookPos.setDead(); // or lookpos.remove()
                }
            }
        }
        return super.onItemRightClick(world, player, handIn);
    }

 

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.