本文整理汇总了Java中com.comphenix.protocol.wrappers.nbt.NbtFactory.fromNMSCompound方法的典型用法代码示例。如果您正苦于以下问题:Java NbtFactory.fromNMSCompound方法的具体用法?Java NbtFactory.fromNMSCompound怎么用?Java NbtFactory.fromNMSCompound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.comphenix.protocol.wrappers.nbt.NbtFactory
的用法示例。
在下文中一共展示了NbtFactory.fromNMSCompound方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMapChunk
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
private void onMapChunk( PacketEvent event ) {
final Player player = event.getPlayer();
final PacketContainer packet = event.getPacket();
final Locale locale = this.i18n.getLocale( player.getUniqueId() );
List handleList = packet.getSpecificModifier( List.class ).read( 0 );
for ( Object compoundHandle : handleList ) {
NbtCompound compound = NbtFactory.fromNMSCompound( compoundHandle );
String id = compound.getString( "id" );
if ( id.equals( "minecraft:sign" ) || id.equals( "Sign" ) ) {
for ( int i = 1; i <= 4; ++i ) {
final String key = "Text" + i;
String message = this.gson.fromJson( compound.getString( key ), ChatComponent.class ).getUnformattedText();
String translated = this.translateMessageIfAppropriate( locale, message );
if ( message != translated ) {
compound.put( key, WrappedChatComponent.fromText( translated ).getJson() );
}
}
}
}
}
示例2: constructStructureNbt
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
private NbtCompound constructStructureNbt(int x, int y, int z, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ) {
HashMap<String, Object> tag = new HashMap<>();
tag.put("name", UUID.randomUUID().toString());
tag.put("author", "Empire92"); // :D
tag.put("metadata", "");
tag.put("x", x);
tag.put("y", y);
tag.put("z", z);
tag.put("posX", posX);
tag.put("posY", posY);
tag.put("posZ", posZ);
tag.put("sizeX", sizeX);
tag.put("sizeY", sizeY);
tag.put("sizeZ", sizeZ);
tag.put("rotation", "NONE");
tag.put("mirror", "NONE");
tag.put("mode", "SAVE");
tag.put("ignoreEntities", true);
tag.put("powered", false);
tag.put("showair", false);
tag.put("showboundingbox", true);
tag.put("integrity", 1.0f);
tag.put("seed", 0);
tag.put("id", "minecraft:structure_block");
Object nmsTag = BukkitQueue_0.fromNative(FaweCache.asTag(tag));
return NbtFactory.fromNMSCompound(nmsTag);
}
示例3: get
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
@Override
public NbtCompound get(String id, CommandSender commandSender) {
Object nmsnbt;
try {
nmsnbt = MinecraftReflection.getNBTCompoundClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
ReflectionHelper.entityWrite(getEntity(id), nmsnbt);
return NbtFactory.fromNMSCompound(nmsnbt);
}
示例4: get
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
@Override
public NbtCompound get(String id, CommandSender commandSender) {
Object nmsnbt;
try {
nmsnbt = MinecraftReflection.getNBTCompoundClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
ReflectionHelper.tileWrite(getTileEntity(parseId(id, commandSender)), nmsnbt);
return NbtFactory.fromNMSCompound(nmsnbt);
}
示例5: readValue
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
@Override
public Object readValue(DataInput in, CommandContext commandContext) throws IOException {
byte[] bytes = new byte[in.readInt()];
in.readFully(bytes);
ByteArrayInputStream memoryIn = new ByteArrayInputStream(bytes);
NbtCompound comp = NbtFactory.fromNMSCompound(ReflectionHelper.nbtRead(memoryIn));
return comp.getValue("data");
}