use of net.minecraft.nbt.NBTTagFloat in project LogisticsPipes by RS485.
the class DebugHelper method addNBTToTree.
private void addNBTToTree(NBTBase nbt, DefaultMutableTreeNode node) throws SecurityException, IllegalArgumentException {
if (nbt == null) {
return;
}
if (nbt instanceof NBTTagByte) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagByte");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagByte) nbt).getByte()));
node.add(type);
} else if (nbt instanceof NBTTagByteArray) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagByteArray");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
int i = 0;
for (byte byt : ((NBTTagByteArray) nbt).getByteArray()) {
content.add(new DefaultMutableTreeNode("[" + i + "]: " + byt));
i++;
}
node.add(content);
node.add(type);
} else if (nbt instanceof NBTTagDouble) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagDouble");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagDouble) nbt).getDouble()));
node.add(type);
} else if (nbt instanceof NBTTagFloat) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagFloat");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagFloat) nbt).getFloat()));
node.add(type);
} else if (nbt instanceof NBTTagInt) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagInt");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagInt) nbt).getInt()));
node.add(type);
} else if (nbt instanceof NBTTagIntArray) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagIntArray");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
int i = 0;
for (int byt : ((NBTTagIntArray) nbt).getIntArray()) {
content.add(new DefaultMutableTreeNode("[" + i + "]: " + byt));
i++;
}
type.add(content);
node.add(type);
} else if (nbt instanceof NBTTagList) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagList");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
int i = 0;
for (NBTBase object : (NBTTagList) nbt) {
DefaultMutableTreeNode nbtNode = new DefaultMutableTreeNode("[" + i + "]");
addNBTToTree(object, nbtNode);
content.add(nbtNode);
i++;
}
type.add(content);
node.add(type);
} else if (nbt instanceof NBTTagCompound) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagCompound");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
for (String key : ((NBTTagCompound) nbt).getKeySet()) {
NBTBase value = ((NBTTagCompound) nbt).getTag(key);
DefaultMutableTreeNode nbtNode = new DefaultMutableTreeNode(key);
addNBTToTree(value, nbtNode);
content.add(nbtNode);
}
type.add(content);
node.add(type);
} else if (nbt instanceof NBTTagLong) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagLong");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagLong) nbt).getLong()));
node.add(type);
} else if (nbt instanceof NBTTagShort) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagShort");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagShort) nbt).getShort()));
node.add(type);
} else if (nbt instanceof NBTTagString) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagString");
type.add(new DefaultMutableTreeNode("Data: '" + ((NBTTagString) nbt).getString() + "'"));
node.add(type);
} else {
throw new UnsupportedOperationException("Unsupported NBTBase of type:" + nbt.getClass().getName());
}
}
use of net.minecraft.nbt.NBTTagFloat in project SimplyJetpacks by Tonius.
the class ItemMysteriousPotato method onItemUse.
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int meta, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityMobSpawner) {
NBTTagCompound tag = new NBTTagCompound();
tile.writeToNBT(tag);
tag.setString("EntityId", "Zombie");
NBTTagList spawnPotentials = new NBTTagList();
NBTTagCompound zombieSpawn = new NBTTagCompound();
zombieSpawn.setString("Type", "Zombie");
zombieSpawn.setInteger("Weight", 1);
NBTTagCompound zombieSpawnProperties = new NBTTagCompound();
zombieSpawnProperties.setString("id", "Zombie");
NBTTagList equipment = new NBTTagList();
equipment.appendTag(new NBTTagCompound());
equipment.appendTag(new NBTTagCompound());
equipment.appendTag(new NBTTagCompound());
equipment.appendTag(ModItems.jetpackPotato.writeToNBT(new NBTTagCompound()));
zombieSpawnProperties.setTag("Equipment", equipment);
NBTTagList dropChances = new NBTTagList();
for (int i = 0; i <= 4; i++) {
dropChances.appendTag(new NBTTagFloat(0.0F));
}
zombieSpawnProperties.setTag("DropChances", dropChances);
zombieSpawn.setTag("Properties", zombieSpawnProperties);
spawnPotentials.appendTag(zombieSpawn);
tag.setTag("SpawnPotentials", spawnPotentials);
tag.setShort("SpawnCount", (short) 2);
tag.setShort("SpawnRange", (short) 8);
tag.setShort("Delay", (short) -1);
tag.setShort("MinSpawnDelay", (short) 30);
tag.setShort("MaxSpawnDelay", (short) 60);
tag.setShort("MaxNearbyEntities", (short) 10);
tag.setShort("RequiredPlayerRange", (short) 96);
tile.readFromNBT(tag);
}
}
return true;
}
use of net.minecraft.nbt.NBTTagFloat in project MorePlanets by SteveKunG.
the class ItemElectricHoeMP method getElectricityStored.
@Override
public float getElectricityStored(ItemStack itemStack) {
if (!itemStack.hasTagCompound()) {
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 ItemElectricShovelMP method getElectricityStored.
@Override
public float getElectricityStored(ItemStack itemStack) {
if (!itemStack.hasTagCompound()) {
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.hasTagCompound()) {
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;
}
Aggregations