Merge branch 'breaking' into breaking-114

This commit is contained in:
Jesse Boyd 2019-07-17 21:31:06 +10:00
commit eff203c3b8
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
6 changed files with 117 additions and 7 deletions

View File

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

View File

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

View File

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

View File

@ -23,6 +23,8 @@ import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public final class NamespacedRegistry<V extends RegistryItem> extends Registry<V> {
@ -59,7 +61,11 @@ public final class NamespacedRegistry<V extends RegistryItem> extends Registry<V
}
public V getByInternalId(int index) {
try {
return values.get(index);
} catch (IndexOutOfBoundsException e) {
return null;
}
}
public int getInternalId(V value) {

View File

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

View File

@ -108,6 +108,15 @@ public class BiomeTypes {
return BiomeType.REGISTRY.get(id);
}
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);
}
@ -115,4 +124,82 @@ public class BiomeTypes {
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);
}
}