Search in sources :

Example 1 with DropperAction

use of mekanism.common.network.to_server.PacketDropperUse.DropperAction in project Mekanism by mekanism.

the class GuiTankGauge method mouseClicked.

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
    if (isMouseOver(mouseX, mouseY) && tankType != null) {
        ItemStack stack = minecraft.player.inventory.getCarried();
        if (gui() instanceof GuiMekanismTile && !stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) {
            int index = infoHandler.getTankIndex();
            if (index != -1) {
                DropperAction action;
                if (button == 0) {
                    action = Screen.hasShiftDown() ? DropperAction.DUMP_TANK : DropperAction.FILL_DROPPER;
                } else {
                    action = DropperAction.DRAIN_DROPPER;
                }
                Mekanism.packetHandler.sendToServer(new PacketDropperUse(((GuiMekanismTile<?, ?>) gui()).getTileEntity().getBlockPos(), action, tankType, index));
            }
            return true;
        }
    }
    return super.mouseClicked(mouseX, mouseY, button);
}
Also used : DropperAction(mekanism.common.network.to_server.PacketDropperUse.DropperAction) PacketDropperUse(mekanism.common.network.to_server.PacketDropperUse) ItemGaugeDropper(mekanism.common.item.ItemGaugeDropper) ItemStack(net.minecraft.item.ItemStack) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile)

Example 2 with DropperAction

use of mekanism.common.network.to_server.PacketDropperUse.DropperAction in project Mekanism by mekanism.

the class GuiTankBar method mouseClicked.

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
    if (isMouseOver(mouseX, mouseY)) {
        ItemStack stack = Minecraft.getInstance().player.inventory.getCarried();
        if (gui() instanceof GuiMekanismTile && !stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) {
            TankType tankType = getType(getHandler().getStack());
            if (tankType != null) {
                int index = getHandler().getTankIndex();
                if (index != -1) {
                    DropperAction action;
                    if (button == 0) {
                        action = Screen.hasShiftDown() ? DropperAction.DUMP_TANK : DropperAction.FILL_DROPPER;
                    } else {
                        action = DropperAction.DRAIN_DROPPER;
                    }
                    Mekanism.packetHandler.sendToServer(new PacketDropperUse(((GuiMekanismTile<?, ?>) gui()).getTileEntity().getBlockPos(), action, tankType, index));
                }
                return true;
            }
        }
    }
    return super.mouseClicked(mouseX, mouseY, button);
}
Also used : DropperAction(mekanism.common.network.to_server.PacketDropperUse.DropperAction) PacketDropperUse(mekanism.common.network.to_server.PacketDropperUse) ItemGaugeDropper(mekanism.common.item.ItemGaugeDropper) TankType(mekanism.common.network.to_server.PacketDropperUse.TankType) ItemStack(net.minecraft.item.ItemStack) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile)

Aggregations

GuiMekanismTile (mekanism.client.gui.GuiMekanismTile)2 ItemGaugeDropper (mekanism.common.item.ItemGaugeDropper)2 PacketDropperUse (mekanism.common.network.to_server.PacketDropperUse)2 DropperAction (mekanism.common.network.to_server.PacketDropperUse.DropperAction)2 ItemStack (net.minecraft.item.ItemStack)2 TankType (mekanism.common.network.to_server.PacketDropperUse.TankType)1