use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.
the class BlockManaBattery method destroy.
private void destroy(World world, int i, int j, int k) {
TileEntityManaBattery te = getTileEntity(world, i, j, k);
if (te != null && !world.isRemote) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
int dmg = (int) ((PowerNodeRegistry.For(world).getPower(te, te.getPowerType()) / te.getCapacity()) * 100);
if (dmg == 0)
dmg = 1;
ItemStack stack = new ItemStack(this);
stack.damageItem(stack.getMaxDamage() - dmg, new EntityDummyCaster(world));
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setFloat("mana_battery_charge", PowerNodeRegistry.For(world).getPower(te, te.getPowerType()));
stack.stackTagCompound.setInteger("mana_battery_powertype", te.getPowerType().ID());
if (!stack.stackTagCompound.hasKey("Lore"))
stack.stackTagCompound.setTag("Lore", new NBTTagList());
NBTTagList tagList = new NBTTagList();
PowerTypes powerType = te.getPowerType();
float amt = PowerNodeRegistry.For(world).getPower(te, powerType);
tagList.appendTag(new NBTTagString(String.format("Contains %.2f %s%s etherium", amt, powerType.chatColor(), powerType.name())));
stack.stackTagCompound.setTag("Lore", tagList);
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, stack);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.
the class BlockManaBattery method getSubBlocks.
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
ItemStack stack = new ItemStack(this);
par3List.add(stack);
for (PowerTypes type : PowerTypes.all()) {
stack = new ItemStack(this, 1, type.ID());
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setFloat("mana_battery_charge", new TileEntityManaBattery().getCapacity());
stack.stackTagCompound.setInteger("mana_battery_powertype", type.ID());
par3List.add(stack);
}
}
use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.
the class BlockManaBattery method colorMultiplier.
@Override
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) {
int metadata = blockAccess.getBlockMetadata(x, y, z);
PowerTypes type = PowerTypes.getByID(metadata);
if (type == PowerTypes.DARK)
return 0x850e0e;
else if (type == PowerTypes.LIGHT)
return 0x61cfc3;
else if (type == PowerTypes.NEUTRAL)
return 0x2683d2;
else
return 0xFFFFFF;
}
use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.
the class ClientProxy method drawPowerOnBlockHighlight.
@Override
public void drawPowerOnBlockHighlight(EntityPlayer player, MovingObjectPosition target, float partialTicks) {
if (AMCore.proxy.getLocalPlayer().getCurrentArmor(3) != null && (AMCore.proxy.getLocalPlayer().getCurrentArmor(3).getItem() == ItemsCommonProxy.magitechGoggles || ArmorHelper.isInfusionPreset(AMCore.proxy.getLocalPlayer().getCurrentArmor(3), GenericImbuement.magitechGoggleIntegration))) {
TileEntity te = player.worldObj.getTileEntity(target.blockX, target.blockY, target.blockZ);
if (te != null && te instanceof IPowerNode) {
AMCore.proxy.setTrackedLocation(new AMVector3(target.blockX, target.blockY, target.blockZ));
} else {
AMCore.proxy.setTrackedLocation(AMVector3.zero());
}
if (AMCore.proxy.hasTrackedLocationSynced()) {
PowerNodeEntry data = AMCore.proxy.getTrackedData();
Block block = player.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
float yOff = 0.5f;
if (data != null) {
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
for (PowerTypes type : ((IPowerNode) te).getValidPowerTypes()) {
float pwr = data.getPower(type);
float pct = pwr / ((IPowerNode) te).getCapacity() * 100;
RenderUtilities.drawTextInWorldAtOffset(String.format("%s%.2f (%.2f%%)", type.chatColor(), pwr, pct), target.blockX - (player.prevPosX - (player.prevPosX - player.posX) * partialTicks) + 0.5f, target.blockY + yOff - (player.prevPosY - (player.prevPosY - player.posY) * partialTicks) + block.getBlockBoundsMaxY() * 0.8f, target.blockZ - (player.prevPosZ - (player.prevPosZ - player.posZ) * partialTicks) + 0.5f, 0xFFFFFF);
yOff += 0.12f;
}
GL11.glPopAttrib();
}
}
}
}
use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.
the class SpellRecipeManager method ParseEssenceIDs.
public static int[] ParseEssenceIDs(String s) {
if (s.toLowerCase().equals("e:*")) {
int[] all = new int[PowerTypes.all().length];
int count = 0;
for (PowerTypes type : PowerTypes.all()) {
all[count++] = type.ID();
}
return all;
}
s = s.toLowerCase().replace("e:", "");
String[] split = s.split("\\|");
int[] ids = new int[split.length];
for (int i = 0; i < split.length; ++i) {
try {
ids[i] = Integer.parseInt(split[i]);
} catch (NumberFormatException nex) {
LogHelper.warn("Invalid power type ID while parsing value %s", s);
ids[i] = 0;
}
}
return ids;
}
Aggregations