本文整理汇总了Java中net.lomeli.lomlib.util.NBTUtil类的典型用法代码示例。如果您正苦于以下问题:Java NBTUtil类的具体用法?Java NBTUtil怎么用?Java NBTUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NBTUtil类属于net.lomeli.lomlib.util包,在下文中一共展示了NBTUtil类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSubItems
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) {
ItemStack empty = new ItemStack(itemIn);
NBTUtil.setInteger(empty, ModNBT.STORED_ENERGY, 0);
subItems.add(empty);
ItemStack full = new ItemStack(itemIn);
NBTUtil.setInteger(full, ModNBT.STORED_ENERGY, Config.fusionCoreCapacity);
subItems.add(full);
}
示例2: receiveEnergy
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
@Override
public int receiveEnergy(ItemStack stack, int max, boolean simulate) {
if (stack == null) return 0;
int energy = NBTUtil.getInt(stack, ModNBT.STORED_ENERGY);
int added = Math.min(Config.fusionCoreCapacity - energy, max);
if (!simulate)
NBTUtil.setInteger(stack, ModNBT.STORED_ENERGY, energy + added);
return added;
}
示例3: extractEnergy
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
@Override
public int extractEnergy(ItemStack stack, int max, boolean simulate) {
if (stack == null) return 0;
int energy = getEnergyStored(stack);
int loss = Math.min(energy, max);
if (!simulate)
NBTUtil.setInteger(stack, ModNBT.STORED_ENERGY, energy - loss);
return loss;
}
示例4: handleItemTooltipEvent
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
@SubscribeEvent
public void handleItemTooltipEvent(ItemTooltipEvent event) {
ItemStack stack = event.itemStack;
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && CharmRegistry.isValidArmor(stack) && NBTUtil.hasTag(stack, ModLibs.CHARM_TAG)) {
String[] charms = ArmorAAPI.charmRegistry.getItemCharms(stack);
if (charms != null && charms.length > 0) {
event.toolTip.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "Charms:" + EnumChatFormatting.RESET);
for (String id : charms) {
AbstractCharm charm = ArmorAAPI.charmRegistry.getCharm(id);
if (charm != null && ArmorAAPI.charmRegistry.canApplyCharmToItem(stack, id))
event.toolTip.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal(charm.unlocalizedName()) + EnumChatFormatting.RESET);
}
}
}
}
示例5: getItemCharms
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
@Override
public String[] getItemCharms(ItemStack stack) {
if (stack == null || stack.getItem() == null)
return new String[0];
String values = NBTUtil.getString(stack, ModLibs.CHARM_TAG);
String[] charms = values.split(";");
return charms != null ? charms : new String[0];
}
示例6: applyCharmToItem
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
@Override
public boolean applyCharmToItem(ItemStack stack, String charmID) {
if (itemHasCharm(stack, charmID))
return false;
String values = NBTUtil.getString(stack, ModLibs.CHARM_TAG) + charmID + ";";
NBTUtil.setString(stack, ModLibs.CHARM_TAG, values);
return true;
}
示例7: setStackEMC
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
public static void setStackEMC(ItemStack stack, EnergyValue value) {
if (stack == null)
return;
NBTTagCompound emcTag = new NBTTagCompound();
value.writeToNBT(emcTag);
NBTUtil.setTagCompound(stack, EMC_TAG, emcTag);
int meta = value.getValue() > 1200000f ? 5 : MathHelper.floor(value.getValue() / 200000f);
stack.setItemDamage(meta);
}
示例8: getStackEMC
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
public static EnergyValue getStackEMC(ItemStack stack) {
EnergyValue value = new EnergyValue(0);
if (stack != null && stack.hasTagCompound()) {
NBTTagCompound emcTag = NBTUtil.getTagCompound(stack, EMC_TAG);
value.readFromNBT(emcTag);
}
return value;
}
示例9: getEnergyStored
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
@Override
public int getEnergyStored(ItemStack stack) {
if (stack == null) return 0;
return NBTUtil.getInt(stack, ModNBT.STORED_ENERGY);
}
示例10: hasOwnerUUID
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
public static boolean hasOwnerUUID(ItemStack itemStack) {
return itemStack != null && itemStack.getItem() != null && NBTUtil.hasTag(itemStack, "ownerUUIDMostSig") && NBTUtil.hasTag(itemStack, "ownerUUIDLeastSig");
}
示例11: getOwnerUUID
import net.lomeli.lomlib.util.NBTUtil; //导入依赖的package包/类
public static UUID getOwnerUUID(ItemStack itemStack) {
return hasOwnerUUID(itemStack) ? new UUID(NBTUtil.getLong(itemStack, "ownerUUIDMostSig"), NBTUtil.getLong(itemStack, "ownerUUIDLeastSig")) : null;
}