public void readFromNBT(NBTTagCompound nbt) { parseData(nbt.getShort("flags"), nbt.getByte("outputs")); dX = nbt.getFloat("x"); dY = nbt.getFloat("y"); dZ = nbt.getFloat("z"); }
@Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { facing = nbt.getInteger("facing"); // prevRotation = nbt.getFloat("prevRotation"); rotation = nbt.getFloat("rotation"); turnSpeed = nbt.getFloat("turnSpeed"); }
@Override public void parseRuleData(NBTTagCompound tag) { mobID = tag.getString("mobID"); xOffset = tag.getFloat("xOffset"); zOffset = tag.getFloat("zOffset"); yOffset = tag.getFloat("yOffset"); rotation = tag.getFloat("rotation"); }
@Override public void readLosely(NBTTagCompound compound) { this.hasLens.setValue(compound.getBoolean("hasLens")); this.color.setValue(compound.getInteger("color")); this.brightness.setValue(compound.getFloat("brightness")); this.prevBrightness = this.brightness.getValue(); this.focus.setValue(compound.getFloat("focus")); this.prevFocus = this.focus.getValue(); this.beat.setValue(compound.getBoolean("beat")); }
@Override public void readRestorableFromNBT(NBTTagCompound tagCompound) { super.readRestorableFromNBT(tagCompound); strength = tagCompound.getFloat("strength"); power = tagCompound.getFloat("power"); efficiency = tagCompound.getFloat("efficiency"); purity = tagCompound.getFloat("purity"); glowing = tagCompound.getBoolean("glowing"); byte version = tagCompound.getByte("version"); if (version < (byte) 2) { // We have to convert the power. power *= 20.0f; } }
@Override public void readFromNBT(NBTTagCompound compound) { this.hasLens.setValue(compound.getBoolean("hasLens")); this.color.setValue(compound.getInteger("color")); this.brightness.setValue(compound.getFloat("brightness")); this.prevBrightness = this.brightness.getValue(); this.pitch.setValue(compound.getFloat("pitch")); this.prevPitch = this.pitch.getValue(); this.rotation.setValue(compound.getFloat("rotation")); this.prevRotation = this.rotation.getValue(); this.focus.setValue(compound.getFloat("focus")); this.prevFocus = this.focus.getValue(); this.beat.setValue(compound.getBoolean("beat")); }
@Override public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); if (tag.hasKey("phase") && tag.hasKey("phaseDamage")) { float f = this.getMaxHealth() / 5; switch (tag.getInteger("phase")) { case 0: f *= 5; break; case 1: f *= 4; break; case 2: f *= 3; break; case 3: f *= 2; break; case 4: default: break; } this.setHealth(f - tag.getFloat("phaseDamage")); } if (tag.hasKey("phaseTicks")) this.setPhaseTicks(tag.getInteger("phaseTicks")); }
@Override public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); dataWatcher.updateObject(HIT_POS_X, compound.getFloat("hitPosX")); dataWatcher.updateObject(HIT_POS_Y, compound.getFloat("hitPosY")); dataWatcher.updateObject(HIT_POS_Z, compound.getFloat("hitPosZ")); hitX = compound.getInteger("hitX"); hitY = compound.getInteger("hitY"); hitZ = compound.getInteger("hitZ"); // retrieving owner name saved by super-class EntityThrowable dataWatcher.updateObject(THROWER_INDEX, compound.getString("ownerName")); dataWatcher.updateObject( WHIP_TYPE_INDEX, WhipType.values()[compound.getInteger("whipType") % WhipType.values().length]); dataWatcher.updateObject(IN_GROUND_INDEX, compound.getByte("customInGround")); }
float calculateStrength(NBTTagCompound tags, Block block, int meta) { float mineSpeed = tags.getInteger("MiningSpeed"); int heads = 1; if (tags.hasKey("MiningSpeed2")) { mineSpeed += tags.getInteger("MiningSpeed2"); heads++; } if (tags.hasKey("MiningSpeedHandle")) { mineSpeed += tags.getInteger("MiningSpeedHandle"); heads++; } if (tags.hasKey("MiningSpeedExtra")) { mineSpeed += tags.getInteger("MiningSpeedExtra"); heads++; } float trueSpeed = mineSpeed / (heads * 100f); int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); int durability = tags.getInteger("Damage"); float stonebound = tags.getFloat("Shoddy"); float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; trueSpeed += bonusLog; if (hlvl <= tags.getInteger("HarvestLevel")) return trueSpeed; return 0.1f; }
public void readFromItemNBT(NBTTagCompound nbt) { temperature = nbt.getInteger("temp"); NBTTagList nbttaglist = nbt.getTagList("Metals"); for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); int id = nbttagcompound1.getInteger("ID"); float amount = nbttagcompound1.getShort("Amount"); // Added so that hopefully old worlds that stored metal as shorts wont break float amountF = amount + nbttagcompound1.getFloat("AmountF"); Metal m = MetalRegistry.instance.getMetalFromItem(Item.itemsList[id]); addMetal(MetalRegistry.instance.getMetalFromItem(Item.itemsList[id]), amount); } nbttaglist = nbt.getTagList("Items"); storage = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < storage.length) { storage[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } if (currentAlloy != null) { currentAlloy.outputAmount = nbt.getInteger("outputAmount"); } }
@Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); Utils.readStacksFromNBT(nbttagcompound, "items", items); energyStored = nbttagcompound.getFloat("energyStored"); NBTTagList list = nbttagcompound.getTagList("planned"); for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound cpt = (NBTTagCompound) list.tagAt(i); ItemStack stack = ItemStack.loadItemStackFromNBT(cpt); for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) { if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) { plannedOutput.add(r); } } } if (nbttagcompound.hasKey("recipe")) { ItemStack stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("recipe")); for (AssemblyRecipe r : plannedOutput) { if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) { setCurrentRecipe(r); break; } } } }
public static float getPlayerCurrentReagentAmount(EntityPlayer player) { NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); if (data.hasKey("BM:StoredReagentAmount")) { return data.getFloat("BM:StoredReagentAmount"); } return 0; }
public static float getCurrentIncense(EntityPlayer player) { NBTTagCompound data = player.getEntityData(); if (data.hasKey("BM:CurrentIncense")) { return data.getFloat("BM:CurrentIncense"); } return 0; }
public static float getCurrentAdditionalMaxHP(EntityPlayer player) { NBTTagCompound data = player.getEntityData(); if (data.hasKey("BM:MaxAddedHP")) { return data.getFloat("BM:MaxAddedHP"); } return 0; }
@Override public float getFoodDecay(ItemStack is) { if (is.hasTagCompound() && is.getTagCompound().hasKey("foodDecay")) { NBTTagCompound nbt = is.getTagCompound(); return nbt.getFloat("foodDecay"); } return 0f; }
public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.field_174932_a = Block.getBlockById(compound.getInteger("blockId")) .getStateFromMeta(compound.getInteger("blockData")); this.field_174931_f = EnumFacing.getFront(compound.getInteger("facing")); this.lastProgress = this.progress = compound.getFloat("progress"); this.extending = compound.getBoolean("extending"); }
private float getMaxHealthFromStack(ItemStack item) { NBTTagCompound maxHealthAttrib = getAttributeFromStack(item, "generic.maxHealth"); if (maxHealthAttrib == null) { return Float.NaN; } if (!maxHealthAttrib.hasKey("Base")) { return Float.NaN; } return maxHealthAttrib.getFloat("Base"); }
public void readFromNBT(NBTTagCompound nbt) { this.doSpinning = true; // nbt.getBoolean("doSpinning"); this.angularVelocityRadians = nbt.getFloat("omegaRad"); this.skyAngularVelocity = nbt.getFloat("omegaSky"); this.angularVelocityTarget = nbt.getFloat("omegaTarget"); this.angularVelocityAccel = nbt.getFloat("omegaAcc"); NBTTagCompound oneBlock = (NBTTagCompound) nbt.getTag("oneBlock"); if (oneBlock != null) { this.oneSSBlock = BlockVec3.readFromNBT(oneBlock); } else { this.oneSSBlock = null; } // A lot of the data can be refreshed by checkSS this.checkSS(this.oneSSBlock, false); // Send packets to clients in this dimension List<Object> objList = new ArrayList<Object>(); objList.add(Float.valueOf(this.angularVelocityRadians)); objList.add(Boolean.valueOf(this.thrustersFiring)); GalacticraftCore.packetPipeline.sendToDimension( new PacketSimple(EnumSimplePacket.C_UPDATE_STATION_SPIN, objList), this.spaceStationDimensionID); objList = new ArrayList<Object>(); objList.add(Double.valueOf(this.spinCentreX)); objList.add(Double.valueOf(this.spinCentreZ)); GalacticraftCore.packetPipeline.sendToDimension( new PacketSimple(EnumSimplePacket.C_UPDATE_STATION_DATA, objList), this.spaceStationDimensionID); objList = new ArrayList<Object>(); objList.add(Integer.valueOf(this.ssBoundsMinX)); objList.add(Integer.valueOf(this.ssBoundsMaxX)); objList.add(Integer.valueOf(this.ssBoundsMinY)); objList.add(Integer.valueOf(this.ssBoundsMaxY)); objList.add(Integer.valueOf(this.ssBoundsMinZ)); objList.add(Integer.valueOf(this.ssBoundsMaxZ)); GalacticraftCore.packetPipeline.sendToDimension( new PacketSimple(EnumSimplePacket.C_UPDATE_STATION_BOX, objList), this.spaceStationDimensionID); }
@Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); charge = nbttagcompound.getInteger("Charge"); progress = nbttagcompound.getFloat("Progress"); stage = nbttagcompound.getInteger("Stage"); duration = nbttagcompound.getInteger("Duration"); reverse = nbttagcompound.getBoolean("Reverse"); }
@Override public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); this.slimelingInventory.readFromNBT(nbt.getTagList("SlimelingInventory")); this.colorRed = nbt.getFloat("SlimeRed"); this.colorGreen = nbt.getFloat("SlimeGreen"); this.colorBlue = nbt.getFloat("SlimeBlue"); this.age = nbt.getInteger("SlimelingAge"); this.slimelingName = nbt.getString("SlimelingName"); this.favFoodID = nbt.getInteger("FavFoodID"); this.attackDamage = nbt.getFloat("SlimelingDamage"); this.kills = nbt.getInteger("SlimelingKills"); this.setColorRed(this.colorRed); this.setColorGreen(this.colorGreen); this.setColorBlue(this.colorBlue); this.setAge(this.age); this.setName(this.slimelingName); this.setKillCount(this.kills); }
public void onUpdate(ItemStack item, World world, Entity heldEnt, int meta, boolean held) { ItemUtils.checkCompound(item); if (!item.stackTagCompound.hasKey("colourData")) { NBTTagCompound colours = new NBTTagCompound(); colours.setFloat("r", 0.8F); colours.setFloat("g", 0.0F); colours.setFloat("b", 0.8F); } float rgb[] = null; NBTTagCompound colours = item.stackTagCompound.getCompoundTag("colourData"); if (item.stackTagCompound.hasKey("focus")) { ISceptreFocus focus = getFocus(item); if (focus != null) { focus.onItemTick(item); rgb = focus.getRGB(); } else item.stackTagCompound.removeTag("focus"); } if (rgb == null) rgb = new float[] {0.8F, 0F, 0.8F}; float oR = colours.getFloat("r"); float oG = colours.getFloat("g"); float oB = colours.getFloat("b"); if (oR > rgb[0] + step) oR -= step; else if (oR < rgb[0] - step) oR += step; if (oG > rgb[1] + step) oG -= step; else if (oG < rgb[1] - step) oG += step; if (oB > rgb[2] + step) oB -= step; else if (oB < rgb[2] - step) oB += step; colours.setFloat("r", oR); colours.setFloat("g", oG); colours.setFloat("b", oB); item.stackTagCompound.setTag("colourData", colours); }
public static EnergyValue loadEnergyValueFromNBT(NBTTagCompound nbtTagCompound) { if (nbtTagCompound.hasKey("energyValue") && nbtTagCompound.hasKey("energyType")) { float energyValue = nbtTagCompound.getFloat("energyValue"); EnergyType energyType = EnergyType.getEnergyTypeFromOrdinal(nbtTagCompound.getInteger("energyType")); return new EnergyValue(energyValue, energyType); } return null; }
@Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); fireTemperature = nbttagcompound.getFloat("temperature"); fuelTimeLeft = nbttagcompound.getFloat("fuelTimeLeft"); fuelBurnTemp = nbttagcompound.getFloat("fuelBurnTemp"); charcoalCounter = nbttagcompound.getInteger("charcoalCounter"); airFromBellowsTime = nbttagcompound.getFloat("airFromBellowsTime"); airFromBellows = nbttagcompound.getFloat("airFromBellows"); isValid = nbttagcompound.getBoolean("isValid"); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); fireItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < fireItemStacks.length) { fireItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } }
/** Reads the tags from NBT. */ @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); // Read the energy variables. energy = tagCompound.getFloat("Energy"); energyIn = tagCompound.getFloat("EnergyIn"); // Read the GUI variables. energyGui = tagCompound.getInteger("EnergyGui"); // Read the state variables. isActive = tagCompound.getBoolean("IsActive"); hasEnergy = tagCompound.getBoolean("HasEnergy"); usableGenerators = tagCompound.getInteger("UsableGenerators"); // Read the coordinate arrays. int machinesX[] = tagCompound.getIntArray("MachinesHexoriumGeneratorX"); int machinesY[] = tagCompound.getIntArray("MachinesHexoriumGeneratorY"); int machinesZ[] = tagCompound.getIntArray("MachinesHexoriumGeneratorZ"); // Prepare the ArrayList for machines. machinesHexoriumGenerator = new ArrayList<HexDevice>(); // Build the machine list using the coordinate arrays. for (int i = 0; i < machinesX.length; i++) machinesHexoriumGenerator.add( new HexDevice( machinesX[i], machinesY[i], machinesZ[i], HexBlocks.blockHexoriumGenerator)); // Read the items. machineItemStacks = new ItemStack[getSizeInventory()]; NBTTagList tagsItems = tagCompound.getTagList("Items", 10); for (int i = 0; i < tagsItems.tagCount(); ++i) { NBTTagCompound tagCompound1 = tagsItems.getCompoundTagAt(i); byte byte0 = tagCompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < machineItemStacks.length) { machineItemStacks[byte0] = ItemStack.loadItemStackFromNBT(tagCompound1); } } }
@Override public void processCommand(ICommandSender sender, String[] par2ArrayOfStr) { MinecraftServer server = ModLoader.getMinecraftServerInstance(); EntityPlayer player = getCommandSenderAsPlayer(sender); EntityPlayerMP playerMP = (EntityPlayerMP) sender; String ho = ""; if (par2ArrayOfStr.length == 0) { ho = "[Default]"; } else { ho = par2ArrayOfStr[0]; } setBackLocation(player); NBTTagCompound playerdata = NecessitiesMain.instance.necessities_data.getCompoundTag(player.username); NecessitiesMain.instance.necessities_data.setCompoundTag(player.username, playerdata); NBTTagCompound homes = playerdata.getCompoundTag("Homes"); playerdata.setCompoundTag("Homes", homes); // Go to the specified home if (!homes.hasKey(ho)) { sender.sendChatToPlayer("Unknown home."); return; } NBTTagCompound h = homes.getCompoundTag(ho); double posX = h.getDouble("PosX"); double posY = h.getDouble("PosY"); double posZ = h.getDouble("PosZ"); float yaw = h.getFloat("Yaw"); float pitch = h.getFloat("Pitch"); int dim = h.getInteger("Dim"); if (player.dimension != dim) server.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) player), dim); playerMP.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch); } // public voice processCommand(...)
@Override public float getStrVsBlock(ItemStack stack, Block block, int meta) { NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); if (tags.getBoolean("Broken")) return 0.1f; Material[] materials = getEffectiveMaterials(); for (int i = 0; i < materials.length; i++) { if (materials[i] == block.blockMaterial) { float speed = tags.getInteger("MiningSpeed"); speed /= 100f; int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); int durability = tags.getInteger("Damage"); float shoddy = tags.getFloat("Shoddy"); speed += shoddy * durability / 100f; if (hlvl <= tags.getInteger("HarvestLevel")) return speed; return 0.1f; } } materials = getEffectiveSecondaryMaterials(); for (int i = 0; i < materials.length; i++) { if (materials[i] == block.blockMaterial) { float speed = tags.getInteger("MiningSpeed2"); speed /= 100f; int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); int durability = tags.getInteger("Damage"); float shoddy = tags.getFloat("Shoddy"); speed += shoddy * durability / 100f; if (hlvl <= tags.getInteger("HarvestLevel2")) return speed; return 0.1f; } } return super.getStrVsBlock(stack, block, meta); }
public void getData(EntityPlayer player) { if (player != null) { data = player.getEntityData().getCompoundTag(player.PERSISTED_NBT_TAG); if (data.hasKey("GoldTotal")) { int i = data.getInteger("GoldTotal"); gold.setGold(player, i); } if (data.hasKey("Worthy")) ; { float j = data.getFloat("Worthy"); worthy.setWorthy(player, j); } } }
@Override public void readFromNBT(NBTTagCompound tagCompound, GalaxyGenerator generator) { super.readFromNBT(tagCompound, generator); x = tagCompound.getFloat("X"); y = tagCompound.getFloat("Y"); z = tagCompound.getFloat("Z"); size = tagCompound.getFloat("Size"); mass = tagCompound.getFloat("Mass"); type = tagCompound.getByte("Type"); temperature = tagCompound.getInteger("Temperature"); color = tagCompound.getInteger("Color"); seed = tagCompound.getInteger("Seed"); generated = tagCompound.getBoolean("Generated"); NBTTagList planetList = tagCompound.getTagList("Planets", 10); for (int i = 0; i < planetList.tagCount(); i++) { Planet planet = new Planet(); planet.readFromNBT(planetList.getCompoundTagAt(i), generator); addPlanet(planet); planet.setStar(this); } generateMissing(tagCompound, generator); }
@Override public void readFromNBT(NBTTagCompound nbttc) { super.readFromNBT(nbttc); this.silktouch = nbttc.getBoolean("silktouch"); this.fortune = nbttc.getByte("fortune"); this.efficiency = nbttc.getByte("efficiency"); this.unbreaking = nbttc.getByte("unbreaking"); this.pp.readFromNBT(nbttc); this.src1 = FluidStack.loadFluidStackFromNBT(nbttc.getCompoundTag("src1")); this.src2 = FluidStack.loadFluidStackFromNBT(nbttc.getCompoundTag("src2")); this.res = FluidStack.loadFluidStackFromNBT(nbttc.getCompoundTag("res")); this.animationSpeed = nbttc.getFloat("animationSpeed"); this.animationStage = nbttc.getInteger("animationStage"); this.buf = (int) (FluidContainerRegistry.BUCKET_VOLUME * 4 * Math.pow(1.3, this.fortune)); PowerManager.configureR(this.pp, this.efficiency, this.unbreaking); }
/** (abstract) Protected helper method to read subclass entity data from NBT. */ @Override public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); sex = nbt.getInteger("Sex"); size_mod = nbt.getFloat("Size Modifier"); strength_mod = nbt.getFloat("Strength Modifier"); aggression_mod = nbt.getFloat("Aggression Modifier"); obedience_mod = nbt.getFloat("Obedience Modifier"); colour_mod = nbt.getFloat("Colour Modifier"); climate_mod = nbt.getFloat("Climate Adaptation Modifier"); hard_mod = nbt.getFloat("Hardiness Modifier"); hunger = nbt.getInteger("Hunger"); mateSizeMod = nbt.getFloat("MateSize"); this.dataWatcher.updateObject(15, nbt.getInteger("Age")); nextEgg = nbt.getLong("nextEgg"); }