3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-19 17:30:08 +01:00

Update new adapter classes

Dieser Commit ist enthalten in:
dordsor21 2023-10-14 20:46:11 +01:00
Ursprung 2a45fcde38
Commit ed30e5bb8d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
2 geänderte Dateien mit 69 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -19,6 +19,7 @@ import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitEntity;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2.nbt.PaperweightLazyCompoundTag; import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2.nbt.PaperweightLazyCompoundTag;
import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.internal.Constants;
@ -111,11 +112,13 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
this.biomeHolderIdMap = biomeRegistry.asHolderIdMap(); this.biomeHolderIdMap = biomeRegistry.asHolderIdMap();
} }
public int getChunkX() { @Override
public int getX() {
return chunkX; return chunkX;
} }
public int getChunkZ() { @Override
public int getZ() {
return chunkZ; return chunkZ;
} }
@ -355,6 +358,51 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
}; };
} }
@Override
public Set<com.sk89q.worldedit.entity.Entity> getFullEntities() {
List<Entity> entities = PaperweightPlatformAdapter.getEntities(ensureLoaded(serverLevel, chunkX, chunkZ));
if (entities.isEmpty()) {
return Collections.emptySet();
}
int size = entities.size();
return new AbstractSet<>() {
@Override
public int size() {
return size;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean contains(Object get) {
if (!(get instanceof com.sk89q.worldedit.entity.Entity e)) {
return false;
}
UUID getUUID = e.getState().getNbtData().getUUID();
for (Entity entity : entities) {
UUID uuid = entity.getUUID();
if (uuid.equals(getUUID)) {
return true;
}
}
return false;
}
@Nonnull
@Override
public Iterator<com.sk89q.worldedit.entity.Entity> iterator() {
Iterable<com.sk89q.worldedit.entity.Entity> result = entities
.stream()
.map(input -> new BukkitEntity(input.getBukkitEntity()))
.collect(Collectors.toList());
return result.iterator();
}
};
}
private void removeEntity(Entity entity) { private void removeEntity(Entity entity) {
entity.discard(); entity.discard();
} }

Datei anzeigen

@ -42,6 +42,8 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
private final char[][] blocks; private final char[][] blocks;
private final int minHeight; private final int minHeight;
private final int maxHeight; private final int maxHeight;
private final int chunkX;
private final int chunkZ;
final ServerLevel serverLevel; final ServerLevel serverLevel;
final LevelChunk levelChunk; final LevelChunk levelChunk;
private PalettedContainer<Holder<Biome>>[] biomes = null; private PalettedContainer<Holder<Biome>>[] biomes = null;
@ -52,6 +54,8 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
this.minHeight = serverLevel.getMinBuildHeight(); this.minHeight = serverLevel.getMinBuildHeight();
this.maxHeight = serverLevel.getMaxBuildHeight() - 1; // Minecraft max limit is exclusive. this.maxHeight = serverLevel.getMaxBuildHeight() - 1; // Minecraft max limit is exclusive.
this.blocks = new char[getSectionCount()][]; this.blocks = new char[getSectionCount()][];
this.chunkX = levelChunk.locX;
this.chunkZ = levelChunk.locZ;
} }
protected void storeTile(BlockEntity blockEntity) { protected void storeTile(BlockEntity blockEntity) {
@ -89,6 +93,11 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
return this.entities; return this.entities;
} }
@Override
public Set<com.sk89q.worldedit.entity.Entity> getFullEntities() {
throw new UnsupportedOperationException("Cannot get full entities from GET copy.");
}
@Override @Override
public CompoundTag getEntity(UUID uuid) { public CompoundTag getEntity(UUID uuid) {
for (CompoundTag tag : entities) { for (CompoundTag tag : entities) {
@ -140,6 +149,16 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
return minHeight >> 4; return minHeight >> 4;
} }
@Override
public int getX() {
return chunkX;
}
@Override
public int getZ() {
return chunkZ;
}
@Override @Override
public BiomeType getBiomeType(int x, int y, int z) { public BiomeType getBiomeType(int x, int y, int z) {
Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()].get(x >> 2, (y & 15) >> 2, z >> 2); Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()].get(x >> 2, (y & 15) >> 2, z >> 2);