本文整理汇总了Java中net.minecraft.nbt.NBTTagLong类的典型用法代码示例。如果您正苦于以下问题:Java NBTTagLong类的具体用法?Java NBTTagLong怎么用?Java NBTTagLong使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NBTTagLong类属于net.minecraft.nbt包,在下文中一共展示了NBTTagLong类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFromNBT
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound tag) {
NBTTagList list = tag.getTagList("blocks", Constants.NBT.TAG_LONG);
blocks.clear();
for (int i = 0; i < list.tagCount(); i++) {
blocks.add(BlockPos.fromLong(((NBTTagLong) list.get(i)).getLong()));
}
list = tag.getTagList("leaves", Constants.NBT.TAG_COMPOUND);
leavesToTick.clear();
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound tc = list.getCompoundTagAt(i);
BlockPos pos = BlockPos.fromLong(tc.getLong("p"));
int counter = tc.getInteger("c");
leavesToTick.put(pos, counter);
}
}
示例2: deserializeNBT
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Override
public void deserializeNBT(NBTTagCompound nbt)
{
this.growthRanges[0].deserializeNBT(nbt.getCompoundTag("tGrowthRangeMinimal"));
this.growthRanges[1].deserializeNBT(nbt.getCompoundTag("tGrowthRangeOptimal"));
this.growthRanges[2].deserializeNBT(nbt.getCompoundTag("tGrowthRangePerfect"));
this.humidityGrowthRange = Pair.of(nbt.getCompoundTag("hGrowthRange").getFloat("min"), nbt.getCompoundTag("hGrowthRange").getFloat("max"));
this.generation = nbt.getInteger("generation");
this.wild = nbt.getBoolean("wild");
this.type = EnumCrop.values()[nbt.getByte("type")];
this.plantedAt = new Calendar();
if (nbt.hasKey("plantedAt"))
{
this.plantedAt.deserializeNBT((NBTTagLong) nbt.getTag("plantedAt"));
}
this.health = nbt.getFloat("health");
this.growthRate = nbt.getFloat("growthRate");
this.waterConsumption = nbt.getFloat("waterConsumption");
this.growth = nbt.getFloat("growth");
this.nutrientConsumption.clear();
nbt.getTagList("nutrientConsumption", NBT.TAG_COMPOUND).forEach(tag -> this.nutrientConsumption.put(EnumPlantNutrient.values()[((NBTTagCompound)tag).getByte("nutrient")], ((NBTTagCompound)tag).getFloat("amount")));
}
示例3: test_merge__Can_create_new_Tag
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Test
public void test_merge__Can_create_new_Tag() {
// Given:
NBTTagCompound nbt = new NBTTagCompound();
Table data = new DefaultTable();
String key = "my_key";
long value = 53;
data.rawset(key, value);
// When:
NBTTagCompound actual = underTest.merge(nbt, data);
// Then:
assertThat(actual.getKeySet()).containsOnly(key);
assertThat(actual.getTag(key)).isEqualTo(new NBTTagLong(value));
}
示例4: test_toNbtCompound__With_numeric_Value
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Test
public void test_toNbtCompound__With_numeric_Value() {
// Given:
Table data = new DefaultTable();
String key = "my_key";
long value = 42;
data.rawset(key, value);
String keyString = String.valueOf(key);
// When:
NBTTagCompound actual = underTest.toNbtCompound(data);
// Then:
assertThat(actual.getKeySet()).containsOnly(keyString);
assertThat(actual.getTag(keyString)).isEqualTo(new NBTTagLong(value));
}
示例5: test_toNbtCompound__With_Compound_Value
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Test
public void test_toNbtCompound__With_Compound_Value() {
// Given:
Table data = new DefaultTable();
String key = "my_key";
Table value = new DefaultTable();
data.rawset(key, value);
String key2 = "my_key2";
long value2 = 42;
value.rawset(key2, value2);
// When:
NBTTagCompound actual = underTest.toNbtCompound(data);
// Then:
assertThat(actual.getKeySet()).containsOnly(key);
assertThat(actual.getTag(key)).isExactlyInstanceOf(NBTTagCompound.class);
NBTTagCompound actualValue = actual.getCompoundTag(key);
assertThat(actualValue.getKeySet()).containsOnly(key2);
assertThat(actualValue.getTag(key2)).isEqualTo(new NBTTagLong(value2));
}
示例6: readFromNBT
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
if (tag.hasKey("Energy")) {
energy.receiveEnergy(tag.getInteger("Energy"), false);
}
if (tag.hasKey("CurrentPos")) {
currentPos = BlockPos.fromLong(tag.getLong("CurrentPos"));
}
if (tag.hasKey("Range")) {
range = tag.getInteger("Range");
}
if (tag.hasKey("Surfaces")) {
NBTTagList surfaces = tag.getTagList("Surfaces", Constants.NBT.TAG_LONG);
for (NBTBase surface : surfaces) {
this.surfaces.add(BlockPos.fromLong(((NBTTagLong) surface).getLong()));
}
}
tank.readFromNBT(tag);
}
示例7: linkPortalWithOrigin
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
private void linkPortalWithOrigin(EntityPlayer player, World world, ItemStack stack, ControlBlockLocation thisPortal,
PortalLinkerOrigin remoteInfo) {
ControlBlockLocation remotePortal = findControllerBlock(world, remoteInfo.pos, STANDARD_SIZER);
stack.setTagInfo("origin", new NBTTagLong(0));
stack.setTagInfo("dimid", new NBTTagInt(0));
if (remotePortal == null) {
return;
}
linkPortalTo(world, thisPortal, remotePortal, remoteInfo.dimId, remoteInfo.side);
linkPortalTo(world, remotePortal, thisPortal, player.dimension, getSide(player, thisPortal));
playSound(player);
stack.damageItem(1, player);
}
示例8: asJson
import net.minecraft.nbt.NBTTagLong; //导入依赖的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;
}
}
示例9: createTag
import net.minecraft.nbt.NBTTagLong; //导入依赖的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);
}
示例10: getObject
import net.minecraft.nbt.NBTTagLong; //导入依赖的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;
}
示例11: writeToNBT
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
tagCompound = super.writeToNBT(tagCompound);
tagCompound.setBoolean(IS_MASTER, isMaster);
NBTTagList slaveList = new NBTTagList();
for (BlockPos slavePos : slaves) {
slaveList.appendTag(new NBTTagLong(slavePos.toLong()));
}
tagCompound.setTag(SLAVES, slaveList);
if (masterPos != null) {
tagCompound.setLong(MASTER_POS, masterPos.toLong());
}
return tagCompound;
}
示例12: readFromNBT
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
isMaster = tagCompound.getBoolean(IS_MASTER);
NBTTagList tagList = tagCompound.getTagList(SLAVES, Constants.NBT.TAG_LONG);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTBase tag = tagList.get(i);
if (tag instanceof NBTTagLong) {
BlockPos blockPos = BlockPos.fromLong(((NBTTagLong) tag).getLong());
slaves.add(blockPos);
}
}
masterPos = BlockPos.fromLong(tagCompound.getLong(MASTER_POS));
}
示例13: setValidValue
import net.minecraft.nbt.NBTTagLong; //导入依赖的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));
}
示例14: createFromItemNBT
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
public void createFromItemNBT(NBTTagCompound tag)
{
this.uprootedAt = Optional.of(new Calendar());
if (tag.hasKey("uprootedAt", NBT.TAG_LONG))
{
this.uprootedAt.get().deserializeNBT((NBTTagLong) tag.getTag("uprootedAt"));
}
this.deserializeNBT(tag);
}
示例15: deserializeNBT
import net.minecraft.nbt.NBTTagLong; //导入依赖的package包/类
@Override
public void deserializeNBT(NBTTagCompound nbt)
{
this.moistureLevel = nbt.getFloat("moisture");
for (NBTBase tag : nbt.getTagList("nutrientData", NBT.TAG_COMPOUND))
{
NBTTagCompound tagCompound = (NBTTagCompound) tag;
this.nutrientData.put(EnumPlantNutrient.values()[tagCompound.getByte("key")], tagCompound.getFloat("value"));
}
if (nbt.hasKey("calendar"))
{
this.timeKeeper.deserializeNBT((NBTTagLong) nbt.getTag("calendar"));
}
}