Java Code Examples for cpw.mods.fml.common.network.PacketDispatcher#sendPacketToServer()

The following examples show how to use cpw.mods.fml.common.network.PacketDispatcher#sendPacketToServer() . 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: GuiBusFluidImport.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int sizeX, int sizeY)
{
	PacketDispatcher.sendPacketToServer(new PacketBusFluidImport(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 0, player.username).makePacket());
	Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture);

	if (tileentity != null)
	{
		WidgetRedstoneModes redstoneSwitch = (WidgetRedstoneModes) buttonList.get(0);
		redstoneSwitch.setRedstoneMode(tileentity.getRedstoneMode());
		WidgetFluidModes fluidSwitch = (WidgetFluidModes) buttonList.get(1);
		fluidSwitch.setFluidMode(tileentity.getFluidMode());
	}

	this.fontRenderer.drawString(BlockEnum.FLUIDIMPORT.getStatName(), 5, 0, 0x000000);
}
 
Example 2
Source File: GuiBusFluidExport.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
	PacketDispatcher.sendPacketToServer(new PacketBusFluidExport(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 0, player.username).makePacket());

	Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture);

	if (tileentity != null)
	{
		WidgetRedstoneModes redstoneSwitch = (WidgetRedstoneModes) buttonList.get(0);
		redstoneSwitch.setRedstoneMode(tileentity.getRedstoneMode());
		WidgetFluidModes fluidSwitch = (WidgetFluidModes) buttonList.get(1);
		fluidSwitch.setFluidMode(tileentity.getFluidMode());
	}

	this.fontRenderer.drawString(BlockEnum.FLUIDEXPORT.getStatName(), 5, 0, 0x000000);
}
 
Example 3
Source File: GuiBusFluidStorage.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@Override
protected void keyTyped(char key, int par2)
{
	if (textFieldPriority.isFocused())
	{
		textFieldPriority.textboxKeyTyped(key, par2);
		if (!textFieldPriority.getText().isEmpty())
		{
			try
			{
				int priority = Integer.valueOf(textFieldPriority.getText());
				PacketDispatcher.sendPacketToServer(new PacketBusFluidStorage(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, priority).makePacket());
			} catch (NumberFormatException e)
			{
			}

		}
	} else
	{
		super.keyTyped(key, par2);
	}
}
 
Example 4
Source File: HGKeyHandler.java    From HexxitGear with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;

    if (player == null || tickEnd)
        return;

    if (kb.equals(activateHexxitArmor)) {
        if (ArmorSet.getPlayerArmorSet(player.username) != null) {
            Object[] data = new Object[] { player.username };
            PacketDispatcher.sendPacketToServer(PacketWrapper.createPacket(HexxitGear.modNetworkChannel, Packets.armorAbility, data));
            //ArmorSet.readArmorPacket(player.username);
        }
    }
}
 
Example 5
Source File: GuiMEBattery.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void updateScreen()
{
	PacketDispatcher.sendPacketToServer(new PacketMEBattery(world, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, player.username).makePacket());

	if (world.getBlockTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) instanceof TileEntityMEBattery)
	{
		TileEntityMEBattery battery = (TileEntityMEBattery) world.getBlockTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
		currentEnergy = battery.getMECurrentPower();
		maxEnergy = battery.getMEMaxPower();
	}
}
 
Example 6
Source File: GuiLevelEmitterFluid.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void actionPerformed(GuiButton button)
{
	switch (button.id)
	{
	case 0:
		modifyAmount(-1);
		break;
	case 1:
		modifyAmount(-10);
		break;
	case 2:
		modifyAmount(-100);
		break;
	case 3:
		modifyAmount(+1);
		break;
	case 4:
		modifyAmount(+10);
		break;
	case 5:
		modifyAmount(+100);
		break;
	case 6:
		PacketDispatcher.sendPacketToServer(new PacketLevelEmitterFluid(tileentity.worldObj, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord).makePacket());
		break;

	}
}
 
Example 7
Source File: GuiBusFluidImport.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void actionPerformed(GuiButton button)
{
	switch (button.id)
	{
	case 0:
		PacketDispatcher.sendPacketToServer(new PacketBusFluidImport(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 1, player.username).makePacket());
		break;
	case 1:
		PacketDispatcher.sendPacketToServer(new PacketBusFluidImport(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 2, player.username).makePacket());
		break;
	default:
	}
}
 
Example 8
Source File: GuiBusFluidExport.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void actionPerformed(GuiButton button)
{
	switch (button.id)
	{
	case 0:
		PacketDispatcher.sendPacketToServer(new PacketBusFluidExport(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 1, player.username).makePacket());
		break;
	case 1:
		PacketDispatcher.sendPacketToServer(new PacketBusFluidExport(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 2, player.username).makePacket());
		break;
	default:
	}
}
 
Example 9
Source File: WidgetFluidSelector.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@Override
public void mouseClicked(int posX, int posY, int mouseX, int mouseY)
{
	if (fluid != null && isPointInRegion(posX, posY, sizeX, sizeY, mouseX, mouseY))
	{
		TileEntityTerminalFluid terminalFluid = guiTerminalFluid.tileEntity;
		PacketDispatcher.sendPacketToServer(new PacketTerminalFluid(terminalFluid.worldObj, terminalFluid.xCoord, terminalFluid.yCoord, terminalFluid.zCoord, fluid).makePacket());
		selected = true;
		guiTerminalFluid.updateSelected(this);
		guiTerminalFluid.currentFluidAmount = amount;
		guiTerminalFluid.currentFluidName = fluid.getLocalizedName();
	}
}
 
Example 10
Source File: GuiSolderingStation.java    From ExtraCells1 with MIT License 4 votes vote down vote up
public void actionPerformed(GuiButton button)
{
	int slotID = mc.thePlayer.inventory.currentItem;
	switch (button.id)
	{
	case 0:
		// -2048
		if (Util.getCellRegistry().getHandlerForCell(this.mc.thePlayer.getCurrentEquippedItem()).storedItemCount() == 0)
		{
			PacketDispatcher.sendPacketToServer(PacketSolderingStation.changeSize(mc.thePlayer, tileX, tileY, tileZ, -2048, slotID).makePacket());
		} else
		{
			this.mc.thePlayer.addChatMessage(StatCollector.translateToLocal("tooltip.solderingwarning.cellnotempty"));
		}
		break;

	case 1:
		// +2048
		if (Util.getCellRegistry().getHandlerForCell(this.mc.thePlayer.getCurrentEquippedItem()).storedItemCount() == 0)
		{
			PacketDispatcher.sendPacketToServer(PacketSolderingStation.changeSize(mc.thePlayer, tileX, tileY, tileZ, 2048, slotID).makePacket());
		} else
		{
			this.mc.thePlayer.addChatMessage(StatCollector.translateToLocal("tooltip.solderingwarning.cellnotempty"));
		}
		break;

	case 2:
		// -1
		if (Util.getCellRegistry().getHandlerForCell(this.mc.thePlayer.getCurrentEquippedItem()).storedItemCount() == 0)
		{
			PacketDispatcher.sendPacketToServer(PacketSolderingStation.changeTypes(mc.thePlayer, tileX, tileY, tileZ, -1, slotID).makePacket());
		} else
		{
			this.mc.thePlayer.addChatMessage(StatCollector.translateToLocal("tooltip.solderingwarning.cellnotempty"));
		}
		break;

	case 3:
		// +1
		if (Util.getCellRegistry().getHandlerForCell(this.mc.thePlayer.getCurrentEquippedItem()).storedItemCount() == 0)
		{
			PacketDispatcher.sendPacketToServer(PacketSolderingStation.changeTypes(mc.thePlayer, tileX, tileY, tileZ, 1, slotID).makePacket());
		} else
		{
			this.mc.thePlayer.addChatMessage(StatCollector.translateToLocal("tooltip.solderingwarning.cellnotempty"));
		}
		break;

	default:
		break;
	}
}
 
Example 11
Source File: GuiLevelEmitterFluid.java    From ExtraCells1 with MIT License 4 votes vote down vote up
public void modifyAmount(long amount)
{
	if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
		amount *= 100;
	PacketDispatcher.sendPacketToServer(new PacketLevelEmitterFluid(tileentity.worldObj, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, amount).makePacket());
}
 
Example 12
Source File: WidgetFluidRequest.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public void mouseClicked(int posX, int posY, int mouseX, int mouseY)
{
	TileEntity tileEntity = guiTerminalFluid.tileEntity;
	PacketDispatcher.sendPacketToServer(new PacketTerminalFluid(tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, new FluidStack(fluid, 1000)).makePacket());
}