Search in sources :

Example 1 with MessageCircuitDatabaseTemplate

use of com.bluepowermod.network.message.MessageCircuitDatabaseTemplate in project BluePower by Qmunity.

the class GuiCircuitDatabaseSharing method handleMouseClick.

@Override
protected void handleMouseClick(Slot slot, int p_146984_2_, int p_146984_3_, int p_146984_4_) {
    if (slot != null && slot.getHasStack() && slot.inventory == circuitDatabase.circuitInventory) {
        if (BluePower.proxy.isSneakingInGui()) {
            if (slot.getSlotIndex() == curDeletingTemplate) {
                if (circuitDatabase.clientCurrentTab == 1) {
                    circuitDatabase.stackDatabase.deleteStack(slot.getStack());
                    circuitDatabase.updateGateInventory();
                } else {
                    BPNetworkHandler.INSTANCE.sendToServer(new MessageCircuitDatabaseTemplate(circuitDatabase, slot.getStack(), true));
                }
            } else {
                curDeletingTemplate = slot.getSlotIndex();
                return;
            }
        } else {
            // Navigate to the copy & share tab.
            circuitDatabase.clientCurrentTab = 0;
            BPNetworkHandler.INSTANCE.sendToServer(new MessageCircuitDatabaseTemplate(circuitDatabase, slot.getStack()));
        }
    } else {
        super.handleMouseClick(slot, p_146984_2_, p_146984_3_, p_146984_4_);
    }
    curDeletingTemplate = -1;
}
Also used : MessageCircuitDatabaseTemplate(com.bluepowermod.network.message.MessageCircuitDatabaseTemplate)

Example 2 with MessageCircuitDatabaseTemplate

use of com.bluepowermod.network.message.MessageCircuitDatabaseTemplate in project BluePower by Qmunity.

the class TileCircuitDatabase method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    if (!worldObj.isRemote) {
        if (copyInventory.getStackInSlot(0) != null) {
            if (curCopyProgress >= 0) {
                if (++curCopyProgress > UPLOAD_AND_COPY_TIME) {
                    curCopyProgress = -1;
                    if (copy(triggeringPlayer, copyInventory.getStackInSlot(0), copyInventory.getStackInSlot(1), true)) {
                        copy(triggeringPlayer, copyInventory.getStackInSlot(0), copyInventory.getStackInSlot(1), false);
                    }
                }
            }
            if (curUploadProgress >= 0) {
                if (++curUploadProgress > UPLOAD_AND_COPY_TIME) {
                    curUploadProgress = -1;
                    if (selectedShareOption == 1 && triggeringPlayer != null)
                        BPNetworkHandler.INSTANCE.sendTo(new MessageCircuitDatabaseTemplate(this, copyInventory.getStackInSlot(0)), (EntityPlayerMP) triggeringPlayer);
                    if (selectedShareOption == 2) {
                        stackDatabase.saveItemStack(copyInventory.getStackInSlot(0));
                        BPNetworkHandler.INSTANCE.sendToAll(new MessageSendClientServerTemplates(stackDatabase.loadItemStacks()));
                    }
                    selectedShareOption = 0;
                }
            }
        } else {
            curCopyProgress = -1;
            curUploadProgress = -1;
            selectedShareOption = 0;
        }
    }
}
Also used : MessageCircuitDatabaseTemplate(com.bluepowermod.network.message.MessageCircuitDatabaseTemplate) MessageSendClientServerTemplates(com.bluepowermod.network.message.MessageSendClientServerTemplates) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

MessageCircuitDatabaseTemplate (com.bluepowermod.network.message.MessageCircuitDatabaseTemplate)2 MessageSendClientServerTemplates (com.bluepowermod.network.message.MessageSendClientServerTemplates)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1