Java Code Examples for cpw.mods.fml.common.network.PacketDispatcher#sendPacketToAllPlayers()
The following examples show how to use
cpw.mods.fml.common.network.PacketDispatcher#sendPacketToAllPlayers() .
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 | 6 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID) { super.onNeighborBlockChange(world, x, y, z, neighborID); if (!world.isRemote) { if (world.getBlockTileEntity(x, y, z) instanceof TileEntityBusFluidExport) PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket()); ((TileEntityBusFluidExport) world.getBlockTileEntity(x, y, z)).setRedstoneStatus(world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z)); } ForgeDirection blockOrientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); TileEntity blockTE = world.getBlockTileEntity(x, y, z); if (blockTE instanceof TileEntityBusFluidExport) { TileEntity fluidHandler = world.getBlockTileEntity(x + blockOrientation.offsetX, y + blockOrientation.offsetY, z + blockOrientation.offsetZ); ((TileEntityBusFluidExport) blockTE).setFluidHandler(fluidHandler instanceof IFluidHandler ? (IFluidHandler) fluidHandler : null); } }
Example 2
Source File: BlockBusFluidImport.java From ExtraCells1 with MIT License | 6 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID) { super.onNeighborBlockChange(world, x, y, z, neighborID); if (!world.isRemote) { if (world.getBlockTileEntity(x, y, z) instanceof TileEntityBusFluidImport) ((TileEntityBusFluidImport) world.getBlockTileEntity(x, y, z)).setRedstoneStatus(world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z)); PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket()); } ForgeDirection blockOrientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); TileEntity blockTE = world.getBlockTileEntity(x, y, z); if (blockTE instanceof TileEntityBusFluidImport) { TileEntity fluidHandler = world.getBlockTileEntity(x + blockOrientation.offsetX, y + blockOrientation.offsetY, z + blockOrientation.offsetZ); ((TileEntityBusFluidImport) blockTE).setFluidHandler(fluidHandler instanceof IFluidHandler ? (IFluidHandler) fluidHandler : null); } }
Example 3
Source File: TileEntityMonitorStorageFluid.java From ExtraCells1 with MIT License | 6 votes |
@Override public void setGrid(IGridInterface gi) { if (!worldObj.isRemote) { grid = gi; if (gi != null) { IMEInventoryHandler cellArray = gi.getCellArray(); if (cellArray != null) onNetworkInventoryChange(cellArray.getAvailableItems()); } else { setPowerStatus(false); } PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); } }
Example 4
Source File: BlockBusFluidStorage.java From ExtraCells1 with MIT License | 6 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID) { TileEntity blockTE = world.getBlockTileEntity(x, y, z); if (blockTE instanceof TileEntityBusFluidStorage) { TileEntityBusFluidStorage storageBus = (TileEntityBusFluidStorage) blockTE; if (!world.isRemote) { storageBus.updateGrid(); PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket()); MinecraftForge.EVENT_BUS.post(new GridStorageUpdateEvent(world, new WorldCoord(x, y, z), storageBus.getGrid())); } ForgeDirection blockOrientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); TileEntity fluidHandler = world.getBlockTileEntity(x + blockOrientation.offsetX, y + blockOrientation.offsetY, z + blockOrientation.offsetZ); storageBus.setFluidHandler(fluidHandler instanceof IFluidHandler ? (IFluidHandler) fluidHandler : null); } }
Example 5
Source File: TileEntityMonitorStorageFluid.java From ExtraCells1 with MIT License | 6 votes |
@Override public void onNetworkInventoryChange(IItemList iss) { long lastAmount = fluidAmount; fluidAmount = 0; if (fluid != null) { for (IAEItemStack stack : iss) { if (stack != null && stack.getItem() == ItemEnum.FLUIDDISPLAY.getItemInstance() && stack.getItemDamage() == fluid.getID()) { fluidAmount += stack.getStackSize(); } } } if (lastAmount != fluidAmount) { lastAmount = fluidAmount; PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); } }
Example 6
Source File: TileEntityTerminalFluid.java From ExtraCells1 with MIT License | 6 votes |
public void updateFluids(IItemList currentItems) { fluidsInNetwork = new ArrayList<SpecialFluidStack>(); if (grid != null) { for (IAEItemStack itemstack : currentItems) { if (itemstack.getItem() == FLUIDDISPLAY.getItemInstance() && itemstack.getStackSize() > 0) { fluidsInNetwork.add(new SpecialFluidStack(itemstack.getItemDamage(), itemstack.getStackSize())); } } } PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); }
Example 7
Source File: TileEntityTerminalFluid.java From ExtraCells1 with MIT License | 6 votes |
@ForgeSubscribe public void onNetworkPatternChange(GridPatternUpdateEvent e) { if (grid != null) { IMEInventoryHandler inventoryHandler = grid.getCraftableArray(); if (inventoryHandler != null) { craftableFluidsInNetwork = new ArrayList<Fluid>(); for (IAEItemStack stack : inventoryHandler.getAvailableItems()) { if (stack.getItem() == FLUIDDISPLAY.getItemInstance()) { craftableFluidsInNetwork.add(FluidRegistry.getFluid(stack.getItemDamage())); } } } } PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); }
Example 8
Source File: TileEntityCertusTank.java From ExtraCells1 with MIT License | 5 votes |
public void compareAndUpdate() { FluidStack current = tank.getFluid(); if (current != null) { if (lastBeforeUpdate != null) { if (Math.abs(current.amount - lastBeforeUpdate.amount) >= 500) { PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); lastBeforeUpdate = current.copy(); } else if (lastBeforeUpdate.amount < tank.getCapacity() && current.amount == tank.getCapacity() || lastBeforeUpdate.amount == tank.getCapacity() && current.amount < tank.getCapacity()) { PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); lastBeforeUpdate = current.copy(); } } else { PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); lastBeforeUpdate = current.copy(); } } else if (lastBeforeUpdate != null) { PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); lastBeforeUpdate = null; } }
Example 9
Source File: PacketBusFluidExport.java From ExtraCells1 with MIT License | 5 votes |
@Override public void execute(EntityPlayer player, Side side) throws ProtocolException { if (side.isServer()) { TileEntityBusFluidExport tile = (TileEntityBusFluidExport) world.getBlockTileEntity(x, y, z); switch (action) { case 0: if (tile != null) PacketDispatcher.sendPacketToAllPlayers(tile.getDescriptionPacket()); break; case 1: if (tile.getRedstoneMode().ordinal() >= 3) { tile.setRedstoneMode(RedstoneModeInput.values()[0]); } else { tile.setRedstoneMode(RedstoneModeInput.values()[tile.getRedstoneMode().ordinal() + 1]); } if (tile != null) PacketDispatcher.sendPacketToAllPlayers(tile.getDescriptionPacket()); break; case 2: if (tile.getFluidMode().ordinal() >= 2) { tile.setFluidMode(FluidMode.values()[0]); } else { tile.setFluidMode(FluidMode.values()[tile.getFluidMode().ordinal() + 1]); } if (tile != null) PacketDispatcher.sendPacketToAllPlayers(tile.getDescriptionPacket()); break; } } }
Example 10
Source File: TileEntityTerminalFluid.java From ExtraCells1 with MIT License | 5 votes |
public void setNetworkReady(boolean isReady) { networkReady = isReady; if (getGrid() != null) { IMEInventoryHandler cellArray = getGrid().getCellArray(); if (cellArray != null) updateFluids(cellArray.getAvailableItems()); } PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); }
Example 11
Source File: BlockCertusTank.java From ExtraCells1 with MIT License | 5 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID) { if (!world.isRemote) { PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket()); } }
Example 12
Source File: TileEntityTerminalFluid.java From ExtraCells1 with MIT License | 5 votes |
@Override public void setPowerStatus(boolean hasPower) { powerStatus = hasPower; PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); }
Example 13
Source File: TileEntityInterfaceFluid.java From ExtraCells1 with MIT License | 5 votes |
@Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { if (from == ForgeDirection.UNKNOWN) return null; FluidStack drained = tanks[from.ordinal()].drain(maxDrain, doDrain); if (drained != null) PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); return drained; }
Example 14
Source File: TileEntityMEBattery.java From ExtraCells1 with MIT License | 4 votes |
void onUpdatePower() { PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); if (worldObj != null) worldObj.updateAllLightTypes(xCoord, yCoord, zCoord); }
Example 15
Source File: TileEntityLevelEmitterFluid.java From ExtraCells1 with MIT License | 4 votes |
public void setRedstoneAction(RedstoneModeInput action) { redstoneAction = action; PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); updateRedstoneStates(); }
Example 16
Source File: TileEntityMonitorStorageFluid.java From ExtraCells1 with MIT License | 4 votes |
public void setMatrixed() { matrixed = true; PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); }
Example 17
Source File: BlockBusFluidStorage.java From ExtraCells1 with MIT License | 4 votes |
@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; }
Example 18
Source File: BlockBusFluidImport.java From ExtraCells1 with MIT License | 4 votes |
@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 19
Source File: BlockBusFluidExport.java From ExtraCells1 with MIT License | 4 votes |
@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 20
Source File: ColorableECTile.java From ExtraCells1 with MIT License | 4 votes |
public void setColor(int offset) { color = offset; PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); }