Java Code Examples for net.minecraft.world.World.getEntityByID()

The following are Jave code examples for showing how to use getEntityByID() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Melodium   File: SongHorse.java   View Source Code Vote up 6 votes
@Override
public void songEnded(EntityPlayer player, ItemStack instrument, int interval) {
	World world = player.world;
	player.dismountRidingEntity();
	if (!world.isRemote) {
		NBTTagCompound tag = ItemUtil.getOrCreateTag(instrument);
		if (tag.hasKey("id")) {
			int id = tag.getInteger("id");
			EntityHorse horse = (EntityHorse) world.getEntityByID(id);
			if (horse != null) {
				horse.setDead();

			}
		}
	}

}
 
Example 2
Project: VillagerInventory   File: ModGuiHandler.java   View Source Code Vote up 5 votes
/**
 * Returns a Server side Container to be displayed to the user.
 */
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int entityId, int professionId, int careerId)
{
	if (id == GUI_VILLAGER_INVENTORY)
	{
		EntityVillager villager = (EntityVillager)world.getEntityByID(entityId);
		if (villager != null)
		{
			return new ContainerVillagerInventory(player.inventory, villager.getVillagerInventory(), villager, player);
		}
	}
	return null;
}
 
Example 3
Project: NemesisSystem   File: Reaper.java   View Source Code Vote up 5 votes
private void unloadNemesis(World world, INemesisRegistry registry, NemesisEntry nemesis) {
	Entity entity = world.getEntityByID(nemesis.getSpawned());

	if (nemesis.isLoaded() && entity == null) {
		nemesis.setUnloaded(world.getTotalWorldTime());
		registry.update(nemesis);
		return;
	}

	if (entity == null) {
		return;
	}

	boolean playersNear = NemesisUtil.findPlayersAround(world, entity.getPosition(), 100).size() > 0;

	if (nemesis.isLoaded() && !playersNear) {
		nemesis.setUnloaded(world.getTotalWorldTime());
		registry.update(nemesis);
		return;
	}

	if (!nemesis.isLoaded() && playersNear) {
		nemesis.setUnloaded(null);
		registry.update(nemesis);
		return;
	}
}
 
Example 4
Project: Mods   File: ItemMedigun.java   View Source Code Vote up 5 votes
@Override
public boolean use(ItemStack stack, EntityLivingBase living, World world, EnumHand hand,
		PredictionMessage message) {
	// if(!world.isRemote||living !=
	// Minecraft.getMinecraft().player!(TF2weapons.medigunLock&&living.getCapability(TF2weapons.WEAPONS_CAP,
	// null).healTarget>0)) return false;
	// System.out.println("View: "+var4+" "+startX+" "+startY+" "+startZ+"
	// "+startX+endX+" "+endY+" "+endZ);
	if (world.isRemote && living == Minecraft.getMinecraft().player) {
		RayTraceResult trace = this.trace(stack, living, world);
		if (world.getEntityByID(living.getCapability(TF2weapons.WEAPONS_CAP, null).getHealTarget()) == null
				&& trace != null && trace.entityHit != null && trace.entityHit instanceof EntityLivingBase
				&& !(trace.entityHit instanceof EntityBuilding)) {
			List<RayTraceResult> list = new ArrayList<RayTraceResult>();
			trace.hitInfo = new float[] { 0, 0 };
			list.add(trace);
			message.target = list;
			// System.out.println("healing:
			// "+trace.entityHit.getEntityId());
			// living.getCapability(TF2weapons.aaWEAPONS_CAP,
			// null).healTarget=trace.entityHit.getEntityId();
			// TF2weapons.network.sendToServer(new
			// TF2Message.CapabilityMessage(living));

			// ClientProxy.playWeaponSound(living,
			// ItemFromData.getSound(stack,PropertyType.HEAL_START_SOUND),
			// false, 0, stack);
		}
	} else if (!world.isRemote && message != null && message.readData != null) {
		living.getCapability(TF2weapons.WEAPONS_CAP, null).setHealTarget((int) message.readData.get(0)[0]);
	}
	return true;
}
 
Example 5
Project: CustomWorldGen   File: SPacketCamera.java   View Source Code Vote up 4 votes
@Nullable
@SideOnly(Side.CLIENT)
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 6
Project: BaseClient   File: S19PacketEntityStatus.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 7
Project: DecompiledMinecraft   File: S19PacketEntityHeadLook.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 8
Project: DecompiledMinecraft   File: S19PacketEntityStatus.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 9
Project: CustomWorldGen   File: SPacketEntityStatus.java   View Source Code Vote up 4 votes
@SideOnly(Side.CLIENT)
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 10
Project: DecompiledMinecraft   File: S43PacketCamera.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 11
Project: Backmemed   File: SPacketEntity.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 12
Project: CustomWorldGen   File: CPacketUseEntity.java   View Source Code Vote up 4 votes
public Entity getEntityFromWorld(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 13
Project: CustomWorldGen   File: SPacketEntity.java   View Source Code Vote up 4 votes
@SideOnly(Side.CLIENT)
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 14
Project: BaseClient   File: S14PacketEntity.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 15
Project: CustomWorldGen   File: SPacketEntityHeadLook.java   View Source Code Vote up 4 votes
@SideOnly(Side.CLIENT)
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 16
Project: BaseClient   File: S49PacketUpdateEntityNBT.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 17
Project: BaseClient   File: S43PacketCamera.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 18
Project: Backmemed   File: SPacketEntityStatus.java   View Source Code Vote up 4 votes
public Entity getEntity(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 19
Project: Backmemed   File: CPacketUseEntity.java   View Source Code Vote up 4 votes
@Nullable
public Entity getEntityFromWorld(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 20
Project: minecraft-quiverbow   File: Helper_Client.java   View Source Code Vote up 3 votes
public static void displayParticles(int entityID, byte particle, byte strength)
{
	//String SFX;
	
	if (PARTICLES == null) { registerParticles(); } // First time init
	
	if (particle >= PARTICLES.length) { return; } // Not a possible particle
	
	if (PARTICLES[particle] == null) { return; } // Not a valid particle
	
	World world = Minecraft.getMinecraft().theWorld;
	
	if (world == null) { return; }	// World doesn't exist? oO
	
	Entity entity = world.getEntityByID(entityID);
	
	if (entity == null) { return; }	// Entity doesn't exist
	
	int count = 0;
	
	while (count < strength)
	{
		world.spawnParticle(PARTICLES[particle], 
				entity.posX + entity.motionX * (double) count / 4.0D, 
				entity.posY + entity.motionY * (double) count / 4.0D, 
				entity.posZ + entity.motionZ * (double) count / 4.0D, 
           		0, 0.2D, 0);
		
		count += 1;
	}
}