Java Code Examples for net.minecraft.tileentity.TileEntity#getDescriptionPacket()

The following examples show how to use net.minecraft.tileentity.TileEntity#getDescriptionPacket() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockBusFluidExport.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float offsetX, float offsetY, float offsetZ)
{
	if (!world.isRemote)
	{
		ItemStack currentItem = player.inventory.getCurrentItem();
		if (currentItem != null)
		{
			IMemoryCard card = Util.getAppEngApi().getMemoryCardHandler();
			TileEntity blockTE = world.getBlockTileEntity(x, y, z);

			if (card.isMemoryCard(currentItem))
			{
				if (player.isSneaking())
				{
					NBTTagCompound nbt = new NBTTagCompound();
					blockTE.writeToNBT(nbt);
					nbt.removeTag("x");
					nbt.removeTag("y");
					nbt.removeTag("z");
					blockTE.readFromNBT(nbt);
					card.setMemoryCardContents(currentItem, getUnlocalizedName() + ".name", nbt);
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.SettingsSaved")));
					return true;
				} else if (card.getSettingsName(currentItem).equals(getUnlocalizedName() + ".name") || card.getSettingsName(currentItem).equals("AppEng.GuiITooltip.Blank"))
				{
					blockTE.readFromNBT(card.getData(currentItem));
					Packet description = blockTE.getDescriptionPacket();
					if (description != null)
						PacketDispatcher.sendPacketToAllPlayers(description);
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.SettingsLoaded")));
					return true;
				} else
				{
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.IncorrectDevice")));
					return true;
				}
			}
		}
		if (world.getBlockTileEntity(x, y, z) == null || player.isSneaking())
		{
			return false;
		}
		player.openGui(Extracells.instance, 4, world, x, y, z);
	}
	return true;
}
 
Example 2
Source File: BlockBusFluidImport.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float offsetX, float offsetY, float offsetZ)
{
	if (!world.isRemote)
	{
		ItemStack currentItem = player.inventory.getCurrentItem();
		if (currentItem != null)
		{
			IMemoryCard card = Util.getAppEngApi().getMemoryCardHandler();
			TileEntity blockTE = world.getBlockTileEntity(x, y, z);

			if (card.isMemoryCard(currentItem))
			{
				if (player.isSneaking())
				{
					NBTTagCompound nbt = new NBTTagCompound();
					blockTE.writeToNBT(nbt);
					nbt.removeTag("x");
					nbt.removeTag("y");
					nbt.removeTag("z");
					blockTE.readFromNBT(nbt);
					card.setMemoryCardContents(currentItem, getUnlocalizedName() + ".name", nbt);
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.SettingsSaved")));
					return true;
				} else if (card.getSettingsName(currentItem).equals(getUnlocalizedName() + ".name") || card.getSettingsName(currentItem).equals("AppEng.GuiITooltip.Blank"))
				{
					blockTE.readFromNBT(card.getData(currentItem));
					Packet description = blockTE.getDescriptionPacket();
					if (description != null)
						PacketDispatcher.sendPacketToAllPlayers(description);
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.SettingsLoaded")));
					return true;
				} else
				{
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.IncorrectDevice")));
					return true;
				}
			}
		}
		if (world.getBlockTileEntity(x, y, z) == null || player.isSneaking())
		{
			return false;
		}
		player.openGui(Extracells.instance, 3, world, x, y, z);
	}
	return true;
}
 
Example 3
Source File: BlockBusFluidStorage.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float offsetX, float offsetY, float offsetZ)
{
	if (!world.isRemote)
	{
		ItemStack currentItem = player.inventory.getCurrentItem();
		if (currentItem != null)
		{
			IMemoryCard card = Util.getAppEngApi().getMemoryCardHandler();
			TileEntity blockTE = world.getBlockTileEntity(x, y, z);

			if (card.isMemoryCard(currentItem))
			{
				if (player.isSneaking())
				{
					NBTTagCompound nbt = new NBTTagCompound();
					blockTE.writeToNBT(nbt);
					nbt.removeTag("x");
					nbt.removeTag("y");
					nbt.removeTag("z");
					blockTE.readFromNBT(nbt);
					card.setMemoryCardContents(currentItem, getUnlocalizedName() + ".name", nbt);
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.SettingsSaved")));
					return true;
				} else if (card.getSettingsName(currentItem).equals(getUnlocalizedName() + ".name") || card.getSettingsName(currentItem).equals("AppEng.GuiITooltip.Blank"))
				{
					blockTE.readFromNBT(card.getData(currentItem));
					Packet description = blockTE.getDescriptionPacket();
					if (description != null)
						PacketDispatcher.sendPacketToAllPlayers(description);
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.SettingsLoaded")));
					return true;
				} else
				{
					player.sendChatToPlayer(new ChatMessageComponent().addText(StatCollector.translateToLocal("ChatMsg.IncorrectDevice")));
					return true;
				}
			}
		}
		if (world.getBlockTileEntity(x, y, z) == null || player.isSneaking())
		{
			return false;
		}
		PacketDispatcher.sendPacketToPlayer(world.getBlockTileEntity(x, y, z).getDescriptionPacket(), (Player) player);
		player.openGui(Extracells.instance, 2, world, x, y, z);
	}
	return true;
}