Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

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.