net.minecraft.nbt.NBTTagIntArray Java Examples
The following examples show how to use
net.minecraft.nbt.NBTTagIntArray.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiEditSingleNBT.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
private static String getValue(NBTBase base) { switch (base.getId()) { case 7: { String s = ""; for (byte b : ((NBTTagByteArray) base).func_150292_c()) { s = s + b + " "; } return s; } case 9: { return "TagList"; } case 10: { return "TagCompound"; } case 11: { String i = ""; for (int a : ((NBTTagIntArray) base).func_150302_c()) { i = i + a + " "; } return i; } } return NBTStringHelper.toString(base); }
Example #2
Source File: GuiEditNBT.java From NBTEdit with GNU General Public License v3.0 | 6 votes |
private static String getValue(NBTBase base){ switch(base.getId()){ case 7: String s = ""; for (byte b : ((NBTTagByteArray)base).func_150292_c() /*byteArray*/){ s += b + " "; } return s; case 9: return "TagList"; case 10: return "TagCompound"; case 11: String i = ""; for (int a : ((NBTTagIntArray)base).func_150302_c() /*intArray*/){ i += a + " "; } return i; default: return NBTStringHelper.toString(base); } }
Example #3
Source File: GuiEditNBT.java From NBTEdit with GNU General Public License v3.0 | 6 votes |
private static void setValidValue(Node<NamedNBT> node, String value){ NamedNBT named = node.getObject(); NBTBase base = named.getNBT(); if (base instanceof NBTTagByte) named.setNBT(new NBTTagByte(ParseHelper.parseByte(value))); if (base instanceof NBTTagShort) named.setNBT(new NBTTagShort(ParseHelper.parseShort(value))); if (base instanceof NBTTagInt) named.setNBT(new NBTTagInt(ParseHelper.parseInt(value))); if (base instanceof NBTTagLong) named.setNBT(new NBTTagLong(ParseHelper.parseLong(value))); if(base instanceof NBTTagFloat) named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value))); if(base instanceof NBTTagDouble) named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value))); if(base instanceof NBTTagByteArray) named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value))); if(base instanceof NBTTagIntArray) named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value))); if (base instanceof NBTTagString) named.setNBT(new NBTTagString(value)); }
Example #4
Source File: DataAchromatic.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void writeToPacket(NBTTagCompound compound) { int[] array = new int[removeClientQueue.size()]; for (int i = 0; i < removeClientQueue.size(); i++) { array[i] = removeClientQueue.get(i); } compound.setTag("removals", new NBTTagIntArray(array)); array = new int[addClientQueue.size()]; for (int i = 0; i < addClientQueue.size(); i++) { array[i] = addClientQueue.get(i); } compound.setTag("additions", new NBTTagIntArray(array)); removeClientQueue.clear(); addClientQueue.clear(); }
Example #5
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reads an unknown object withPriority a known name from NBT * @param tag - tag to read the value from * @param key - name of the value * @return object or suggestionValue if nothing is found */ public Object load(NBTTagCompound tag, String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); if (saveTag instanceof NBTTagFloat) { return tag.getFloat(key); } else if (saveTag instanceof NBTTagDouble) { return tag.getDouble(key); } else if (saveTag instanceof NBTTagInt) { return tag.getInteger(key); } else if (saveTag instanceof NBTTagString) { if (tag.getBoolean(key + "::nova.isBigInteger")) { return new BigInteger(tag.getString(key)); } else if (tag.getBoolean(key + "::nova.isBigDecimal")) { return new BigDecimal(tag.getString(key)); } else { return tag.getString(key); } } else if (saveTag instanceof NBTTagShort) { return tag.getShort(key); } else if (saveTag instanceof NBTTagByte) { if (tag.getBoolean(key + "::nova.isBoolean")) { return tag.getBoolean(key); } else { return tag.getByte(key); } } else if (saveTag instanceof NBTTagLong) { return tag.getLong(key); } else if (saveTag instanceof NBTTagByteArray) { return tag.getByteArray(key); } else if (saveTag instanceof NBTTagIntArray) { return tag.getIntArray(key); } else if (saveTag instanceof NBTTagCompound) { NBTTagCompound innerTag = tag.getCompoundTag(key); return toNova(innerTag); } } return null; }
Example #6
Source File: Firework.java From minecraft-roguelike with GNU General Public License v3.0 | 5 votes |
public static ItemStack get(Random rand, int stackSize){ ItemStack rocket = new ItemStack(Items.FIREWORKS, stackSize); NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound fireworks = new NBTTagCompound(); fireworks.setByte("Flight", (byte) (rand.nextInt(3) + 1)); NBTTagList explosion = new NBTTagList(); NBTTagCompound properties = new NBTTagCompound(); properties.setByte("Flicker", (byte) (rand.nextBoolean() ? 1 : 0)); properties.setByte("Trail", (byte) (rand.nextBoolean() ? 1 : 0)); properties.setByte("Type", (byte) (rand.nextInt(5))); int size = rand.nextInt(4) + 1; int[] colorArr = new int[size]; for(int i = 0; i < size; ++i){ colorArr[i] = DyeColor.HSLToColor(rand.nextFloat(), (float)1.0, (float)0.5); } NBTTagIntArray colors = new NBTTagIntArray(colorArr); properties.setTag("Colors", colors); explosion.appendTag(properties); fireworks.setTag("Explosions", explosion); tag.setTag("Fireworks", fireworks); rocket.setTagCompound(tag); return rocket; }
Example #7
Source File: NBTStringHelper.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
public static NBTBase newTag(byte type){ switch (type) { case 0: return new NBTTagEnd(); case 1: return new NBTTagByte((byte) 0); case 2: return new NBTTagShort(); case 3: return new NBTTagInt(0); case 4: return new NBTTagLong(0); case 5: return new NBTTagFloat(0); case 6: return new NBTTagDouble(0); case 7: return new NBTTagByteArray(new byte[0]); case 8: return new NBTTagString(""); case 9: return new NBTTagList(); case 10: return new NBTTagCompound(); case 11: return new NBTTagIntArray(new int[0]); default: return null; } }
Example #8
Source File: DataAchromatic.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void writeAllDataToPacket(NBTTagCompound compound) { int[] array = new int[achromaticEntities.size()]; for (int i = 0; i < achromaticEntities.size(); i++) { array[i] = achromaticEntities.get(i); } compound.setTag("additions", new NBTTagIntArray(array)); compound.setTag("removals", new NBTTagIntArray(new int[0])); }
Example #9
Source File: NBTStringHelper.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
public static NBTBase newTag(byte type) { switch (type) { case 1: { return new NBTTagCompound(); } case 2: { return new NBTTagByte((byte) 0); } case 3: { return new NBTTagShort(); } case 4: { return new NBTTagInt(0); } case 5: { return new NBTTagLong(0L); } case 6: { return new NBTTagFloat(0.0f); } case 7: { return new NBTTagDouble(0.0); } case 8: { return new NBTTagString(""); } case 9: { return new NBTTagList(); } case 10: { return new NBTTagByteArray(new byte[0]); } case 11: { return new NBTTagIntArray(new int[0]); } } return null; }
Example #10
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reads an unknown object withPriority a known name from NBT * @param tag - tag to read the value from * @param key - name of the value * @return object or suggestionValue if nothing is found */ public Object load(NBTTagCompound tag, String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); if (saveTag instanceof NBTTagFloat) { return tag.getFloat(key); } else if (saveTag instanceof NBTTagDouble) { return tag.getDouble(key); } else if (saveTag instanceof NBTTagInt) { return tag.getInteger(key); } else if (saveTag instanceof NBTTagString) { if (tag.getBoolean(key + "::nova.isBigInteger")) { return new BigInteger(tag.getString(key)); } else if (tag.getBoolean(key + "::nova.isBigDecimal")) { return new BigDecimal(tag.getString(key)); } else { return tag.getString(key); } } else if (saveTag instanceof NBTTagShort) { return tag.getShort(key); } else if (saveTag instanceof NBTTagByte) { if (tag.getBoolean(key + "::nova.isBoolean")) { return tag.getBoolean(key); } else { return tag.getByte(key); } } else if (saveTag instanceof NBTTagLong) { return tag.getLong(key); } else if (saveTag instanceof NBTTagByteArray) { return tag.getByteArray(key); } else if (saveTag instanceof NBTTagIntArray) { return tag.getIntArray(key); } else if (saveTag instanceof NBTTagCompound) { NBTTagCompound innerTag = tag.getCompoundTag(key); return toNova(innerTag); } } return null; }
Example #11
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reads an unknown object withPriority a known name from NBT * @param tag - tag to read the value from * @param key - name of the value * @return object or suggestionValue if nothing is found */ @Nullable public Object load(@Nullable NBTTagCompound tag, @Nullable String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); if (saveTag instanceof NBTTagFloat) { return tag.getFloat(key); } else if (saveTag instanceof NBTTagDouble) { return tag.getDouble(key); } else if (saveTag instanceof NBTTagInt) { return tag.getInteger(key); } else if (saveTag instanceof NBTTagString) { return tag.getString(key); } else if (saveTag instanceof NBTTagShort) { return tag.getShort(key); } else if (saveTag instanceof NBTTagByte) { if (tag.getBoolean("isBoolean")) { return tag.getBoolean(key); } else { return tag.getByte(key); } } else if (saveTag instanceof NBTTagLong) { return tag.getLong(key); } else if (saveTag instanceof NBTTagByteArray) { return tag.getByteArray(key); } else if (saveTag instanceof NBTTagIntArray) { return tag.getIntArray(key); } else if (saveTag instanceof NBTTagCompound) { NBTTagCompound innerTag = tag.getCompoundTag(key); return toNova(innerTag); } } return null; }
Example #12
Source File: StorageLastRelay.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public void readNBT(Capability<ICapabilityLastRelay> capability, ICapabilityLastRelay instance, EnumFacing side, NBTBase nbt) { NBTTagIntArray tag = (NBTTagIntArray) nbt; int[] backingArray = tag.getIntArray(); //If all these values are 0, then assume the blockPos was just null anyways if (!(backingArray[0] == 0 && backingArray[1] == 0 && backingArray[2] == 0)) { BlockPos pos = new BlockPos(backingArray[0], backingArray[1], backingArray[2]); instance.setLastRelay(pos); } }
Example #13
Source File: StorageLastRelay.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public NBTBase writeNBT(Capability<ICapabilityLastRelay> capability, ICapabilityLastRelay instance, EnumFacing side) { int x = 0, y = 0, z = 0; if (instance.hasLastRelay()) { x = instance.getLastRelay().getX(); y = instance.getLastRelay().getY(); z = instance.getLastRelay().getZ(); } return new NBTTagIntArray(new int[]{x, y, z}); }
Example #14
Source File: GuiEditSingleNBT.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
private static void setValidValue(Node<NamedNBT> node, String value) { NamedNBT named = node.getObject(); NBTBase base = named.getNBT(); if (base instanceof NBTTagByte) { named.setNBT(new NBTTagByte(ParseHelper.parseByte(value))); } if (base instanceof NBTTagShort) { named.setNBT(new NBTTagShort(ParseHelper.parseShort(value))); } if (base instanceof NBTTagInt) { named.setNBT(new NBTTagInt(ParseHelper.parseInt(value))); } if (base instanceof NBTTagLong) { named.setNBT(new NBTTagLong(ParseHelper.parseLong(value))); } if (base instanceof NBTTagFloat) { named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value))); } if (base instanceof NBTTagDouble) { named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value))); } if (base instanceof NBTTagByteArray) { named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value))); } if (base instanceof NBTTagIntArray) { named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value))); } if (base instanceof NBTTagString) { named.setNBT(new NBTTagString(value)); } }
Example #15
Source File: StorageChunk.java From AdvancedRocketry with MIT License | 4 votes |
public void writeToNBT(NBTTagCompound nbt) { nbt.setInteger("xSize", sizeX); nbt.setInteger("ySize", sizeY); nbt.setInteger("zSize", sizeZ); Iterator<TileEntity> tileEntityIterator = tileEntities.iterator(); NBTTagList tileList = new NBTTagList(); while(tileEntityIterator.hasNext()) { TileEntity tile = tileEntityIterator.next(); try { NBTTagCompound tileNbt = new NBTTagCompound(); tile.writeToNBT(tileNbt); tileList.appendTag(tileNbt); } catch(RuntimeException e) { AdvancedRocketry.logger.warn("A tile entity has thrown an error: " + tile.getClass().getCanonicalName()); blocks[tile.getPos().getX()][tile.getPos().getY()][tile.getPos().getZ()] = Blocks.AIR; metas[tile.getPos().getX()][tile.getPos().getY()][tile.getPos().getZ()] = 0; tileEntityIterator.remove(); } } int[] blockId = new int[sizeX*sizeY*sizeZ]; int[] metasId = new int[sizeX*sizeY*sizeZ]; for(int x = 0; x < sizeX; x++) { for(int y = 0; y < sizeY; y++) { for(int z = 0; z < sizeZ; z++) { blockId[z + (sizeZ*y) + (sizeZ*sizeY*x)] = Block.getIdFromBlock(blocks[x][y][z]); metasId[z + (sizeZ*y) + (sizeZ*sizeY*x)] = (int)metas[x][y][z]; } } } NBTTagIntArray idList = new NBTTagIntArray(blockId); NBTTagIntArray metaList = new NBTTagIntArray(metasId); nbt.setTag("idList", idList); nbt.setTag("metaList", metaList); nbt.setTag("tiles", tileList); /*for(int x = 0; x < sizeX; x++) { for(int y = 0; y < sizeY; y++) { for(int z = 0; z < sizeZ; z++) { idList.appendTag(new NBTTagInt(Block.getIdFromBlock(blocks[x][y][z]))); metaList.appendTag(new NBTTagInt(metas[x][y][z])); //NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("block", Block.getIdFromBlock(blocks[x][y][z])); tag.setShort("meta", metas[x][y][z]); NBTTagCompound tileNbtData = null; for(TileEntity tile : tileEntities) { NBTTagCompound tileNbt = new NBTTagCompound(); tile.writeToNBT(tileNbt); if(tileNbt.getInteger("x") == x && tileNbt.getInteger("y") == y && tileNbt.getInteger("z") == z){ tileNbtData = tileNbt; break; } } if(tileNbtData != null) tag.setTag("tile", tileNbtData); nbt.setTag(String.format("%d.%d.%d", x,y,z), tag); } } }*/ }
Example #16
Source File: LastNodeCapabilityProvider.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public void deserializeNBT(NBTTagIntArray nbt) { ValkyrienSkiesControl.lastRelayCapability.getStorage() .readNBT(ValkyrienSkiesControl.lastRelayCapability, inst, null, nbt); }
Example #17
Source File: LastNodeCapabilityProvider.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public NBTTagIntArray serializeNBT() { return (NBTTagIntArray) ValkyrienSkiesControl.lastRelayCapability.getStorage() .writeNBT(ValkyrienSkiesControl.lastRelayCapability, inst, null); }
Example #18
Source File: JsonToNBTConverter.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
private NBTTagCompound getTag(JsonObject object){ NBTTagCompound nbt = new NBTTagCompound(); for(Map.Entry<String, JsonElement> entry : object.entrySet()) { JsonObject keyObject = entry.getValue().getAsJsonObject(); int type = keyObject.get("type").getAsInt(); JsonElement element = keyObject.get("value"); switch(type){ case 1: nbt.setByte(entry.getKey(), (byte)element.getAsDouble()); break; case 2: nbt.setShort(entry.getKey(), (short)element.getAsDouble()); case 3: nbt.setInteger(entry.getKey(), (int)element.getAsDouble()); break; case 4: nbt.setLong(entry.getKey(), (long)element.getAsDouble()); break; case 5: nbt.setFloat(entry.getKey(), (float)element.getAsDouble()); break; case 6: nbt.setDouble(entry.getKey(), element.getAsDouble()); break; // case 7: // return new NBTTagByteArray(); // break; case 8: nbt.setString(entry.getKey(), element.getAsString()); break; case 9: JsonArray array = element.getAsJsonArray(); NBTTagList tagList = new NBTTagList(); for(JsonElement e : array) { tagList.appendTag(getTag(e.getAsJsonObject())); } nbt.setTag(entry.getKey(), tagList); break; case 10: nbt.setTag(entry.getKey(), getTag(element.getAsJsonObject())); break; case 11: array = element.getAsJsonArray(); int[] intArray = new int[array.size()]; for(int i = 0; i < array.size(); i++) { intArray[i] = array.get(i).getAsInt(); } nbt.setTag(entry.getKey(), new NBTTagIntArray(intArray)); break; default: throw new IllegalArgumentException("NBT type no " + type + " is not supported by the Json to NBT converter!"); } } return nbt; }