Search in sources :

Example 1 with IBindable

use of WayofTime.alchemicalWizardry.api.items.interfaces.IBindable in project BloodMagic by WayofTime.

the class RitualEffectExpulsion method performEffect.

@Override
public void performEffect(IMasterRitualStone ritualStone) {
    String owner = ritualStone.getOwner();
    int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
    World world = ritualStone.getWorld();
    int x = ritualStone.getXCoord();
    int y = ritualStone.getYCoord();
    int z = ritualStone.getZCoord();
    if (currentEssence < this.getCostPerRefresh()) {
        SoulNetworkHandler.causeNauseaToPlayer(owner);
    } else {
        boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false);
        boolean hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false);
        int teleportDistance = hasVirtus ? 300 : 100;
        int range = hasPotentia ? 50 : 25;
        List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range);
        boolean flag = false;
        TileEntity tile = world.getTileEntity(x, y + 1, z);
        IInventory inventoryTile = null;
        if (tile instanceof IInventory) {
            inventoryTile = (IInventory) tile;
        }
        for (EntityPlayer entityplayer : playerList) {
            if (entityplayer.capabilities.isCreativeMode) {
                continue;
            }
            String playerString = SpellHelper.getUsername(entityplayer);
            if (!playerString.equals(owner)) {
                if (inventoryTile != null) {
                    boolean test = false;
                    for (int i = 0; i < inventoryTile.getSizeInventory(); i++) {
                        ItemStack stack = inventoryTile.getStackInSlot(i);
                        if (stack != null && stack.getItem() instanceof IBindable && EnergyItems.getOwnerName(stack).equals(playerString)) {
                            test = true;
                        }
                    }
                    if (test) {
                        continue;
                    }
                }
                flag = teleportRandomly(entityplayer, teleportDistance) || flag;
            }
        }
        if (flag) {
            if (hasVirtus) {
                this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true);
            }
            if (hasPotentia) {
                this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true);
            }
            SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh());
        }
    }
    boolean hasTennebrae = this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, false);
    if (hasTennebrae && SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, 1000)) {
        boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false);
        boolean hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false);
        int teleportDistance = hasVirtus ? 300 : 100;
        int range = hasPotentia ? 50 : 25;
        List<EntityLivingBase> livingList = SpellHelper.getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range);
        boolean flag = false;
        for (EntityLivingBase livingEntity : livingList) {
            if (livingEntity instanceof EntityPlayer) {
                continue;
            }
            flag = teleportRandomly(livingEntity, teleportDistance) || flag;
        }
        if (flag) {
            if (hasVirtus) {
                this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true);
            }
            if (hasPotentia) {
                this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true);
            }
            this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, true);
            SoulNetworkHandler.syphonFromNetwork(owner, 1000);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) IBindable(WayofTime.alchemicalWizardry.api.items.interfaces.IBindable) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IBindable

use of WayofTime.alchemicalWizardry.api.items.interfaces.IBindable in project BloodMagic by WayofTime.

the class SubCommandBind method processSubCommand.

@Override
public void processSubCommand(ICommandSender commandSender, String[] args) {
    super.processSubCommand(commandSender, args);
    EntityPlayer player = getCommandSenderAsPlayer(commandSender);
    String playerName = player.getCommandSenderName();
    ItemStack held = player.getHeldItem();
    boolean bind = true;
    if (held != null && held.getItem() instanceof IBindable) {
        if (args.length > 0) {
            if (args[0].equalsIgnoreCase("help"))
                return;
            if (isBoolean(args[0])) {
                bind = Boolean.parseBoolean(args[0]);
                if (args.length > 2)
                    playerName = args[1];
            } else {
                playerName = args[0];
            }
        }
        if (bind) {
            EnergyItems.setItemOwner(held, playerName);
            commandSender.addChatMessage(new ChatComponentTranslation("commands.bind.success"));
        } else {
            if (!EnergyItems.getOwnerName(held).isEmpty()) {
                held.stackTagCompound.removeTag("ownerName");
                commandSender.addChatMessage(new ChatComponentTranslation("commands.bind.remove.success"));
            }
        }
    }
}
Also used : IBindable(WayofTime.alchemicalWizardry.api.items.interfaces.IBindable) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IBindable

use of WayofTime.alchemicalWizardry.api.items.interfaces.IBindable in project BloodMagic by WayofTime.

the class RitualEffectUnbinding method performEffect.

@Override
public void performEffect(IMasterRitualStone ritualStone) {
    String owner = ritualStone.getOwner();
    int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
    World world = ritualStone.getWorld();
    int x = ritualStone.getXCoord();
    int y = ritualStone.getYCoord();
    int z = ritualStone.getZCoord();
    if (currentEssence < this.getCostPerRefresh()) {
        SoulNetworkHandler.causeNauseaToPlayer(owner);
    } else {
        int d0 = 0;
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) x, (double) y + 1, (double) z, (double) (x + 1), (double) (y + 2), (double) (z + 1)).expand(d0, d0, d0);
        List list = world.getEntitiesWithinAABB(EntityItem.class, axisalignedbb);
        Iterator iterator = list.iterator();
        EntityItem item;
        boolean drain = false;
        while (iterator.hasNext()) {
            final int sanctusDrain = 1000;
            item = (EntityItem) iterator.next();
            ItemStack itemStack = item.getEntityItem();
            if (itemStack == null) {
                continue;
            }
            boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
            if (hasSanctus) {
                if (itemStack.getItem() instanceof IBindable && !EnergyItems.getOwnerName(itemStack).equals("")) {
                    world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z - 5));
                    world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5));
                    world.addWeatherEffect(new EntityLightningBolt(world, x - 5, y + 1, z));
                    world.addWeatherEffect(new EntityLightningBolt(world, x + 5, y + 1, z));
                    EnergyItems.setItemOwner(itemStack, "");
                    this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true);
                    drain = true;
                    ritualStone.setActive(false);
                    break;
                }
            }
            if (itemStack.getItem() == ModItems.boundHelmet) {
                ritualStone.setVar1(5);
            } else if (itemStack.getItem() == ModItems.boundPlate) {
                ritualStone.setVar1(8);
            } else if (itemStack.getItem() == ModItems.boundLeggings) {
                ritualStone.setVar1(7);
            } else if (itemStack.getItem() == ModItems.boundBoots) {
                ritualStone.setVar1(4);
            } else if (UnbindingRegistry.isRequiredItemValid(itemStack)) {
                ritualStone.setVar1(UnbindingRegistry.getIndexForItem(itemStack) + 9);
            }
            if (ritualStone.getVar1() > 0 && ritualStone.getVar1() <= 8) {
                item.setDead();
                doLightning(world, x, y, z);
                ItemStack[] inv = ((BoundArmour) itemStack.getItem()).getInternalInventory(itemStack);
                int bloodSockets = 0;
                if (itemStack.getItem() == ModItems.boundHelmet) {
                    bloodSockets = 5;
                } else if (itemStack.getItem() == ModItems.boundPlate) {
                    bloodSockets = 8;
                } else if (itemStack.getItem() == ModItems.boundLeggings) {
                    bloodSockets = 7;
                } else if (itemStack.getItem() == ModItems.boundBoots) {
                    bloodSockets = 4;
                }
                if (inv != null) {
                    for (ItemStack internalItem : inv) {
                        if (internalItem != null) {
                            doLightning(world, x, y, z);
                            EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, internalItem.copy());
                            world.spawnEntityInWorld(newItem);
                        }
                    }
                }
                EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, new ItemStack(ModBlocks.bloodSocket, bloodSockets));
                world.spawnEntityInWorld(newItem);
                ritualStone.setActive(false);
                drain = true;
                break;
            } else if (ritualStone.getVar1() >= 9) {
                item.setDead();
                doLightning(world, x, y, z);
                List<ItemStack> spawnedItem = UnbindingRegistry.getOutputForIndex(ritualStone.getVar1() - 9);
                if (spawnedItem != null) {
                    for (ItemStack itemStack1 : spawnedItem) {
                        EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, itemStack1.copy());
                        world.spawnEntityInWorld(newItem);
                    }
                }
                ritualStone.setActive(false);
                drain = true;
                break;
            }
        }
        if (drain) {
            SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh());
        }
    }
    if (world.rand.nextInt(10) == 0) {
        SpellHelper.sendIndexedParticleToAllAround(world, x, y, z, 20, world.provider.dimensionId, 1, x, y, z);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) IBindable(WayofTime.alchemicalWizardry.api.items.interfaces.IBindable) BoundArmour(WayofTime.alchemicalWizardry.common.items.armour.BoundArmour) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 4 with IBindable

use of WayofTime.alchemicalWizardry.api.items.interfaces.IBindable in project BloodMagic by WayofTime.

the class CommandBind method processCommand.

public void processCommand(ICommandSender iCommandSender, String[] astring) {
    EntityPlayerMP entityplayermp = getCommandSenderAsPlayer(iCommandSender);
    ItemStack item = entityplayermp.getCurrentEquippedItem();
    EntityPlayerMP targetPlayer = getPlayer(iCommandSender, astring[0]);
    if (targetPlayer == null) {
        throw new CommandException("commands.bind.failed.noPlayer");
    }
    if (item != null && item.getItem() instanceof IBindable) {
        if (EnergyItems.getOwnerName(item).isEmpty()) {
            EnergyItems.checkAndSetItemOwner(item, targetPlayer);
            func_152373_a(iCommandSender, this, "commands.bind.success");
        } else {
            throw new CommandException("commands.bind.failed.alreadyBound");
        }
    } else if (!(item.getItem() instanceof IBindable)) {
        throw new CommandException("commands.bind.failed.notBindable");
    }
}
Also used : IBindable(WayofTime.alchemicalWizardry.api.items.interfaces.IBindable) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) ItemStack(net.minecraft.item.ItemStack)

Example 5 with IBindable

use of WayofTime.alchemicalWizardry.api.items.interfaces.IBindable in project BloodMagic by WayofTime.

the class CommandUnbind method processCommand.

public void processCommand(ICommandSender iCommandSender, String[] astring) {
    EntityPlayerMP entityplayermp = getCommandSenderAsPlayer(iCommandSender);
    ItemStack item = entityplayermp.getCurrentEquippedItem();
    if (item != null && item.getItem() instanceof IBindable) {
        if (!EnergyItems.getOwnerName(item).isEmpty()) {
            item.getTagCompound().removeTag("ownerName");
            func_152373_a(iCommandSender, this, "commands.unbind.success");
        } else {
            throw new CommandException("commands.unbind.failed.notBindable");
        }
    } else if (!(item.getItem() instanceof IBindable)) {
        throw new CommandException("commands.unbind.failed.notBindable");
    }
}
Also used : IBindable(WayofTime.alchemicalWizardry.api.items.interfaces.IBindable) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IBindable (WayofTime.alchemicalWizardry.api.items.interfaces.IBindable)6 ItemStack (net.minecraft.item.ItemStack)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 World (net.minecraft.world.World)3 CommandException (net.minecraft.command.CommandException)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 BoundArmour (WayofTime.alchemicalWizardry.common.items.armour.BoundArmour)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityItem (net.minecraft.entity.item.EntityItem)1 IInventory (net.minecraft.inventory.IInventory)1 Item (net.minecraft.item.Item)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1