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'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.

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

  • 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.

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...

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.