本文整理汇总了Java中net.minecraft.nbt.NBTTagByte类的典型用法代码示例。如果您正苦于以下问题:Java NBTTagByte类的具体用法?Java NBTTagByte怎么用?Java NBTTagByte使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NBTTagByte类属于net.minecraft.nbt包,在下文中一共展示了NBTTagByte类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFromNBT
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
public void readFromNBT(final NBTTagCompound par1NBTTagCompound) {
super.readFromNBT(par1NBTTagCompound);
if (par1NBTTagCompound.hasKey("block_no") && par1NBTTagCompound.getTag("block_no") instanceof NBTTagInt) {
this.b = par1NBTTagCompound.getInteger("block_no");
}
else {
LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (block_no)", new Object[0]);
}
if (par1NBTTagCompound.hasKey("chunk_no") && par1NBTTagCompound.getTag("chunk_no") instanceof NBTTagByte) {
this.chunk_no = par1NBTTagCompound.getByte("chunk_no");
}
else {
LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (chunk_no)", new Object[0]);
}
if (this.chunk_no == -128) {
this.finished = true;
}
else {
this.setChunk(this.chunk_no);
}
this.tank.readFromNBT(par1NBTTagCompound.getCompoundTag("tank"));
this.init = true;
}
示例2: asJson
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
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;
}
}
示例3: getColorFromItemStack
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass)
{
NBTTagCompound tag = stack.getTagCompound();
int biomeId = -1;
if ( tag != null )
{
NBTTagByte biome = ( NBTTagByte ) tag.getTag( SAMPLED_BIOME_TAG );
if ( biome != null )
{
biomeId = biome.getByte() & 255;
}
}
if ( pass == 1 )
{
return biomeId >= 0 ? BiomeGenBase.getBiomeGenArray()[ biomeId ].color : 0;
}
return 0xFFFFFFFF;
}
示例4: createTag
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
/** Creates and returns a primitive NBT tag from a value.
* If the value already is an NBT tag, it is returned instead. */
public static NBTBase createTag(Object value) {
if (value == null)
throw new IllegalArgumentException("value is null");
if (value instanceof NBTBase) return (NBTBase)value;
if (value instanceof Byte) return new NBTTagByte((Byte)value);
if (value instanceof Short) return new NBTTagShort((Short)value);
if (value instanceof Integer) return new NBTTagInt((Integer)value);
if (value instanceof Long) return new NBTTagLong((Long)value);
if (value instanceof Float) return new NBTTagFloat((Float)value);
if (value instanceof Double) return new NBTTagDouble((Double)value);
if (value instanceof String) return new NBTTagString((String)value);
if (value instanceof byte[]) return new NBTTagByteArray((byte[])value);
if (value instanceof int[]) return new NBTTagIntArray((int[])value);
throw new IllegalArgumentException("Can't create an NBT tag of value: " + value);
}
示例5: getObject
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
public static Object getObject(NBTBase base)
{
if(base instanceof NBTTagByte)
return ((NBTTagByte)base).func_150290_f();
if(base instanceof NBTTagShort)
return ((NBTTagShort)base).func_150289_e();
if(base instanceof NBTTagInt)
return ((NBTTagInt)base).func_150287_d();
if(base instanceof NBTTagLong)
return ((NBTTagLong)base).func_150291_c();
if(base instanceof NBTTagFloat)
return ((NBTTagFloat)base).func_150288_h();
if(base instanceof NBTTagDouble)
return ((NBTTagDouble)base).func_150286_g();
if(base instanceof NBTTagByteArray)
return ((NBTTagByteArray)base).func_150292_c();
if(base instanceof NBTTagString)
return ((NBTTagString)base).func_150285_a_();
if(base instanceof NBTTagList)
return base;
if(base instanceof NBTTagCompound)
return ((NBTTagCompound)base);
if(base instanceof NBTTagIntArray)
return ((NBTTagIntArray)base).func_150302_c();
return null;
}
示例6: setValidValue
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
private static void setValidValue(Node<NamedNBT> node, String value){
NamedNBT named = node.getObject();
NBTBase base = named.getNBT();
if (base instanceof NBTTagByte)
named.setNBT(new NBTTagByte(ParseHelper.parseByte(value)));
if (base instanceof NBTTagShort)
named.setNBT(new NBTTagShort(ParseHelper.parseShort(value)));
if (base instanceof NBTTagInt)
named.setNBT(new NBTTagInt(ParseHelper.parseInt(value)));
if (base instanceof NBTTagLong)
named.setNBT(new NBTTagLong(ParseHelper.parseLong(value)));
if(base instanceof NBTTagFloat)
named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value)));
if(base instanceof NBTTagDouble)
named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value)));
if(base instanceof NBTTagByteArray)
named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value)));
if(base instanceof NBTTagIntArray)
named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value)));
if (base instanceof NBTTagString)
named.setNBT(new NBTTagString(value));
}
示例7: getCraftingResult
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
@Override
@Nonnull
public ItemStack getCraftingResult(InventoryCrafting inv) {
int lanolinCount = 0;
ItemStack craftStack = null;
for(int i = 0; i < inv.getSizeInventory(); i++){
ItemStack tempStack = inv.getStackInSlot(i);
if(tempStack.getItem().getRegistryName().equals(ModItems.itemLanolin.getRegistryName()))
lanolinCount++;
else if(ItemLanolin.canCraftWith(tempStack) && craftStack == null) {
craftStack = tempStack.copy();
}
else if(tempStack != ItemStack.EMPTY)
return ItemStack.EMPTY;
}
if (craftStack == ItemStack.EMPTY || !ItemLanolin.canCraftWith(craftStack)) {
return ItemStack.EMPTY;
}
// Copy Existing NBT
if(craftStack.hasTagCompound()) {
if(craftStack.getTagCompound().hasKey("lanolin")){
// Increase existing lanolin count
lanolinCount += craftStack.getTagCompound().getInteger("lanolin");
}
}
if(craftStack.getItem() instanceof ItemArmor)
craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, Config.MAX_LANOLIN_ARMOR)));
else if(craftStack.getItem() instanceof ItemTool)
craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, Config.MAX_LANOLIN_TOOLS)));
else // Unconfigured item, that passed
craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, 15)));
return craftStack;
}
示例8: readItemsFromNBT
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
public static NonNullList<Pair<Integer, ItemStack>> readItemsFromNBT(NBTTagCompound tagCompound)
{
NonNullList<Pair<Integer, ItemStack>> items = NonNullList.create();
NBTTagList nbtList = tagCompound.getTagList("Items", 10);
for (int i = 0; i < nbtList.tagCount(); ++i)
{
NBTTagCompound nbtTagCompound = nbtList.getCompoundTagAt(i);
NBTBase nbt = nbtTagCompound.getTag("Slot");
int j;
if (nbt instanceof NBTTagByte)
{
j = nbtTagCompound.getByte("Slot") & 255;
} else
{
j = nbtTagCompound.getShort("Slot");
}
if (j >= 0)
{
ItemStack itemstack = new ItemStack(nbtTagCompound);
items.add(Pair.of(j, itemstack));
}
}
return items;
}
示例9: writeToNBT
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagIn) {
NBTTagCompound tagOut = super.writeToNBT(tagIn);
tagOut.setTag("inputtank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(inputTank, null));
tagOut.setTag("outputtank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(outputTank, null));
tagOut.setTag("heatstorage", Thermionics.CAPABILITY_HEATSTORAGE.writeNBT(heat, null));
tagOut.setTag("inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(itemStorage, null));
tagOut.setTag("locked", new NBTTagByte((byte) (tanksLocked ? 1 : 0)));
return tagOut;
}
示例10: getNBTBaseData
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
public static Object getNBTBaseData(final NBTBase nbt) {
if (nbt == null) {
return null;
}
switch (nbt.getId()) {
case 1: {
return ((NBTTagByte)nbt).func_150290_f();
}
case 2: {
return ((NBTTagShort)nbt).func_150289_e();
}
case 3: {
return ((NBTTagInt)nbt).func_150287_d();
}
case 4: {
return ((NBTTagLong)nbt).func_150291_c();
}
case 5: {
return ((NBTTagFloat)nbt).func_150288_h();
}
case 6: {
return ((NBTTagDouble)nbt).func_150286_g();
}
case 8: {
return ((NBTTagString)nbt).func_150285_a_();
}
case 10: {
return nbt;
}
default: {
return null;
}
}
}
示例11: getNBTBase
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
public static NBTBase getNBTBase(final Object o) {
if (o instanceof Integer) {
return (NBTBase)new NBTTagInt((Integer)o);
}
if (o instanceof Short) {
return (NBTBase)new NBTTagShort((Short)o);
}
if (o instanceof Long) {
return (NBTBase)new NBTTagLong((Long)o);
}
if (o instanceof String) {
return (NBTBase)new NBTTagString((String)o);
}
if (o instanceof Double) {
return (NBTBase)new NBTTagDouble((Double)o);
}
if (o instanceof Float) {
return (NBTBase)new NBTTagFloat((Float)o);
}
if (o instanceof NBTTagCompound) {
return (NBTBase)o;
}
if (o instanceof Byte) {
return (NBTBase)new NBTTagByte((Byte)o);
}
LogHelper.debug("Can't find type for " + o, new Object[0]);
throw null;
}
示例12: isStackLayout
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
private boolean isStackLayout(NBTTagCompound nbt) {
return nbt.hasKey("id") &&
nbt.hasKey("Count") &&
nbt.hasKey("Damage") &&
nbt.getTag("id") instanceof NBTTagShort &&
nbt.getTag("Count") instanceof NBTTagByte &&
nbt.getTag("Damage") instanceof NBTTagShort;
}
示例13: getMergers
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
private Map<Class<? extends NBTBase>, NbtMerger<? extends NBTBase>> getMergers() {
if (mergers == null) {
mergers = new HashMap<>();
registerMerger(NBTTagByte.class, new NbtByteMerger(this));
registerMerger(NBTTagCompound.class, new NbtCompoundMerger(this));
registerMerger(NBTTagDouble.class, new NbtDoubleMerger(this));
registerMerger(NBTTagFloat.class, new NbtFloatMerger(this));
registerMerger(NBTTagInt.class, new NbtIntMerger(this));
registerMerger(NBTTagList.class, new NbtListMerger(this));
registerMerger(NBTTagLong.class, new NbtLongMerger(this));
registerMerger(NBTTagShort.class, new NbtShortMerger(this));
registerMerger(NBTTagString.class, new NbtStringMerger(this));
}
return mergers;
}
示例14: merge
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
@Override
public NBTTagByte merge(NBTTagByte nbt, Object data, String key, String path) {
if (data instanceof Boolean) {
return NbtConverter.toNbt((Boolean) data);
}
if (data instanceof Number) {
return NbtConverter.toNbt(((Number) data).byteValue());
}
throw converter.conversionException(path, data, "boolean/number");
}
示例15: toNBTElement
import net.minecraft.nbt.NBTTagByte; //导入依赖的package包/类
/**
* Converts a {@link JsonElement} into an {@link NBTBase}
*
* @param element the {@link JsonElement} to convert
* @return the converted {@link NBTBase}
*/
public static NBTBase toNBTElement(JsonElement element) {
if (element.isJsonArray()) {
NBTTagList list = new NBTTagList();
for (JsonElement elem : element.getAsJsonArray()) list.appendTag(toNBTElement(elem));
return list;
}
else if (element.isJsonObject()) {
NBTTagCompound compound = new NBTTagCompound();
for (Map.Entry<String, JsonElement> entry : element.getAsJsonObject().entrySet()) compound.setTag(entry.getKey(), toNBTElement(entry.getValue()));
return compound;
}
else if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isNumber()) {
Number num = element.getAsJsonPrimitive().getAsNumber();
if (num instanceof Byte) return new NBTTagByte(num.byteValue());
else if (num instanceof Short) return new NBTTagShort(num.shortValue());
else if (num instanceof Integer) return new NBTTagInt(num.intValue());
else if (num instanceof Long) return new NBTTagLong(num.longValue());
else if (num instanceof Float) return new NBTTagFloat(num.floatValue());
else if (num instanceof Double) return new NBTTagDouble(num.doubleValue());
else return new NBTTagDouble(num.doubleValue());
}
else if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isString())
return new NBTTagString(element.getAsJsonPrimitive().getAsString());
else return null;
}