@Override
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("RootUser")) {
this.rootUser = compound.getString("RootUser");
}
if (compound.hasKey("Rules")) {
NBTTagList rulesList = compound.getTagList("Rules",NBT.TAG_COMPOUND);
this.rules = new ArrayList<Rule>();
for (int i = 0,max = rulesList.tagCount(); i < max; ++i) {
NBTTagCompound ruleNBT = (NBTTagCompound)rulesList.get(i);
this.rules.add(new Rule(ruleNBT.getString("ID"),ruleNBT.getString("Name"),ruleNBT.getInteger("Mode")));
}
}
if (this.rules == null || this.rules.size() == 0) {
// Reset rules.
this.rules = new ArrayList<Rule>();
this.rules.add(new Rule("<machines>",Rule.MODE_OPEN));
this.rules.add(new Rule("<players>",Rule.MODE_RESTRICTED));
}
super.readFromNBT(compound);
}
项目:rezolve
文件:RemoteShellEntity.java
@Override
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("Machines")) {
NBTTagList machineList = compound.getTagList("Machines",NBT.TAG_COMPOUND);
this.connectedMachines = new ArrayList<BlockPos>();
for (int i = 0,max = machineList.tagCount(); i < max; ++i) {
NBTTagCompound machineNBT = (NBTTagCompound)machineList.get(i);
this.connectedMachines.add(new BlockPos(machineNBT.getInteger("X"),machineNBT.getInteger("Y"),machineNBT.getInteger("Z")));
}
} else {
this.connectedMachines = null;
}
super.readFromNBT(compound);
}
项目:Bewitchment
文件:TileEntityGlyph.java
@Override
protected void readDatanBT(NBTTagCompound tag) {
cooldown = tag.getInteger("cooldown");
if (tag.hasKey("ritual"))
ritual = Ritual.REGISTRY.getValue(new ResourceLocation(tag.getString("ritual")));
if (tag.hasKey("player"))
entityPlayer = UUID.fromString(tag.getString("player"));
if (tag.hasKey("data"))
ritualData = tag.getCompoundTag("data");
if (tag.hasKey("entityList")) {
entityList = new ArrayList<Tuple<String,String>>();
tag.getTagList("entityList",NBT.TAG_STRING).forEach(nbts -> {
String[] names = ((NBTTagString) nbts).getString().split("!");
if (names.length == 2)
entityList.add(new Tuple<String,String>(names[0],names[1]));
});
}
}
项目:BetterBeginningsReborn
文件:TileEntityInfusionRepair.java
@Override
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(mainHandler,null,compound.getTag(INV_TAG));
mode = Mode.valueOf(compound.getString(MODE));
NBTTagList ingredientList = compound.getTagList(PENDING_INGREDIENTS,NBT.TAG_COMPOUND);
pendingIngredients = new Stack<RecipeElement>();
for(int tag = 0; tag < ingredientList.tagCount(); tag++)
{
pendingIngredients.add(ElementRegistry.createElementFromNBT(ingredientList.getCompoundTagAt(tag)));
}
xpLevelsNeeded = compound.getInteger(LEVELS_NEEDED);
xpLevelsTaken = compound.getInteger(LEVELS_TAKEN);
healthTaken = compound.getFloat(HEALTH_TAKEN);
}
项目:ExPetrum
文件:CropStats.java
@Override
public void deserializeNBT(NBTTagCompound nbt)
{
this.growthRanges[0].deserializeNBT(nbt.getCompoundTag("tGrowthRangeminimal"));
this.growthRanges[1].deserializeNBT(nbt.getCompoundTag("tGrowthRangeOptimal"));
this.growthRanges[2].deserializeNBT(nbt.getCompoundTag("tGrowthRangePerfect"));
this.humidityGrowthRange = Pair.of(nbt.getCompoundTag("hGrowthRange").getFloat("min"),nbt.getCompoundTag("hGrowthRange").getFloat("max"));
this.generation = nbt.getInteger("generation");
this.wild = nbt.getBoolean("wild");
this.type = EnumCrop.values()[nbt.getByte("type")];
this.plantedAt = new Calendar();
if (nbt.hasKey("plantedAt"))
{
this.plantedAt.deserializeNBT((NBTTagLong) nbt.getTag("plantedAt"));
}
this.health = nbt.getFloat("health");
this.growthRate = nbt.getFloat("growthRate");
this.waterConsumption = nbt.getFloat("waterConsumption");
this.growth = nbt.getFloat("growth");
this.nutrientConsumption.clear();
nbt.getTagList("nutrientConsumption",NBT.TAG_COMPOUND).forEach(tag -> this.nutrientConsumption.put(EnumPlantNutrient.values()[((NBTTagCompound)tag).getByte("nutrient")],((NBTTagCompound)tag).getFloat("amount")));
}
项目:Alchemy
文件:ExParticleFirework_Starter.java
@Patch.Exception
@Hook("net.minecraft.entity.item.EntityFireworkRocket#func_70103_a")
public static Hook.Result handleStatusUpdate(EntityFireworkRocket rocket,byte id) {
if (id == 17 && rocket.world.isRemote) {
ItemStack item = rocket.getDataManager().get(EntityFireworkRocket.FIREWORK_ITEM);
NBTTagCompound nbt = null;
if (item != null && item.hasTagCompound()) {
nbt = item.getTagCompound().getCompoundTag("Fireworks");
if (item.getTagCompound().hasKey("display",NBT.TAG_COMPOUND))
nbt.setTag("display",item.getTagCompound().getTag("display"));
}
rocket.world.makeFireworks(rocket.posX,rocket.posY,rocket.posZ,rocket.motionX,rocket.motionY,rocket.motionZ,nbt);
}
return Hook.Result.NULL;
}
@Override
public void deserializeNBT(NBTBase nbtb) {
if (nbtb instanceof NBTTagList) {
NBTTagList nbtl = (NBTTagList) nbtb;
for (int i = 0; i < nbtl.tagCount(); i++) {
NBTTagCompound nbt = nbtl.getCompoundTagAt(i);
boolean hasPos = false;
long l = 0;
if (nbt.hasKey("x",NBT.TAG_INT) && nbt.hasKey("y",NBT.TAG_INT) && nbt.hasKey("z",NBT.TAG_INT)) {
l = packLong(nbt.getInteger("x"),nbt.getInteger("y"),nbt.getInteger("z"));
hasPos = true;
} else if (nbt.hasKey("cp",NBT.TAG_LONG)) {
l = nbt.getLong("cp");
hasPos = true;
}
if (hasPos) {
if (nbt.hasKey("e")) {
Battery eb = new Battery(MCFluxConfig.WORLDCHUNK_CAP);
eb.deserializeNBT(nbt.getTag("e"));
eChunks.put(l,eb);
}
}
}
}
}
项目:ARKCraft
文件:IBurner.java
@Override
public default void readFromNBT(NBTTagCompound compound)
{
setBurning(compound.getBoolean("burning"));
setBurningTicks(compound.getInteger("burningTicks"));
NBTTagList inventory = compound.getTagList("inventory",NBT.TAG_COMPOUND);
Collection<NBTTagCompound> out = new ArrayList<>();
for (int i = 0; i < inventory.tagCount(); i++)
out.add(inventory.getCompoundTagAt(i));
List<ItemStack> in = CollectionUtil.convert(out,(NBTTagCompound n) -> n.getBoolean("null") ? null : ItemStack
.loadItemStackFromNBT(n));
for (int i = 0; i < getInventory().length; i++)
getInventory()[i] = in.get(i);
}
项目:PopularMMOS-EpicProportions-Mod
文件:InventoryPail.java
/**
* A custom method to read our inventory from an ItemStack's NBT compound
*/
public void readFromNBT(NBTTagCompound compound)
{
// Gets the custom taglist we wrote to this compound,if any
// 1.7.2+ change to compound.getTagList("ItemInventory",Constants.NBT.TAG_COMPOUND);
NBTTagList items = compound.getTagList("PailInventory",Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); ++i)
{
// 1.7.2+ change to items.getCompoundTagAt(i)
NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i);
int slot = item.getInteger("Slot");
// Just double-checking that the saved slot index is within our inventory array bounds
if (slot >= 0 && slot < getSizeInventory()) {
inventory[slot] = ItemStack.loadItemStackFromNBT(item);
}
}
}
private static final void iterate(NBTTagCompound parent,NBTTreeConsumer consumer,int depth) {
if(parent == null) return;
consumer.consume(depth+1,"<compound>",parent,null);
for(Object keyObject : parent.getKeySet()) {
String key = (String)keyObject;
NBTBase value = parent.getTag(key);
consumer.consume(depth+1,key,value,parent);
if(value instanceof NBTTagCompound) {
iterate((NBTTagCompound)value,consumer,depth+1);
}
if(value instanceof NBTTagList) {
NBTTagList list = (NBTTagList) value;
if(list.getTagType() == NBT.TAG_COMPOUND) {
for(int i = 0; i < list.tagCount(); i++) {
NBTTagCompound compound = list.getCompoundTagAt(i);
iterate(compound,depth+1);
}
}
}
}
consumer.consume(depth+1,"",parent);
}
项目:TaleCraft
文件:NBTHelper.java
private static void asJson(NBTBase tag,StringBuilder builder) {
switch(tag.getId()) {
case NBT.TAG_BYTE: builder.append(((NBTTagByte)tag).getByte()).append('b'); break;
case NBT.TAG_SHORT: builder.append(((NBTTagShort)tag).getByte()).append('b'); break;
case NBT.TAG_INT: builder.append(((NBTTagInt)tag).getInt()); break;
case NBT.TAG_LONG: builder.append(((NBTTagLong)tag).getByte()).append('l'); break;
case NBT.TAG_FLOAT: builder.append(((NBTTagFloat)tag).getFloat()).append('f'); break;
case NBT.TAG_DOUBLE: builder.append(((NBTTagDouble)tag).getDouble()).append('d'); break;
case NBT.TAG_STRING: builder.append('"').append(((NBTTagString)tag).getString()).append('"'); break;
case NBT.TAG_BYTE_ARRAY: builder.append(Arrays.toString(((NBTTagByteArray)tag).getByteArray())); break;
case NBT.TAG_INT_ARRAY: builder.append(Arrays.toString(((NBTTagIntArray)tag).getIntArray())); break;
case NBT.TAG_COMPOUND: asJson((NBTTagCompound) tag,builder); break;
case NBT.TAG_LIST: asJson((NBTTagList) tag,builder); break;
}
}
项目:morecommands
文件:ServerPlayerSettings.java
/**
* Reads the player's chat channels fron nbt and joins them
*/
@Override
public void deserializeNBT(NBTTagCompound settings) {
MoreCommands.getProxy().ensureChatChannelsLoaded();
NBTTagList chatChannels = settings.getTagList(NBT_CHATCHANNELS_IDENTIFIER,NBT.TAG_STRING);
if (chatChannels != null) {
for (int i = 0; i < chatChannels.tagCount(); i++) {
ChatChannel channel = ChatChannel.getChannel(chatChannels.getStringTagAt(i));
if (channel != null && !channel.isChannelMember(this.player)) channel.join(this.player);
}
}
if (this.chatChannels.isEmpty())
ChatChannel.getMasterChannel().join(this.player);
this.playerChannelsToSave.clear();
this.loggedOut = false;
}
项目:morecommands
文件:EntityUtils.java
/**
* removes an enchantment from the current item
*/
public static void removeEnchantment(EntityLivingBase entity,Enchantment enchantment) {
if (entity.getHeldItemmainhand() == ItemStack.EMPTY) return;
NBTTagCompound compound = entity.getHeldItemmainhand().getTagCompound();
if (compound == null) return;
NBTTagList enchantments = compound.hasKey("ench",NBT.TAG_LIST) ? compound.getTagList("ench",NBT.TAG_COMPOUND) : null;
if (enchantments == null) return;
int id = Enchantment.getEnchantmentID(enchantment);
NBTTagList newList = new NBTTagList();
for (int i = 0; i < enchantments.tagCount(); i++) {
if (enchantments.getCompoundTagAt(i).getShort("id") != id) {
newList.appendTag(enchantments.getCompoundTagAt(i));
}
}
if (newList.tagCount() == 0) compound.removeTag("ench");
else compound.setTag("ench",newList);
}
项目:morecommands
文件:EntityUtils.java
/**
* @return whether the player has this enchantment
*/
public static boolean hasEnchantment(EntityLivingBase entity,Enchantment enchantment) {
if (entity.getHeldItemmainhand() == ItemStack.EMPTY) return false;
NBTTagCompound compound = entity.getHeldItemmainhand().getTagCompound();
if (compound == null) return false;
NBTTagList enchantments = compound.hasKey("ench",NBT.TAG_COMPOUND) : null;
if (enchantments == null) return false;
int id = Enchantment.getEnchantmentID(enchantment);
for (int i = 0; i < enchantments.tagCount(); i++) {
if (enchantments.getCompoundTagAt(i).getShort("id") == id) {
return true;
}
}
return false;
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
if(nbtTags.hasKey("fluidTank"))
{
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
}
if(nbtTags.hasKey("controlType"))
{
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
}
if(nbtTags.hasKey("recurringNodes"))
{
NBTTagList tagList = nbtTags.getTagList("recurringNodes",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
recurringNodes.add(Coord4D.read((NBTTagCompound)tagList.getCompoundTagAt(i)));
}
}
}
@Override
public void setFilterData(NBTTagCompound nbtTags)
{
radius = nbtTags.getInteger("radius");
minY = nbtTags.getInteger("minY");
maxY = nbtTags.getInteger("maxY");
doEject = nbtTags.getBoolean("doEject");
doPull = nbtTags.getBoolean("doPull");
silkTouch = nbtTags.getBoolean("silkTouch");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
inverse = nbtTags.getBoolean("inverse");
if(nbtTags.hasKey("filters"))
{
NBTTagList tagList = nbtTags.getTagList("filters",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(minerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
}
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
if(itemStack.stackTagCompound.hasKey("hasminerConfig"))
{
radius = itemStack.stackTagCompound.getInteger("radius");
minY = itemStack.stackTagCompound.getInteger("minY");
maxY = itemStack.stackTagCompound.getInteger("maxY");
doEject = itemStack.stackTagCompound.getBoolean("doEject");
doPull = itemStack.stackTagCompound.getBoolean("doPull");
silkTouch = itemStack.stackTagCompound.getBoolean("silkTouch");
inverse = itemStack.stackTagCompound.getBoolean("inverse");
if(itemStack.stackTagCompound.hasKey("filters"))
{
NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(minerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
}
}
}
}
@Override
public void setFilterData(NBTTagCompound nbtTags)
{
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
if(nbtTags.hasKey("color"))
{
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
autoEject = nbtTags.getBoolean("autoEject");
roundRobin = nbtTags.getBoolean("roundRobin");
rrIndex = nbtTags.getInteger("rrIndex");
if(nbtTags.hasKey("filters"))
{
NBTTagList tagList = nbtTags.getTagList("filters",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
}
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
if(itemStack.stackTagCompound.hasKey("hasSorterConfig"))
{
if(itemStack.stackTagCompound.hasKey("color"))
{
color = TransporterUtils.colors.get(itemStack.stackTagCompound.getInteger("color"));
}
autoEject = itemStack.stackTagCompound.getBoolean("autoEject");
roundRobin = itemStack.stackTagCompound.getBoolean("roundRobin");
if(itemStack.stackTagCompound.hasKey("filters"))
{
NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
}
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
if(nbtTags.hasKey("filters"))
{
NBTTagList tagList = nbtTags.getTagList("filters",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
}
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
if(itemStack.stackTagCompound.hasKey("hasOredictionificatorConfig"))
{
if(itemStack.stackTagCompound.hasKey("filters"))
{
NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
}
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
if(handleInventory())
{
NBTTagList tagList = nbtTags.getTagList("Items",NBT.TAG_COMPOUND);
inventory = new ItemStack[getSizeInventory()];
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
{
NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount);
byte slotID = tagCompound.getByte("Slot");
if(slotID >= 0 && slotID < getSizeInventory())
{
setInventorySlotContents(slotID,ItemStack.loadItemStackFromNBT(tagCompound));
}
}
}
}
@Override
public NBTTagList getInventory(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
if(itemStack.stackTagCompound == null)
{
return null;
}
return itemStack.stackTagCompound.getTagList("Items",NBT.TAG_COMPOUND);
}
return null;
}
@Override
public NBTTagList getInventory(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
if(itemStack.stackTagCompound == null)
{
return null;
}
return itemStack.stackTagCompound.getTagList("Items",NBT.TAG_COMPOUND);
}
return null;
}
@Override
public NBTTagList getInventory(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
if(itemStack.stackTagCompound == null)
{
return null;
}
return itemStack.stackTagCompound.getTagList("Items",NBT.TAG_COMPOUND);
}
return null;
}
@Override
public void load(NBTTagCompound nbtTags)
{
super.load(nbtTags);
tier = TransporterTier.values()[nbtTags.getInteger("tier")];
if(nbtTags.hasKey("color"))
{
getTransmitter().setColor(TransporterUtils.colors.get(nbtTags.getInteger("color")));
}
if(nbtTags.hasKey("stacks"))
{
NBTTagList tagList = nbtTags.getTagList("stacks",NBT.TAG_COMPOUND);
for(int i = 0; i < tagList.tagCount(); i++)
{
TransporterStack stack = TransporterStack.readFromNBT(tagList.getCompoundTagAt(i));
getTransmitter().transit.add(stack);
TransporterManager.add(stack);
}
}
}
@Override
public void load(NBTTagCompound nbtTags)
{
NBTTagList tagList = nbtTags.getTagList("Items",NBT.TAG_COMPOUND);
inventory = new ItemStack[2];
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
{
NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount);
byte slotID = tagCompound.getByte("Slot");
if(slotID >= 0 && slotID < 2)
{
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
}
@Override
public void load(NBTTagCompound nbtTags)
{
editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")];
NBTTagList tagList = nbtTags.getTagList("Items",NBT.TAG_COMPOUND);
inventory = new ItemStack[2];
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
{
NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount);
byte slotID = tagCompound.getByte("Slot");
if(slotID >= 0 && slotID < 2)
{
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
if(nbtTags.hasKey("cachedFluid"))
{
fluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid"));
}
}
项目:UHC-Reloaded
文件:Misc.java
/**
* The utility method to get the player's name from the skull item stack.
*
* @param skull The item stack of the skull
* @return The name of player,empty if invalid
*/
public static String getownerFromSkull(ItemStack skull) {
if (skull.getItem() != Items.SKULL) {
return "";
}
if (!skull.hasTagCompound()) {
return "";
}
if (skull.getTagCompound().hasKey("SkullOwner",NBT.TAG_STRING)) {
return skull.getTagCompound().getString("SkullOwner");
}
if (skull.getTagCompound().hasKey("SkullOwner",NBT.TAG_COMPOUND)) {
NBTTagCompound tag = skull.getTagCompound().getCompoundTag("SkullOwner");
if (tag.hasKey("Name",NBT.TAG_STRING)) {
return tag.getString("Name");
}
}
return "";
}
项目:UHC-Reloaded
文件:Misc.java
/**
* Add a tooltip for an item stack. It will be auto formatted to reset.
*
* @param stack The original item stack that needs a tool tip
* @param tooltip The list of tool tips to be added
* @return The new item stack with these tool tip
*/
public static ItemStack appendToolTip(ItemStack stack,Iterable<String> tooltip) {
NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
boolean needAppend = false;
NBTTagCompound tag1;
if (tag.hasKey("display",NBT.TAG_COMPOUND)) {
tag1 = tag.getCompoundTag("display");
if (tag.hasKey("Lore",NBT.TAG_LIST)) {
needAppend = true;
}
} else {
tag.setTag("display",new NBTTagCompound());
tag1 = tag.getCompoundTag("display");
}
if (!needAppend) {
tag1.setTag("Lore",new NBTTagList());
}
for (String s : tooltip) {
tag1.getTagList("Lore",NBT.TAG_LIST).appendTag(new NBTTagString(textformatting.RESET + s));
}
tag.setTag("display",tag1);
ItemStack output = stack.copy();
output.setTagCompound(tag);
return output;
}
项目:AdvancedRocketry
文件:ItemSpaceArmor.java
public ItemStack removeComponent(World world,ItemStack armor,int index) {
NBTTagCompound nbt;
NBTTagList componentList;
if(armor.hasTagCompound()) {
nbt = armor.getTagCompound();
componentList = nbt.getTagList(componentNBTName,NBT.TAG_COMPOUND);
}
else {
return null;
}
EmbeddedInventory inv = loadEmbeddedInventory(armor);
ItemStack stack = inv.getStackInSlot(index);
inv.setInventorySlotContents(index,null);
if(stack != null) {
IArmorComponent component = (IArmorComponent) stack.getItem();
component.onComponentRemoved(world,armor);
saveEmbeddedInventory(armor,inv);
}
return stack;
}
项目:AdvancedRocketry
文件:SpaceObjectAsteroid.java
@Override
public void readFromNbt(NBTTagCompound nbt) {
super.readFromNbt(nbt);
NBTTagList list = nbt.getTagList("composition",NBT.TAG_COMPOUND);
compositionMapping.clear();
for(int i = 0; i < list.tagCount(); i++) {
NBTTagCompound tag = list.getCompoundTagAt(i);
int blockId = tag.getInteger("id");
int rarity = tag.getInteger("amt");
compositionMapping.put(Block.getBlockById(blockId),rarity);
}
numberOfBlocks = nbt.getInteger("numBlocks");
uuid = nbt.getLong("uuid");
data.readFromNBT(nbt);
}
项目:GimmeTime
文件:AlarmHandler.java
private static void loadAlarms(File suggestedAlarmFile) throws Exception {
alarms = Lists.newArrayList();
NBTTagCompound nbt = CompressedStreamTools.read(suggestedAlarmFile);
if (nbt == null)
return;
NBTTagList list = nbt.getTagList(TAG_ALARMS,NBT.TAG_COMPOUND);
for (int i = 0; i < list.tagCount(); i++) {
Alarm alarm = new Alarm();
alarm.readFromNBT(list.getCompoundTagAt(i));
alarms.add(alarm);
}
}
项目:taam
文件:PipeInfo.java
public void readFromNBT(NBTTagCompound tag) {
pressure = tag.getInteger("pressure");
suction = tag.getInteger("suction");
NBTTagList list = tag.getTagList("content",NBT.TAG_COMPOUND);
content.clear();
if (list != null && list.tagCount() != 0) {
content.ensureCapacity(list.tagCount());
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound fluidTag = list.getCompoundTagAt(i);
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
if(stack != null) {
content.add(stack);
}
}
}
content.trimToSize();
recalculateFillLevel();
}
项目:fortressmod
文件:GeneratorCore.java
private List<List<Point>> readLayersFromNBT(NBTTagCompound compound,String id) {
NBTTagList layersList = compound.getTagList(id,NBT.TAG_COMPOUND);
//fill layersRead
List<List<Point>> layersRead = new ArrayList<List<Point>>();
for (int layerIndex = 0; layerIndex < layersList.tagCount(); layerIndex++) {
//get list from layersList
NBTTagCompound listCompound = layersList.getCompoundTagAt(layerIndex);
NBTTagList list = listCompound.getTagList("list",NBT.TAG_COMPOUND);
//fill layerRead
List<Point> layerRead = new ArrayList<Point>();
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
int x = item.getInteger("x");
int y = item.getInteger("y");
int z = item.getInteger("z");
layerRead.add(new Point(x,y,z));
}
layersRead.add(layerRead);
}
return layersRead;
}
@Override
public void readFromNBT(NBTTagCompound nbtTags) {
super.readFromNBT(nbtTags);
NBTTagList tagList = nbtTags.getTagList("Items",NBT.TAG_COMPOUND);
inventory = new ItemStack[getSizeInventory()];
for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) {
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(tagCount);
byte slot = tagCompound.getByte("Slot");
if (slot >= 0 && slot < getSizeInventory()) {
setInventorySlotContents(slot,ItemStack.loadItemStackFromNBT(tagCompound));
}
}
}
项目:Bewitchment
文件:Ritual.java
public static NonNullList<ItemStack> getItemsUsedForInput(NBTTagCompound tag) {
NonNullList<ItemStack> list = NonNullList.create();
NBTTagList tagList = tag.getTagList("itemsUsed",NBT.TAG_COMPOUND);
tagList.forEach(nbt -> {
NBTTagCompound itemTag = (NBTTagCompound) nbt;
list.add(new ItemStack(itemTag));
});
return list;
}
项目:Halloween
文件:EntityCreeperween.java
@Override
public void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
if (compound.hasKey("Fuse",NBT.TAG_ANY_NUMERIC)) this.fuseTime = compound.getShort("Fuse");
if (compound.hasKey("ExplosionRadius",NBT.TAG_ANY_NUMERIC)) this.explosionRadius = compound.getByte("ExplosionRadius");
if (compound.getBoolean("ignited")) this.ignite();
this.setEntityInvulnerable(true);
}
项目:Game-Stages
文件:PlayerDataHandler.java
@Override
public void readNBT (Capability<IStageData> capability,IStageData instance,EnumFacing side,NBTBase nbt) {
final NBTTagCompound tag = (NBTTagCompound) nbt;
final NBTTagList tagList = tag.getTagList("UnlockedStages",NBT.TAG_STRING);
for (int index = 0; index < tagList.tagCount(); index++) {
instance.unlockStage(tagList.getStringTagAt(index));
}
}
项目:BetterBeginningsReborn
文件:TileEntityCampfire.java
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
// Inventory
CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,mainHandler,tagCompound.getTagList(INV_TAG,NBT.TAG_COMPOUND));
// Burn Time & Cook Time
burnTime = tagCompound.getShort("BurnTime");
cookTime = tagCompound.getShort("CookTime");
currentItemBurnTime = FuelRegistry.getBurnTime(FuelConsumerType.CAMPFIRE,stackFuel());
decayTime = tagCompound.getShort("DecayTime");
campfireState = tagCompound.getByte("CampfireState");
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。