Search in sources :

Example 1 with MessageSendClientServerTemplates

use of com.bluepowermod.network.message.MessageSendClientServerTemplates 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)

Example 2 with MessageSendClientServerTemplates

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

the class BlockCircuitDatabase method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
    if (super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9)) {
        TileCircuitDatabase database = (TileCircuitDatabase) world.getTileEntity(x, y, z);
        database.clientCurrentTab = 0;
        if (!world.isRemote) {
            BPNetworkHandler.INSTANCE.sendTo(new MessageSendClientServerTemplates(new ItemStackDatabase().loadItemStacks()), (EntityPlayerMP) player);
        }
        return true;
    } else {
        return false;
    }
}
Also used : TileCircuitDatabase(com.bluepowermod.tile.tier3.TileCircuitDatabase) MessageSendClientServerTemplates(com.bluepowermod.network.message.MessageSendClientServerTemplates) ItemStackDatabase(com.bluepowermod.helper.ItemStackDatabase)

Aggregations

MessageSendClientServerTemplates (com.bluepowermod.network.message.MessageSendClientServerTemplates)2 ItemStackDatabase (com.bluepowermod.helper.ItemStackDatabase)1 MessageCircuitDatabaseTemplate (com.bluepowermod.network.message.MessageCircuitDatabaseTemplate)1 TileCircuitDatabase (com.bluepowermod.tile.tier3.TileCircuitDatabase)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1