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


Java BaseEntity.getNbtData方法代码示例

本文整理汇总了Java中com.sk89q.worldedit.entity.BaseEntity.getNbtData方法的典型用法代码示例。如果您正苦于以下问题:Java BaseEntity.getNbtData方法的具体用法?Java BaseEntity.getNbtData怎么用?Java BaseEntity.getNbtData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldedit.entity.BaseEntity的用法示例。


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

示例1: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Override
public Entity createEntity(final Location loc, final BaseEntity entity) {
    if (entity != null) {
        CompoundTag tag = entity.getNbtData();
        Map<String, Tag> map = ReflectionUtils.getMap(tag.getValue());
        map.put("Id", new StringTag(entity.getTypeId()));
        ListTag pos = (ListTag) map.get("Pos");
        if (pos != null) {
            List<Tag> posList = ReflectionUtils.getList(pos.getValue());
            posList.set(0, new DoubleTag(loc.getX()));
            posList.set(1, new DoubleTag(loc.getY()));
            posList.set(2, new DoubleTag(loc.getZ()));
        }
        queue.setEntity(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), tag);
    }
    return null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:18,代码来源:FastWorldEditExtent.java

示例2: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
    World world = getWorld();
    net.minecraft.entity.Entity createdEntity = EntityList.createEntityByName(entity.getTypeId(), world);
    if (createdEntity != null) {
        CompoundTag nativeTag = entity.getNbtData();
        if (nativeTag != null) {
            NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData());
            for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
                tag.removeTag(name);
            }
            createdEntity.readFromNBT(tag);
        }

        createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

        world.spawnEntityInWorld(createdEntity);
        return new WorldEditEntity(createdEntity);
    } else {
        return null;
    }
}
 
开发者ID:nailed,项目名称:nailed,代码行数:24,代码来源:WorldEditWorld.java

示例3: applyEntityData

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void applyEntityData(Entity entity, BaseEntity baseEntity) {
    final ObjectStore store = ObjectStoreRegistry.get().get(entity.getClass())
            .orElseThrow(() -> new IllegalStateException("Missing object store for entity " + entity.getType()));
    final CompoundTag tag = baseEntity.getNbtData();
    final DataView dataView = tag == null ? DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED) : DataViewNbt.from(tag);
    for (String field : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
        dataView.remove(DataQuery.of(field));
    }
    store.deserialize(entity, dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternWorldEdit,代码行数:13,代码来源:LanternWEWorld.java

示例4: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Nullable
public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state)
{
    Preconditions.checkNotNull(location);
    Preconditions.checkNotNull(state);

    CraftWorld craftWorld = (CraftWorld)location.getWorld();
    WorldServer worldServer = craftWorld.getHandle();

    net.minecraft.server.v1_10_R1.Entity createdEntity = createEntityFromId(state.getTypeId(), craftWorld.getHandle());
    if (createdEntity != null)
    {
        CompoundTag nativeTag = state.getNbtData();
        if (nativeTag != null)
        {
            NBTTagCompound tag = (NBTTagCompound)fromNative(nativeTag);
            for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
                tag.remove(name);
            }
            readTagIntoEntity(tag, createdEntity);
        }
        createdEntity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

        worldServer.addEntity(createdEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        return createdEntity.getBukkitEntity();
    }
    return null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:29,代码来源:FaweAdapter_1_10.java

示例5: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Nullable
public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state)
{
    Preconditions.checkNotNull(location);
    Preconditions.checkNotNull(state);

    CraftWorld craftWorld = (CraftWorld)location.getWorld();
    WorldServer worldServer = craftWorld.getHandle();

    Entity createdEntity = createEntityFromId(state.getTypeId(), craftWorld.getHandle());
    if (createdEntity != null)
    {
        CompoundTag nativeTag = state.getNbtData();
        if (nativeTag != null)
        {
            NBTTagCompound tag = (NBTTagCompound)fromNative(nativeTag);
            for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
                tag.remove(name);
            }
            readTagIntoEntity(tag, createdEntity);
        }
        createdEntity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

        worldServer.addEntity(createdEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        return createdEntity.getBukkitEntity();
    }
    return null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:29,代码来源:FaweAdapter_1_12.java

示例6: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Nullable
public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state)
{
    Preconditions.checkNotNull(location);
    Preconditions.checkNotNull(state);

    CraftWorld craftWorld = (CraftWorld)location.getWorld();
    WorldServer worldServer = craftWorld.getHandle();

    net.minecraft.server.v1_9_R2.Entity createdEntity = createEntityFromId(state.getTypeId(), craftWorld.getHandle());
    if (createdEntity != null)
    {
        CompoundTag nativeTag = state.getNbtData();
        if (nativeTag != null)
        {
            NBTTagCompound tag = (NBTTagCompound)fromNative(nativeTag);
            for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
                tag.remove(name);
            }
            readTagIntoEntity(tag, createdEntity);
        }
        createdEntity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

        worldServer.addEntity(createdEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        return createdEntity.getBukkitEntity();
    }
    return null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:29,代码来源:FaweAdapter_1_9.java

示例7: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity state) {
    try {
        if (classEntity == null) return null;
        World world = location.getWorld();
        Object nmsWorld = getHandleWorld.invoke(world);

        Object createdEntity = createEntityFromId(state.getTypeId(), nmsWorld);

        if (createdEntity != null) {
            CompoundTag nativeTag = state.getNbtData();
            Map<String, Tag> rawMap = ReflectionUtils.getMap(nativeTag.getValue());
            for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
                rawMap.remove(name);
            }
            if (nativeTag != null) {
                Object tag = fromNative(nativeTag);
                readTagIntoEntity.invoke(createdEntity, tag);
            }

            setLocation.invoke(createdEntity, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

            addEntity.invoke(nmsWorld, createdEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
            return (Entity) getBukkitEntity.invoke(createdEntity);
        }
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
    return null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:32,代码来源:FaweAdapter_All.java

示例8: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Nullable
@Override
public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state) {
    checkNotNull(location);
    checkNotNull(state);

    CraftWorld craftWorld = ((CraftWorld) location.getWorld());
    WorldServer worldServer = craftWorld.getHandle();

    Entity createdEntity = createEntityFromId(state.getTypeId(), craftWorld.getHandle());

    if (createdEntity != null) {
        CompoundTag nativeTag = state.getNbtData();
        if (nativeTag != null) {
            NBTTagCompound tag = (NBTTagCompound) fromNative(nativeTag);
            for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
                tag.remove(name);
            }
            readTagIntoEntity(tag, createdEntity);
        }

        createdEntity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

        worldServer.addEntity(createdEntity, SpawnReason.CUSTOM);
        return createdEntity.getBukkitEntity();
    } else {
        return null;
    }
}
 
开发者ID:sk89q,项目名称:worldedit-adapters,代码行数:30,代码来源:Spigot_v1_12_R1.java

示例9: createEntity

import com.sk89q.worldedit.entity.BaseEntity; //导入方法依赖的package包/类
@Nullable
@Override
public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state) {
    checkNotNull(location);
    checkNotNull(state);

    CraftWorld craftWorld = ((CraftWorld) location.getWorld());
    WorldServer worldServer = craftWorld.getHandle();

    Entity createdEntity = createEntityFromId(state.getTypeId(), craftWorld.getHandle());

    if (createdEntity != null) {
        CompoundTag nativeTag = state.getNbtData();
        if (nativeTag != null) {
            NBTTagCompound tag = (NBTTagCompound) fromNative(state.getTypeId(), nativeTag);
            for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
                tag.remove(name);
            }
            readTagIntoEntity(tag, createdEntity);
        }

        createdEntity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

        worldServer.addEntity(createdEntity, SpawnReason.CUSTOM);
        return createdEntity.getBukkitEntity();
    } else {
        return null;
    }
}
 
开发者ID:sk89q,项目名称:worldedit-adapters,代码行数:30,代码来源:CraftBukkit_v1_6_R3.java


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