Search in sources :

Example 1 with MessageTileSync

use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.

the class GuiMixer method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button.id == 0) {
        NBTTagCompound tag = new NBTTagCompound();
        tile.outputAll = ((GuiButtonState) button).state;
        tag.setBoolean("outputAll", tile.outputAll);
        ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(tile, tag));
        this.initGui();
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) MessageTileSync(blusunrize.immersiveengineering.common.util.network.MessageTileSync)

Example 2 with MessageTileSync

use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.

the class GuiTurret method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    NBTTagCompound tag = new NBTTagCompound();
    int listOffset = -1;
    if (button.id == 0) {
        int rem = ((GuiReactiveList) button).selectedOption;
        tile.targetList.remove(rem);
        tag.setInteger("remove", rem);
        listOffset = ((GuiReactiveList) button).getOffset() - 1;
    } else if (button.id == 1 && !this.nameField.getText().isEmpty()) {
        String name = this.nameField.getText();
        if (!tile.targetList.contains(name)) {
            listOffset = ((GuiReactiveList) buttonList.get(0)).getMaxOffset();
            tag.setString("add", name);
            tile.targetList.add(name);
        }
        this.nameField.setText("");
    } else if (button.id == 2) {
        tile.whitelist = !((GuiButtonState) button).state;
        tag.setBoolean("whitelist", tile.whitelist);
    } else if (button.id == 3) {
        tile.attackAnimals = ((GuiButtonState) button).state;
        tag.setBoolean("attackAnimals", tile.attackAnimals);
    } else if (button.id == 4) {
        tile.attackPlayers = ((GuiButtonState) button).state;
        tag.setBoolean("attackPlayers", tile.attackPlayers);
    } else if (button.id == 5) {
        tile.attackNeutrals = ((GuiButtonState) button).state;
        tag.setBoolean("attackNeutrals", tile.attackNeutrals);
    } else if (button.id == 6 && tile instanceof TileEntityTurretChem) {
        ((TileEntityTurretChem) tile).ignite = ((GuiButtonState) button).state;
        tag.setBoolean("ignite", ((TileEntityTurretChem) tile).ignite);
    } else if (button.id == 6 && tile instanceof TileEntityTurretGun) {
        ((TileEntityTurretGun) tile).expelCasings = ((GuiButtonState) button).state;
        tag.setBoolean("expelCasings", ((TileEntityTurretGun) tile).expelCasings);
    }
    if (!tag.hasNoTags()) {
        ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(tile, tag));
        this.initGui();
        if (listOffset >= 0)
            ((GuiReactiveList) this.buttonList.get(0)).setOffset(listOffset);
    }
}
Also used : GuiReactiveList(blusunrize.immersiveengineering.client.gui.elements.GuiReactiveList) TileEntityTurretGun(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun) GuiButtonState(blusunrize.immersiveengineering.client.gui.elements.GuiButtonState) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityTurretChem(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretChem) MessageTileSync(blusunrize.immersiveengineering.common.util.network.MessageTileSync)

Example 3 with MessageTileSync

use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.

the class GuiAutoWorkbench method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) throws IOException {
    if (button instanceof GuiButtonItem) {
        if (//disable
        button.id == tile.selectedRecipe)
            tile.selectedRecipe = -1;
        else
            tile.selectedRecipe = button.id;
        NBTTagCompound message = new NBTTagCompound();
        message.setInteger("recipe", tile.selectedRecipe);
        ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(this.tile, message));
        initGui();
    }
}
Also used : GuiButtonItem(blusunrize.immersiveengineering.client.gui.elements.GuiButtonItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) MessageTileSync(blusunrize.immersiveengineering.common.util.network.MessageTileSync)

Example 4 with MessageTileSync

use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.

the class GuiModWorkbench method mouseReleased.

@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
    super.mouseReleased(mouseX, mouseY, state);
    Slot s = inventorySlots.getSlot(0);
    if (s != null && s.getHasStack() && s.getStack().getItem() instanceof IConfigurableTool) {
        ItemStack stack = s.getStack();
        IConfigurableTool tool = ((IConfigurableTool) stack.getItem());
        NBTTagCompound message = new NBTTagCompound();
        ToolConfigBoolean[] boolArray = tool.getBooleanOptions(stack);
        int iBool = 0;
        ToolConfigFloat[] floatArray = tool.getFloatOptions(stack);
        int iFloat = 0;
        for (GuiButton button : this.buttonList) {
            if (button instanceof GuiButtonCheckbox && boolArray != null)
                message.setBoolean("b_" + boolArray[iBool++].name, ((GuiButtonCheckbox) button).state);
            if (button instanceof GuiSliderIE && floatArray != null)
                message.setFloat("f_" + floatArray[iFloat++].name, (float) ((GuiSliderIE) button).sliderValue);
        }
        if (//Only send packets when values have changed
        lastMessage == null || !lastMessage.equals(message))
            ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(this.workbench, message));
        lastMessage = message;
    }
}
Also used : ToolConfigBoolean(blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigBoolean) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GuiButton(net.minecraft.client.gui.GuiButton) GuiSliderIE(blusunrize.immersiveengineering.client.gui.elements.GuiSliderIE) IESlot(blusunrize.immersiveengineering.common.gui.IESlot) Slot(net.minecraft.inventory.Slot) IConfigurableTool(blusunrize.immersiveengineering.api.tool.IConfigurableTool) ToolConfigFloat(blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigFloat) GuiButtonCheckbox(blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox) ItemStack(net.minecraft.item.ItemStack) MessageTileSync(blusunrize.immersiveengineering.common.util.network.MessageTileSync)

Example 5 with MessageTileSync

use of blusunrize.immersiveengineering.common.util.network.MessageTileSync in project ImmersiveEngineering by BluSunrize.

the class TileEntityTeslaCoil method sendRenderPacket.

protected void sendRenderPacket(Entity target) {
    NBTTagCompound tag = new NBTTagCompound();
    tag.setInteger("targetEntity", target.getEntityId());
    ImmersiveEngineering.packetHandler.sendToAll(new MessageTileSync(this, tag));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) MessageTileSync(blusunrize.immersiveengineering.common.util.network.MessageTileSync)

Aggregations

MessageTileSync (blusunrize.immersiveengineering.common.util.network.MessageTileSync)13 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)13 GuiReactiveList (blusunrize.immersiveengineering.client.gui.elements.GuiReactiveList)2 ItemStack (net.minecraft.item.ItemStack)2 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)2 ExcavatorHandler (blusunrize.immersiveengineering.api.tool.ExcavatorHandler)1 IConfigurableTool (blusunrize.immersiveengineering.api.tool.IConfigurableTool)1 ToolConfigBoolean (blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigBoolean)1 ToolConfigFloat (blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigFloat)1 ButtonSorter (blusunrize.immersiveengineering.client.gui.GuiSorter.ButtonSorter)1 GuiButtonCheckbox (blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox)1 GuiButtonItem (blusunrize.immersiveengineering.client.gui.elements.GuiButtonItem)1 GuiButtonState (blusunrize.immersiveengineering.client.gui.elements.GuiButtonState)1 GuiSliderIE (blusunrize.immersiveengineering.client.gui.elements.GuiSliderIE)1 TileEntityTurretChem (blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretChem)1 TileEntityTurretGun (blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun)1 IESlot (blusunrize.immersiveengineering.common.gui.IESlot)1 Block (net.minecraft.block.Block)1 GuiButton (net.minecraft.client.gui.GuiButton)1 Slot (net.minecraft.inventory.Slot)1