3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 18:40:05 +01:00

Merge branch 'breaking-114' into commanding

Dieser Commit ist enthalten in:
Jesse Boyd 2019-07-18 20:22:44 +10:00
Commit 4ed3fe724e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
8 geänderte Dateien mit 169 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -50,6 +50,7 @@ import java.util.List;
public abstract class ChunkListener implements Listener { public abstract class ChunkListener implements Listener {
protected int rateLimit = 0; protected int rateLimit = 0;
protected Location lastCancelPos;
private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS}; private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS};
public ChunkListener() { public ChunkListener() {
@ -59,6 +60,10 @@ public abstract class ChunkListener implements Listener {
plm.registerEvents(this, plugin); plm.registerEvents(this, plugin);
try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {}
TaskManager.IMP.repeat(() -> { TaskManager.IMP.repeat(() -> {
Location tmpLoc = lastCancelPos;
if (tmpLoc != null) {
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + tmpLoc);
}
rateLimit--; rateLimit--;
physicsFreeze = false; physicsFreeze = false;
itemFreeze = false; itemFreeze = false;
@ -66,6 +71,7 @@ public abstract class ChunkListener implements Listener {
physSkip = 0; physSkip = 0;
physCancelPair = Long.MIN_VALUE; physCancelPair = Long.MIN_VALUE;
physCancel = false; physCancel = false;
lastCancelPos = null;
counter.clear(); counter.clear();
for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) { for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) {
@ -231,7 +237,7 @@ public abstract class ChunkListener implements Listener {
physCancelPair = MathMan.pairInt(cx, cz); physCancelPair = MathMan.pairInt(cx, cz);
if (rateLimit <= 0) { if (rateLimit <= 0) {
rateLimit = 20; rateLimit = 20;
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation()); lastCancelPos = block.getLocation();
} }
cancelNearby(cx, cz); cancelNearby(cx, cz);
event.setCancelled(true); event.setCancelled(true);
@ -305,7 +311,7 @@ public abstract class ChunkListener implements Listener {
cancelNearby(cx, cz); cancelNearby(cx, cz);
if (rateLimit <= 0) { if (rateLimit <= 0) {
rateLimit = 20; rateLimit = 20;
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled falling block lag source at " + block.getLocation()); lastCancelPos = block.getLocation();
} }
event.setCancelled(true); event.setCancelled(true);
return; return;

Datei anzeigen

@ -60,7 +60,7 @@ public class ChunkListener_9 extends ChunkListener {
physCancelPair = MathMan.pairInt(cx, cz); physCancelPair = MathMan.pairInt(cx, cz);
if (rateLimit <= 0) { if (rateLimit <= 0) {
rateLimit = 20; rateLimit = 20;
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation()); lastCancelPos = block.getLocation();
} }
cancelNearby(cx, cz); cancelNearby(cx, cz);
event.setCancelled(true); event.setCancelled(true);

Datei anzeigen

@ -11,8 +11,11 @@ import org.bukkit.ChunkSnapshot;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collection;
public class AsyncChunk implements Chunk { public class AsyncChunk implements Chunk {
private final AsyncWorld world; private final AsyncWorld world;
@ -178,4 +181,19 @@ public class AsyncChunk implements Chunk {
public void setForceLoaded(boolean arg0) { public void setForceLoaded(boolean arg0) {
world.getChunkAt(x, z).setForceLoaded(arg0); world.getChunkAt(x, z).setForceLoaded(arg0);
} }
@Override
public boolean addPluginChunkTicket(final Plugin plugin) {
return world.addPluginChunkTicket(this.getX(), this.getZ(), plugin);
}
@Override
public boolean removePluginChunkTicket(final Plugin plugin) {
return world.removePluginChunkTicket(this.getX(), this.getZ(), plugin);
}
@Override
public Collection<Plugin> getPluginChunkTickets() {
return world.getPluginChunkTickets(this.getX(), this.getZ());
}
} }

Datei anzeigen

@ -17,6 +17,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -1179,6 +1180,31 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
return parent.getForceLoadedChunks(); return parent.getForceLoadedChunks();
} }
@Override
public boolean addPluginChunkTicket(int x, int z, @NotNull Plugin plugin) {
return getBukkitWorld().addPluginChunkTicket(x, z, plugin);
}
@Override
public boolean removePluginChunkTicket(int x, int z, @NotNull Plugin plugin) {
return getBukkitWorld().removePluginChunkTicket(x, z, plugin);
}
@Override
public void removePluginChunkTickets(@NotNull Plugin plugin) {
getBukkitWorld().removePluginChunkTickets(plugin);
}
@Override
public @NotNull Collection<Plugin> getPluginChunkTickets(int x, int z) {
return getBukkitWorld().getPluginChunkTickets(x, z);
}
@Override
public @NotNull Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
return getBukkitWorld().getPluginChunkTickets();
}
@Override @Override
public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException { public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
return TaskManager.IMP.sync(new Supplier<Integer>() { return TaskManager.IMP.sync(new Supplier<Integer>() {

Datei anzeigen

@ -22,6 +22,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -109,7 +110,6 @@ public class SchematicStreamer extends NBTStreamer {
if (value != 0) { if (value != 0) {
int first = value & 0x0F; int first = value & 0x0F;
int second = (value & 0xF0) >> 4; int second = (value & 0xF0) >> 4;
int gIndex = index << 1;
try { try {
if (first != 0) adds.write(first); if (first != 0) adds.write(first);
if (second != 0) adds.write(second); if (second != 0) adds.write(second);
@ -122,7 +122,10 @@ public class SchematicStreamer extends NBTStreamer {
ByteReader biomeReader = new ByteReader() { ByteReader biomeReader = new ByteReader() {
@Override @Override
public void run(int index, int value) { public void run(int index, int value) {
fc.setBiome(index, BiomeTypes.register(value)); BiomeType biome = BiomeTypes.getLegacy(value);
if (biome != null) {
fc.setBiome(index, biome);
}
} }
}; };
NBTStreamReader<Integer, Integer> initializer23 = new NBTStreamReader<Integer, Integer>() { NBTStreamReader<Integer, Integer> initializer23 = new NBTStreamReader<Integer, Integer>() {

Datei anzeigen

@ -70,7 +70,11 @@ public final class NamespacedRegistry<V extends RegistryItem & Keyed> extends Re
} }
public V getByInternalId(int index) { public V getByInternalId(int index) {
try {
return values.get(index); return values.get(index);
} catch (IndexOutOfBoundsException e) {
return null;
}
} }
public int getInternalId(V value) { public int getInternalId(V value) {

Datei anzeigen

@ -30,13 +30,21 @@ public class BiomeType implements RegistryItem, Keyed {
public static final NamespacedRegistry<BiomeType> REGISTRY = new NamespacedRegistry<>("biome type"); public static final NamespacedRegistry<BiomeType> REGISTRY = new NamespacedRegistry<>("biome type");
private String id; private final String id;
private int legacyId = -1;
private int internalId;
public BiomeType(String id) { public BiomeType(String id) {
this.id = id; this.id = id;
} }
private int internalId; public int getLegacyId() {
return legacyId;
}
public void setLegacyId(int legacyId) {
this.legacyId = legacyId;
}
@Override @Override
public void setInternalId(int internalId) { public void setInternalId(int internalId) {

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.biome; package com.sk89q.worldedit.world.biome;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection;
/** /**
* Stores a list of common Biome String IDs. * Stores a list of common Biome String IDs.
@ -113,7 +114,102 @@ public final class BiomeTypes {
return BiomeType.REGISTRY.register(biome.getId(), biome); return BiomeType.REGISTRY.register(biome.getId(), biome);
} }
public static BiomeType getLegacy(int legacyId) {
for (BiomeType type : values()) {
if (type.getLegacyId() == legacyId) {
return type;
}
}
return null;
}
public static BiomeType get(int internalId) {
return BiomeType.REGISTRY.getByInternalId(internalId);
}
public static @Nullable BiomeType get(final String id) { public static @Nullable BiomeType get(final String id) {
return BiomeType.REGISTRY.get(id); return BiomeType.REGISTRY.get(id);
} }
public static Collection<BiomeType> values() {
return BiomeType.REGISTRY.values();
}
static {
OCEAN.setLegacyId(0);
PLAINS.setLegacyId(1);
DESERT.setLegacyId(2);
MOUNTAINS.setLegacyId(3);
FOREST.setLegacyId(4);
TAIGA.setLegacyId(5);
SWAMP.setLegacyId(6);
RIVER.setLegacyId(7);
NETHER.setLegacyId(8);
THE_END.setLegacyId(9);
FROZEN_OCEAN.setLegacyId(10);
FROZEN_RIVER.setLegacyId(11);
SNOWY_TUNDRA.setLegacyId(12);
SNOWY_MOUNTAINS.setLegacyId(13);
MUSHROOM_FIELDS.setLegacyId(14);
MUSHROOM_FIELD_SHORE.setLegacyId(15);
BEACH.setLegacyId(16);
DESERT_HILLS.setLegacyId(17);
WOODED_HILLS.setLegacyId(18);
TAIGA_HILLS.setLegacyId(19);
MOUNTAIN_EDGE.setLegacyId(20);
JUNGLE.setLegacyId(21);
JUNGLE_HILLS.setLegacyId(22);
JUNGLE_EDGE.setLegacyId(23);
DEEP_OCEAN.setLegacyId(24);
STONE_SHORE.setLegacyId(25);
SNOWY_BEACH.setLegacyId(26);
BIRCH_FOREST.setLegacyId(27);
BIRCH_FOREST_HILLS.setLegacyId(28);
DARK_FOREST.setLegacyId(29);
SNOWY_TAIGA.setLegacyId(30);
SNOWY_TAIGA_HILLS.setLegacyId(31);
GIANT_TREE_TAIGA.setLegacyId(32);
GIANT_TREE_TAIGA_HILLS.setLegacyId(33);
WOODED_MOUNTAINS.setLegacyId(34);
SAVANNA.setLegacyId(35);
SAVANNA_PLATEAU.setLegacyId(36);
BADLANDS.setLegacyId(37);
WOODED_BADLANDS_PLATEAU.setLegacyId(38);
BADLANDS_PLATEAU.setLegacyId(39);
SMALL_END_ISLANDS.setLegacyId(40);
END_MIDLANDS.setLegacyId(41);
END_HIGHLANDS.setLegacyId(42);
END_BARRENS.setLegacyId(43);
WARM_OCEAN.setLegacyId(44);
LUKEWARM_OCEAN.setLegacyId(45);
COLD_OCEAN.setLegacyId(46);
DEEP_WARM_OCEAN.setLegacyId(47);
DEEP_LUKEWARM_OCEAN.setLegacyId(48);
DEEP_COLD_OCEAN.setLegacyId(49);
DEEP_FROZEN_OCEAN.setLegacyId(50);
THE_VOID.setLegacyId(127);
SUNFLOWER_PLAINS.setLegacyId(129);
DESERT_LAKES.setLegacyId(130);
GRAVELLY_MOUNTAINS.setLegacyId(131);
FLOWER_FOREST.setLegacyId(132);
TAIGA_MOUNTAINS.setLegacyId(133);
SWAMP_HILLS.setLegacyId(134);
ICE_SPIKES.setLegacyId(140);
MODIFIED_JUNGLE.setLegacyId(149);
MODIFIED_JUNGLE_EDGE.setLegacyId(151);
TALL_BIRCH_FOREST.setLegacyId(155);
TALL_BIRCH_HILLS.setLegacyId(156);
DARK_FOREST_HILLS.setLegacyId(157);
SNOWY_TAIGA_MOUNTAINS.setLegacyId(158);
GIANT_SPRUCE_TAIGA.setLegacyId(160);
GIANT_SPRUCE_TAIGA_HILLS.setLegacyId(161);
MODIFIED_GRAVELLY_MOUNTAINS.setLegacyId(162);
SHATTERED_SAVANNA.setLegacyId(163);
SHATTERED_SAVANNA_PLATEAU.setLegacyId(164);
ERODED_BADLANDS.setLegacyId(165);
MODIFIED_WOODED_BADLANDS_PLATEAU.setLegacyId(166);
MODIFIED_BADLANDS_PLATEAU.setLegacyId(167);
// BAMBOO_JUNGLE.setLegacyId(168);
// BAMBOO_JUNGLE_HILLS.setLegacyId(169);
}
} }