Posted February 5, 20223 yr 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); }
February 5, 20223 yr 12 hours ago, ElTotisPro50 said: Minecraft.getInstance() this is client side only so world.isRemote returns always true
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.