use of net.minecraft.nbt.NBTTagFloat in project MorePlanets by SteveKunG.
the class ItemElectricShovelMP method getElectricityStored.
@Override
public float getElectricityStored(ItemStack itemStack) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
float energyStored = 0f;
if (itemStack.getTagCompound().hasKey("Electricity")) {
NBTBase obj = itemStack.getTagCompound().getTag("Electricity");
if (obj instanceof NBTTagDouble) {
energyStored = ((NBTTagDouble) obj).getFloat();
} else if (obj instanceof NBTTagFloat) {
energyStored = ((NBTTagFloat) obj).getFloat();
}
}
itemStack.setItemDamage((int) (100 - energyStored / this.getMaxElectricityStored(itemStack) * 100));
return energyStored;
}
use of net.minecraft.nbt.NBTTagFloat in project MorePlanets by SteveKunG.
the class ItemElectricAxeMP method getElectricityStored.
@Override
public float getElectricityStored(ItemStack itemStack) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
float energyStored = 0f;
if (itemStack.getTagCompound().hasKey("Electricity")) {
NBTBase obj = itemStack.getTagCompound().getTag("Electricity");
if (obj instanceof NBTTagDouble) {
energyStored = ((NBTTagDouble) obj).getFloat();
} else if (obj instanceof NBTTagFloat) {
energyStored = ((NBTTagFloat) obj).getFloat();
}
}
itemStack.setItemDamage((int) (100 - energyStored / this.getMaxElectricityStored(itemStack) * 100));
return energyStored;
}
use of net.minecraft.nbt.NBTTagFloat in project MorePlanets by SteveKunG.
the class ItemElectricPickaxeMP method getElectricityStored.
@Override
public float getElectricityStored(ItemStack itemStack) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
float energyStored = 0f;
if (itemStack.getTagCompound().hasKey("Electricity")) {
NBTBase obj = itemStack.getTagCompound().getTag("Electricity");
if (obj instanceof NBTTagDouble) {
energyStored = ((NBTTagDouble) obj).getFloat();
} else if (obj instanceof NBTTagFloat) {
energyStored = ((NBTTagFloat) obj).getFloat();
}
}
itemStack.setItemDamage((int) (100 - energyStored / this.getMaxElectricityStored(itemStack) * 100));
return energyStored;
}
use of net.minecraft.nbt.NBTTagFloat in project MorePlanets by SteveKunG.
the class ItemElectricSwordMP method getElectricityStored.
@Override
public float getElectricityStored(ItemStack itemStack) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
float energyStored = 0f;
if (itemStack.getTagCompound().hasKey("Electricity")) {
NBTBase obj = itemStack.getTagCompound().getTag("Electricity");
if (obj instanceof NBTTagDouble) {
energyStored = ((NBTTagDouble) obj).getFloat();
} else if (obj instanceof NBTTagFloat) {
energyStored = ((NBTTagFloat) obj).getFloat();
}
}
itemStack.setItemDamage((int) (100 - energyStored / this.getMaxElectricityStored(itemStack) * 100));
return energyStored;
}
use of net.minecraft.nbt.NBTTagFloat in project BuildCraft by BuildCraft.
the class NbtSquisherTester method genNbt.
private static NBTTagCompound genNbt(int bptSize) {
Random rand = new Random(0x517123);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setByte("primitive|byte", (byte) 1);
nbt.setShort("primitive|short", (short) 2);
nbt.setInteger("primitive|int", 4);
nbt.setLong("primitive|long", 6);
nbt.setFloat("primitive|float", 10.01f);
nbt.setDouble("primitive|double", 11.11010101010101001010);
nbt.setByteArray("array|byte", new byte[] { 12, 13, 14 });
nbt.setIntArray("array|int", new int[] { 15000, 160000, 17000, 180000 });
nbt.setString("string", "OMG A VALUE");
NBTTagList list = new NBTTagList();
list.appendTag(new NBTTagFloat(19.91f));
list.appendTag(new NBTTagFloat(19.45f));
list.appendTag(new NBTTagFloat(19.41f));
list.appendTag(new NBTTagFloat(19.32f));
list.appendTag(new NBTTagFloat(19.76f));
nbt.setTag("complex|list", list);
nbt.setTag("complex|tag", new NBTTagCompound());
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("a", false);
compound.setDouble("b", 20.02);
nbt.setTag("complex|compound", compound);
String[] names = { "minecraft:air", "minecraft:log", "minecraft:torch", "minecraft:stone", "minecraft:fence" };
int[] metas = { 1, 16, 5, 7, 4 };
NBTTagCompound[] blocks = new NBTTagCompound[sum(metas)];
int block = 0;
for (int b = 0; b < names.length; b++) {
NBTTagCompound blockNbt = new NBTTagCompound();
blockNbt.setString("id", names[b]);
blocks[block++] = blockNbt.copy();
for (int m = 1; m < metas[b]; m++) {
blockNbt.setByte("meta", (byte) m);
blocks[block++] = blockNbt.copy();
}
}
NBTTagCompound air = blocks[0];
NBTTagList bpt = new NBTTagList();
int chests = 0;
for (int i = 0; i < bptSize; i++) {
double r = rand.nextDouble();
final NBTTagCompound toUse;
if (r < 0.4) {
toUse = air;
} else if (r < 0.9999) {
toUse = blocks[rand.nextInt(blocks.length)];
} else {
toUse = genRandomChest(rand);
chests++;
}
bpt.appendTag(toUse);
}
System.out.println(chests + " random chests in a " + Math.cbrt(bptSize) + " bpt");
nbt.setTag("bpt", bpt);
return nbt;
}
Aggregations