Java Code Examples for net.minecraft.entity.player.EntityPlayer.getEntityId()

The following are Jave code examples for showing how to use getEntityId() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Never-Enough-Currency   File: MessageSyncRemove.java   Source Code and License Vote up 6 votes
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncRemove message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityPlayer en = (EntityPlayer) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
					if (player.inventory.getStackInSlot(i) != ItemStack.EMPTY && player.inventory.getStackInSlot(i).getItem() instanceof ItemMoneyBase) {
						player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
					}
				}
			}
		}
	}
	return null;
}
 
Example 2
Project: Never-Enough-Currency   File: MessageSyncClearList.java   Source Code and License Vote up 6 votes
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncClearList message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityPlayer en = (EntityPlayer) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
				CartCapability entityData = en.getCapability(Currency.CART_DATA, null);

				entityData.setCart(NonNullList.withSize(entityData.getSizeInventory(), ItemStack.EMPTY), true);
				List<Float> prices = Arrays.asList(new Float[25]);
				for (int i = 0; i < prices.size(); i++) {
					prices.set(i, (float) 0);
				}
			}
		}
	}
	return null;
}
 
Example 3
Project: Never-Enough-Currency   File: MessageSyncAdd.java   Source Code and License Vote up 6 votes
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncAdd message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				for (ItemStack stack : CurrencyUtils.itemMoneyAmount(message.amount)) {
					if (stack != null && stack != ItemStack.EMPTY && en instanceof EntityPlayer) {
						EntityPlayer pl = (EntityPlayer) en;
						pl.inventory.addItemStackToInventory(stack);
					}
				}
			}
		}
	}
	return null;
}
 
Example 4
Project: WirelessRedstone   File: WRClientPH.java   Source Code and License Vote up 5 votes
private void throwTracker(WorldClient world, EntityPlayer player, int entityID, int throwerID, int freq) {
    Entity thrower = world.getEntityByID(throwerID);
    if (throwerID == player.getEntityId())
        thrower = player;

    if (thrower != null && thrower instanceof EntityLiving) {
        EntityWirelessTracker tracker = new EntityWirelessTracker(world, 0, (EntityLiving) thrower);
        tracker.setEntityId(entityID);
        world.addEntityToWorld(entityID, tracker);
        world.playSound(null, thrower.posX, thrower.posY, thrower.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
    }
}
 
Example 5
Project: WirelessRedstone   File: WRClientPH.java   Source Code and License Vote up 5 votes
private void throwREP(int entityID, int throwerID, WorldClient world, EntityPlayer player) {
    Entity thrower = world.getEntityByID(throwerID);
    if (throwerID == player.getEntityId())
        thrower = player;

    if (thrower != null && thrower instanceof EntityLivingBase) {
        EntityREP rep = new EntityREP(world, (EntityLivingBase) thrower);
        rep.setEntityId(entityID);
        world.addEntityToWorld(entityID, rep);
    }
}
 
Example 6
Project: ToolBelt   File: BeltContentsChange.java   Source Code and License Vote up 5 votes
public BeltContentsChange(EntityPlayer player, ContainingInventory where, int slot, ItemStack stack)
{
    this.player = player.getEntityId();
    this.where = where;
    this.slot = slot;
    this.stack = stack;
}
 
Example 7
Project: Never-Enough-Currency   File: MessageSyncDrops.java   Source Code and License Vote up 5 votes
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncDrops message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				CurrencyUtils.dropMoneyAmount(message.amount, en.getEntityWorld(), en.posX, en.posY, en.posZ);
			}
		}
	}
	return null;
}
 
Example 8
Project: CustomWorldGen   File: SPacketSpawnPlayer.java   Source Code and License Vote up 5 votes
public SPacketSpawnPlayer(EntityPlayer player)
{
    this.entityId = player.getEntityId();
    this.uniqueId = player.getGameProfile().getId();
    this.x = player.posX;
    this.y = player.posY;
    this.z = player.posZ;
    this.yaw = (byte)((int)(player.rotationYaw * 256.0F / 360.0F));
    this.pitch = (byte)((int)(player.rotationPitch * 256.0F / 360.0F));
    this.watcher = player.getDataManager();
}
 
Example 9
Project: BaseClient   File: S0CPacketSpawnPlayer.java   Source Code and License Vote up 5 votes
public S0CPacketSpawnPlayer(EntityPlayer player)
{
    this.entityId = player.getEntityId();
    this.playerId = player.getGameProfile().getId();
    this.x = MathHelper.floor_double(player.posX * 32.0D);
    this.y = MathHelper.floor_double(player.posY * 32.0D);
    this.z = MathHelper.floor_double(player.posZ * 32.0D);
    this.yaw = (byte)((int)(player.rotationYaw * 256.0F / 360.0F));
    this.pitch = (byte)((int)(player.rotationPitch * 256.0F / 360.0F));
    ItemStack itemstack = player.inventory.getCurrentItem();
    this.currentItem = itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem());
    this.watcher = player.getDataWatcher();
}
 
Example 10
Project: connor41-etfuturum2   File: ArmourStandInteractMessage.java   Source Code and License Vote up 5 votes
public ArmourStandInteractMessage(int dimID, EntityArmourStand stand, EntityPlayer player) {
	this.dimID = dimID;
	standID = stand.getEntityId();
	playerID = player.getEntityId();
	MovingObjectPosition hit = Minecraft.getMinecraft().objectMouseOver;
	hitPos = Vec3.createVectorHelper(hit.hitVec.xCoord - stand.posX, hit.hitVec.yCoord - stand.posY, hit.hitVec.zCoord - stand.posZ);
}
 
Example 11
Project: SerenityCE   File: BotDetector.java   Source Code and License Vote up 5 votes
private boolean isPlayerValid(EntityPlayer player) {
    if (player.getEntityId() >= 1000000000)
        return false;

    /* if (!onFloor(player) && player.posY == player.lastTickPosY)
        return false; */

    if (!isOnTab(player))
        return false;

    return true;
}
 
Example 12
Project: Backmemed   File: SPacketSpawnPlayer.java   Source Code and License Vote up 5 votes
public SPacketSpawnPlayer(EntityPlayer player)
{
    this.entityId = player.getEntityId();
    this.uniqueId = player.getGameProfile().getId();
    this.x = player.posX;
    this.y = player.posY;
    this.z = player.posZ;
    this.yaw = (byte)((int)(player.rotationYaw * 256.0F / 360.0F));
    this.pitch = (byte)((int)(player.rotationPitch * 256.0F / 360.0F));
    this.watcher = player.getDataManager();
}
 
Example 13
Project: WirelessRedstone   File: WRClientPH.java   Source Code and License Vote up 4 votes
private void processTrackerUpdate(PacketCustom packet, WorldClient world, EntityPlayer player) {
    int entityID = packet.readInt();
    int freq = packet.readUShort();
    boolean attached = packet.readBoolean();

    Entity e = world.getEntityByID(entityID);
    if (e != null && e.isDead)
        e = null;

    if (!(e instanceof EntityWirelessTracker)) {
        if (e != null)
            throw new IllegalStateException("EntityID mapped to non tracker");

        e = new EntityWirelessTracker(world, freq);
        e.setEntityId(entityID);
        world.addEntityToWorld(entityID, e);
    }
    EntityWirelessTracker tracker = (EntityWirelessTracker) e;

    if (attached) {
        int attachedEntityID = packet.readInt();

        Entity attachedEntity;
        if (attachedEntityID == player.getEntityId())
            attachedEntity = player;
        else
            attachedEntity = world.getEntityByID(attachedEntityID);

        if (attachedEntity == null) {
            return;
        }

        tracker.attached = true;
        tracker.attachedEntity = attachedEntity;
        tracker.attachedX = packet.readFloat();
        tracker.attachedY = packet.readFloat();
        tracker.attachedZ = packet.readFloat();
        tracker.attachedYaw = packet.readFloat();
    } else {
        tracker.attachedEntity = null;
        tracker.attached = false;

        tracker.posX = packet.readFloat();
        tracker.posY = packet.readFloat();
        tracker.posZ = packet.readFloat();
        tracker.motionX = packet.readFloat();
        tracker.motionY = packet.readFloat();
        tracker.motionZ = packet.readFloat();

        tracker.setPosition(tracker.posX, tracker.posY, tracker.posZ);
        tracker.setVelocity(tracker.motionX, tracker.motionY, tracker.motionZ);

        tracker.attachmentCounter = packet.readUShort();
        tracker.item = packet.readBoolean();
    }
}
 
Example 14
Project: BaseClient   File: S0APacketUseBed.java   Source Code and License Vote up 4 votes
public S0APacketUseBed(EntityPlayer player, BlockPos bedPosIn)
{
    this.playerID = player.getEntityId();
    this.bedPos = bedPosIn;
}
 
Example 15
Project: BaseClient   File: S0APacketUseBed.java   Source Code and License Vote up 4 votes
public S0APacketUseBed(EntityPlayer player, BlockPos bedPosIn)
{
    this.playerID = player.getEntityId();
    this.bedPos = bedPosIn;
}
 
Example 16
Project: CustomWorldGen   File: SPacketUseBed.java   Source Code and License Vote up 4 votes
public SPacketUseBed(EntityPlayer player, BlockPos posIn)
{
    this.playerID = player.getEntityId();
    this.bedPos = posIn;
}