Search in sources :

Example 1 with IAltarManipulator

use of WayofTime.alchemicalWizardry.api.items.IAltarManipulator in project BloodMagic by WayofTime.

the class BlockAltar method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) {
    TEAltar tileEntity = (TEAltar) world.getTileEntity(x, y, z);
    if (tileEntity == null || player.isSneaking()) {
        return false;
    }
    ItemStack playerItem = player.getCurrentEquippedItem();
    if (playerItem != null) {
        if (playerItem.getItem().equals(ModItems.divinationSigil)) {
            if (player.worldObj.isRemote) {
                world.markBlockForUpdate(x, y, z);
            } else {
                tileEntity.sendChatInfoToPlayer(player);
            }
            return true;
        } else if (playerItem.getItem().equals(ModItems.itemSeerSigil)) {
            if (player.worldObj.isRemote) {
                world.markBlockForUpdate(x, y, z);
            } else {
                tileEntity.sendMoreChatInfoToPlayer(player);
            }
            return true;
        } else if (playerItem.getItem() instanceof IAltarManipulator) {
            return false;
        } else if (playerItem.getItem().equals(ModItems.sigilOfHolding)) {
            ItemStack item = SigilOfHolding.getCurrentSigil(playerItem);
            if (item != null && item.getItem().equals(ModItems.divinationSigil)) {
                if (player.worldObj.isRemote) {
                    world.markBlockForUpdate(x, y, z);
                } else {
                    tileEntity.sendChatInfoToPlayer(player);
                }
                return true;
            } else if (item != null && item.getItem().equals(ModItems.itemSeerSigil)) {
                if (player.worldObj.isRemote) {
                    world.markBlockForUpdate(x, y, z);
                } else {
                    tileEntity.sendMoreChatInfoToPlayer(player);
                }
                return true;
            }
        }
    }
    if (tileEntity.getStackInSlot(0) == null && playerItem != null) {
        ItemStack newItem = playerItem.copy();
        newItem.stackSize = 1;
        --playerItem.stackSize;
        tileEntity.setInventorySlotContents(0, newItem);
        tileEntity.startCycle();
    } else if (tileEntity.getStackInSlot(0) != null && playerItem == null) {
        player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
        tileEntity.setInventorySlotContents(0, null);
        tileEntity.setActive();
    }
    world.markBlockForUpdate(x, y, z);
    return true;
}
Also used : IAltarManipulator(WayofTime.alchemicalWizardry.api.items.IAltarManipulator) TEAltar(WayofTime.alchemicalWizardry.common.tileEntity.TEAltar) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IAltarManipulator (WayofTime.alchemicalWizardry.api.items.IAltarManipulator)1 TEAltar (WayofTime.alchemicalWizardry.common.tileEntity.TEAltar)1 ItemStack (net.minecraft.item.ItemStack)1