use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class PaperweightGetBlocks_Copy method storeEntity.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void storeEntity(Entity entity) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag();
entities.add((CompoundTag) adapter.toNative(entity.save(compoundTag)));
}
use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class FabricPlayer method sendFakeBlock.
@Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
World world = getWorld();
if (!(world instanceof FabricWorld)) {
return;
}
BlockPos loc = FabricAdapter.toBlockPos(pos);
if (block == null) {
final BlockUpdateS2CPacket packetOut = new BlockUpdateS2CPacket(((FabricWorld) world).getWorld(), loc);
player.networkHandler.sendPacket(packetOut);
} else {
final BlockUpdateS2CPacket packetOut = new BlockUpdateS2CPacket();
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeBlockPos(loc);
buf.writeVarInt(Block.getRawIdFromState(FabricAdapter.adapt(block.toImmutableState())));
try {
packetOut.read(buf);
} catch (IOException e) {
return;
}
player.networkHandler.sendPacket(packetOut);
if (block instanceof BaseBlock && block.getBlockType().equals(BlockTypes.STRUCTURE_BLOCK)) {
final BaseBlock baseBlock = (BaseBlock) block;
final CompoundTag nbtData = baseBlock.getNbtData();
if (nbtData != null) {
player.networkHandler.sendPacket(new BlockEntityUpdateS2CPacket(new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), STRUCTURE_BLOCK_PACKET_ID, NBTConverter.toNative(nbtData)));
}
}
}
}
use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class FabricWorld method createEntity.
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
World world = getWorld();
final Optional<EntityType<?>> entityType = EntityType.get(entity.getType().getId());
if (!entityType.isPresent())
return null;
net.minecraft.entity.Entity createdEntity = entityType.get().create(world);
if (createdEntity != null) {
CompoundTag nativeTag = entity.getNbtData();
if (nativeTag != null) {
net.minecraft.nbt.CompoundTag tag = NBTConverter.toNative(entity.getNbtData());
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}
createdEntity.fromTag(tag);
}
createdEntity.setPositionAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.spawnEntity(createdEntity);
return new FabricEntity(createdEntity);
} else {
return null;
}
}
use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class ChunkStore method getChunk.
// FAWE end
/**
* Get a chunk at a location.
*
* @param position the position of the chunk
* @return a chunk
* @throws ChunkStoreException thrown if there is an error from the chunk store
* @throws DataException thrown on data error
* @throws IOException thrown on I/O error
*/
public Chunk getChunk(BlockVector2 position, World world) throws DataException, IOException {
CompoundTag rootTag = getChunkTag(position, world);
// FAWE start - biome and entity restore
int dataVersion = rootTag.getInt("DataVersion");
if (dataVersion == 0) {
dataVersion = -1;
}
if (dataVersion >= Constants.DATA_VERSION_MC_1_17) {
return ChunkStoreHelper.getChunk(rootTag, () -> getEntitiesTag(position, world));
} else {
return ChunkStoreHelper.getChunk(rootTag);
}
// FAWE end
}
use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class AbstractChangeSet method add.
public void add(EntityCreate change) {
CompoundTag tag = change.state.getNbtData();
addEntityCreate(MainUtil.setEntityInfo(tag, change.getEntity()));
}
Aggregations