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);
}
}
}
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"));
}
}
}
}
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);
}
}
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");
}
}
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");
}
}
Aggregations