当前位置: 首页>>代码示例>>Java>>正文


Java NBTException类代码示例

本文整理汇总了Java中net.minecraft.nbt.NBTException的典型用法代码示例。如果您正苦于以下问题:Java NBTException类的具体用法?Java NBTException怎么用?Java NBTException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NBTException类属于net.minecraft.nbt包,在下文中一共展示了NBTException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseStack

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
public static ItemStack parseStack(String name) {
    if (name.contains("/")) {
        String[] split = StringUtils.split(name, "/");
        ItemStack stack = parseStackNoNBT(split[0]);
        if (ItemStackTools.isEmpty(stack)) {
            return stack;
        }
        NBTTagCompound nbt;
        try {
            nbt = JsonToNBT.getTagFromJson(split[1]);
        } catch (NBTException e) {
            InControl.logger.log(Level.ERROR, "Error parsing NBT in '" + name + "'!");
            return ItemStackTools.getEmptyStack();
        }
        stack.setTagCompound(nbt);
        return stack;
    } else {
        return parseStackNoNBT(name);
    }
}
 
开发者ID:McJty,项目名称:InControl,代码行数:21,代码来源:Tools.java

示例2: getEntityDataTag

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
public NBTTagCompound getEntityDataTag()
{
	NBTTagCompound tag = null;
	
	if (!this.entityNBTData.equals(""))
	{
		try
		{
			tag = JsonToNBT.getTagFromJson(this.entityNBTData);
		}
		catch (NBTException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	return tag;
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:20,代码来源:BuildEntity.java

示例3: getBlockStateDataTag

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
public NBTTagCompound getBlockStateDataTag()
{
	NBTTagCompound tag = null;
	
	if (!this.blockStateData.equals(""))
	{
		try
		{
			tag = JsonToNBT.getTagFromJson(this.blockStateData);
		}
		catch (NBTException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	return tag;
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:20,代码来源:BuildBlock.java

示例4: SpecialItem

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
SpecialItem(String n, byte c, short m, @Nullable String t) {
	name = n;
	amount = c;
	meta = m;
	if (t != null) {
		NBTTagCompound nbt;
		try {
			nbt = JsonToNBT.getTagFromJson(t);
		} catch (NBTException e) {
			MCFluxReport.sendException(e, "NBT Decoding");
			nbt = null;
		}
		tag = nbt;
	} else
		tag = null;
	item = Item.getByNameOrId(name);
}
 
开发者ID:Szewek,项目名称:Minecraft-Flux,代码行数:18,代码来源:SpecialEvent.java

示例5: Deserialize

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
@Override
public Object Deserialize(Object input) {
    String json = "{}";
    if(input instanceof String) {
        json = input.toString();
    } else if(input instanceof ScriptObjectMirror) {
        json = NashornConfigProcessor.getInstance().nashorn.stringifyJsonObject((JSObject) input);
    }

    try {
        return JsonToNBT.getTagFromJson(json);
    } catch (NBTException e) {
        LogHelper.error("Unable to convert '" + json + "' to NBT tag.", e);
        return new NBTTagCompound();
    }
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:17,代码来源:NbtTagCompoundDeserializer.java

示例6: makeItemStackFromString

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
/** Creates a new ItemStack from the string acquired from makeStringFromItemStack or an oredict name, with an oredict index option */
public static ItemStack makeItemStackFromString(String stackString, int oreIndex) {
	if(stackString == LightningInfusionRecipe.nullIdentifier) return null;
	try { // try to load it as a regular NBT stack
		if(!isStringOreDict(stackString)) {
			return ItemStack.loadItemStackFromNBT(JsonToNBT.getTagFromJson(stackString));
		} else {
			throw new NBTException("OreDict exists");
		}
	} catch(NBTException e) { // now try to get it as an oredict entry
		List<ItemStack> list;
		if(isStringOreDict(stackString) && oreIndex < (list = OreDictionary.getOres(stackString)).size()) {
			return list.get(oreIndex); // yep
		} else {
			return null; // guess not
		}
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:19,代码来源:StackHelper.java

示例7: handleClickServer

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
public void handleClickServer(EntityNPC npc){
	if(action.startsWith("action.nbt=")){
		String[] equalsplit = action.split("=");
		String nbt_json = "";
		for(int i = 1; i < equalsplit.length; i++){
			nbt_json += equalsplit[i];
		}
		NBTTagCompound newNBT;
		try {
			newNBT = JsonToNBT.getTagFromJson(nbt_json);
		} catch (NBTException e) {
			e.printStackTrace();
			return;
		}
		npc.getScriptData().merge(newNBT);
	}
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:18,代码来源:NPCDialogue.java

示例8: getResourceStack

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
public ItemStack getResourceStack() {
    if(stackOverride != null) {
        NBTTagCompound tag;
        try {
            tag = JsonToNBT.getTagFromJson(stackOverride);
        } catch (NBTException e) {
            e.printStackTrace();
            return new ItemStack(getBlock(), 1, stackMeta);
        }
        if(tag != null) {
            ItemStack stack = new ItemStack(tag);
            if(stack != null) {
                return stack;
            }
        }
    }
    return new ItemStack(getBlock(), 1, stackMeta);
}
 
开发者ID:InfinityRaider,项目名称:SettlerCraft,代码行数:19,代码来源:Schematic.java

示例9: readFromNBT

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
/********************************************************************************
 * Abstract - WorldSavedData
 ********************************************************************************/

@Override
public void readFromNBT( NBTTagCompound comp ) 
{
	this.owners.clear();
	
	try 
	{
		this.owners.putAll( 
			NBTUtil.toLimitedBlockOwnersMap( (NBTTagList)comp.getTag( NBT_OWNER_MAP ) ) 
		);
	} 
	catch ( NBTException e ) 
	{
		Log.error( e.getMessage() );
	}
}
 
开发者ID:DerOli82,项目名称:LimitedResources,代码行数:21,代码来源:LimitedBlockOwners.java

示例10: toCoordinate

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
/**
 * Gets Coordinate out of an NBTTagCompound
 * 
 * @param NBTTagCompound
 * @return Coordinate
 * @throws NBTException
 */
public static Coordinate toCoordinate( NBTTagCompound comp ) throws NBTException
{
	//All four keys required!
	if( ( comp.hasKey( NBT_COORDINATE_DIMID ) == false ) ||
		( comp.hasKey( NBT_COORDINATE_X ) == false ) ||
		( comp.hasKey( NBT_COORDINATE_Y ) == false ) ||
		( comp.hasKey( NBT_COORDINATE_Z ) == false ) )
	{
		throw new NBTException( "NBTTagCompound has no coordinates." );
	}
	return new Coordinate( 
		comp.getInteger( NBT_COORDINATE_DIMID ),
		comp.getInteger( NBT_COORDINATE_X ),
		comp.getInteger( NBT_COORDINATE_Y ),
		comp.getInteger( NBT_COORDINATE_Z )
	);
}
 
开发者ID:DerOli82,项目名称:LimitedResources,代码行数:25,代码来源:NBTUtil.java

示例11: validateChildren

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
protected boolean validateChildren() throws ParserException
 {
     super.validateChildren();
     this.blocks = this.validateRequiredAttribute(String.class, "Block", true);
     this.weight = this.validateNamedAttribute(Float.class, "Weight", this.weight, true);
     String nbtJson = this.validateNamedAttribute(String.class, "NBT", null, true);
     if (nbtJson != null) {
     	try {
     		NBTBase base = JsonToNBT.getTagFromJson(nbtJson);
     		if (base instanceof NBTTagCompound) {
     			this.nbt = (NBTTagCompound)base;
     		} else {
     			throw new ParserException("NBT is not a compound tag");
     		}
} catch (NBTException e) {
	throw new ParserException("Failed to parse JSON", e);
}
     }
     return true;
 }
 
开发者ID:lawremi,项目名称:CustomOreGen,代码行数:21,代码来源:ValidatorBlockDescriptor.java

示例12: onInitialSpawn

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) {
	setItemStackToSlot(this.isLeftHanded() ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND, new ItemStack(HarshenItems.PROPS, 1, 0));
	try {
		setItemStackToSlot(this.isLeftHanded() ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, new ItemStack(JsonToNBT.getTagFromJson("{id:\"minecraft:shield\",Count:1b,tag:{BlockEntityTag:{Patterns:[{Pattern:\"ss\",Color:6},{Pattern:\"flo\",Color:1}],Base:8}},Damage:0s}")));
	} catch (NBTException e) {
		e.printStackTrace();
	}
       this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1));
       this.setLeftHanded(false);
	return livingdata;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:13,代码来源:EntitySoullessKnight.java

示例13: processCommand

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("commands.testfor.usage", new Object[0]);
    }
    else
    {
        Entity entity = func_175768_b(sender, args[0]);
        NBTTagCompound nbttagcompound = null;

        if (args.length >= 2)
        {
            try
            {
                nbttagcompound = JsonToNBT.getTagFromJson(buildString(args, 1));
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.testfor.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        if (nbttagcompound != null)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            entity.writeToNBT(nbttagcompound1);

            if (!NBTUtil.func_181123_a(nbttagcompound, nbttagcompound1, true))
            {
                throw new CommandException("commands.testfor.failure", new Object[] {entity.getName()});
            }
        }

        notifyOperators(sender, this, "commands.testfor.success", new Object[] {entity.getName()});
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:41,代码来源:CommandTestFor.java

示例14: deserialize

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
@Override
public NBTTagCompound deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
    try
    {
        return JsonToNBT.getTagFromJson(json.getAsString());
    } catch (NBTException e)
    {
        e.printStackTrace();
    }

    throw new JsonParseException("Failed to parse nbt");
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:14,代码来源:NBTTagCompoundDeserializer.java

示例15: deserialize

import net.minecraft.nbt.NBTException; //导入依赖的package包/类
public SetNBT deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn)
{
    try
    {
        NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(JsonUtils.getString(object, "tag"));
        return new SetNBT(conditionsIn, nbttagcompound);
    }
    catch (NBTException nbtexception)
    {
        throw new JsonSyntaxException(nbtexception);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:SetNBT.java


注:本文中的net.minecraft.nbt.NBTException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。