Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-27 03:12:37 +01:00
Address comments
Dieser Commit ist enthalten in:
Ursprung
e1bd3e28c4
Commit
6f83adcff0
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
|
|||||||
|
|
||||||
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;
|
||||||
@ -377,44 +378,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||||
return new AbstractCollection<>() {
|
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||||
@Override
|
e.save(tag);
|
||||||
public int size() {
|
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||||
return size;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Object get) {
|
|
||||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
UUID getUUID = NbtUtils.uuid(getTag);
|
|
||||||
for (Entity entity : entities) {
|
|
||||||
UUID uuid = entity.getUUID();
|
|
||||||
if (uuid.equals(getUUID)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Iterator<FaweCompoundTag> iterator() {
|
|
||||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
|
||||||
CompoundTag tag = new CompoundTag();
|
|
||||||
input.save(tag);
|
|
||||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
|
||||||
})::iterator;
|
|
||||||
return result.iterator();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -423,43 +391,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||||
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) {
|
||||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
|
|||||||
|
|
||||||
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;
|
||||||
@ -377,44 +378,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||||
return new AbstractCollection<>() {
|
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||||
@Override
|
e.save(tag);
|
||||||
public int size() {
|
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||||
return size;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Object get) {
|
|
||||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
UUID getUUID = NbtUtils.uuid(getTag);
|
|
||||||
for (Entity entity : entities) {
|
|
||||||
UUID uuid = entity.getUUID();
|
|
||||||
if (uuid.equals(getUUID)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Iterator<FaweCompoundTag> iterator() {
|
|
||||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
|
||||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
|
||||||
input.save(tag);
|
|
||||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
|
||||||
})::iterator;
|
|
||||||
return result.iterator();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -423,43 +391,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||||
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) {
|
||||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
|
|||||||
|
|
||||||
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;
|
||||||
@ -378,44 +379,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||||
return new AbstractCollection<>() {
|
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||||
@Override
|
e.save(tag);
|
||||||
public int size() {
|
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||||
return size;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Object get) {
|
|
||||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
UUID getUUID = NbtUtils.uuid(getTag);
|
|
||||||
for (Entity entity : entities) {
|
|
||||||
UUID uuid = entity.getUUID();
|
|
||||||
if (uuid.equals(getUUID)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Iterator<FaweCompoundTag> iterator() {
|
|
||||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
|
||||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
|
||||||
input.save(tag);
|
|
||||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
|
||||||
})::iterator;
|
|
||||||
return result.iterator();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -424,43 +392,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||||
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) {
|
||||||
|
@ -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;
|
||||||
@ -378,45 +379,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> {
|
||||||
return new AbstractCollection<>() {
|
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||||
@Override
|
e.save(tag);
|
||||||
public int size() {
|
return FaweCompoundTag.of(() -> (LinCompoundTag) adapter.toNativeLin(tag));
|
||||||
return size;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Object get) {
|
|
||||||
if (!(get instanceof FaweCompoundTag getTag)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
UUID getUUID = NbtUtils.uuid(getTag);
|
|
||||||
for (Entity entity : entities) {
|
|
||||||
UUID uuid = entity.getUUID();
|
|
||||||
if (uuid.equals(getUUID)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Iterator<FaweCompoundTag> iterator() {
|
|
||||||
Iterable<FaweCompoundTag> result = entities.stream().map(input -> {
|
|
||||||
CompoundTag tag = new CompoundTag();
|
|
||||||
input.save(tag);
|
|
||||||
return FaweCompoundTag.of((LinCompoundTag) adapter.toNativeLin(tag));
|
|
||||||
})::iterator;
|
|
||||||
return result.iterator();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -427,43 +394,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
|||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
int size = entities.size();
|
return new NativeEntityFunctionSet<>(entities, Entity::getUUID, e -> new BukkitEntity(e.getBukkitEntity()));
|
||||||
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) {
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.fastasyncworldedit.bukkit.adapter;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.AbstractSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class NativeEntityFunctionSet<NativeEntity, Result> extends AbstractSet<Result> {
|
||||||
|
|
||||||
|
private final List<NativeEntity> nativeEntities;
|
||||||
|
private final Function<NativeEntity, UUID> uuidGetter;
|
||||||
|
private final Function<NativeEntity, Result> resultFunction;
|
||||||
|
|
||||||
|
public NativeEntityFunctionSet(
|
||||||
|
List<NativeEntity> nativeEntities,
|
||||||
|
Function<NativeEntity, UUID> uuidGetter,
|
||||||
|
Function<NativeEntity, Result> resultFunction
|
||||||
|
) {
|
||||||
|
this.nativeEntities = nativeEntities;
|
||||||
|
this.uuidGetter = uuidGetter;
|
||||||
|
this.resultFunction = resultFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return nativeEntities.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 (NativeEntity entity : nativeEntities) {
|
||||||
|
UUID uuid = uuidGetter.apply(entity);
|
||||||
|
if (uuid.equals(getUUID)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Iterator<Result> iterator() {
|
||||||
|
return nativeEntities
|
||||||
|
.stream()
|
||||||
|
.map(resultFunction)
|
||||||
|
.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -32,7 +32,6 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch
|
|||||||
private final IQueueExtent<IQueueChunk> queue;
|
private final IQueueExtent<IQueueChunk> queue;
|
||||||
private Consumer<IChunkGet> task;
|
private Consumer<IChunkGet> task;
|
||||||
private volatile long lastPair = Long.MAX_VALUE;
|
private volatile long lastPair = Long.MAX_VALUE;
|
||||||
private volatile boolean isProcessing;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -59,16 +58,12 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch
|
|||||||
}
|
}
|
||||||
lastPair = pair;
|
lastPair = pair;
|
||||||
synchronized (set) {
|
synchronized (set) {
|
||||||
if (!set.contains(chunkX, chunkZ)) {
|
return set.add(chunkX, chunkZ);
|
||||||
set.add(chunkX, chunkZ);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndRun(int chunkX, int chunkZ) {
|
private void checkAndRun(int chunkX, int chunkZ) {
|
||||||
if (!isProcessing && shouldRun(chunkX, chunkZ)) {
|
if (shouldRun(chunkX, chunkZ)) {
|
||||||
task.accept(queue.getCachedGet(chunkX, chunkZ));
|
task.accept(queue.getCachedGet(chunkX, chunkZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +83,6 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChunkGet processGet(final IChunkGet get) {
|
public IChunkGet processGet(final IChunkGet get) {
|
||||||
isProcessing = true;
|
|
||||||
if (shouldRun(get.getX(), get.getZ())) {
|
if (shouldRun(get.getX(), get.getZ())) {
|
||||||
task.accept(get);
|
task.accept(get);
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
|
|||||||
if (offsetX == Integer.MAX_VALUE) {
|
if (offsetX == Integer.MAX_VALUE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
short sx = (short) (x - offsetX);
|
if (x > 32767 || x < -32769 || z > 32769 || z < -32767) {
|
||||||
short sz = (short) (z - offsetZ);
|
|
||||||
if (sx > 32767 || sx < -32767 || sz > 32767 || sz < -32767) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
short sx = (short) (x - offsetX);
|
||||||
|
short sz = (short) (z - offsetZ);
|
||||||
try {
|
try {
|
||||||
return set.get(MathMan.pairSearchCoords(sx, sz));
|
return set.get(MathMan.pairSearchCoords(sx, sz));
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren