Search in sources :

Example 6 with TEMasterStone

use of WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone in project BloodMagic by WayofTime.

the class ItemRitualDismantler method breakRitualStoneAtMasterStone.

public boolean breakRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity instanceof TEMasterStone) {
        TEMasterStone masterStone = (TEMasterStone) tileEntity;
        int direction = masterStone.getDirection();
        String ritualName = Rituals.checkValidRitual(world, x, y, z);
        List<RitualComponent> ritualList = Rituals.getRitualList(ritualName);
        if (ritualList == null) {
            return false;
        }
        for (RitualComponent rc : ritualList) {
            if (!world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) && world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) instanceof RitualStone) {
                if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed()) || player.capabilities.isCreativeMode) {
                    world.setBlockToAir(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
                    EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(ModBlocks.ritualStone));
                    if (world.isRemote) {
                        world.playAuxSFX(2005, x, y + 1, z, 0);
                    } else {
                        world.spawnEntityInWorld(entityItem);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RitualComponent(WayofTime.alchemicalWizardry.api.rituals.RitualComponent) TEMasterStone(WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone) ItemStack(net.minecraft.item.ItemStack) RitualStone(WayofTime.alchemicalWizardry.common.block.RitualStone) EntityItem(net.minecraft.entity.item.EntityItem)

Example 7 with TEMasterStone

use of WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone in project BloodMagic by WayofTime.

the class ItemRitualDiviner method placeRitualStoneAtMasterStone.

public boolean placeRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
    int direction = this.getDirection(stack);
    ItemStack[] playerInventory = player.inventory.mainInventory;
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity instanceof TEMasterStone) {
        List<RitualComponent> ritualList = Rituals.getRitualList(this.getCurrentRitual(stack));
        if (ritualList == null) {
            return false;
        }
        int playerInvRitualStoneLocation = -1;
        for (int i = 0; i < playerInventory.length; i++) {
            if (playerInventory[i] == null) {
                continue;
            }
            if (new ItemStack(ModBlocks.ritualStone).isItemEqual(playerInventory[i])) {
                playerInvRitualStoneLocation = i;
                break;
            }
        }
        for (RitualComponent rc : ritualList) {
            if (world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction))) {
                if (playerInvRitualStoneLocation >= 0 || player.capabilities.isCreativeMode) {
                    if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) {
                        world.playAuxSFX(200, x, y + 1, z, 0);
                        return true;
                    }
                    if (!player.capabilities.isCreativeMode) {
                        player.inventory.decrStackSize(playerInvRitualStoneLocation, 1);
                    }
                    if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
                        world.setBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction), ModBlocks.ritualStone, rc.getStoneType(), 3);
                        if (world.isRemote) {
                            world.playAuxSFX(2005, x, y + 1, z, 0);
                            return true;
                        }
                    }
                    return true;
                }
            } else {
                Block block = world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
                if (block == ModBlocks.ritualStone) {
                    int metadata = world.getBlockMetadata(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
                    if (metadata != rc.getStoneType()) {
                        if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
                            if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) {
                                world.playAuxSFX(200, x, y + 1, z, 0);
                                return true;
                            }
                            world.setBlockMetadataWithNotify(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction), rc.getStoneType(), 3);
                            return true;
                        }
                    }
                } else {
                    world.playAuxSFX(0, x, y + 1, z, 0);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RitualComponent(WayofTime.alchemicalWizardry.api.rituals.RitualComponent) Block(net.minecraft.block.Block) TEMasterStone(WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TEMasterStone (WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone)7 TileEntity (net.minecraft.tileentity.TileEntity)5 ItemStack (net.minecraft.item.ItemStack)3 RitualComponent (WayofTime.alchemicalWizardry.api.rituals.RitualComponent)2 MRSRenderer (WayofTime.alchemicalWizardry.api.renderer.MRSRenderer)1 RitualStone (WayofTime.alchemicalWizardry.common.block.RitualStone)1 ActivationCrystal (WayofTime.alchemicalWizardry.common.items.ActivationCrystal)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Block (net.minecraft.block.Block)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 Item (net.minecraft.item.Item)1