Posted December 14, 201410 yr I'm trying to get a specific item to kill the player or a nearby player if it exists as an EntityItem in world. The problem is that, even though I am making a check for it, it is running the kill code for all items. package com.spectrum.handlers; import com.spectrum.item.ASItem; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.init.Items; import net.minecraft.util.DamageSource; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class AntiwaveEntityHandler { @SubscribeEvent public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) { if (event.entity instanceof EntityItem){ EntityItem entity = (EntityItem)event.entity; if(entity.getEntityItem() != null) { if(entity.getEntityItem().getItem().getUnlocalizedName().equals(ASItem.antiItem.getUnlocalizedName())); { event.setCanceled(true); entity.worldObj.getClosestPlayerToEntity(entity, 10).attackEntityFrom(DamageSource.outOfWorld, 1000.0F); entity.worldObj.getClosestPlayerToEntity(entity, 10).experienceLevel = 0; entity.setDead(); } } } } } Any help? glubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglub.
December 14, 201410 yr Why are you using 'unlocalized names'? I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
December 14, 201410 yr Author I saw something about it in someone else's similar problem that they ended up fixing, so I thought that I would test it. Here is the original code: if(entity.getEntityItem().getItem() == ASItem.antiItem) {...} EDIT: Nevermind, I found the problem. There was a semicolon at the end of an if() statement where there shouldn't be. glubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglubglub.
December 14, 201410 yr EDIT: Nevermind, I found the problem. There was a semicolon at the end of an if() statement where there shouldn't be. Hehe. I had that exact same problem, but with a loop yesterday. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.