Java Code Examples for net.minecraft.nbt.NBTTagCompound#getFloat()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#getFloat() .
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: ToolMetaItem.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
public float getToolDigSpeed(ItemStack itemStack) { T metaToolValueItem = getItem(itemStack); if (metaToolValueItem != null) { NBTTagCompound toolTag = getToolStatsTag(itemStack); SolidMaterial toolMaterial = getToolMaterial(itemStack); IToolStats toolStats = metaToolValueItem.getToolStats(); float toolSpeed = 0; if (toolTag != null && toolTag.hasKey("DigSpeed")) { toolSpeed = toolTag.getFloat("DigSpeed"); } else if (toolMaterial != null) { toolSpeed = toolMaterial.toolSpeed; } float multiplier = toolStats.getDigSpeedMultiplier(itemStack); return toolSpeed * multiplier; } return 0; }
Example 2
Source File: EntityPermNoClipItem.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void readEntityFromNBT(NBTTagCompound com) { super.readEntityFromNBT(com); this.fixPosX = com.getFloat("fX"); this.fixPosY = com.getFloat("fY"); this.fixPosZ = com.getFloat("fZ"); this.masterX = com.getInteger("mX"); this.masterY = com.getInteger("mY"); this.masterZ = com.getInteger("mZ"); getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherMasterId, new ChunkCoordinates(masterX, masterY, masterZ)); ChunkCoordinates cc = new ChunkCoordinates(Float.floatToIntBits(fixPosX), Float.floatToIntBits(fixPosY), Float.floatToIntBits(fixPosZ)); getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedId, cc); }
Example 3
Source File: StellarBody.java From AdvancedRocketry with MIT License | 6 votes |
public void readFromNBT(NBTTagCompound nbt) { id = nbt.getInteger("id"); temperature = nbt.getInteger("temperature"); name = nbt.getString("name"); posX = nbt.getShort("posX"); posZ = nbt.getShort("posZ"); if(nbt.hasKey("size")) size = nbt.getFloat("size"); if(nbt.hasKey("seperation")) starSeperation = nbt.getFloat("seperation"); subStars.clear(); if(nbt.hasKey("subStars")) { NBTTagList list = nbt.getTagList("subStars", NBT.TAG_COMPOUND); for(int i = 0; i < list.tagCount(); i++) { StellarBody star = new StellarBody(); star.readFromNBT(list.getCompoundTagAt(i)); subStars.add(star); } } }
Example 4
Source File: TileEntityAssemblyIOUnit.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); clawProgress = tag.getFloat("clawProgress"); shouldClawClose = tag.getBoolean("clawClosing"); state = tag.getByte("state"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[1]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 5
Source File: TileEntityElectricCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbtTagCompound){ super.readFromNBT(nbtTagCompound); redstoneMode = nbtTagCompound.getInteger("redstoneMode"); outputTimer = nbtTagCompound.getBoolean("outputTimer") ? 20 : 0; turbineSpeed = nbtTagCompound.getFloat("turbineSpeed"); lastEnergyProduction = nbtTagCompound.getInteger("energyProduction"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 6
Source File: TileEntitySoundBlock.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readFromNBTCustom(NBTTagCompound nbt) { super.readFromNBTCustom(nbt); if (nbt.hasKey("Sound", Constants.NBT.TAG_STRING)) { this.soundName = nbt.getString("Sound"); } this.redstoneState = nbt.getBoolean("Powered"); this.repeat = nbt.getBoolean("Repeat"); this.volume = nbt.getFloat("Volume"); this.pitch = nbt.getFloat("Pitch"); }
Example 7
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 8
Source File: MetaTileEntityBlockBreaker.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); this.outputFacing = EnumFacing.VALUES[data.getInteger("OutputFacing")]; this.breakProgressTicksLeft = data.getInteger("BlockBreakProgress"); this.currentBlockHardness = data.getFloat("BlockHardness"); }
Example 9
Source File: HexUpdateHandler.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void handle(HexUpdateEvent event) { NBTTagCompound nbt = event.centerToUpdate.getCustomNBT(); if(nbt.hasKey("TFC2_Data")) { NBTTagCompound data = nbt.getCompoundTag("TFC2_Data"); if(data.hasKey("CropData")) { NBTTagCompound cropData = data.getCompoundTag("CropData"); long lastRegenTick = cropData.getLong("lastRegenTick"); if(lastRegenTick + Timekeeper.ticksInPeriod < Timekeeper.getInstance().getTotalTicks()) { cropData.setLong("lastRegenTick", lastRegenTick + Timekeeper.ticksInPeriod); float nutrients = cropData.getFloat("nutrients"); float maxNutrients = TileCrop.GetMaxNutrients(event.map); cropData.setFloat("nutrients", Math.min(maxNutrients, nutrients + maxNutrients/4)); } } if(data.hasKey("hydration")) { byte[] hydrationArray = data.getByteArray("hydration"); int waterLevel = 0; for(int i = 0; i < 64; i++) { hydrationArray[i] = (byte)Math.max(0, hydrationArray[i]-5); waterLevel += hydrationArray[i]; } if(waterLevel > 0) data.setByteArray("hydration", hydrationArray); else data.removeTag("hydration"); } } }
Example 10
Source File: BarrelModeCompost.java From ExNihiloAdscensio with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Override public void readFromNBT(NBTTagCompound tag) { fillAmount = tag.getFloat("fillAmount"); this.color = new Color(tag.getInteger("color")); if (tag.hasKey("originalColor")) this.originalColor = new Color(tag.getInteger("originalColor")); this.progress = tag.getFloat("progress"); if (tag.hasKey("block")) { Block block = Block.REGISTRY.getObject(new ResourceLocation(tag.getString("block"))); compostState = block.getStateFromMeta(tag.getInteger("meta")); } }
Example 11
Source File: ModCrooked.java From Ex-Aliquo with MIT License | 5 votes |
public void modify(ItemStack[] input, ItemStack tool) { NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); tags.setBoolean(name, true); int modifiers = tags.getInteger("Modifiers"); modifiers -= 1; tags.setInteger("Modifiers", modifiers); int attack = tags.getInteger("Attack"); attack = 0; tags.setInteger("Attack", attack); int miningSpeed = tags.getInteger("MiningSpeed"); miningSpeed -= 300; if (miningSpeed < 0) miningSpeed = 0; tags.setInteger("MiningSpeed", miningSpeed); if (tags.hasKey("MiningSpeed2")) { int miningSpeed2 = tags.getInteger("MiningSpeed2"); miningSpeed2 -= 300; if (miningSpeed2 < 0) miningSpeed2 = 0; tags.setInteger("MiningSpeed2", miningSpeed2); } float knockback = tags.getFloat("Knockback"); knockback *= 1.5F; addToolTip(tool, color + tooltip, color + key); }
Example 12
Source File: TileEntityPneumaticBase.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound nbt){ if(getClass() != TileEntityPneumaticBase.class && saveTeInternals()) { super.readFromNBT(nbt); } if(nbt.hasKey("pneumatic")) nbt = nbt.getCompoundTag("pneumatic"); currentAir = nbt.getInteger("currentAir"); maxPressure = nbt.getFloat("maxPressure"); volume = nbt.getInteger("volume"); if(volume == 0) { Log.error("Volume was 0! Assigning default"); volume = DEFAULT_VOLUME; } }
Example 13
Source File: FixedPointUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static float getDoubleFromNBT(NBTTagCompound nbt, String key) { // See net.minecraft.nbt.NBTBase.NBT_TYPES[] for meaning of type ids. byte dataType = nbt.getTagId(key); if (dataType == Constants.NBT.TAG_DOUBLE) // double return (float) nbt.getDouble(key); // NOTE: For legacy case else if (dataType == Constants.NBT.TAG_FLOAT) return nbt.getFloat(key); else if (dataType == Constants.NBT.TAG_LONG) { return fixedToDouble(nbt.getLong(key)); } return 0; }
Example 14
Source File: BarrelModeFluidTransform.java From ExNihiloAdscensio with MIT License | 5 votes |
@Override public void readFromNBT(NBTTagCompound tag) { if (tag.hasKey("inputTag")) { NBTTagCompound inputTag = (NBTTagCompound) tag.getTag("inputTag"); inputStack = FluidStack.loadFluidStackFromNBT(inputTag); } if (tag.hasKey("outputTag")) { NBTTagCompound outputTag = (NBTTagCompound) tag.getTag("outputTag"); outputStack = FluidStack.loadFluidStackFromNBT(outputTag); } if (tag.hasKey("progress")) { progress = tag.getFloat("progress"); } }
Example 15
Source File: TileEntityLiftLever.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); leverOffset = compound.getFloat("leverOffset"); targetYPosition = compound.getDouble("targetYPosition"); hasHeightBeenSet = compound.getBoolean("hasHeightBeenSet"); }
Example 16
Source File: AMVector3.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 4 votes |
public static AMVector3 readFromNBT(NBTTagCompound compound){ return new AMVector3(compound.getFloat("Vec3_x"), compound.getFloat("Vec3_y"), compound.getFloat("Vec3_z")); }
Example 17
Source File: ModuleFlowDetector.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); rotation = tag.getFloat("rotation"); oldFlow = tag.getInteger("flow");//taggin it for waila purposes. }
Example 18
Source File: TypeRW.java From OpenModsLib with MIT License | 4 votes |
@Override public Float readFromNBT(NBTTagCompound tag, String name) { return tag.getFloat(name); }
Example 19
Source File: GTTileBaseMachine.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); progress = nbt.getFloat("progress"); }
Example 20
Source File: SyncableFloat.java From OpenModsLib with MIT License | 4 votes |
@Override public void readFromNBT(NBTTagCompound tag, String name) { value = tag.getFloat(name); }