Search in sources :

Example 1 with AlchChestTile

use of moze_intel.projecte.gameObjs.tiles.AlchChestTile in project ProjectE by sinkillerj.

the class BlackHoleBand method updateInAlchChest.

@Override
public void updateInAlchChest(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ItemStack stack) {
    AlchChestTile tile = ((AlchChestTile) world.getTileEntity(pos));
    if (stack.getItemDamage() == 1) {
        AxisAlignedBB aabb = new AxisAlignedBB(tile.getPos().getX() - 5, tile.getPos().getY() - 5, tile.getPos().getZ() - 5, tile.getPos().getX() + 5, tile.getPos().getY() + 5, tile.getPos().getZ() + 5);
        double centeredX = tile.getPos().getX() + 0.5;
        double centeredY = tile.getPos().getY() + 0.5;
        double centeredZ = tile.getPos().getZ() + 0.5;
        for (EntityItem e : tile.getWorld().getEntitiesWithinAABB(EntityItem.class, aabb)) {
            WorldHelper.gravitateEntityTowards(e, centeredX, centeredY, centeredZ);
            if (!e.getEntityWorld().isRemote && !e.isDead && e.getDistanceSq(centeredX, centeredY, centeredZ) < 1.21) {
                ItemStack result = ItemHandlerHelper.insertItemStacked(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null), e.getEntityItem(), false);
                if (result != null) {
                    e.setEntityItemStack(result);
                } else {
                    e.setDead();
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) AlchChestTile(moze_intel.projecte.gameObjs.tiles.AlchChestTile) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with AlchChestTile

use of moze_intel.projecte.gameObjs.tiles.AlchChestTile in project ProjectE by sinkillerj.

the class GemEternalDensity method updateInAlchChest.

@Override
public void updateInAlchChest(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ItemStack stack) {
    if (!world.isRemote && stack.getItemDamage() == 1) {
        AlchChestTile tile = ((AlchChestTile) world.getTileEntity(pos));
        condense(stack, tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null));
        tile.markDirty();
    }
}
Also used : AlchChestTile(moze_intel.projecte.gameObjs.tiles.AlchChestTile)

Example 3 with AlchChestTile

use of moze_intel.projecte.gameObjs.tiles.AlchChestTile 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 4 with AlchChestTile

use of moze_intel.projecte.gameObjs.tiles.AlchChestTile in project ProjectE by sinkillerj.

the class RepairTalisman method updateInAlchChest.

@Override
public void updateInAlchChest(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ItemStack stack) {
    if (world.isRemote) {
        return;
    }
    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
    }
    AlchChestTile tile = ((AlchChestTile) world.getTileEntity(pos));
    byte coolDown = stack.getTagCompound().getByte("Cooldown");
    if (coolDown > 0) {
        stack.getTagCompound().setByte("Cooldown", (byte) (coolDown - 1));
    } else {
        boolean hasAction = false;
        IItemHandler inv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        for (int i = 0; i < inv.getSlots(); i++) {
            ItemStack invStack = inv.getStackInSlot(i);
            if (invStack == null || invStack.getItem() instanceof RingToggle || !invStack.getItem().isRepairable()) {
                continue;
            }
            if (ItemHelper.isDamageable(invStack) && invStack.getItemDamage() > 0) {
                invStack.setItemDamage(invStack.getItemDamage() - 1);
                if (!hasAction) {
                    hasAction = true;
                }
            }
        }
        if (hasAction) {
            stack.getTagCompound().setByte("Cooldown", (byte) 19);
            tile.markDirty();
        }
    }
}
Also used : AlchChestTile(moze_intel.projecte.gameObjs.tiles.AlchChestTile) IItemHandler(net.minecraftforge.items.IItemHandler) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) RingToggle(moze_intel.projecte.gameObjs.items.rings.RingToggle) ItemStack(net.minecraft.item.ItemStack)

Example 5 with AlchChestTile

use of moze_intel.projecte.gameObjs.tiles.AlchChestTile in project ProjectE by sinkillerj.

the class GuiHandler method getClientGuiElement.

@Override
public Object getClientGuiElement(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 GUIAlchChest(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 GUIAlchChest(player.inventory, hand, inventory);
            }
        case Constants.CONDENSER_GUI:
            if (tile != null && tile instanceof CondenserTile)
                return new GUICondenser(player.inventory, (CondenserTile) tile);
            break;
        case Constants.TRANSMUTE_STONE_GUI:
            return new GUITransmutation(player.inventory, new TransmutationInventory(player), null);
        case Constants.RM_FURNACE_GUI:
            if (tile != null && tile instanceof RMFurnaceTile)
                return new GUIRMFurnace(player.inventory, (RMFurnaceTile) tile);
            break;
        case Constants.DM_FURNACE_GUI:
            if (tile != null && tile instanceof DMFurnaceTile)
                return new GUIDMFurnace(player.inventory, (DMFurnaceTile) tile);
            break;
        case Constants.COLLECTOR1_GUI:
            if (tile != null && tile instanceof CollectorMK1Tile)
                return new GUICollectorMK1(player.inventory, (CollectorMK1Tile) tile);
            break;
        case Constants.COLLECTOR2_GUI:
            if (tile != null && tile instanceof CollectorMK2Tile)
                return new GUICollectorMK2(player.inventory, (CollectorMK2Tile) tile);
            break;
        case Constants.COLLECTOR3_GUI:
            if (tile != null && tile instanceof CollectorMK3Tile)
                return new GUICollectorMK3(player.inventory, (CollectorMK3Tile) tile);
            break;
        case Constants.RELAY1_GUI:
            if (tile != null && tile instanceof RelayMK1Tile)
                return new GUIRelayMK1(player.inventory, (RelayMK1Tile) tile);
            break;
        case Constants.RELAY2_GUI:
            if (tile != null && tile instanceof RelayMK2Tile)
                return new GUIRelayMK2(player.inventory, (RelayMK2Tile) tile);
            break;
        case Constants.RELAY3_GUI:
            if (tile != null && tile instanceof RelayMK3Tile)
                return new GUIRelayMK3(player.inventory, (RelayMK3Tile) tile);
            break;
        case Constants.MERCURIAL_GUI:
            return new GUIMercurialEye(player.inventory, new MercurialEyeInventory(player.getHeldItem(hand)));
        case Constants.PHILOS_STONE_GUI:
            return new GUIPhilosStone(player.inventory);
        case Constants.TRANSMUTATION_GUI:
            return new GUITransmutation(player.inventory, new TransmutationInventory(player), hand);
        case Constants.ETERNAL_DENSITY_GUI:
            return new GUIEternalDensity(player.inventory, new EternalDensityInventory(player.getHeldItem(hand), player));
        case Constants.CONDENSER_MK2_GUI:
            return new GUICondenserMK2(player.inventory, (CondenserMK2Tile) tile);
    }
    return null;
}
Also used : AlchChestTile(moze_intel.projecte.gameObjs.tiles.AlchChestTile) GUIRMFurnace(moze_intel.projecte.gameObjs.gui.GUIRMFurnace) GUITransmutation(moze_intel.projecte.gameObjs.gui.GUITransmutation) GUIMercurialEye(moze_intel.projecte.gameObjs.gui.GUIMercurialEye) CollectorMK3Tile(moze_intel.projecte.gameObjs.tiles.CollectorMK3Tile) RelayMK2Tile(moze_intel.projecte.gameObjs.tiles.RelayMK2Tile) TileEntity(net.minecraft.tileentity.TileEntity) GUIAlchChest(moze_intel.projecte.gameObjs.gui.GUIAlchChest) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) TransmutationInventory(moze_intel.projecte.gameObjs.container.inventory.TransmutationInventory) EnumHand(net.minecraft.util.EnumHand) GUIEternalDensity(moze_intel.projecte.gameObjs.gui.GUIEternalDensity) CondenserTile(moze_intel.projecte.gameObjs.tiles.CondenserTile) MercurialEyeInventory(moze_intel.projecte.gameObjs.container.inventory.MercurialEyeInventory) CollectorMK2Tile(moze_intel.projecte.gameObjs.tiles.CollectorMK2Tile) BlockPos(net.minecraft.util.math.BlockPos) GUICondenser(moze_intel.projecte.gameObjs.gui.GUICondenser) RelayMK1Tile(moze_intel.projecte.gameObjs.tiles.RelayMK1Tile) GUICollectorMK1(moze_intel.projecte.gameObjs.gui.GUICollectorMK1) GUICollectorMK2(moze_intel.projecte.gameObjs.gui.GUICollectorMK2) GUICollectorMK3(moze_intel.projecte.gameObjs.gui.GUICollectorMK3) EternalDensityInventory(moze_intel.projecte.gameObjs.container.inventory.EternalDensityInventory) GUIPhilosStone(moze_intel.projecte.gameObjs.gui.GUIPhilosStone) GUICondenserMK2(moze_intel.projecte.gameObjs.gui.GUICondenserMK2) DMFurnaceTile(moze_intel.projecte.gameObjs.tiles.DMFurnaceTile) CollectorMK1Tile(moze_intel.projecte.gameObjs.tiles.CollectorMK1Tile) EnumDyeColor(net.minecraft.item.EnumDyeColor) RMFurnaceTile(moze_intel.projecte.gameObjs.tiles.RMFurnaceTile) GUIDMFurnace(moze_intel.projecte.gameObjs.gui.GUIDMFurnace) GUIRelayMK1(moze_intel.projecte.gameObjs.gui.GUIRelayMK1) RelayMK3Tile(moze_intel.projecte.gameObjs.tiles.RelayMK3Tile) GUIRelayMK2(moze_intel.projecte.gameObjs.gui.GUIRelayMK2) GUIRelayMK3(moze_intel.projecte.gameObjs.gui.GUIRelayMK3)

Aggregations

AlchChestTile (moze_intel.projecte.gameObjs.tiles.AlchChestTile)5 EternalDensityInventory (moze_intel.projecte.gameObjs.container.inventory.EternalDensityInventory)2 MercurialEyeInventory (moze_intel.projecte.gameObjs.container.inventory.MercurialEyeInventory)2 TransmutationInventory (moze_intel.projecte.gameObjs.container.inventory.TransmutationInventory)2 CollectorMK1Tile (moze_intel.projecte.gameObjs.tiles.CollectorMK1Tile)2 CollectorMK2Tile (moze_intel.projecte.gameObjs.tiles.CollectorMK2Tile)2 CollectorMK3Tile (moze_intel.projecte.gameObjs.tiles.CollectorMK3Tile)2 CondenserTile (moze_intel.projecte.gameObjs.tiles.CondenserTile)2 DMFurnaceTile (moze_intel.projecte.gameObjs.tiles.DMFurnaceTile)2 RMFurnaceTile (moze_intel.projecte.gameObjs.tiles.RMFurnaceTile)2 RelayMK1Tile (moze_intel.projecte.gameObjs.tiles.RelayMK1Tile)2 RelayMK2Tile (moze_intel.projecte.gameObjs.tiles.RelayMK2Tile)2 RelayMK3Tile (moze_intel.projecte.gameObjs.tiles.RelayMK3Tile)2 EnumDyeColor (net.minecraft.item.EnumDyeColor)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumHand (net.minecraft.util.EnumHand)2 BlockPos (net.minecraft.util.math.BlockPos)2 IItemHandlerModifiable (net.minecraftforge.items.IItemHandlerModifiable)2 AlchBagContainer (moze_intel.projecte.gameObjs.container.AlchBagContainer)1