本文整理匯總了Java中net.minecraft.nbt.JsonToNBT.func_150315_a方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonToNBT.func_150315_a方法的具體用法?Java JsonToNBT.func_150315_a怎麽用?Java JsonToNBT.func_150315_a使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.nbt.JsonToNBT
的用法示例。
在下文中一共展示了JsonToNBT.func_150315_a方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getItemStackwNBT
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
/**
* Get an ItemStack instance with given amount of items and NBT Tag pTag is
* optional, and this function will return an ItemStack without NBT if pTag
* is empty
*
* @param pAmount
* @param pTag
* @return An itemstack with attached NBTTag, or null if the tag was invalid, or the itemdescriptor
* couldn't be turned into a valid itemstack
*/
public ItemStack getItemStackwNBT( int pAmount, String pTag )
{
NBTTagCompound tNBT = null;
boolean tDamagedNBT = false;
try
{
if( !pTag.isEmpty() )
tNBT = (NBTTagCompound) JsonToNBT.func_150315_a( pTag );
}
catch( Exception e )
{
_mLog.error( String.format( "Found invalid NBT Tag: %s", pTag ) );
tDamagedNBT = true;
}
if( !tDamagedNBT )
return getItemStackwNBT( pAmount, tNBT );
else
return null;
}
示例2: addNBTToStack
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
private void addNBTToStack(final String nbtString, final ItemStack stack, final EntityPlayer player) {
NBTBase base;
try {
base = JsonToNBT.func_150315_a(nbtString);
if (base instanceof NBTTagCompound) {
stack.setTagCompound((NBTTagCompound) base);
} else {
player.addChatMessage(new ChatComponentText("Error: Invalid NBT type provided in JSON."));
}
} catch (final NBTException e) {
player.addChatMessage(new ChatComponentText("Error: Invalid NBT JSON data: " + e.getMessage()));
}
}
示例3: makeItemStack
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
/**
* Makes an {@link ItemStack} based on the itemName reference, with supplied meta, stackSize and nbt, if possible
*
* Will return null if the item doesn't exist (because it's not from a loaded mod for example)
* Will throw a {@link RuntimeException} if the nbtString is invalid for use in an {@link ItemStack}
*
* @param itemName a registry name reference
* @param meta the meta
* @param stackSize the stack size
* @param nbtString an nbt stack as a string, will be processed by {@link JsonToNBT}
* @return a new itemstack
*/
public static ItemStack makeItemStack(String itemName, int meta, int stackSize, String nbtString)
{
if (itemName == null) throw new IllegalArgumentException("The itemName cannot be null");
Item item = GameData.getItemRegistry().func_82594_a(itemName);
if (item == null) {
FMLLog.getLogger().log(Level.TRACE, "Unable to find item with name {}", itemName);
return null;
}
ItemStack is = new ItemStack(item,1,meta);
if (!Strings.isNullOrEmpty(nbtString)) {
NBTBase nbttag = null;
try
{
nbttag = JsonToNBT.func_150315_a(nbtString);
} catch (NBTException e)
{
FMLLog.getLogger().log(Level.WARN, "Encountered an exception parsing ItemStack NBT string {}", nbtString, e);
throw Throwables.propagate(e);
}
if (!(nbttag instanceof NBTTagCompound)) {
FMLLog.getLogger().log(Level.WARN, "Unexpected NBT string - multiple values {}", nbtString);
throw new RuntimeException("Invalid NBT JSON");
} else {
is.func_77982_d((NBTTagCompound) nbttag);
}
}
return is;
}
示例4: VerifyConfig
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
private boolean VerifyConfig(CustomDrops pDropListToCheck)
{
boolean tSuccess = true;
for (CustomDrops.CustomDrop X : pDropListToCheck.getCustomDrops())
{
for (CustomDrops.CustomDrop.Drop Y : X.getDrops())
{
if (ItemDescriptor.fromString(Y.getItemName()) == null)
{
_mLogger.error(String.format("In ItemDropID: [%s], can't find item [%s]", Y.getIdentifier(), Y.getItemName()));
tSuccess = false;
}
if (Y.mTag != null && !Y.mTag.isEmpty())
{
try
{
NBTTagCompound tNBT = (NBTTagCompound) JsonToNBT.func_150315_a(Y.mTag);
if (tNBT == null) {
tSuccess = false;
}
}
catch (Exception e)
{
_mLogger.error(String.format("In ItemDropID: [%s], NBTTag is invalid", Y.getIdentifier()));
tSuccess = false;
}
}
}
}
return tSuccess;
}
示例5: parseNBT
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
public static NBTTagCompound parseNBT(String nbtTxt) {
if(nbtTxt == null || nbtTxt.isEmpty()) {
return null;
}
try {
NBTBase nbtbase = JsonToNBT.func_150315_a(nbtTxt);
return (NBTTagCompound) nbtbase;
} catch (NBTException e) {
Log.warn("EntityUtil.parseNBT: Could not parse NBT " + nbtTxt + " Error: " + e);
e.printStackTrace();
return null;
}
}
示例6: deserialize
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
@Override
public NBTTagCompound deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
try {
return (NBTTagCompound) JsonToNBT.func_150315_a(json.getAsString());
} catch (NBTException e) {
throw new JsonParseException(e);
}
}
示例7: VerifyConfig
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
/**
* Verify the loaded config and report errors if found
*
* @param pLootGroupsToCheck
* @return
*/
private boolean VerifyConfig( LootGroups pLootGroupsToCheck, boolean pIsLocalConfig )
{
boolean tSuccess = true;
List<Integer> tIDlist = new ArrayList<Integer>();
List<String> tNameList = new ArrayList<String>();
for( LootGroup X : pLootGroupsToCheck.getLootTable() )
{
if( tIDlist.contains( X.getGroupID() ) )
{
_mLogger.error( String.format( "[LootBags] LootGroup ID %d already exists!", X.getGroupID() ) );
tSuccess = false;
break;
}
else
tIDlist.add( X.getGroupID() );
if( tNameList.contains( X.getGroupName() ) )
{
_mLogger.error( String.format( "[LootBags] LootGroup with the Name %s already exists!", X.getGroupName() ) );
tSuccess = false;
break;
}
else
tNameList.add( X.getGroupName() );
// Skip lootItems check if we received the server config
if( pIsLocalConfig )
{ // This is a server-run. Verify we actually do have all items defined
if( X.getDrops().size() == 0 )
{
_mLogger.error( String.format( "[LootBags] LootGroup ID %d is empty. Adding dummy item", X.getGroupID() ) );
String tNothingDrop = ItemDescriptor.fromItem( Items.cookie ).toString();
X.getDrops().add( _mLGF.createDrop( tNothingDrop, "cookiedropbecauseempty", 1, false, 100, 0 ) );
// tSuccess = false; // Don't break on empty groups
break;
}
for( Drop Y : X.getDrops() )
{
if( ItemDescriptor.fromString( Y.getItemName() ) == null )
{
_mLogger.error( String.format( "[LootBags] In ItemDropID: [%s], can't find item [%s]", Y.getIdentifier(), Y.getItemName() ) );
tSuccess = false; // Maybe add the nothing-item here? Or the invalid-item item from HQM
}
if( Y.getNBTTag() != null && !Y.getNBTTag().isEmpty() )
{
try
{
NBTTagCompound tNBT = (NBTTagCompound) JsonToNBT.func_150315_a( Y.getNBTTag() );
if( tNBT == null )
tSuccess = false;
}
catch( Exception e )
{
_mLogger.error( String.format( "[LootBags] In ItemDropID: [%s], NBTTag is invalid", Y.getIdentifier() ) );
tSuccess = false;
}
}
}
}
}
return tSuccess;
}
示例8: drawScreen
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
{
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
this.inputField.drawTextBox();
IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().func_146236_a(Mouse.getX(), Mouse.getY());
if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null)
{
HoverEvent hoverevent = ichatcomponent.getChatStyle().getChatHoverEvent();
if (hoverevent.getAction() == HoverEvent.Action.SHOW_ITEM)
{
ItemStack itemstack = null;
try
{
NBTBase nbtbase = JsonToNBT.func_150315_a(hoverevent.getValue().getUnformattedText());
if (nbtbase != null && nbtbase instanceof NBTTagCompound)
{
itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound)nbtbase);
}
}
catch (NBTException nbtexception)
{
;
}
if (itemstack != null)
{
this.renderToolTip(itemstack, p_73863_1_, p_73863_2_);
}
else
{
this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", p_73863_1_, p_73863_2_);
}
}
else if (hoverevent.getAction() == HoverEvent.Action.SHOW_TEXT)
{
this.func_146283_a(Splitter.on("\n").splitToList(hoverevent.getValue().getFormattedText()), p_73863_1_, p_73863_2_);
}
else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ACHIEVEMENT)
{
StatBase statbase = StatList.func_151177_a(hoverevent.getValue().getUnformattedText());
if (statbase != null)
{
IChatComponent ichatcomponent1 = statbase.func_150951_e();
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"), new Object[0]);
chatcomponenttranslation.getChatStyle().setItalic(Boolean.valueOf(true));
String s = statbase instanceof Achievement ? ((Achievement)statbase).getDescription() : null;
ArrayList arraylist = Lists.newArrayList(new String[] {ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText()});
if (s != null)
{
arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150));
}
this.func_146283_a(arraylist, p_73863_1_, p_73863_2_);
}
else
{
this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", p_73863_1_, p_73863_2_);
}
}
GL11.glDisable(GL11.GL_LIGHTING);
}
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
示例9: summon
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
/**
* Spawns an entity of the specified type at the player location. Parameters
* of the entity are tweaked by the provided Json tag string if present.
*/
public static void summon(final EntityPlayer player, final String entityType, final String json) {
final double d0 = (double) player.getPlayerCoordinates().posX + 0.5D;
final double d1 = (double) player.getPlayerCoordinates().posY;
final double d2 = (double) player.getPlayerCoordinates().posZ + 0.5D;
final World world = player.getEntityWorld();
NBTTagCompound nbt = new NBTTagCompound();
boolean doSpawnWithEgg = true;
if (json != null && !json.isEmpty()) {
try {
final NBTBase nbtbase = JsonToNBT.func_150315_a(json);
if (!(nbtbase instanceof NBTTagCompound)) {
ModLog.warn("Malformed json string");
return;
}
nbt = (NBTTagCompound) nbtbase;
doSpawnWithEgg = false;
} catch (final NBTException ex) {
ex.printStackTrace();
return;
}
}
nbt.setString("id", entityType);
final Entity theEntity = EntityList.createEntityFromNBT(nbt, world);
if (theEntity == null) {
ModLog.warn("Unable to summon entity");
return;
}
theEntity.setLocationAndAngles(d0, d1, d2, theEntity.rotationYaw, theEntity.rotationPitch);
if (doSpawnWithEgg && theEntity instanceof EntityLiving) {
((EntityLiving) theEntity).onSpawnWithEgg((IEntityLivingData) null);
}
setTamed(theEntity, player);
world.spawnEntityInWorld(theEntity);
Entity entity2 = theEntity;
for (NBTTagCompound compound = nbt; entity2 != null
&& compound.hasKey("Riding", 10); compound = compound.getCompoundTag("Riding")) {
Entity entity = EntityList.createEntityFromNBT(compound.getCompoundTag("Riding"), world);
if (entity != null) {
entity.setLocationAndAngles(d0, d1, d2, entity.rotationYaw, entity.rotationPitch);
world.spawnEntityInWorld(entity);
entity2.mountEntity(entity);
}
entity2 = entity;
}
}
示例10: drawScreen
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int par1, int par2, float par3)
{
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
this.field_146415_a.drawTextBox();
IChatComponent var4 = this.mc.ingameGUI.getChatGUI().func_146236_a(Mouse.getX(), Mouse.getY());
if (var4 != null && var4.getChatStyle().getChatHoverEvent() != null)
{
HoverEvent var5 = var4.getChatStyle().getChatHoverEvent();
if (var5.getAction() == HoverEvent.Action.SHOW_ITEM)
{
ItemStack var6 = null;
try
{
NBTBase var7 = JsonToNBT.func_150315_a(var5.getValue().getUnformattedText());
if (var7 != null && var7 instanceof NBTTagCompound)
{
var6 = ItemStack.loadItemStackFromNBT((NBTTagCompound)var7);
}
}
catch (NBTException var11)
{
;
}
if (var6 != null)
{
this.func_146285_a(var6, par1, par2);
}
else
{
this.func_146279_a(EnumChatFormatting.RED + "Invalid Item!", par1, par2);
}
}
else if (var5.getAction() == HoverEvent.Action.SHOW_TEXT)
{
this.func_146279_a(var5.getValue().getFormattedText(), par1, par2);
}
else if (var5.getAction() == HoverEvent.Action.SHOW_ACHIEVEMENT)
{
StatBase var13 = StatList.func_151177_a(var5.getValue().getUnformattedText());
if (var13 != null)
{
IChatComponent var12 = var13.func_150951_e();
ChatComponentTranslation var8 = new ChatComponentTranslation("stats.tooltip.type." + (var13.isAchievement() ? "achievement" : "statistic"), new Object[0]);
var8.getChatStyle().setItalic(Boolean.valueOf(true));
String var9 = var13 instanceof Achievement ? ((Achievement)var13).getDescription() : null;
ArrayList var10 = Lists.newArrayList(new String[] {var12.getFormattedText(), var8.getFormattedText()});
if (var9 != null)
{
var10.addAll(this.fontRendererObj.listFormattedStringToWidth(var9, 150));
}
this.func_146283_a(var10, par1, par2);
}
else
{
this.func_146279_a(EnumChatFormatting.RED + "Invalid statistic/achievement!", par1, par2);
}
}
GL11.glDisable(GL11.GL_LIGHTING);
}
super.drawScreen(par1, par2, par3);
}
示例11: processCommand
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
if (par2ArrayOfStr.length < 2)
{
throw new WrongUsageException("commands.give.usage", new Object[0]);
}
else
{
EntityPlayerMP var3 = getPlayer(par1ICommandSender, par2ArrayOfStr[0]);
Item var4 = getItemByText(par1ICommandSender, par2ArrayOfStr[1]);
int var5 = 1;
int var6 = 0;
if (par2ArrayOfStr.length >= 3)
{
var5 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[2], 1, 64);
}
if (par2ArrayOfStr.length >= 4)
{
var6 = parseInt(par1ICommandSender, par2ArrayOfStr[3]);
}
ItemStack var7 = new ItemStack(var4, var5, var6);
if (par2ArrayOfStr.length >= 5)
{
String var8 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4).getUnformattedText();
try
{
NBTBase var9 = JsonToNBT.func_150315_a(var8);
if (!(var9 instanceof NBTTagCompound))
{
notifyAdmins(par1ICommandSender, "commands.give.tagError", new Object[] {"Not a valid tag"});
return;
}
var7.setTagCompound((NBTTagCompound)var9);
}
catch (NBTException var10)
{
notifyAdmins(par1ICommandSender, "commands.give.tagError", new Object[] {var10.getMessage()});
return;
}
}
EntityItem var11 = var3.dropPlayerItemWithRandomChoice(var7, false);
var11.delayBeforeCanPickup = 0;
var11.func_145797_a(var3.getCommandSenderName());
notifyAdmins(par1ICommandSender, "commands.give.success", new Object[] {var7.func_151000_E(), Integer.valueOf(var5), var3.getCommandSenderName()});
}
}
示例12: copyFromCommandBlock
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
private void copyFromCommandBlock(NBTTagCompound nbt, ItemStack stack, TileEntityCommandBlock commandBlock, EntityPlayer player)
{
NBTTagCompound tmp = new NBTTagCompound();
commandBlock.writeToNBT(tmp);
String command = tmp.getString("Command");
while(!command.isEmpty() && command.startsWith(" "))
command = command.substring(0);
String[] args = command.split(" ");
if(!args[0].startsWith("summon") && !args[0].startsWith("/summon"))
{
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"The command provided isn't a summon command!"));
return;
}
if(args.length >= 5)
{
try
{
IChatComponent ichatcomponent = CommandSummon.func_147178_a(commandBlock.func_145993_a(), args, 5);
NBTBase nbtbase = JsonToNBT.func_150315_a(ichatcomponent.getUnformattedText());
if(!(nbtbase instanceof NBTTagCompound))
{
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Can't parse NBT data!"));
return;
}
NBTTagCompound compound = (NBTTagCompound)nbtbase;
NBTTagList tasksList = compound.hasKey("CustomAITasks") ? (NBTTagList) compound.getTag("CustomAITasks") : null;
NBTTagList targetTasksList = compound.hasKey("CustomAITargetTasks") ? (NBTTagList) compound.getTag("CustomAITargetTasks") : null;
if(tasksList != null)
nbt.setTag("CustomAITasks", tasksList);
if(targetTasksList != null)
nbt.setTag("CustomAITargetTasks", targetTasksList);
player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC+"Successfully transfered AI data from the command block"));
stack.setItemDamage(1);
}
catch(Exception e)
{
;
}
}
else
{
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Failed to copy from command block: no AI tasks to fetch"));
}
}
示例13: drawScreen
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
{
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
this.inputField.drawTextBox();
IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().func_146236_a(Mouse.getX(), Mouse.getY());
if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null)
{
HoverEvent hoverevent = ichatcomponent.getChatStyle().getChatHoverEvent();
if (hoverevent.getAction() == HoverEvent.Action.SHOW_ITEM)
{
ItemStack itemstack = null;
try
{
NBTBase nbtbase = JsonToNBT.func_150315_a(hoverevent.getValue().getUnformattedText());
if (nbtbase != null && nbtbase instanceof NBTTagCompound)
{
itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound)nbtbase);
}
}
catch (NBTException nbtexception)
{
;
}
if (itemstack != null)
{
this.renderToolTip(itemstack, p_73863_1_, p_73863_2_);
}
else
{
this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", p_73863_1_, p_73863_2_);
}
}
else if (hoverevent.getAction() == HoverEvent.Action.SHOW_TEXT)
{
this.func_146283_a(Splitter.on("\n").splitToList(hoverevent.getValue().getFormattedText()), p_73863_1_, p_73863_2_);
}
else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ACHIEVEMENT)
{
StatBase statbase = StatList.func_151177_a(hoverevent.getValue().getUnformattedText());
if (statbase != null)
{
IChatComponent ichatcomponent1 = statbase.func_150951_e();
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"), new Object[0]);
chatcomponenttranslation.getChatStyle().setItalic(Boolean.valueOf(true));
String s = statbase instanceof Achievement ? ((Achievement)statbase).getDescription() : null;
ArrayList arraylist = Lists.newArrayList(new String[] {ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText()});
if (s != null)
{
arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150));
}
this.func_146283_a(arraylist, p_73863_1_, p_73863_2_);
}
else
{
this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", p_73863_1_, p_73863_2_);
}
}
GL11.glDisable(GL11.GL_LIGHTING);
}
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
示例14: processCommand
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_)
{
if (p_71515_2_.length < 2)
{
throw new WrongUsageException("commands.give.usage", new Object[0]);
}
else
{
EntityPlayerMP entityplayermp = getPlayer(p_71515_1_, p_71515_2_[0]);
Item item = getItemByText(p_71515_1_, p_71515_2_[1]);
int i = 1;
int j = 0;
if (p_71515_2_.length >= 3)
{
i = parseIntBounded(p_71515_1_, p_71515_2_[2], 1, 64);
}
if (p_71515_2_.length >= 4)
{
j = parseInt(p_71515_1_, p_71515_2_[3]);
}
ItemStack itemstack = new ItemStack(item, i, j);
if (p_71515_2_.length >= 5)
{
String s = func_147178_a(p_71515_1_, p_71515_2_, 4).getUnformattedText();
try
{
NBTBase nbtbase = JsonToNBT.func_150315_a(s);
if (!(nbtbase instanceof NBTTagCompound))
{
func_152373_a(p_71515_1_, this, "commands.give.tagError", new Object[] {"Not a valid tag"});
return;
}
itemstack.setTagCompound((NBTTagCompound)nbtbase);
}
catch (NBTException nbtexception)
{
func_152373_a(p_71515_1_, this, "commands.give.tagError", new Object[] {nbtexception.getMessage()});
return;
}
}
EntityItem entityitem = entityplayermp.dropPlayerItemWithRandomChoice(itemstack, false);
entityitem.delayBeforeCanPickup = 0;
entityitem.func_145797_a(entityplayermp.getCommandSenderName());
func_152373_a(p_71515_1_, this, "commands.give.success", new Object[] {itemstack.func_151000_E(), Integer.valueOf(i), entityplayermp.getCommandSenderName()});
}
}
示例15: convertToItemStacks
import net.minecraft.nbt.JsonToNBT; //導入方法依賴的package包/類
public static void convertToItemStacks()
{
itemStackContents = Maps.newHashMap();
for (SpawnChestContents contents : defaultContents.values())
{
ItemStack[] itemStacks = new ItemStack[27];
int count = 0;
for (SpawnChestContents.ItemEntry entry : contents.items)
{
ItemStack stack;
Item item = getItemFromName(entry.id);
if (item == null)
{
FMLLog.warning("[%s] the item: %s in file %s doesn't seem to exist! Not loading this item!!", Reference.MOD_ID, entry.id, contents.name);
continue;
}
Integer meta = entry.meta;
if (meta == null)
meta = 0;
stack = new ItemStack(item, meta, entry.amount);
try
{
NBTBase compoundBase = JsonToNBT.func_150315_a(entry.nbtTags);
if (!(compoundBase instanceof NBTTagCompound))
{
FMLLog.warning("[%s] the tag from the item %s in %s seems to contain an invalid tag!, the nbt data for this item will not be loaded!", Reference.MOD_ID, entry.id, contents.name);
return;
}
stack.setTagCompound((NBTTagCompound) compoundBase);
}
catch (NBTException e)
{
FMLLog.warning("[%s] Failed to read the NBTTags from %s in %s, the nbt data for this item will not be loaded!", Reference.MOD_ID, entry.id, contents.name);
}
itemStacks[count] = stack;
count++;
}
if (contents.resetAfterDeath == null)
contents.resetAfterDeath = false;
itemStackContents.put(contents.name, new SpawnChestItemStackContents(contents.name, contents.resetAfterDeath, itemStacks));
}
}