本文整理了Java中net.minecraft.item.ItemStack.getSubCompound()
方法的一些代码示例,展示了ItemStack.getSubCompound()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.getSubCompound()
方法的具体详情如下:
包路径:net.minecraft.item.ItemStack
类名称:ItemStack
方法名:getSubCompound
暂无
代码示例来源:origin: SleepyTrousers/EnderIO
public static float getCapLevelRaw(@Nonnull ItemStack stack) {
NBTTagCompound tag = stack.getSubCompound("eiocap");
if (tag == null) {
return 1;
}
return tag.getFloat("level");
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
public boolean setLevel(ItemStack stack, double newLevel) {
if (newLevel < 0D || newLevel > 100D) return false;
else {
stack.getSubCompound("Data", true).setDouble("Level", newLevel);
return true;
}
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
public double getLevel(ItemStack stack) {
return stack.getSubCompound("Data", true).getDouble("Level");
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
protected int getCharge(ItemStack stack) {
return stack.getSubCompound("Data", true).getInteger("Charge");
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(@Nonnull EntityLivingBase entityLiving, @Nonnull ItemStack itemStack, @Nonnull EntityEquipmentSlot armorSlot,
@Nonnull ModelBiped _default) {
if (armorType == EntityEquipmentSlot.HEAD && (PaintUtil.hasPaintSource(itemStack) || itemStack.getSubCompound("DSPAINT") != null)) { // TODO 1.13 remove
// DSPAINT
// Don't render the armor model of the helmet if it is painted. The paint will be rendered by the PaintedHelmetLayer.
return PaintedHelmetLayer.no_render;
}
return null;
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
public void levelTool(ItemStack stack) {
double level = stack.getSubCompound("Data", true).getDouble("Level");
double increase = getLevelIncrease(stack);
double newLevel = Math.min(100D, level + increase);
stack.getSubCompound("Data", true).setDouble("Level", newLevel);
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
public int getDamageForDisplay(ItemStack stack) {
int display = stack.getSubCompound("Data", true).getInteger("Damage");
int max = getMaximumToolDamage(stack);
if (display > max) {
stack.getSubCompound("Data", true).setInteger("Damage", max);
return max;
} else return display;
}
代码示例来源:origin: GregTechCE/GregTech
@Override
public int getInternalDamage(ItemStack itemStack) {
NBTTagCompound statsTag = itemStack.getSubCompound("GT.ToolStats");
if (statsTag == null || !statsTag.hasKey("Damage", Constants.NBT.TAG_INT)) {
return 0;
}
return statsTag.getInteger("Damage");
}
代码示例来源:origin: SleepyTrousers/EnderIO
public static List<Pair<String, Float>> getCapDataRaw(@Nonnull ItemStack stack) {
NBTTagCompound tag = stack.getSubCompound("eiocap");
if (tag == null) {
return null;
}
List<Pair<String, Float>> result = new ArrayList<Pair<String, Float>>();
for (String key : tag.getKeySet()) {
if (key != null && !"level".equals(key) && tag.hasKey(key, (new NBTTagFloat(0)).getId())) {
result.add(Pair.of(key, tag.getFloat(key)));
}
}
return result;
}
代码示例来源:origin: WayofTime/BloodMagic
@Nullable
public TeleportLocation getTeleportLocation(ItemStack stack) {
if (!(stack.getItem() instanceof ItemSigilTeleposition))
return null;
if (!stack.hasTagCompound())
return null;
NBTTagCompound locationTag = stack.getSubCompound("tplocation");
if (locationTag == null)
return null;
return TeleportLocation.fromTag(locationTag);
}
代码示例来源:origin: NanamiArihara/FoodCraft-Reloaded
@Nullable
@Override
public IItemColor getItemColorMultiplier() {
return (stack, tintIndex) -> {
if (stack.getSubCompound("cyl") == null)
stack.getOrCreateSubCompound("cyl");
return tintIndex == 1 ? FoodCraftReloadedMod.getLoader(FruitEnumLoader.class).get().getInstanceMap(ItemFruitIcecream.class)
.get(FruitType.values()[stack.getSubCompound("cyl").getInteger("value")]).getType().getColor().getRGB() : -1; };
}
代码示例来源:origin: GregTechCE/GregTech
@Nullable
public static SolidMaterial getHandleMaterial(ItemStack itemStack) {
NBTTagCompound statsTag = itemStack.getSubCompound("GT.ToolStats");
if(statsTag == null || !statsTag.hasKey("HandleMaterial", Constants.NBT.TAG_STRING))
return null;
Material material = Material.MATERIAL_REGISTRY.getObject(statsTag.getString("HandleMaterial"));
if(material instanceof SolidMaterial) {
return (SolidMaterial) material;
}
return null;
}
代码示例来源:origin: GregTechCE/GregTech
@Nullable
public static SolidMaterial getPrimaryMaterial(ItemStack itemStack) {
NBTTagCompound statsTag = itemStack.getSubCompound("GT.ToolStats");
if(statsTag == null || !statsTag.hasKey("PrimaryMaterial", Constants.NBT.TAG_STRING))
return null;
Material material = Material.MATERIAL_REGISTRY.getObject(statsTag.getString("PrimaryMaterial"));
if(material instanceof SolidMaterial) {
return (SolidMaterial) material;
}
return null;
}
代码示例来源:origin: NanamiArihara/FoodCraft-Reloaded
@Override
public ItemMeshDefinition getItemMeshDefinition() {
return stack -> {
if (stack.getSubCompound("cyl") != null)
return FoodCraftReloadedMod.getLoader(FruitEnumLoader.class).get().getInstanceMap(ItemFruitIcecream.class)
.get(FruitType.values()[stack.getSubCompound("cyl").getInteger("value")]).getModelLocation();
return new ModelResourceLocation("");
};
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(@Nonnull Item item, CreativeTabs tab, List<ItemStack> list) {
for (int i = 0; i < ToolTier.values().length; i++) {
ItemStack stack = new ItemStack(item, 1, i);
stack.getSubCompound("Data", true).setInteger("Damage", 0);
list.add(stack);
}
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
private boolean chopTree(BlockPos pos, EntityPlayer player, ItemStack stack) {
NBTTagCompound tag = stack.getSubCompound("Chopping", true);
tag.removeTag("Block"); //Remove the data now we're chopping
tag.removeTag("Times"); //Remove the data now we're chopping
if(player.world.isRemote) return true;
MinecraftForge.EVENT_BUS.register(new ChopTree(pos, player, stack));
player.world.playSound(null, pos, HFSounds.TREE_FALL, SoundCategory.BLOCKS, player.world.rand.nextFloat() * 0.25F, player.world.rand.nextFloat() * 1.0F + 0.5F);
return true;
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public String getPaintName(@Nonnull ItemStack itemStack) {
ItemStack paintSource = PaintUtil.getPaintSource(itemStack);
if (Prep.isValid(paintSource)) {
final NBTTagCompound subCompound = itemStack.getSubCompound("DSPAINT"); // TODO 1.13 remove
if (subCompound != null) {
paintSource = new ItemStack(subCompound);
}
}
if (Prep.isValid(paintSource)) {
return paintSource.getDisplayName();
}
return null;
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) {
if (canUse(stack) && canBeDamaged()) {
if (canLevel(stack, state)) {
ToolHelper.levelTool(stack);
}
stack.getSubCompound("Data", true).setInteger("Damage", getDamageForDisplay(stack) + 1);
}
return true;
}
代码示例来源:origin: SonarSonic/Calculator
@Override
public ItemStack removeModule(ItemStack stack, int slot) {
IModule module = getModuleInSlot(stack, slot);
NBTTagCompound tag = stack.getSubCompound(String.valueOf(slot));
stack.setTagInfo(String.valueOf(slot), new NBTTagCompound());
stack.getTagCompound().setString("slot" + slot, "");
ItemStack toReturn = new ItemStack(ModuleItemRegistry.instance().getValue(module.getName()), 1);
if (tag != null && !tag.hasNoTags())
toReturn.setTagCompound(tag);
return toReturn;
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
public void onQuestCompleted(EntityPlayer player) {
if (player.getHeldItemMainhand() != null) {
long cost = HFApi.quests.hasCompleted(Quests.TOMAS_15K, player) ? 1000 : 2500;
ItemStack stack = player.getHeldItemMainhand().copy();
ItemStack tool = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
tool.getSubCompound("Data", true).setDouble("Level", stack.getSubCompound("Data", true).getDouble("Level"));
rewardGold(player, -cost);
takeHeldStack(player, 1);
rewardItem(player, tool);
spawnXP(player.world, (int) player.posX, (int) player.posY, (int) player.posZ, 5);
}
}
内容来源于网络,如有侵权,请联系作者删除!