Search in sources :

Example 1 with AlchBagContainer

use of moze_intel.projecte.gameObjs.container.AlchBagContainer in project ProjectE by sinkillerj.

the class GuiHandler method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    TileEntity tile = !ITEM_IDS.contains(ID) ? world.getTileEntity(new BlockPos(x, y, z)) : null;
    // if not a TE, x will hold which hand it came from. 1 for off, 0 otherwise
    EnumHand hand = ITEM_IDS.contains(ID) ? (x == 1 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND) : null;
    switch(ID) {
        case Constants.ALCH_CHEST_GUI:
            if (tile != null && tile instanceof AlchChestTile)
                return new AlchChestContainer(player.inventory, (AlchChestTile) tile);
            break;
        case Constants.ALCH_BAG_GUI:
            {
                EnumDyeColor color = EnumDyeColor.byMetadata(player.getHeldItem(hand).getItemDamage());
                IItemHandlerModifiable inventory = (IItemHandlerModifiable) player.getCapability(ProjectEAPI.ALCH_BAG_CAPABILITY, null).getBag(color);
                return new AlchBagContainer(player.inventory, hand, inventory);
            }
        case Constants.CONDENSER_GUI:
            if (tile != null && tile instanceof CondenserTile)
                return new CondenserContainer(player.inventory, (CondenserTile) tile);
            break;
        case Constants.TRANSMUTE_STONE_GUI:
            return new TransmutationContainer(player.inventory, new TransmutationInventory(player), null);
        case Constants.RM_FURNACE_GUI:
            if (tile != null && tile instanceof RMFurnaceTile)
                return new RMFurnaceContainer(player.inventory, (RMFurnaceTile) tile);
            break;
        case Constants.DM_FURNACE_GUI:
            if (tile != null && tile instanceof DMFurnaceTile)
                return new DMFurnaceContainer(player.inventory, (DMFurnaceTile) tile);
            break;
        case Constants.COLLECTOR1_GUI:
            if (tile != null && tile instanceof CollectorMK1Tile)
                return new CollectorMK1Container(player.inventory, (CollectorMK1Tile) tile);
            break;
        case Constants.COLLECTOR2_GUI:
            if (tile != null && tile instanceof CollectorMK2Tile)
                return new CollectorMK2Container(player.inventory, (CollectorMK2Tile) tile);
            break;
        case Constants.COLLECTOR3_GUI:
            if (tile != null && tile instanceof CollectorMK3Tile)
                return new CollectorMK3Container(player.inventory, (CollectorMK3Tile) tile);
            break;
        case Constants.RELAY1_GUI:
            if (tile != null && tile instanceof RelayMK1Tile)
                return new RelayMK1Container(player.inventory, (RelayMK1Tile) tile);
            break;
        case Constants.RELAY2_GUI:
            if (tile != null && tile instanceof RelayMK2Tile)
                return new RelayMK2Container(player.inventory, (RelayMK2Tile) tile);
            break;
        case Constants.RELAY3_GUI:
            if (tile != null && tile instanceof RelayMK3Tile)
                return new RelayMK3Container(player.inventory, (RelayMK3Tile) tile);
            break;
        case Constants.MERCURIAL_GUI:
            return new MercurialEyeContainer(player.inventory, new MercurialEyeInventory(player.getHeldItem(hand)));
        case Constants.PHILOS_STONE_GUI:
            return new PhilosStoneContainer(player.inventory);
        case Constants.TRANSMUTATION_GUI:
            return new TransmutationContainer(player.inventory, new TransmutationInventory(player), hand);
        case Constants.ETERNAL_DENSITY_GUI:
            return new EternalDensityContainer(player.inventory, new EternalDensityInventory(player.getHeldItem(hand), player));
        case Constants.CONDENSER_MK2_GUI:
            return new CondenserMK2Container(player.inventory, (CondenserMK2Tile) tile);
    }
    return null;
}
Also used : AlchChestTile(moze_intel.projecte.gameObjs.tiles.AlchChestTile) CollectorMK2Container(moze_intel.projecte.gameObjs.container.CollectorMK2Container) PhilosStoneContainer(moze_intel.projecte.gameObjs.container.PhilosStoneContainer) AlchChestContainer(moze_intel.projecte.gameObjs.container.AlchChestContainer) RelayMK2Container(moze_intel.projecte.gameObjs.container.RelayMK2Container) CollectorMK3Tile(moze_intel.projecte.gameObjs.tiles.CollectorMK3Tile) RelayMK2Tile(moze_intel.projecte.gameObjs.tiles.RelayMK2Tile) MercurialEyeContainer(moze_intel.projecte.gameObjs.container.MercurialEyeContainer) TileEntity(net.minecraft.tileentity.TileEntity) EternalDensityContainer(moze_intel.projecte.gameObjs.container.EternalDensityContainer) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) TransmutationInventory(moze_intel.projecte.gameObjs.container.inventory.TransmutationInventory) EnumHand(net.minecraft.util.EnumHand) CondenserTile(moze_intel.projecte.gameObjs.tiles.CondenserTile) CollectorMK3Container(moze_intel.projecte.gameObjs.container.CollectorMK3Container) MercurialEyeInventory(moze_intel.projecte.gameObjs.container.inventory.MercurialEyeInventory) CondenserContainer(moze_intel.projecte.gameObjs.container.CondenserContainer) CollectorMK2Tile(moze_intel.projecte.gameObjs.tiles.CollectorMK2Tile) BlockPos(net.minecraft.util.math.BlockPos) RMFurnaceContainer(moze_intel.projecte.gameObjs.container.RMFurnaceContainer) RelayMK1Tile(moze_intel.projecte.gameObjs.tiles.RelayMK1Tile) RelayMK3Container(moze_intel.projecte.gameObjs.container.RelayMK3Container) CondenserMK2Container(moze_intel.projecte.gameObjs.container.CondenserMK2Container) AlchBagContainer(moze_intel.projecte.gameObjs.container.AlchBagContainer) EternalDensityInventory(moze_intel.projecte.gameObjs.container.inventory.EternalDensityInventory) DMFurnaceTile(moze_intel.projecte.gameObjs.tiles.DMFurnaceTile) CollectorMK1Tile(moze_intel.projecte.gameObjs.tiles.CollectorMK1Tile) EnumDyeColor(net.minecraft.item.EnumDyeColor) RelayMK1Container(moze_intel.projecte.gameObjs.container.RelayMK1Container) DMFurnaceContainer(moze_intel.projecte.gameObjs.container.DMFurnaceContainer) RMFurnaceTile(moze_intel.projecte.gameObjs.tiles.RMFurnaceTile) CollectorMK1Container(moze_intel.projecte.gameObjs.container.CollectorMK1Container) RelayMK3Tile(moze_intel.projecte.gameObjs.tiles.RelayMK3Tile) TransmutationContainer(moze_intel.projecte.gameObjs.container.TransmutationContainer)

Example 2 with AlchBagContainer

use of moze_intel.projecte.gameObjs.container.AlchBagContainer in project ProjectE by sinkillerj.

the class TickEvents method playerTick.

@SubscribeEvent
public static void playerTick(TickEvent.PlayerTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        IAlchBagProvider provider = event.player.getCapability(ProjectEAPI.ALCH_BAG_CAPABILITY, null);
        Set<EnumDyeColor> colorsChanged = EnumSet.noneOf(EnumDyeColor.class);
        for (EnumDyeColor color : getBagColorsPresent(event.player)) {
            IItemHandler inv = provider.getBag(color);
            for (int i = 0; i < inv.getSlots(); i++) {
                ItemStack current = inv.getStackInSlot(i);
                if (current != null && current.getItem() instanceof IAlchBagItem && ((IAlchBagItem) current.getItem()).updateInAlchBag(inv, event.player, current)) {
                    colorsChanged.add(color);
                }
            }
        }
        if (!event.player.getEntityWorld().isRemote) {
            for (EnumDyeColor e : colorsChanged) {
                if (event.player.openContainer instanceof AlchBagContainer && event.player.getHeldItem(((AlchBagContainer) event.player.openContainer).hand).getItemDamage() == e.getMetadata())
                    // and we'll stay out of its way.
                    continue;
                else
                    provider.sync(e, (EntityPlayerMP) event.player);
            }
            event.player.getCapability(InternalAbilities.CAPABILITY, null).tick();
            event.player.getCapability(InternalTimers.CAPABILITY, null).tick();
        }
    }
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) IAlchBagItem(moze_intel.projecte.api.item.IAlchBagItem) IAlchBagProvider(moze_intel.projecte.api.capabilities.IAlchBagProvider) AlchBagContainer(moze_intel.projecte.gameObjs.container.AlchBagContainer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) EnumDyeColor(net.minecraft.item.EnumDyeColor) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

AlchBagContainer (moze_intel.projecte.gameObjs.container.AlchBagContainer)2 EnumDyeColor (net.minecraft.item.EnumDyeColor)2 IAlchBagProvider (moze_intel.projecte.api.capabilities.IAlchBagProvider)1 IAlchBagItem (moze_intel.projecte.api.item.IAlchBagItem)1 AlchChestContainer (moze_intel.projecte.gameObjs.container.AlchChestContainer)1 CollectorMK1Container (moze_intel.projecte.gameObjs.container.CollectorMK1Container)1 CollectorMK2Container (moze_intel.projecte.gameObjs.container.CollectorMK2Container)1 CollectorMK3Container (moze_intel.projecte.gameObjs.container.CollectorMK3Container)1 CondenserContainer (moze_intel.projecte.gameObjs.container.CondenserContainer)1 CondenserMK2Container (moze_intel.projecte.gameObjs.container.CondenserMK2Container)1 DMFurnaceContainer (moze_intel.projecte.gameObjs.container.DMFurnaceContainer)1 EternalDensityContainer (moze_intel.projecte.gameObjs.container.EternalDensityContainer)1 MercurialEyeContainer (moze_intel.projecte.gameObjs.container.MercurialEyeContainer)1 PhilosStoneContainer (moze_intel.projecte.gameObjs.container.PhilosStoneContainer)1 RMFurnaceContainer (moze_intel.projecte.gameObjs.container.RMFurnaceContainer)1 RelayMK1Container (moze_intel.projecte.gameObjs.container.RelayMK1Container)1 RelayMK2Container (moze_intel.projecte.gameObjs.container.RelayMK2Container)1 RelayMK3Container (moze_intel.projecte.gameObjs.container.RelayMK3Container)1 TransmutationContainer (moze_intel.projecte.gameObjs.container.TransmutationContainer)1 EternalDensityInventory (moze_intel.projecte.gameObjs.container.inventory.EternalDensityInventory)1