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

The following are Jave code examples for showing how to use getEntityData() 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: connor41-etfuturum2   File: ServerEventHandler.java   Source Code and License Vote up 6 votes
@SubscribeEvent
@SuppressWarnings("unchecked")
public void onWorldTick(TickEvent.ServerTickEvent event) {
	if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER)
		return;

	if (EtFuturum.enablePlayerSkinOverlay)
		if (playerLoggedInCooldown != null)
			if (--playerLoggedInCooldown <= 0) {
				for (World world : MinecraftServer.getServer().worldServers)
					for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) {
						NBTTagCompound nbt = player.getEntityData();
						if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) {
							boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY);
							EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex));
						}
					}
				playerLoggedInCooldown = null;
			}
}
 
Example 2
Project: uniquecrops   File: UCEventHandlerServer.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void checkPlayerDeath(LivingDeathEvent event) {
	
	if (event.getEntityLiving() != null && event.getEntityLiving() instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer)event.getEntityLiving();
		NBTTagCompound tag = player.getEntityData();
		if (tag.hasKey("hasSacrificed") && !tag.getBoolean("hasSacrificed"))
		{
			EntityItem ei = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(UCItems.heart));
			tag.setBoolean("hasSacrificed", true);
			if (!player.worldObj.isRemote)
				player.worldObj.spawnEntityInWorld(ei);
			return;
		}
	}
}
 
Example 3
Project: uniquecrops   File: UCEventHandlerServer.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void checkPlayerNBT(PlayerEvent.Clone event) {
	
	if (!event.isWasDeath())
		return;
	
	EntityPlayer old = event.getOriginal();
	EntityPlayer player = event.getEntityPlayer();
	
	NBTTagCompound oldtag = old.getEntityData();
	NBTTagCompound tag = player.getEntityData();
	if (oldtag.hasKey(GrowthSteps.TAG_GROWTHSTAGES)) {
		tag.setTag(GrowthSteps.TAG_GROWTHSTAGES, oldtag.getTagList(GrowthSteps.TAG_GROWTHSTAGES, 10).copy());
	}
	if (oldtag.hasKey("hasSacrificed"))
		tag.setBoolean("hasSacrificed", oldtag.getBoolean("hasSacrificed"));
	if (oldtag.hasKey(SeedBehavior.TAG_ABSTRACT))
		tag.setInteger(SeedBehavior.TAG_ABSTRACT, oldtag.getInteger(SeedBehavior.TAG_ABSTRACT));
}
 
Example 4
Project: uniquecrops   File: SeedBehavior.java   Source Code and License Vote up 6 votes
public static void setAbstractCropGrowth(EntityPlayer player, boolean add) {
	
	NBTTagCompound tag = player.getEntityData();
	if (!tag.hasKey(TAG_ABSTRACT) && add) {
		tag.setInteger(TAG_ABSTRACT, 1);
		return;
	}
	if (add) {
		tag.setInteger(TAG_ABSTRACT, tag.getInteger(TAG_ABSTRACT) + 1);
	}
	else if (!add) {
		int value = tag.getInteger(TAG_ABSTRACT);
		if (player.worldObj.rand.nextInt(5) == 0)
			tag.setInteger(TAG_ABSTRACT, value - 1);
	}
	if (tag.getInteger(TAG_ABSTRACT) <= 0)
		tag.removeTag(TAG_ABSTRACT);
}
 
Example 5
Project: uniquecrops   File: GrowthSteps.java   Source Code and License Vote up 6 votes
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {

	TileEntity tile = world.getTileEntity(pos);
	if (tile != null && tile instanceof TileFeroxia) {
		TileFeroxia te = (TileFeroxia)tile;
		EntityPlayer player = UCUtils.getPlayerFromUUID(te.getOwner().toString());
		if (!world.isRemote && player != null && world.getPlayerEntityByUUID(te.getOwner()) != null) {
			NBTTagCompound tag = player.getEntityData();
			if (!tag.hasKey("hasSacrificed"))
			{
				player.addChatMessage(new TextComponentString(TextFormatting.RED + "The savage plant whispers: \"The time is right to perform a self sacrifice.\""));
				tag.setBoolean("hasSacrificed", false);
				return false;
			}
			if (tag.hasKey("hasSacrificed") && tag.getBoolean("hasSacrificed"))
			{
				tag.removeTag("hasSacrificed");
				world.setBlockState(pos, ((Feroxia)state.getBlock()).withAge(7), 2);
				GrowthSteps.generateSteps(player);
				return false;
			}
		}
	}
	return false;
}
 
Example 6
Project: Industrial-Foregoing   File: LavaStrawHandler.java   Source Code and License Vote up 5 votes
@Override
public void onDrink(World world, BlockPos pos, FluidStack stack, EntityPlayer player, boolean fromFluidContainer) {
    player.attackEntityFrom(DamageSource.LAVA, 7);
    player.setFire(30);
    NBTTagCompound tag = player.getEntityData();
    tag.setLong("lavaDrink", world.getTotalWorldTime());
}
 
Example 7
Project: Industrial-Foregoing   File: WaterStrawHandler.java   Source Code and License Vote up 5 votes
@Override
public void onDrink(World world, BlockPos pos, FluidStack stack, EntityPlayer player, boolean fromFluidContainer) {
    player.extinguish();
    NBTTagCompound tag = player.getEntityData();
    if (tag.hasKey("lavaDrink") && world.getTotalWorldTime() - tag.getLong("lavaDrink") < 120) { //6 Seconds to drink water after drinking lava to create obsidian
        player.entityDropItem(new ItemStack(Blocks.OBSIDIAN), player.getEyeHeight());

        tag.setLong("lavaDrink", 0);
        world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 1.5F, world.rand.nextFloat() * 0.1F + 0.9F);
    }
}
 
Example 8
Project: connor41-etfuturum2   File: NewRenderPlayer.java   Source Code and License Vote up 5 votes
private void setModel(EntityPlayer player) {
	boolean isAlex;

	NBTTagCompound nbt = player.getEntityData();
	if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE))
		isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY);
	else
		isAlex = PlayerModelManager.isPlayerModelAlex(getEntityTexture(player));

	mainModel = isAlex ? ALEX : STEVE;
	modelBipedMain = (ModelBiped) mainModel;
}
 
Example 9
Project: connor41-etfuturum2   File: SetPlayerModelCommand.java   Source Code and License Vote up 5 votes
@Override
public void processCommand(ICommandSender sender, String[] args) {
	if (args.length != 1 || !"alex".equals(args[0].toLowerCase()) && !"steve".equals(args[0].toLowerCase()))
		throw new WrongUsageException(getCommandUsage(sender));

	if (sender instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) sender;
		NBTTagCompound nbt = player.getEntityData();
		boolean isAlex = "alex".equals(args[0].toLowerCase());
		nbt.setBoolean(MODEL_KEY, isAlex);
		EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex));
	}
}
 
Example 10
Project: uniquecrops   File: UCUtils.java   Source Code and License Vote up 5 votes
public static NBTTagList getServerTaglist(int id) {
	
	MinecraftServer ms = FMLCommonHandler.instance().getMinecraftServerInstance();
	if (ms == null)
		return null;
	EntityPlayer player = (EntityPlayer)ms.getEntityWorld().getEntityByID(id);
	if (player != null) {
		NBTTagCompound tag = player.getEntityData();
		if (tag.hasKey(GrowthSteps.TAG_GROWTHSTAGES)) 
		{
			return tag.getTagList(GrowthSteps.TAG_GROWTHSTAGES, 10);
		}
	}
	return null;
}