3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-10-03 04:10:06 +02:00
Dieser Commit ist enthalten in:
dordsor21 2024-06-30 10:56:24 +01:00
Ursprung aa95ed82a3
Commit fc175659a7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
5 geänderte Dateien mit 52 neuen und 51 gelöschten Zeilen

Datei anzeigen

@ -112,7 +112,7 @@ public class PaperweightPostProcessor implements IBatchProcessor {
@Override @Override
public ProcessorScope getScope() { public ProcessorScope getScope() {
return ProcessorScope.READING_SET_BLOCKS; return ProcessorScope.READING_BLOCKS;
} }
private boolean wasAdjacentToWater(char[] get, char[] set, int i, int x, int y, int z) { private boolean wasAdjacentToWater(char[] get, char[] set, int i, int x, int y, int z) {

Datei anzeigen

@ -112,7 +112,7 @@ public class PaperweightPostProcessor implements IBatchProcessor {
@Override @Override
public ProcessorScope getScope() { public ProcessorScope getScope() {
return ProcessorScope.READING_SET_BLOCKS; return ProcessorScope.READING_BLOCKS;
} }
private boolean wasAdjacentToWater(char[] get, char[] set, int i, int x, int y, int z) { private boolean wasAdjacentToWater(char[] get, char[] set, int i, int x, int y, int z) {

Datei anzeigen

@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1;
import com.fastasyncworldedit.bukkit.adapter.BukkitGetBlocks; import com.fastasyncworldedit.bukkit.adapter.BukkitGetBlocks;
import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore; import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore;
import com.fastasyncworldedit.bukkit.adapter.NativeEntityFunctionSet;
import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweCache; import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.configuration.Settings;
@ -19,6 +20,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_21_R1.nbt.PaperweightLazyCompoundTag; import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1.nbt.PaperweightLazyCompoundTag;
import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.internal.Constants;
@ -139,11 +141,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;
} }
@ -361,49 +365,24 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
@Override @Override
public Set<CompoundTag> getEntities() { public Set<CompoundTag> getEntities() {
ensureLoaded(serverLevel, chunkX, chunkZ); List<Entity> entities = PaperweightPlatformAdapter.getEntities(ensureLoaded(serverLevel, chunkX, chunkZ));
List<Entity> entities = PaperweightPlatformAdapter.getEntities(getChunk());
if (entities.isEmpty()) { if (entities.isEmpty()) {
return Collections.emptySet(); return Collections.emptySet();
} }
int size = entities.size(); return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
return new AbstractSet<>() {
@Override
public int size() {
return size;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean contains(Object get) {
if (!(get instanceof CompoundTag getTag)) {
return false;
}
UUID getUUID = getTag.getUUID();
for (Entity entity : entities) {
UUID uuid = entity.getUUID();
if (uuid.equals(getUUID)) {
return true;
}
}
return false;
}
@Nonnull
@Override
public Iterator<CompoundTag> iterator() {
Iterable<CompoundTag> result = entities.stream().map(input -> {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
input.save(tag); e.save(tag);
return (CompoundTag) adapter.toNative(tag); return (CompoundTag) adapter.toNative(tag);
}).collect(Collectors.toList()); });
return result.iterator();
} }
};
@Override
public Set<com.sk89q.worldedit.entity.Entity> getFullEntities() {
List<Entity> entities = PaperweightPlatformAdapter.getEntities(ensureLoaded(serverLevel, chunkX, chunkZ));
if (entities.isEmpty()) {
return Collections.emptySet();
}
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
} }
private void removeEntity(Entity entity) { private void removeEntity(Entity entity) {
@ -420,17 +399,20 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
if (!callLock.isHeldByCurrentThread()) { if (!callLock.isHeldByCurrentThread()) {
throw new IllegalStateException("Attempted to call chunk GET but chunk was not call-locked."); throw new IllegalStateException("Attempted to call chunk GET but chunk was not call-locked.");
} }
forceLoadSections = false; if (createCopy && copies.containsKey(copyKey)) { // Do not sometimes load chunk if we're going to error
PaperweightGetBlocks_Copy copy = createCopy ? new PaperweightGetBlocks_Copy(levelChunk) : null;
if (createCopy) {
if (copies.containsKey(copyKey)) {
throw new IllegalStateException("Copy key already used."); throw new IllegalStateException("Copy key already used.");
} }
copies.put(copyKey, copy);
}
try { try {
forceLoadSections = false;
ServerLevel nmsWorld = serverLevel; ServerLevel nmsWorld = serverLevel;
LevelChunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ); LevelChunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
PaperweightGetBlocks_Copy copy;
if (createCopy) {
copy = new PaperweightGetBlocks_Copy(nmsChunk);
copies.put(copyKey, copy);
} else {
copy = null;
}
// Remove existing tiles. Create a copy so that we can remove blocks // Remove existing tiles. Create a copy so that we can remove blocks
Map<BlockPos, BlockEntity> chunkTiles = new HashMap<>(nmsChunk.getBlockEntities()); Map<BlockPos, BlockEntity> chunkTiles = new HashMap<>(nmsChunk.getBlockEntities());

Datei anzeigen

@ -44,6 +44,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 Holder<Biome>[][] biomes = null; private Holder<Biome>[][] biomes = null;
@ -54,6 +56,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) {
@ -91,6 +95,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) {
@ -143,6 +152,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()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2]; Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];

Datei anzeigen

@ -112,7 +112,7 @@ public class PaperweightPostProcessor implements IBatchProcessor {
@Override @Override
public ProcessorScope getScope() { public ProcessorScope getScope() {
return ProcessorScope.READING_SET_BLOCKS; return ProcessorScope.READING_BLOCKS;
} }
private boolean wasAdjacentToWater(char[] get, char[] set, int i, int x, int y, int z) { private boolean wasAdjacentToWater(char[] get, char[] set, int i, int x, int y, int z) {