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

The following are Jave code examples for showing how to use getPersistentID() 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: Bewitchment   File:   Vote up 4 votes
public void startRitual(EntityPlayer player) {
	if (player.getEntityWorld().isRemote)
	List<EntityItem> itemsOnGround = getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(getPos()).grow(3, 0, 3));
	List<ItemStack> recipe = -> i.getItem()).collect(Collectors.toList());
	for (Ritual rit : Ritual.REGISTRY) { // Check every ritual
		if (rit.isValidInput(recipe, hasCircles(rit))) { // Check if circles and items match
			if (rit.isValid(player, world, pos, recipe)) { // Checks of extra conditions are met
				if (consumePower(rit.getRequiredStartingPower())) { // Check if there is enough starting power (and uses it in case there is)
					// The following block saves all the item used in the input inside the nbt
					// vvvvvv
					this.ritualData = new NBTTagCompound();
					NBTTagList itemsUsed = new NBTTagList();
					itemsOnGround.forEach(ei -> {
						NBTTagCompound item = new NBTTagCompound();
					ritualData.setTag("itemsUsed", itemsUsed);
					// ^^^^^

					// Sets the ritual up
					this.ritual = rit;
					this.entityPlayer = player.getPersistentID();
					this.cooldown = 1;
					ritual.onStarted(player, this, getWorld(), getPos(), ritualData);
					player.sendStatusMessage(new TextComponentTranslation("ritual." + rit.getRegistryName().toString().replace(':', '.') + ".name", new Object[0]), true);
					world.notifyBlockUpdate(getPos(), world.getBlockState(getPos()), world.getBlockState(getPos()), 3);
				} else {
					player.sendStatusMessage(new TextComponentTranslation("ritual.failure.power", new Object[0]), true);
			} else {
				player.sendStatusMessage(new TextComponentTranslation("ritual.failure.precondition", new Object[0]), true);

	if (!itemsOnGround.isEmpty())
		player.sendStatusMessage(new TextComponentTranslation("ritual.failure.unknown", new Object[0]), true);