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


Java NbtFactory.fromNMSCompound方法代码示例

本文整理汇总了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() );
				}
			}
		}
	}
}
 
开发者ID:BlackyPaw,项目名称:I18N,代码行数:23,代码来源:InterceptorSign.java

示例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);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:28,代码来源:StructureCUI.java

示例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);
}
 
开发者ID:yushijinhun,项目名称:AdvancedCommands,代码行数:12,代码来源:NBTSourceEntity.java

示例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);
}
 
开发者ID:yushijinhun,项目名称:AdvancedCommands,代码行数:12,代码来源:NBTSourceTile.java

示例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");
}
 
开发者ID:yushijinhun,项目名称:AdvancedCommands,代码行数:9,代码来源:DataTypeNBT.java


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