Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-19 09:20:08 +01:00
Merge branch 'main' into feat/block-connections-updates
# Conflicts: # worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightGetBlocks.java # worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightGetBlocks.java # worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightGetBlocks.java # worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R3/PaperweightGetBlocks.java # worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightGetBlocks.java
Dieser Commit ist enthalten in:
Commit
2a79b602e2
@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT"
|
||||
griefprevention = "17.0.0"
|
||||
griefdefender = "2.1.0-SNAPSHOT"
|
||||
residence = "4.5._13.1"
|
||||
towny = "0.100.2.14"
|
||||
towny = "0.100.3.0"
|
||||
plotsquared = "7.3.8"
|
||||
|
||||
# Third party
|
||||
|
@ -283,11 +283,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
|
||||
private static Block getBlockFromType(BlockType blockType) {
|
||||
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||
}
|
||||
|
||||
private static Item getItemFromType(ItemType itemType) {
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
ServerLevel worldServer = craftWorld.getHandle();
|
||||
|
||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
||||
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||
|
||||
if (createdEntity != null) {
|
||||
CompoundBinaryTag nativeTag = state.getNbt();
|
||||
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||
item.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||
|
@ -493,7 +493,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||
baseItemStack.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||
@ -560,7 +560,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
.getServer()
|
||||
.registryAccess()
|
||||
.registryOrThrow(BIOME);
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||
Biome biome = registry.get(resourceLocation);
|
||||
return registry.getId(biome);
|
||||
}
|
||||
|
@ -512,7 +512,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setBiomesToPalettedContainer(biomes, setSectionIndex, existingSection.getBiomes());
|
||||
PalettedContainer<Holder<Biome>> paletteBiomes = setBiomesToPalettedContainer(
|
||||
biomes,
|
||||
setSectionIndex,
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
if (paletteBiomes != null) {
|
||||
PaperweightPlatformAdapter.setBiomesToChunkSection(existingSection, paletteBiomes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -554,11 +561,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (existingSection == null) {
|
||||
PalettedContainer<Holder<Biome>> biomeData = biomes == null ? new PalettedContainer<>(
|
||||
biomeHolderIdMap,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(
|
||||
BiomeTypes.PLAINS)),
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(BiomeTypes.PLAINS)),
|
||||
PalettedContainer.Strategy.SECTION_BIOMES,
|
||||
null
|
||||
) : PaperweightPlatformAdapter.getBiomePalettedContainer(biomes[setSectionIndex], biomeHolderIdMap);
|
||||
@ -626,15 +629,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
|
||||
newSection =
|
||||
PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData
|
||||
);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData != null ? biomeData : (PalettedContainer<Holder<Biome>>) existingSection.getBiomes()
|
||||
);
|
||||
if (!PaperweightPlatformAdapter.setSectionAtomic(
|
||||
levelChunkSections,
|
||||
existingSection,
|
||||
@ -815,13 +817,16 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (bitMask == 0 && biomes == null && !lightUpdate) {
|
||||
callback = null;
|
||||
} else {
|
||||
final int finalBitMask = bitMask;
|
||||
callback = () -> {
|
||||
// Set Modified
|
||||
nmsChunk.setLightCorrect(true); // Set Modified
|
||||
nmsChunk.mustNotSave = false;
|
||||
nmsChunk.setUnsaved(true);
|
||||
// send to player
|
||||
if (!set.getSideEffectSet().shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
|
||||
if (!set
|
||||
.getSideEffectSet()
|
||||
.shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalBitMask == 0 && biomes != null) {
|
||||
this.send();
|
||||
}
|
||||
if (finalizer != null) {
|
||||
@ -844,7 +849,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
queueHandler.async(finalizer, null);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@ -1102,38 +1107,25 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
final int sectionIndex,
|
||||
final PalettedContainerRO<Holder<Biome>> data
|
||||
) {
|
||||
PalettedContainer<Holder<Biome>> biomeData;
|
||||
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomeData = palettedContainer;
|
||||
} else {
|
||||
LOGGER.warn(
|
||||
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
|
||||
"type {} but got {}",
|
||||
PalettedContainer.class.getSimpleName(),
|
||||
data.getClass().getSimpleName()
|
||||
);
|
||||
biomeData = data.recreate();
|
||||
}
|
||||
BiomeType[] sectionBiomes;
|
||||
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
|
||||
return biomeData;
|
||||
return null;
|
||||
}
|
||||
PalettedContainer<Holder<Biome>> biomeData = data.recreate();
|
||||
for (int y = 0, index = 0; y < 4; y++) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (int x = 0; x < 4; x++, index++) {
|
||||
BiomeType biomeType = sectionBiomes[index];
|
||||
if (biomeType == null) {
|
||||
continue;
|
||||
biomeData.set(x, y, z, data.get(x, y, z));
|
||||
} else {
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
private final int maxHeight;
|
||||
final ServerLevel serverLevel;
|
||||
final LevelChunk levelChunk;
|
||||
private PalettedContainer<Holder<Biome>>[] biomes = null;
|
||||
private Holder<Biome>[][] biomes = null;
|
||||
|
||||
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
|
||||
this.levelChunk = levelChunk;
|
||||
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
@Override
|
||||
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()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
|
||||
return PaperweightPlatformAdapter.adapt(biome, serverLevel);
|
||||
}
|
||||
|
||||
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
|
||||
if (biomes == null) {
|
||||
biomes = new PalettedContainer[getSectionCount()];
|
||||
biomes = new Holder[getSectionCount()][];
|
||||
}
|
||||
if (biomes[layer] == null) {
|
||||
biomes[layer] = new Holder[64];
|
||||
}
|
||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomes[layer] = palettedContainer.copy();
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error(
|
||||
"Cannot correctly save biomes to history. Expected class type {} but got {}",
|
||||
|
@ -98,7 +98,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
private static final Field fieldTickingFluidCount;
|
||||
private static final Field fieldTickingBlockCount;
|
||||
private static final Field fieldNonEmptyBlockCount;
|
||||
private static final Field fieldBiomes;
|
||||
|
||||
private static final MethodHandle methodGetVisibleChunk;
|
||||
|
||||
@ -139,8 +139,15 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
fieldTickingFluidCount.setAccessible(true);
|
||||
fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "g"));
|
||||
fieldTickingBlockCount.setAccessible(true);
|
||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "f"));
|
||||
fieldNonEmptyBlockCount.setAccessible(true);
|
||||
Field tmpFieldBiomes;
|
||||
try {
|
||||
// It seems to actually be biomes, but is apparently obfuscated to "j"
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("biomes");
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("j");
|
||||
}
|
||||
fieldBiomes = tmpFieldBiomes;
|
||||
fieldBiomes.setAccessible(true);
|
||||
|
||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||
"getVisibleChunkIfPresent",
|
||||
@ -502,6 +509,14 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
return new LevelChunkSection(layer, dataPaletteBlocks, biomes);
|
||||
}
|
||||
|
||||
public static void setBiomesToChunkSection(LevelChunkSection section, PalettedContainer<Holder<Biome>> biomes) {
|
||||
try {
|
||||
fieldBiomes.set(section, biomes);
|
||||
} catch (IllegalAccessException e) {
|
||||
LOGGER.error("Could not set biomes to chunk section", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link PalettedContainer<Biome>}. Should only be used if no biome container existed beforehand.
|
||||
*/
|
||||
|
@ -284,11 +284,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
|
||||
private static Block getBlockFromType(BlockType blockType) {
|
||||
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||
}
|
||||
|
||||
private static Item getItemFromType(ItemType itemType) {
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -480,7 +480,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
ServerLevel worldServer = craftWorld.getHandle();
|
||||
|
||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
||||
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||
|
||||
if (createdEntity != null) {
|
||||
CompoundBinaryTag nativeTag = state.getNbt();
|
||||
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||
item.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||
|
@ -493,7 +493,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||
baseItemStack.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||
@ -560,7 +560,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
.getServer()
|
||||
.registryAccess()
|
||||
.registryOrThrow(BIOME);
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||
Biome biome = registry.get(resourceLocation);
|
||||
return registry.getId(biome);
|
||||
}
|
||||
|
@ -511,7 +511,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setBiomesToPalettedContainer(biomes, setSectionIndex, existingSection.getBiomes());
|
||||
PalettedContainer<Holder<Biome>> paletteBiomes = setBiomesToPalettedContainer(
|
||||
biomes,
|
||||
setSectionIndex,
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
if (paletteBiomes != null) {
|
||||
PaperweightPlatformAdapter.setBiomesToChunkSection(existingSection, paletteBiomes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -553,11 +560,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (existingSection == null) {
|
||||
PalettedContainer<Holder<Biome>> biomeData = biomes == null ? new PalettedContainer<>(
|
||||
biomeHolderIdMap,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(
|
||||
BiomeTypes.PLAINS)),
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(BiomeTypes.PLAINS)),
|
||||
PalettedContainer.Strategy.SECTION_BIOMES
|
||||
) : PaperweightPlatformAdapter.getBiomePalettedContainer(biomes[setSectionIndex], biomeHolderIdMap);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
@ -624,15 +627,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
|
||||
newSection =
|
||||
PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData
|
||||
);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData != null ? biomeData : (PalettedContainer<Holder<Biome>>) existingSection.getBiomes()
|
||||
);
|
||||
if (!PaperweightPlatformAdapter.setSectionAtomic(
|
||||
levelChunkSections,
|
||||
existingSection,
|
||||
@ -813,13 +815,16 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (bitMask == 0 && biomes == null && !lightUpdate) {
|
||||
callback = null;
|
||||
} else {
|
||||
final int finalBitMask = bitMask;
|
||||
callback = () -> {
|
||||
// Set Modified
|
||||
nmsChunk.setLightCorrect(true); // Set Modified
|
||||
nmsChunk.mustNotSave = false;
|
||||
nmsChunk.setUnsaved(true);
|
||||
// send to player
|
||||
if (!set.getSideEffectSet().shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
|
||||
if (!set
|
||||
.getSideEffectSet()
|
||||
.shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalBitMask == 0 && biomes != null) {
|
||||
this.send();
|
||||
}
|
||||
if (finalizer != null) {
|
||||
@ -842,7 +847,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
queueHandler.async(finalizer, null);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@ -1099,38 +1104,25 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
final int sectionIndex,
|
||||
final PalettedContainerRO<Holder<Biome>> data
|
||||
) {
|
||||
PalettedContainer<Holder<Biome>> biomeData;
|
||||
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomeData = palettedContainer;
|
||||
} else {
|
||||
LOGGER.warn(
|
||||
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
|
||||
"type {} but got {}",
|
||||
PalettedContainer.class.getSimpleName(),
|
||||
data.getClass().getSimpleName()
|
||||
);
|
||||
biomeData = data.recreate();
|
||||
}
|
||||
BiomeType[] sectionBiomes;
|
||||
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
|
||||
return biomeData;
|
||||
return null;
|
||||
}
|
||||
PalettedContainer<Holder<Biome>> biomeData = data.recreate();
|
||||
for (int y = 0, index = 0; y < 4; y++) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (int x = 0; x < 4; x++, index++) {
|
||||
BiomeType biomeType = sectionBiomes[index];
|
||||
if (biomeType == null) {
|
||||
continue;
|
||||
biomeData.set(x, y, z, data.get(x, y, z));
|
||||
} else {
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
private final int maxHeight;
|
||||
final ServerLevel serverLevel;
|
||||
final LevelChunk levelChunk;
|
||||
private PalettedContainer<Holder<Biome>>[] biomes = null;
|
||||
private Holder<Biome>[][] biomes = null;
|
||||
|
||||
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
|
||||
this.levelChunk = levelChunk;
|
||||
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
@Override
|
||||
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()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
|
||||
return PaperweightPlatformAdapter.adapt(biome, serverLevel);
|
||||
}
|
||||
|
||||
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
|
||||
if (biomes == null) {
|
||||
biomes = new PalettedContainer[getSectionCount()];
|
||||
biomes = new Holder[getSectionCount()][];
|
||||
}
|
||||
if (biomes[layer] == null) {
|
||||
biomes[layer] = new Holder[64];
|
||||
}
|
||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomes[layer] = palettedContainer.copy();
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error(
|
||||
"Cannot correctly save biomes to history. Expected class type {} but got {}",
|
||||
|
@ -62,7 +62,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftChunk;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -102,7 +101,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
private static final Field fieldTickingFluidCount;
|
||||
private static final Field fieldTickingBlockCount;
|
||||
private static final Field fieldNonEmptyBlockCount;
|
||||
|
||||
private static final MethodHandle methodGetVisibleChunk;
|
||||
|
||||
@ -111,6 +109,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
private static final MethodHandle methodRemoveGameEventListener;
|
||||
private static final MethodHandle methodremoveTickingBlockEntity;
|
||||
private static final Field fieldBiomes;
|
||||
|
||||
private static final Field fieldOffers;
|
||||
private static final MerchantOffers OFFERS = new MerchantOffers();
|
||||
@ -149,8 +148,15 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
fieldTickingFluidCount.setAccessible(true);
|
||||
fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "f"));
|
||||
fieldTickingBlockCount.setAccessible(true);
|
||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||
fieldNonEmptyBlockCount.setAccessible(true);
|
||||
Field tmpFieldBiomes;
|
||||
try {
|
||||
// It seems to actually be biomes, but is apparently obfuscated to "i"
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("biomes");
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("i");
|
||||
}
|
||||
fieldBiomes = tmpFieldBiomes;
|
||||
fieldBiomes.setAccessible(true);
|
||||
|
||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||
"getVisibleChunkIfPresent",
|
||||
@ -417,7 +423,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
if (set == null) {
|
||||
return newChunkSection(layer, biomeRegistry, biomes);
|
||||
return newChunkSection(biomeRegistry, biomes);
|
||||
}
|
||||
final int[] blockToPalette = FaweCache.INSTANCE.BLOCK_TO_PALETTE.get();
|
||||
final int[] paletteToBlock = FaweCache.INSTANCE.PALETTE_TO_BLOCK.get();
|
||||
@ -507,7 +513,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
@SuppressWarnings("deprecation") // Only deprecated in paper
|
||||
private static LevelChunkSection newChunkSection(
|
||||
int layer,
|
||||
Registry<Biome> biomeRegistry,
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
@ -522,6 +527,14 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
return new LevelChunkSection(dataPaletteBlocks, biomes);
|
||||
}
|
||||
|
||||
public static void setBiomesToChunkSection(LevelChunkSection section, PalettedContainer<Holder<Biome>> biomes) {
|
||||
try {
|
||||
fieldBiomes.set(section, biomes);
|
||||
} catch (IllegalAccessException e) {
|
||||
LOGGER.error("Could not set biomes to chunk section", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link PalettedContainer<Biome>}. Should only be used if no biome container existed beforehand.
|
||||
*/
|
||||
|
@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
|
||||
private static Block getBlockFromType(BlockType blockType) {
|
||||
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||
}
|
||||
|
||||
private static Item getItemFromType(ItemType itemType) {
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
ServerLevel worldServer = craftWorld.getHandle();
|
||||
|
||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
||||
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||
|
||||
if (createdEntity != null) {
|
||||
CompoundBinaryTag nativeTag = state.getNbt();
|
||||
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||
item.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||
|
@ -496,7 +496,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||
baseItemStack.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||
@ -563,7 +563,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
.getServer()
|
||||
.registryAccess()
|
||||
.registryOrThrow(BIOME);
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||
Biome biome = registry.get(resourceLocation);
|
||||
return registry.getId(biome);
|
||||
}
|
||||
|
@ -519,7 +519,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setBiomesToPalettedContainer(biomes, setSectionIndex, existingSection.getBiomes());
|
||||
PalettedContainer<Holder<Biome>> paletteBiomes = setBiomesToPalettedContainer(
|
||||
biomes,
|
||||
setSectionIndex,
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
if (paletteBiomes != null) {
|
||||
PaperweightPlatformAdapter.setBiomesToChunkSection(existingSection, paletteBiomes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -561,11 +568,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (existingSection == null) {
|
||||
PalettedContainer<Holder<Biome>> biomeData = biomes == null ? new PalettedContainer<>(
|
||||
biomeHolderIdMap,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(
|
||||
BiomeTypes.PLAINS)),
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(BiomeTypes.PLAINS)),
|
||||
PalettedContainer.Strategy.SECTION_BIOMES
|
||||
) : PaperweightPlatformAdapter.getBiomePalettedContainer(biomes[setSectionIndex], biomeHolderIdMap);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
@ -632,15 +635,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
|
||||
newSection =
|
||||
PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData
|
||||
);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData != null ? biomeData : (PalettedContainer<Holder<Biome>>) existingSection.getBiomes()
|
||||
);
|
||||
if (!PaperweightPlatformAdapter.setSectionAtomic(
|
||||
levelChunkSections,
|
||||
existingSection,
|
||||
@ -821,13 +823,16 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (bitMask == 0 && biomes == null && !lightUpdate) {
|
||||
callback = null;
|
||||
} else {
|
||||
final int finalBitMask = bitMask;
|
||||
callback = () -> {
|
||||
// Set Modified
|
||||
nmsChunk.setLightCorrect(true); // Set Modified
|
||||
nmsChunk.mustNotSave = false;
|
||||
nmsChunk.setUnsaved(true);
|
||||
// send to player
|
||||
if (!set.getSideEffectSet().shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
|
||||
if (!set
|
||||
.getSideEffectSet()
|
||||
.shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalBitMask == 0 && biomes != null) {
|
||||
this.send();
|
||||
}
|
||||
if (finalizer != null) {
|
||||
@ -850,7 +855,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
queueHandler.async(finalizer, null);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@ -1107,38 +1112,25 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
final int sectionIndex,
|
||||
final PalettedContainerRO<Holder<Biome>> data
|
||||
) {
|
||||
PalettedContainer<Holder<Biome>> biomeData;
|
||||
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomeData = palettedContainer;
|
||||
} else {
|
||||
LOGGER.warn(
|
||||
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
|
||||
"type {} but got {}",
|
||||
PalettedContainer.class.getSimpleName(),
|
||||
data.getClass().getSimpleName()
|
||||
);
|
||||
biomeData = data.recreate();
|
||||
}
|
||||
BiomeType[] sectionBiomes;
|
||||
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
|
||||
return biomeData;
|
||||
return null;
|
||||
}
|
||||
PalettedContainer<Holder<Biome>> biomeData = data.recreate();
|
||||
for (int y = 0, index = 0; y < 4; y++) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (int x = 0; x < 4; x++, index++) {
|
||||
BiomeType biomeType = sectionBiomes[index];
|
||||
if (biomeType == null) {
|
||||
continue;
|
||||
biomeData.set(x, y, z, data.get(x, y, z));
|
||||
} else {
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
private final int maxHeight;
|
||||
final ServerLevel serverLevel;
|
||||
final LevelChunk levelChunk;
|
||||
private PalettedContainer<Holder<Biome>>[] biomes = null;
|
||||
private Holder<Biome>[][] biomes = null;
|
||||
|
||||
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
|
||||
this.levelChunk = levelChunk;
|
||||
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
@Override
|
||||
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()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
|
||||
return PaperweightPlatformAdapter.adapt(biome, serverLevel);
|
||||
}
|
||||
|
||||
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
|
||||
if (biomes == null) {
|
||||
biomes = new PalettedContainer[getSectionCount()];
|
||||
biomes = new Holder[getSectionCount()][];
|
||||
}
|
||||
if (biomes[layer] == null) {
|
||||
biomes[layer] = new Holder[64];
|
||||
}
|
||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomes[layer] = palettedContainer.copy();
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error(
|
||||
"Cannot correctly save biomes to history. Expected class type {} but got {}",
|
||||
|
@ -59,7 +59,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_20_R2.CraftChunk;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -99,7 +98,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
private static final Field fieldTickingFluidCount;
|
||||
private static final Field fieldTickingBlockCount;
|
||||
private static final Field fieldNonEmptyBlockCount;
|
||||
|
||||
private static final MethodHandle methodGetVisibleChunk;
|
||||
|
||||
@ -108,6 +106,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
private static final MethodHandle methodRemoveGameEventListener;
|
||||
private static final MethodHandle methodremoveTickingBlockEntity;
|
||||
private static final Field fieldBiomes;
|
||||
|
||||
/*
|
||||
* This is a workaround for the changes from https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/1fddefce1cdce44010927b888432bf70c0e88cde#src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
@ -143,8 +142,15 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
fieldTickingFluidCount.setAccessible(true);
|
||||
fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "f"));
|
||||
fieldTickingBlockCount.setAccessible(true);
|
||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||
fieldNonEmptyBlockCount.setAccessible(true);
|
||||
Field tmpFieldBiomes;
|
||||
try {
|
||||
// It seems to actually be biomes, but is apparently obfuscated to "i"
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("biomes");
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("i");
|
||||
}
|
||||
fieldBiomes = tmpFieldBiomes;
|
||||
fieldBiomes.setAccessible(true);
|
||||
|
||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||
"getVisibleChunkIfPresent",
|
||||
@ -408,7 +414,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
if (set == null) {
|
||||
return newChunkSection(layer, biomeRegistry, biomes);
|
||||
return newChunkSection(biomeRegistry, biomes);
|
||||
}
|
||||
final int[] blockToPalette = FaweCache.INSTANCE.BLOCK_TO_PALETTE.get();
|
||||
final int[] paletteToBlock = FaweCache.INSTANCE.PALETTE_TO_BLOCK.get();
|
||||
@ -498,7 +504,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
@SuppressWarnings("deprecation") // Only deprecated in paper
|
||||
private static LevelChunkSection newChunkSection(
|
||||
int layer,
|
||||
Registry<Biome> biomeRegistry,
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
@ -513,6 +518,14 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
return new LevelChunkSection(dataPaletteBlocks, biomes);
|
||||
}
|
||||
|
||||
public static void setBiomesToChunkSection(LevelChunkSection section, PalettedContainer<Holder<Biome>> biomes) {
|
||||
try {
|
||||
fieldBiomes.set(section, biomes);
|
||||
} catch (IllegalAccessException e) {
|
||||
LOGGER.error("Could not set biomes to chunk section", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link PalettedContainer<Biome>}. Should only be used if no biome container existed beforehand.
|
||||
*/
|
||||
|
@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
|
||||
private static Block getBlockFromType(BlockType blockType) {
|
||||
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||
}
|
||||
|
||||
private static Item getItemFromType(ItemType itemType) {
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
ServerLevel worldServer = craftWorld.getHandle();
|
||||
|
||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
||||
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||
|
||||
if (createdEntity != null) {
|
||||
CompoundBinaryTag nativeTag = state.getNbt();
|
||||
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||
item.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||
|
@ -494,7 +494,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
|
||||
ItemStack stack = new ItemStack(
|
||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
||||
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||
baseItemStack.getAmount()
|
||||
);
|
||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||
@ -561,7 +561,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
.getServer()
|
||||
.registryAccess()
|
||||
.registryOrThrow(BIOME);
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||
Biome biome = registry.get(resourceLocation);
|
||||
return registry.getId(biome);
|
||||
}
|
||||
|
@ -518,7 +518,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setBiomesToPalettedContainer(biomes, setSectionIndex, existingSection.getBiomes());
|
||||
PalettedContainer<Holder<Biome>> paletteBiomes = setBiomesToPalettedContainer(
|
||||
biomes,
|
||||
setSectionIndex,
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
if (paletteBiomes != null) {
|
||||
PaperweightPlatformAdapter.setBiomesToChunkSection(existingSection, paletteBiomes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -560,11 +567,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (existingSection == null) {
|
||||
PalettedContainer<Holder<Biome>> biomeData = biomes == null ? new PalettedContainer<>(
|
||||
biomeHolderIdMap,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(
|
||||
BiomeTypes.PLAINS)),
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(BiomeTypes.PLAINS)),
|
||||
PalettedContainer.Strategy.SECTION_BIOMES
|
||||
) : PaperweightPlatformAdapter.getBiomePalettedContainer(biomes[setSectionIndex], biomeHolderIdMap);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
@ -631,15 +634,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
|
||||
newSection =
|
||||
PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData
|
||||
);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData != null ? biomeData : (PalettedContainer<Holder<Biome>>) existingSection.getBiomes()
|
||||
);
|
||||
if (!PaperweightPlatformAdapter.setSectionAtomic(
|
||||
levelChunkSections,
|
||||
existingSection,
|
||||
@ -820,13 +822,16 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (bitMask == 0 && biomes == null && !lightUpdate) {
|
||||
callback = null;
|
||||
} else {
|
||||
final int finalBitMask = bitMask;
|
||||
callback = () -> {
|
||||
// Set Modified
|
||||
nmsChunk.setLightCorrect(true); // Set Modified
|
||||
nmsChunk.mustNotSave = false;
|
||||
nmsChunk.setUnsaved(true);
|
||||
// send to player
|
||||
if (!set.getSideEffectSet().shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
|
||||
if (!set
|
||||
.getSideEffectSet()
|
||||
.shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalBitMask == 0 && biomes != null) {
|
||||
this.send();
|
||||
}
|
||||
if (finalizer != null) {
|
||||
@ -849,7 +854,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
queueHandler.async(finalizer, null);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@ -1104,38 +1109,25 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
final int sectionIndex,
|
||||
final PalettedContainerRO<Holder<Biome>> data
|
||||
) {
|
||||
PalettedContainer<Holder<Biome>> biomeData;
|
||||
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomeData = palettedContainer;
|
||||
} else {
|
||||
LOGGER.warn(
|
||||
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
|
||||
"type {} but got {}",
|
||||
PalettedContainer.class.getSimpleName(),
|
||||
data.getClass().getSimpleName()
|
||||
);
|
||||
biomeData = data.recreate();
|
||||
}
|
||||
BiomeType[] sectionBiomes;
|
||||
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
|
||||
return biomeData;
|
||||
return null;
|
||||
}
|
||||
PalettedContainer<Holder<Biome>> biomeData = data.recreate();
|
||||
for (int y = 0, index = 0; y < 4; y++) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (int x = 0; x < 4; x++, index++) {
|
||||
BiomeType biomeType = sectionBiomes[index];
|
||||
if (biomeType == null) {
|
||||
continue;
|
||||
biomeData.set(x, y, z, data.get(x, y, z));
|
||||
} else {
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
private final int maxHeight;
|
||||
final ServerLevel serverLevel;
|
||||
final LevelChunk levelChunk;
|
||||
private PalettedContainer<Holder<Biome>>[] biomes = null;
|
||||
private Holder<Biome>[][] biomes = null;
|
||||
|
||||
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
|
||||
this.levelChunk = levelChunk;
|
||||
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
@Override
|
||||
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()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
|
||||
return PaperweightPlatformAdapter.adapt(biome, serverLevel);
|
||||
}
|
||||
|
||||
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
|
||||
if (biomes == null) {
|
||||
biomes = new PalettedContainer[getSectionCount()];
|
||||
biomes = new Holder[getSectionCount()][];
|
||||
}
|
||||
if (biomes[layer] == null) {
|
||||
biomes[layer] = new Holder[64];
|
||||
}
|
||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomes[layer] = palettedContainer.copy();
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error(
|
||||
"Cannot correctly save biomes to history. Expected class type {} but got {}",
|
||||
|
@ -98,7 +98,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
private static final Field fieldTickingFluidCount;
|
||||
private static final Field fieldTickingBlockCount;
|
||||
private static final Field fieldNonEmptyBlockCount;
|
||||
private static final Field fieldBiomes;
|
||||
|
||||
private static final MethodHandle methodGetVisibleChunk;
|
||||
|
||||
@ -142,8 +142,15 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
fieldTickingFluidCount.setAccessible(true);
|
||||
fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "f"));
|
||||
fieldTickingBlockCount.setAccessible(true);
|
||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||
fieldNonEmptyBlockCount.setAccessible(true);
|
||||
Field tmpFieldBiomes;
|
||||
try {
|
||||
// It seems to actually be biomes, but is apparently obfuscated to "i"
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("biomes");
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
tmpFieldBiomes = LevelChunkSection.class.getDeclaredField("i");
|
||||
}
|
||||
fieldBiomes = tmpFieldBiomes;
|
||||
fieldBiomes.setAccessible(true);
|
||||
|
||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||
"getVisibleChunkIfPresent",
|
||||
@ -407,7 +414,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
if (set == null) {
|
||||
return newChunkSection(layer, biomeRegistry, biomes);
|
||||
return newChunkSection(biomeRegistry, biomes);
|
||||
}
|
||||
final int[] blockToPalette = FaweCache.INSTANCE.BLOCK_TO_PALETTE.get();
|
||||
final int[] paletteToBlock = FaweCache.INSTANCE.PALETTE_TO_BLOCK.get();
|
||||
@ -497,7 +504,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
@SuppressWarnings("deprecation") // Only deprecated in paper
|
||||
private static LevelChunkSection newChunkSection(
|
||||
int layer,
|
||||
Registry<Biome> biomeRegistry,
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
@ -512,6 +518,14 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
return new LevelChunkSection(dataPaletteBlocks, biomes);
|
||||
}
|
||||
|
||||
public static void setBiomesToChunkSection(LevelChunkSection section, PalettedContainer<Holder<Biome>> biomes) {
|
||||
try {
|
||||
fieldBiomes.set(section, biomes);
|
||||
} catch (IllegalAccessException e) {
|
||||
LOGGER.error("Could not set biomes to chunk section", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link PalettedContainer<Biome>}. Should only be used if no biome container existed beforehand.
|
||||
*/
|
||||
|
@ -12,6 +12,6 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/
|
||||
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240604.210637-112")
|
||||
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240615.211816-120")
|
||||
compileOnly(libs.paperlib)
|
||||
}
|
||||
|
@ -291,12 +291,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
private static Block getBlockFromType(BlockType blockType) {
|
||||
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(
|
||||
blockType.getId()));
|
||||
blockType.id()));
|
||||
}
|
||||
|
||||
private static Item getItemFromType(ItemType itemType) {
|
||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(
|
||||
itemType.getId()));
|
||||
itemType.id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -470,7 +470,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
ServerLevel worldServer = craftWorld.getHandle();
|
||||
|
||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
||||
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||
|
||||
if (createdEntity != null) {
|
||||
CompoundBinaryTag nativeTag = state.getNbt();
|
||||
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
|
||||
ItemStack stack = new ItemStack(
|
||||
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
||||
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||
item.getAmount()
|
||||
);
|
||||
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData());
|
||||
|
@ -505,7 +505,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
|
||||
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
|
||||
ItemStack stack = new ItemStack(
|
||||
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
||||
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||
baseItemStack.getAmount()
|
||||
);
|
||||
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData());
|
||||
@ -585,7 +585,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
||||
.getServer()
|
||||
.registryAccess()
|
||||
.registryOrThrow(BIOME);
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||
Biome biome = registry.get(resourceLocation);
|
||||
return registry.getId(biome);
|
||||
}
|
||||
|
@ -521,7 +521,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setBiomesToPalettedContainer(biomes, setSectionIndex, existingSection.getBiomes());
|
||||
PalettedContainer<Holder<Biome>> paletteBiomes = setBiomesToPalettedContainer(
|
||||
biomes,
|
||||
setSectionIndex,
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
if (paletteBiomes != null) {
|
||||
PaperweightPlatformAdapter.setBiomesToChunkSection(existingSection, paletteBiomes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -563,11 +570,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (existingSection == null) {
|
||||
PalettedContainer<Holder<Biome>> biomeData = biomes == null ? new PalettedContainer<>(
|
||||
biomeHolderIdMap,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(
|
||||
BiomeTypes.PLAINS)),
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(BiomeTypes.PLAINS)),
|
||||
PalettedContainer.Strategy.SECTION_BIOMES
|
||||
) : PaperweightPlatformAdapter.getBiomePalettedContainer(biomes[setSectionIndex], biomeHolderIdMap);
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
@ -634,18 +637,15 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
existingSection.getBiomes()
|
||||
);
|
||||
|
||||
newSection =
|
||||
PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData
|
||||
);
|
||||
if (!PaperweightPlatformAdapter.setSectionAtomic(
|
||||
levelChunkSections,
|
||||
existingSection,
|
||||
newSection = PaperweightPlatformAdapter.newChunkSection(
|
||||
layerNo,
|
||||
this::loadPrivately,
|
||||
setArr,
|
||||
adapter,
|
||||
biomeRegistry,
|
||||
biomeData != null ? biomeData : (PalettedContainer<Holder<Biome>>) existingSection.getBiomes()
|
||||
);
|
||||
if (!PaperweightPlatformAdapter.setSectionAtomic(levelChunkSections, existingSection,
|
||||
newSection,
|
||||
getSectionIndex
|
||||
)) {
|
||||
@ -823,13 +823,16 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
if (bitMask == 0 && biomes == null && !lightUpdate) {
|
||||
callback = null;
|
||||
} else {
|
||||
final int finalBitMask = bitMask;
|
||||
callback = () -> {
|
||||
// Set Modified
|
||||
nmsChunk.setLightCorrect(true); // Set Modified
|
||||
nmsChunk.mustNotSave = false;
|
||||
nmsChunk.setUnsaved(true);
|
||||
// send to player
|
||||
if (!set.getSideEffectSet().shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
|
||||
if (!set
|
||||
.getSideEffectSet()
|
||||
.shouldApply(SideEffect.LIGHTING) || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalBitMask == 0 && biomes != null) {
|
||||
this.send();
|
||||
}
|
||||
if (finalizer != null) {
|
||||
@ -852,7 +855,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
queueHandler.async(finalizer, null);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@ -1109,38 +1112,25 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
|
||||
final int sectionIndex,
|
||||
final PalettedContainerRO<Holder<Biome>> data
|
||||
) {
|
||||
PalettedContainer<Holder<Biome>> biomeData;
|
||||
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomeData = palettedContainer;
|
||||
} else {
|
||||
LOGGER.warn(
|
||||
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
|
||||
"type {} but got {}",
|
||||
PalettedContainer.class.getSimpleName(),
|
||||
data.getClass().getSimpleName()
|
||||
);
|
||||
biomeData = data.recreate();
|
||||
}
|
||||
BiomeType[] sectionBiomes;
|
||||
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
|
||||
return biomeData;
|
||||
return null;
|
||||
}
|
||||
PalettedContainer<Holder<Biome>> biomeData = data.recreate();
|
||||
for (int y = 0, index = 0; y < 4; y++) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (int x = 0; x < 4; x++, index++) {
|
||||
BiomeType biomeType = sectionBiomes[index];
|
||||
if (biomeType == null) {
|
||||
continue;
|
||||
biomeData.set(x, y, z, data.get(x, y, z));
|
||||
} else {
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(adapter.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
biomeData.set(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
biomeHolderIdMap.byIdOrThrow(WorldEditPlugin
|
||||
.getInstance()
|
||||
.getBukkitImplAdapter()
|
||||
.getInternalBiomeId(biomeType))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
private final int maxHeight;
|
||||
final ServerLevel serverLevel;
|
||||
final LevelChunk levelChunk;
|
||||
private PalettedContainer<Holder<Biome>>[] biomes = null;
|
||||
private Holder<Biome>[][] biomes = null;
|
||||
|
||||
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
|
||||
this.levelChunk = levelChunk;
|
||||
@ -145,7 +145,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
@Override
|
||||
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()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
|
||||
return PaperweightPlatformAdapter.adapt(biome, serverLevel);
|
||||
}
|
||||
|
||||
@ -174,10 +174,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
||||
|
||||
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
|
||||
if (biomes == null) {
|
||||
biomes = new PalettedContainer[getSectionCount()];
|
||||
biomes = new Holder[getSectionCount()][];
|
||||
}
|
||||
if (biomes[layer] == null) {
|
||||
biomes[layer] = new Holder[64];
|
||||
}
|
||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||
biomes[layer] = palettedContainer.copy();
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error(
|
||||
"Cannot correctly save biomes to history. Expected class type {} but got {}",
|
||||
|
@ -10,7 +10,6 @@ import com.fastasyncworldedit.core.math.BitArrayUnstretched;
|
||||
import com.fastasyncworldedit.core.util.MathMan;
|
||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||
import com.fastasyncworldedit.core.util.TaskManager;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
||||
@ -77,7 +76,6 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -98,7 +96,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
private static final Field fieldTickingFluidCount;
|
||||
private static final Field fieldTickingBlockCount;
|
||||
private static final Field fieldNonEmptyBlockCount;
|
||||
private static final Field fieldBiomes;
|
||||
|
||||
private static final MethodHandle methodGetVisibleChunk;
|
||||
|
||||
@ -142,8 +140,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
fieldTickingFluidCount.setAccessible(true);
|
||||
fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "f"));
|
||||
fieldTickingBlockCount.setAccessible(true);
|
||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||
fieldNonEmptyBlockCount.setAccessible(true);
|
||||
fieldBiomes = LevelChunkSection.class.getDeclaredField(Refraction.pickName("biomes", "i"));
|
||||
fieldBiomes.setAccessible(true);
|
||||
|
||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||
"getVisibleChunkIfPresent",
|
||||
@ -405,7 +403,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
if (set == null) {
|
||||
return newChunkSection(layer, biomeRegistry, biomes);
|
||||
return newChunkSection(biomeRegistry, biomes);
|
||||
}
|
||||
final int[] blockToPalette = FaweCache.INSTANCE.BLOCK_TO_PALETTE.get();
|
||||
final int[] paletteToBlock = FaweCache.INSTANCE.PALETTE_TO_BLOCK.get();
|
||||
@ -495,7 +493,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
|
||||
@SuppressWarnings("deprecation") // Only deprecated in paper
|
||||
private static LevelChunkSection newChunkSection(
|
||||
int layer,
|
||||
Registry<Biome> biomeRegistry,
|
||||
@Nullable PalettedContainer<Holder<Biome>> biomes
|
||||
) {
|
||||
@ -510,6 +507,14 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
return new LevelChunkSection(dataPaletteBlocks, biomes);
|
||||
}
|
||||
|
||||
public static void setBiomesToChunkSection(LevelChunkSection section, PalettedContainer<Holder<Biome>> biomes) {
|
||||
try {
|
||||
fieldBiomes.set(section, biomes);
|
||||
} catch (IllegalAccessException e) {
|
||||
LOGGER.error("Could not set biomes to chunk section", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link PalettedContainer<Biome>}. Should only be used if no biome container existed beforehand.
|
||||
*/
|
||||
|
@ -166,10 +166,10 @@ public interface IBukkitAdapter {
|
||||
*/
|
||||
default Material adapt(ItemType itemType) {
|
||||
checkNotNull(itemType);
|
||||
if (!itemType.getId().startsWith("minecraft:")) {
|
||||
if (!itemType.id().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||
}
|
||||
return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT));
|
||||
return Material.getMaterial(itemType.id().substring(10).toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,10 +180,10 @@ public interface IBukkitAdapter {
|
||||
*/
|
||||
default Material adapt(BlockType blockType) {
|
||||
checkNotNull(blockType);
|
||||
if (!blockType.getId().startsWith("minecraft:")) {
|
||||
if (!blockType.id().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||
}
|
||||
String id = blockType.getId().substring(10).toUpperCase(Locale.ROOT);
|
||||
String id = blockType.id().substring(10).toUpperCase(Locale.ROOT);
|
||||
return Material.getMaterial(id);
|
||||
}
|
||||
|
||||
@ -293,11 +293,11 @@ public interface IBukkitAdapter {
|
||||
}
|
||||
|
||||
default Biome adapt(BiomeType biomeType) {
|
||||
if (!biomeType.getId().startsWith("minecraft:")) {
|
||||
if (!biomeType.id().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
|
||||
}
|
||||
try {
|
||||
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT));
|
||||
return Biome.valueOf(biomeType.id().substring(10).toUpperCase(Locale.ROOT));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fastasyncworldedit.bukkit.regions;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||
import com.fastasyncworldedit.core.regions.RegionWrapper;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
@ -158,6 +159,9 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(com.sk89q.worldedit.entity.Player wePlayer, MaskType type, boolean isWhitelist) {
|
||||
if (isWhitelist && Settings.settings().REGION_RESTRICTIONS_OPTIONS.WORLDGUARD_REGION_BLACKLIST) {
|
||||
return new FaweMask(RegionWrapper.GLOBAL());
|
||||
}
|
||||
final Player player = BukkitAdapter.adapt(wePlayer);
|
||||
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final Location location = player.getLocation();
|
||||
|
@ -40,7 +40,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
||||
@Override
|
||||
public Component getRichName(BiomeType biomeType) {
|
||||
return TranslatableComponent.of(
|
||||
TranslationManager.makeTranslationKey("biome", biomeType.getId())
|
||||
TranslationManager.makeTranslationKey("biome", biomeType.id())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
ItemStack newItem = BukkitAdapter.adapt(itemStack);
|
||||
TaskManager.taskManager().sync(() -> {
|
||||
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
|
||||
if (itemStack.getType().id().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
|
||||
inv.remove(newItem);
|
||||
}
|
||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
||||
@ -267,7 +267,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gameMode) {
|
||||
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase(Locale.ROOT)));
|
||||
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.id().toUpperCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,6 +192,9 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
||||
@Override
|
||||
public BaseItem getItem(int slot) {
|
||||
loadInventory();
|
||||
if (items[slot] == null) {
|
||||
return null;
|
||||
}
|
||||
return BukkitAdapter.adapt(items[slot]);
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public String getId() {
|
||||
public String id() {
|
||||
return "intellectualsites:bukkit";
|
||||
}
|
||||
//FAWE end
|
||||
|
@ -224,7 +224,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
public String id() {
|
||||
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,10 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
getDataFolder().mkdirs();
|
||||
|
||||
//FAWE start - Migrate from config-legacy to worldedit-config
|
||||
migrateLegacyConfig();
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - Modify WorldEdit config name
|
||||
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this);
|
||||
// Load config before we say we've loaded platforms as it is used in listeners of the event
|
||||
@ -151,10 +155,6 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
platform = new BukkitServerInterface(this, getServer());
|
||||
worldEdit.getPlatformManager().register(platform);
|
||||
|
||||
//FAWE start - Migrate from config-legacy to worldedit-config
|
||||
migrateLegacyConfig();
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - Setup permission attachments
|
||||
permissionAttachmentManager = new BukkitPermissionAttachmentManager(this);
|
||||
//FAWE end
|
||||
|
@ -68,7 +68,7 @@ public class CLIBlockRegistry extends BundledBlockRegistry {
|
||||
@Override
|
||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||
Map<String, FileRegistries.BlockProperty> properties =
|
||||
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties;
|
||||
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.id()).properties;
|
||||
Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform =
|
||||
(key, value) -> createProperty(value.type, key, value.values);
|
||||
return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform));
|
||||
|
@ -115,7 +115,7 @@ class CLIPlatform extends AbstractPlatform {
|
||||
@Override
|
||||
public World matchWorld(World world) {
|
||||
return this.worlds.stream()
|
||||
.filter(w -> w.getId().equals(world.getId()))
|
||||
.filter(w -> w.id().equals(world.id()))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class ClipboardWorld extends AbstractWorld implements Clipboard, CLIWorld
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
public String id() {
|
||||
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.fastasyncworldedit.core;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||
import com.fastasyncworldedit.core.limit.FaweLimit;
|
||||
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
|
||||
import com.fastasyncworldedit.core.util.CachedTextureUtil;
|
||||
import com.fastasyncworldedit.core.util.CleanTextureUtil;
|
||||
@ -105,6 +106,8 @@ public class Fawe {
|
||||
* Implementation dependent stuff
|
||||
*/
|
||||
this.setupConfigs();
|
||||
FaweLimit.MAX.CONFIRM_LARGE =
|
||||
Settings.settings().LIMITS.get("default").CONFIRM_LARGE || Settings.settings().GENERAL.LIMIT_UNLIMITED_CONFIRMS;
|
||||
TaskManager.IMP = this.implementation.getTaskManager();
|
||||
|
||||
TaskManager.taskManager().async(() -> {
|
||||
|
@ -100,6 +100,9 @@ public class Config {
|
||||
}
|
||||
|
||||
public boolean load(File file) {
|
||||
if (!file.exists()) {
|
||||
return false;
|
||||
}
|
||||
existingMigrateNodes = new ArrayList<>();
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
|
||||
for (String key : yml.getKeys(true)) {
|
||||
|
@ -791,6 +791,11 @@ public class Settings extends Config {
|
||||
})
|
||||
public boolean UNSTUCK_ON_GENERATE = true;
|
||||
|
||||
@Comment({
|
||||
"If unlimited limits should still require /confirm on large. Defaults to limits.default.confirm-large otherwise."
|
||||
})
|
||||
public boolean LIMIT_UNLIMITED_CONFIRMS = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
LOGGER.error("Could not read {}\n" + "Renamed to {}", file, dest.getAbsolutePath(), ex);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,22 +21,17 @@ import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TransformFactory extends AbstractFactory<ResettableExtent> {
|
||||
|
||||
private final RichTransformParser richTransformParser;
|
||||
|
||||
/**
|
||||
* Create a new factory.
|
||||
*
|
||||
* @param worldEdit the WorldEdit instance
|
||||
*/
|
||||
public TransformFactory(WorldEdit worldEdit) {
|
||||
super(worldEdit, new NullTransformParser(worldEdit));
|
||||
|
||||
richTransformParser = new RichTransformParser(worldEdit);
|
||||
super(worldEdit, new NullTransformParser(worldEdit), new RichTransformParser(worldEdit));
|
||||
|
||||
// split and parse each sub-transform
|
||||
register(new RandomTransformParser(worldEdit));
|
||||
@ -51,68 +46,7 @@ public class TransformFactory extends AbstractFactory<ResettableExtent> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResettableExtent parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
List<ResettableExtent> transforms = new ArrayList<>();
|
||||
|
||||
for (String component : input.split(" ")) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ResettableExtent match = richTransformParser.parseFromInput(component, context);
|
||||
if (match != null) {
|
||||
transforms.add(match);
|
||||
continue;
|
||||
}
|
||||
parseFromParsers(context, transforms, component);
|
||||
}
|
||||
|
||||
return getResettableExtent(input, transforms);
|
||||
}
|
||||
|
||||
private void parseFromParsers(
|
||||
final ParserContext context,
|
||||
final List<ResettableExtent> transforms,
|
||||
final String component
|
||||
) {
|
||||
ResettableExtent match = null;
|
||||
for (InputParser<ResettableExtent> parser : getParsers()) {
|
||||
match = parser.parseFromInput(component, context);
|
||||
|
||||
if (match != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match == null) {
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(component)));
|
||||
}
|
||||
transforms.add(match);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a transform without considering parsing through the {@link RichTransformParser}, therefore not accepting
|
||||
* "richer" parsing where & and , are used. Exists to prevent stack overflows.
|
||||
*
|
||||
* @param input input string
|
||||
* @param context input context
|
||||
* @return parsed result
|
||||
* @throws InputParseException if no result found
|
||||
*/
|
||||
public ResettableExtent parseWithoutRich(String input, ParserContext context) throws InputParseException {
|
||||
List<ResettableExtent> transforms = new ArrayList<>();
|
||||
|
||||
for (String component : input.split(" ")) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
parseFromParsers(context, transforms, component);
|
||||
}
|
||||
|
||||
return getResettableExtent(input, transforms);
|
||||
}
|
||||
|
||||
private ResettableExtent getResettableExtent(final String input, final List<ResettableExtent> transforms) {
|
||||
protected ResettableExtent getParsed(final String input, final List<ResettableExtent> transforms) {
|
||||
switch (transforms.size()) {
|
||||
case 0:
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
|
@ -37,14 +37,14 @@ public abstract class FaweParser<T> extends InputParser<T> implements AliasedPar
|
||||
for (int i = 0; i < toParse.length(); i++) {
|
||||
char c = toParse.charAt(i);
|
||||
switch (c) {
|
||||
case ',', '&' -> {
|
||||
case ',', '&', ' ' -> {
|
||||
if (expression) {
|
||||
continue;
|
||||
}
|
||||
String result = toParse.substring(last, i);
|
||||
if (!result.isEmpty()) {
|
||||
inputs.add(result);
|
||||
and.add(c == '&');
|
||||
and.add(c == '&' || c == ' ');
|
||||
} else {
|
||||
throw new InputParseException(Caption.of("fawe.error.parse.invalid-dangling-character", c));
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.fastasyncworldedit.core.extension.factory.parser.common;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
|
||||
import com.fastasyncworldedit.core.limit.FaweLimit;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class HotbarParser<T> extends SimpleInputParser<T> {
|
||||
|
||||
private final List<String> aliases = ImmutableList.of("#hotbar");
|
||||
|
||||
protected HotbarParser(final WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMatchedAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
protected List<BlockType> getBlockTypes(ParserContext context) {
|
||||
Player player = context.requirePlayer();
|
||||
BlockBag bag = player.getInventoryBlockBag();
|
||||
if (!(bag instanceof final SlottableBlockBag slottable)) {
|
||||
// Matches DefaultBlockParser
|
||||
throw new InputParseException(Caption.of("fawe.error.unsupported"));
|
||||
}
|
||||
List<BlockType> types = new ArrayList<>();
|
||||
FaweLimit limit = player.getLimit();
|
||||
boolean anyBlock = player.hasPermission("worldedit.anyblock");
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
BaseItem item = slottable.getItem(slot);
|
||||
if (item != null && item.getType().hasBlockType()) {
|
||||
BlockType type = item.getType().getBlockType();
|
||||
if (!anyBlock && worldEdit.getConfiguration().disallowedBlocks.contains(type.id().toLowerCase(Locale.ROOT))) {
|
||||
throw new DisallowedUsageException(Caption.of(
|
||||
"worldedit.error.disallowed-block",
|
||||
TextComponent.of(type.getId())
|
||||
));
|
||||
}
|
||||
if (!limit.isUnlimited()) {
|
||||
if (limit.DISALLOWED_BLOCKS.contains(type.id().toLowerCase(Locale.ROOT))) {
|
||||
throw new DisallowedUsageException(Caption.of(
|
||||
"fawe.error.limit.disallowed-block",
|
||||
TextComponent.of(type.getId())
|
||||
));
|
||||
}
|
||||
}
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
if (types.isEmpty()) {
|
||||
throw new InputParseException(Caption.of("fawe.error.no-valid-on-hotbar"));
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.fastasyncworldedit.core.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.common.HotbarParser;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
||||
public class HotbarMaskParser extends HotbarParser<Mask> {
|
||||
|
||||
public HotbarMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return new BlockTypeMask(context.getExtent(), getBlockTypes(context));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.fastasyncworldedit.core.extension.factory.parser.pattern;
|
||||
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.common.HotbarParser;
|
||||
import com.fastasyncworldedit.core.math.random.TrueRandom;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
public class HotbarPatternParser extends HotbarParser<Pattern> {
|
||||
|
||||
public HotbarPatternParser(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern parseFromSimpleInput(String input, ParserContext context) {
|
||||
RandomPattern random = new RandomPattern(new TrueRandom());
|
||||
for (BlockType type : getBlockTypes(context)) {
|
||||
random.add(type, 1);
|
||||
}
|
||||
return random;
|
||||
}
|
||||
|
||||
}
|
@ -101,7 +101,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
|
||||
@SuppressWarnings("unchecked")
|
||||
private <B extends BlockStateHolder<B>> B checkBlock(B block) {
|
||||
if (blockedBlocks != null) {
|
||||
if (blockedBlocks.contains(block.getBlockType().getId())) {
|
||||
if (blockedBlocks.contains(block.getBlockType().id())) {
|
||||
return (B) (block instanceof BlockState ? RESERVED : RESERVED.toBaseBlock()); // set to reserved/empty
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
|
||||
}
|
||||
BlockState state = BlockTypesCache.states[block];
|
||||
if (blockedBlocks != null) {
|
||||
if (blockedBlocks.contains(state.getBlockType().getId())) {
|
||||
if (blockedBlocks.contains(state.getBlockType().id())) {
|
||||
blocks[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
continue;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(position);
|
||||
if (!oldBiome.getId().equals(newBiome.getId())) {
|
||||
if (!oldBiome.id().equals(newBiome.id())) {
|
||||
this.changeSet.addBiomeChange(position.x(), position.y(), position.z(), oldBiome, newBiome);
|
||||
return getExtent().setBiome(position, newBiome);
|
||||
} else {
|
||||
@ -121,7 +121,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z));
|
||||
if (!oldBiome.getId().equals(newBiome.getId())) {
|
||||
if (!oldBiome.id().equals(newBiome.id())) {
|
||||
this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome);
|
||||
return getExtent().setBiome(x, y, z, newBiome);
|
||||
} else {
|
||||
|
@ -237,7 +237,7 @@ public class FastSchematicWriter implements ClipboardWriter {
|
||||
if (!brokenEntities) {
|
||||
loc = loc.setPosition(loc.add(min.toVector3()));
|
||||
}
|
||||
values.put("Id", new StringTag(state.getType().getId()));
|
||||
values.put("Id", new StringTag(state.getType().id()));
|
||||
values.put("Pos", writeVector(loc));
|
||||
values.put("Rotation", writeRotation(entity.getLocation()));
|
||||
|
||||
@ -297,7 +297,7 @@ public class FastSchematicWriter implements ClipboardWriter {
|
||||
for (int i = 0; i < paletteList.size(); i++) {
|
||||
int ordinal = paletteList.get(i);
|
||||
BiomeType state = BiomeTypes.get(ordinal);
|
||||
out12.writeNamedTag(state.getId(), i);
|
||||
out12.writeNamedTag(state.id(), i);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -19,7 +19,6 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
@ -174,27 +173,23 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
||||
ArrayList<HashMap<String, Object>> palette = new ArrayList<>();
|
||||
for (BlockVector3 point : region) {
|
||||
BlockState block = clipboard.getBlock(point);
|
||||
int combined = block.getInternalId();
|
||||
char ordinal = block.getOrdinalChar();
|
||||
BlockType type = block.getBlockType();
|
||||
|
||||
if (type == BlockTypes.STRUCTURE_VOID || indexes.containsKey(combined)) {
|
||||
if (type == BlockTypes.STRUCTURE_VOID || indexes.containsKey(ordinal)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
indexes.put(combined, (Integer) palette.size());
|
||||
indexes.put(ordinal, palette.size());
|
||||
HashMap<String, Object> paletteEntry = new HashMap<>();
|
||||
paletteEntry.put("Name", type.getId());
|
||||
paletteEntry.put("Name", type.id());
|
||||
if (block.getInternalId() != type.getInternalId()) {
|
||||
Map<String, Object> properties = null;
|
||||
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
|
||||
int propIndex = property.getIndex(block.getInternalId());
|
||||
if (propIndex != 0) {
|
||||
if (properties == null) {
|
||||
properties = new HashMap<>();
|
||||
}
|
||||
Object value = property.getValues().get(propIndex);
|
||||
properties.put(property.getName(), value.toString());
|
||||
for (Map.Entry<Property<?>, Object> entry : block.getStates().entrySet()) {
|
||||
if (properties == null) {
|
||||
properties = new HashMap<>();
|
||||
}
|
||||
properties.put(entry.getKey().getName(), entry.getValue().toString());
|
||||
}
|
||||
if (properties != null) {
|
||||
paletteEntry.put("Properties", properties);
|
||||
@ -211,16 +206,23 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
||||
for (BlockVector3 point : region) {
|
||||
BaseBlock block = clipboard.getFullBlock(point);
|
||||
if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) {
|
||||
int combined = block.getInternalId();
|
||||
int index = indexes.get(combined);
|
||||
List<Integer> pos = Arrays.asList(point.x() - min.x(),
|
||||
point.y() - min.y(), point.z() - min.z()
|
||||
char ordinal = block.getOrdinalChar();
|
||||
int index = indexes.get(ordinal);
|
||||
List<Integer> pos = Arrays.asList(
|
||||
point.x() - min.x(),
|
||||
point.y() - min.y(),
|
||||
point.z() - min.z()
|
||||
);
|
||||
if (!block.hasNbtData()) {
|
||||
blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos));
|
||||
} else {
|
||||
Map<String, Tag> tag = new HashMap<>(block.getNbtData().getValue());
|
||||
tag.remove("x");
|
||||
tag.remove("y");
|
||||
tag.remove("z");
|
||||
CompoundTag cTag = new CompoundTag(tag);
|
||||
blocks.add(
|
||||
FaweCache.INSTANCE.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
|
||||
FaweCache.INSTANCE.asMap("state", index, "pos", pos, "nbt", cTag));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,16 +233,24 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
||||
ArrayList<Map<String, Object>> entities = new ArrayList<>();
|
||||
for (Entity entity : clipboard.getEntities()) {
|
||||
Location loc = entity.getLocation();
|
||||
List<Double> pos = Arrays.asList(loc.x(), loc.y(), loc.z());
|
||||
List<Integer> blockPos = Arrays.asList(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
List<Double> pos = Arrays.asList(
|
||||
loc.x() - min.x(),
|
||||
loc.y() - min.y(),
|
||||
loc.z() - min.z()
|
||||
);
|
||||
List<Integer> blockPos = Arrays.asList(
|
||||
loc.getBlockX() - min.x(),
|
||||
loc.getBlockY() - min.y(),
|
||||
loc.getBlockZ() - min.z()
|
||||
);
|
||||
BaseEntity state = entity.getState();
|
||||
if (state != null) {
|
||||
CompoundTag nbt = state.getNbtData();
|
||||
Map<String, Tag> nbtMap = nbt.getValue();
|
||||
Map<String, Tag> nbtMap = new HashMap<>(nbt.getValue());
|
||||
// Replace rotation data
|
||||
nbtMap.put("Rotation", writeRotation(entity.getLocation()));
|
||||
nbtMap.put("id", new StringTag(state.getType().getId()));
|
||||
Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt);
|
||||
nbtMap.put("id", new StringTag(state.getType().id()));
|
||||
Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", new CompoundTag(nbtMap));
|
||||
entities.add(entityMap);
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
int lightLevel = iChunk.getEmittedLight(node.x() & 15, node.y(), node.z() & 15);
|
||||
BlockState state = this.queue.getBlock(node.x(), node.y(), node.z());
|
||||
String id = state.getBlockType().getId().toLowerCase(Locale.ROOT);
|
||||
String id = state.getBlockType().id().toLowerCase(Locale.ROOT);
|
||||
if (lightLevel <= 1) {
|
||||
continue;
|
||||
}
|
||||
@ -396,7 +396,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
break east;
|
||||
}
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
this.computeSpreadBlockLight(x + 1, y, z, currentLight, queue, visited);
|
||||
break east;
|
||||
}
|
||||
@ -449,7 +449,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
break west;
|
||||
}
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
this.computeSpreadBlockLight(x - 1, y, z, currentLight, queue, visited);
|
||||
break west;
|
||||
}
|
||||
@ -502,7 +502,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
break south;
|
||||
}
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
this.computeSpreadBlockLight(x, y, z + 1, currentLight, queue, visited);
|
||||
break south;
|
||||
}
|
||||
@ -555,7 +555,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
break north;
|
||||
}
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
this.computeSpreadBlockLight(x, y, z - 1, currentLight, queue, visited);
|
||||
break north;
|
||||
}
|
||||
@ -707,7 +707,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairNorth(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -725,7 +725,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairSouth(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -743,7 +743,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairEast(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -761,7 +761,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairWest(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -787,11 +787,11 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean isStairOrTrueTop(BlockState state, boolean top) {
|
||||
return !state.getBlockType().getId().contains("stair") || state.getState(stairHalf).equals("top") == top;
|
||||
return !state.getBlockType().id().contains("stair") || state.getState(stairHalf).equals("top") == top;
|
||||
}
|
||||
|
||||
private boolean isSlabOrTrueValue(BlockState state, String value) {
|
||||
return !state.getBlockType().getId().contains("slab") || state.getState(slabHalf).equals(value);
|
||||
return !state.getBlockType().id().contains("slab") || state.getState(slabHalf).equals(value);
|
||||
}
|
||||
|
||||
private void computeRemoveBlockLight(
|
||||
|
@ -236,7 +236,7 @@ public class CavesGen extends GenBase {
|
||||
BlockState material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
||||
BlockState materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
|
||||
BlockType blockType = material.getBlockType();
|
||||
switch (blockType.getId()) {
|
||||
switch (blockType.id()) {
|
||||
case "minecraft:mycelium", "minecraft:grass_block" -> grassFound = true;
|
||||
}
|
||||
if (this.isSuitableBlock(material, materialAbove)) {
|
||||
@ -277,7 +277,7 @@ public class CavesGen extends GenBase {
|
||||
}
|
||||
|
||||
protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) {
|
||||
return switch (material.getBlockType().getId()) {
|
||||
return switch (material.getBlockType().id()) {
|
||||
case "minecraft:air", "minecraft:cave_air", "minecraft:void_air", "minecraft:water", "minecraft:lava", "minecraft:bedrock" -> false;
|
||||
default -> true;
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
||||
List<BlockState> all = type.getAllStates();
|
||||
hasAll = all.stream().map(this::test).reduce(true, (a, b) -> a && b);
|
||||
if (hasAll) {
|
||||
strings.add(type.getId());
|
||||
strings.add(type.id());
|
||||
} else {
|
||||
for (BlockState state : all) {
|
||||
if (test(state)) {
|
||||
|
@ -183,7 +183,7 @@ public class BlockMaskBuilder {
|
||||
builders = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("(minecraft:)?" + regex);
|
||||
for (BlockType type : BlockTypesCache.values) {
|
||||
if (pattern.matcher(type.getId()).find()) {
|
||||
if (pattern.matcher(type.id()).find()) {
|
||||
blockTypeList.add(type);
|
||||
builders.add(new FuzzyStateAllowingBuilder(type));
|
||||
add(type);
|
||||
@ -284,7 +284,7 @@ public class BlockMaskBuilder {
|
||||
} else {
|
||||
boolean success = false;
|
||||
for (BlockType myType : BlockTypesCache.values) {
|
||||
if (myType.getId().matches("(minecraft:)?" + input)) {
|
||||
if (myType.id().matches("(minecraft:)?" + input)) {
|
||||
add(myType);
|
||||
success = true;
|
||||
}
|
||||
@ -571,7 +571,7 @@ public class BlockMaskBuilder {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Property %s cannot be applied to block type %s",
|
||||
property.getName(),
|
||||
type.getId()
|
||||
type.id()
|
||||
));
|
||||
}
|
||||
masked.computeIfAbsent(property, k -> new ArrayList<>()).add(index);
|
||||
|
@ -79,7 +79,7 @@ public class TypeSwapPattern extends AbstractExtentPattern {
|
||||
}
|
||||
|
||||
private BlockState getNewBlock(BlockState existing) {
|
||||
String oldId = existing.getBlockType().getId();
|
||||
String oldId = existing.getBlockType().id();
|
||||
String newId = oldId;
|
||||
if (inputPattern != null) {
|
||||
newId = inputPattern.matcher(oldId).replaceAll(outputString);
|
||||
|
@ -297,7 +297,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
public void add(BlockChange change) {
|
||||
try {
|
||||
BlockVector3 loc = change.getPosition();
|
||||
BaseBlock from = change.getPrevious();
|
||||
BaseBlock from = change.previous();
|
||||
BaseBlock to = change.getCurrent();
|
||||
add(loc, from, to);
|
||||
} catch (Exception e) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.fastasyncworldedit.core.limit;
|
||||
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@ -121,7 +122,8 @@ public class FaweLimit {
|
||||
MAX.SCHEM_FILE_SIZE_LIMIT = Integer.MAX_VALUE;
|
||||
MAX.MAX_EXPRESSION_MS = 50;
|
||||
MAX.FAST_PLACEMENT = true;
|
||||
MAX.CONFIRM_LARGE = true;
|
||||
MAX.CONFIRM_LARGE =
|
||||
Settings.settings().LIMITS.get("default").CONFIRM_LARGE || Settings.settings().GENERAL.LIMIT_UNLIMITED_CONFIRMS;
|
||||
MAX.RESTRICT_HISTORY_TO_REGIONS = false;
|
||||
MAX.STRIP_NBT = Collections.emptySet();
|
||||
MAX.UNIVERSAL_DISALLOWED_BLOCKS = false;
|
||||
|
@ -130,7 +130,7 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
* A filter block is used to iterate over blocks / positions. Essentially combines BlockVector3,
|
||||
* Extent and BlockState functions in a way that avoids lookups.
|
||||
*/
|
||||
ChunkFilterBlock initFilterBlock();
|
||||
ChunkFilterBlock createFilterBlock();
|
||||
|
||||
/**
|
||||
* Returns the number of chunks in this queue.
|
||||
@ -144,7 +144,14 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
default ChunkFilterBlock apply(ChunkFilterBlock block, Filter filter, Region region, int chunkX, int chunkZ, boolean full) {
|
||||
default ChunkFilterBlock apply(
|
||||
@Nullable ChunkFilterBlock block,
|
||||
Filter filter,
|
||||
Region region,
|
||||
int chunkX,
|
||||
int chunkZ,
|
||||
boolean full
|
||||
) {
|
||||
if (!filter.appliesChunk(chunkX, chunkZ)) {
|
||||
return block;
|
||||
}
|
||||
@ -154,8 +161,9 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
if (newChunk != null) {
|
||||
chunk = newChunk;
|
||||
if (block == null) {
|
||||
block = this.initFilterBlock();
|
||||
block = this.createFilterBlock();
|
||||
}
|
||||
block.initChunk(chunkX, chunkZ);
|
||||
chunk.filterBlocks(filter, block, region, full);
|
||||
}
|
||||
this.submit(chunk);
|
||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
@ -145,9 +146,10 @@ public class ParallelQueueExtent extends PassthroughExtent {
|
||||
final int size = Math.min(chunks.size(), Settings.settings().QUEUE.PARALLEL_THREADS);
|
||||
if (size <= 1) {
|
||||
// if PQE is ever used with PARALLEL_THREADS = 1, or only one chunk is edited, just run sequentially
|
||||
ChunkFilterBlock block = null;
|
||||
while (chunksIter.hasNext()) {
|
||||
BlockVector2 pos = chunksIter.next();
|
||||
getExtent().apply(null, filter, region, pos.x(), pos.z(), full);
|
||||
block = getExtent().apply(block, filter, region, pos.x(), pos.z(), full);
|
||||
}
|
||||
getExtent().flush();
|
||||
filter.finish();
|
||||
@ -155,6 +157,7 @@ public class ParallelQueueExtent extends PassthroughExtent {
|
||||
final ForkJoinTask[] tasks = IntStream.range(0, size).mapToObj(i -> handler.submit(() -> {
|
||||
try {
|
||||
final Filter newFilter = filter.fork();
|
||||
final Region newRegion = region.clone();
|
||||
// Create a chunk that we will reuse/reset for each operation
|
||||
final SingleThreadQueueExtent queue = (SingleThreadQueueExtent) getNewQueue();
|
||||
synchronized (queue) {
|
||||
@ -172,7 +175,7 @@ public class ParallelQueueExtent extends PassthroughExtent {
|
||||
chunkX = pos.x();
|
||||
chunkZ = pos.z();
|
||||
}
|
||||
block = queue.apply(block, newFilter, region, chunkX, chunkZ, full);
|
||||
block = queue.apply(block, newFilter, newRegion, chunkX, chunkZ, full);
|
||||
}
|
||||
queue.flush();
|
||||
filter.finish();
|
||||
|
@ -495,7 +495,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkFilterBlock initFilterBlock() {
|
||||
public ChunkFilterBlock createFilterBlock() {
|
||||
return new CharFilterBlock(this);
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,23 @@ public abstract class CharBlocks implements IBlocks {
|
||||
protected static final Section FULL = new Section() {
|
||||
@Override
|
||||
public char[] get(CharBlocks blocks, int layer) {
|
||||
return blocks.blocks[layer];
|
||||
char[] arr = blocks.blocks[layer];
|
||||
if (arr == null) {
|
||||
// Chunk probably trimmed mid-operations, but do nothing about it to avoid other issues
|
||||
return EMPTY.get(blocks, layer, false);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
// Ignore aggressive switch here.
|
||||
@Override
|
||||
public char[] get(CharBlocks blocks, int layer, boolean aggressive) {
|
||||
return blocks.blocks[layer];
|
||||
char[] arr = blocks.blocks[layer];
|
||||
if (arr == null) {
|
||||
// Chunk probably trimmed mid-operations, but do nothing about it to avoid other issues
|
||||
return EMPTY.get(blocks, layer, false);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public class PolyhedralRegion extends AbstractRegion {
|
||||
public PolyhedralRegion(PolyhedralRegion region) {
|
||||
this(region.world);
|
||||
vertices.addAll(region.vertices);
|
||||
triangles.addAll(region.triangles);
|
||||
region.triangles.forEach(triangle -> triangles.add(triangle.clone()));
|
||||
vertexBacklog.addAll(region.vertexBacklog);
|
||||
|
||||
minimumPoint = region.minimumPoint;
|
||||
|
@ -7,10 +7,14 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.polyhedron.Edge;
|
||||
|
||||
public class Triangle {
|
||||
public class Triangle implements Cloneable {
|
||||
|
||||
public static double RADIUS = 0.5;
|
||||
|
||||
private final BlockVector3 pos1;
|
||||
private final BlockVector3 pos2;
|
||||
private final BlockVector3 pos3;
|
||||
|
||||
private final double[][] verts = new double[3][3];
|
||||
private final double[] center = new double[3];
|
||||
private final double[] radius = new double[3];
|
||||
@ -28,6 +32,9 @@ public class Triangle {
|
||||
private final double b;
|
||||
|
||||
public Triangle(BlockVector3 pos1, BlockVector3 pos2, BlockVector3 pos3) {
|
||||
this.pos1 = pos1;
|
||||
this.pos2 = pos2;
|
||||
this.pos3 = pos3;
|
||||
verts[0] = new double[]{pos1.x(), pos1.y(), pos1.z()};
|
||||
verts[1] = new double[]{pos2.x(), pos2.y(), pos2.z()};
|
||||
verts[2] = new double[]{pos3.x(), pos3.y(), pos3.z()};
|
||||
@ -290,4 +297,9 @@ public class Triangle {
|
||||
return dot(normal, vmax) >= 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Triangle clone() {
|
||||
return new Triangle(pos1, pos2, pos3);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ public class MainUtil {
|
||||
@Nonnull
|
||||
public static CompoundTag setEntityInfo(@Nonnull CompoundTag tag, @Nonnull Entity entity) {
|
||||
Map<String, Tag> map = new HashMap<>(tag.getValue());
|
||||
map.put("Id", new StringTag(entity.getState().getType().getId()));
|
||||
map.put("Id", new StringTag(entity.getState().getType().id()));
|
||||
ListTag pos = (ListTag) map.get("Pos");
|
||||
if (pos != null) {
|
||||
Location loc = entity.getLocation();
|
||||
|
@ -929,10 +929,10 @@ public class TextureUtil implements TextureHolder {
|
||||
}.getType();
|
||||
|
||||
for (BlockType blockType : BlockTypesCache.values) {
|
||||
if (!blockType.getMaterial().isFullCube() || blockType.getId().toLowerCase().contains("shulker")) {
|
||||
if (!blockType.getMaterial().isFullCube() || blockType.id().toLowerCase().contains("shulker")) {
|
||||
continue;
|
||||
}
|
||||
switch (blockType.getId().toLowerCase(Locale.ROOT)) {
|
||||
switch (blockType.id().toLowerCase(Locale.ROOT)) {
|
||||
case "slime_block":
|
||||
case "honey_block":
|
||||
case "mob_spawner":
|
||||
@ -940,7 +940,7 @@ public class TextureUtil implements TextureHolder {
|
||||
continue;
|
||||
}
|
||||
int combined = blockType.getInternalId();
|
||||
String id = blockType.getId();
|
||||
String id = blockType.id();
|
||||
String[] split = id.split(":", 2);
|
||||
String name = split.length == 1 ? id : split[1];
|
||||
String nameSpace = split.length == 1 ? "" : split[0];
|
||||
|
@ -196,7 +196,7 @@ public abstract class LocalConfiguration {
|
||||
BlockTypes.BEDROCK
|
||||
FAWE end*/
|
||||
);
|
||||
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
|
||||
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::id).toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -277,7 +277,7 @@ public abstract class LocalConfiguration {
|
||||
id = Integer.parseInt(splitter[0]);
|
||||
data = Byte.parseByte(splitter[1]);
|
||||
}
|
||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
|
||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).id();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
|
||||
|
@ -1906,7 +1906,7 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
@Deprecated
|
||||
public String getWandItem() {
|
||||
return wandItem.getType().getId();
|
||||
return wandItem.getType().id();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1917,7 +1917,7 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
@Deprecated
|
||||
public String getNavWandItem() {
|
||||
return navWandItem.getType().getId();
|
||||
return navWandItem.getType().id();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
@ -129,7 +129,7 @@ public class BaseItem implements NbtValued {
|
||||
}
|
||||
}
|
||||
|
||||
return getType().getId() + nbtString;
|
||||
return getType().id() + nbtString;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class BiomeCommands {
|
||||
PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%",
|
||||
BiomeType.REGISTRY.values().stream()
|
||||
.map(biomeType -> TextComponent.builder()
|
||||
.append(biomeType.getId())
|
||||
.append(biomeType.id())
|
||||
.append(" (")
|
||||
.append(biomeRegistry.getRichName(biomeType))
|
||||
.append(")")
|
||||
@ -166,7 +166,7 @@ public class BiomeCommands {
|
||||
|
||||
List<Component> components = biomes.stream().map(biome ->
|
||||
biomeRegistry.getRichName(biome).hoverEvent(
|
||||
HoverEvent.showText(TextComponent.of(biome.getId()))
|
||||
HoverEvent.showText(TextComponent.of(biome.id()))
|
||||
)
|
||||
).collect(Collectors.toList());
|
||||
actor.print(Caption.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));
|
||||
|
@ -349,7 +349,7 @@ public class GeneralCommands {
|
||||
if (world == null) {
|
||||
actor.print(Caption.of("worldedit.world.remove"));
|
||||
} else {
|
||||
actor.print(Caption.of("worldedit.world.set", TextComponent.of(world.getId())));
|
||||
actor.print(Caption.of("worldedit.world.set", TextComponent.of(world.id())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ public class GeneralCommands {
|
||||
if (itemsOnly && searchType.hasBlockType()) {
|
||||
continue;
|
||||
}
|
||||
final String id = searchType.getId();
|
||||
final String id = searchType.id();
|
||||
if (id.contains(idMatch)) {
|
||||
Component name = searchType.getRichName();
|
||||
results.put(id, TextComponent.builder()
|
||||
|
@ -79,8 +79,6 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
@ -841,7 +839,7 @@ public class SelectionCommands {
|
||||
toolTip = TextComponent.of(state.getAsString());
|
||||
blockName = blockName.append(TextComponent.of("*"));
|
||||
} else {
|
||||
toolTip = TextComponent.of(blockType.getId());
|
||||
toolTip = TextComponent.of(blockType.id());
|
||||
}
|
||||
blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip));
|
||||
line.append(blockName);
|
||||
|
@ -22,6 +22,8 @@ package com.sk89q.worldedit.command;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweVersion;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.limit.FaweLimit;
|
||||
import com.fastasyncworldedit.core.util.UpdateNotification;
|
||||
import com.intellectualsites.paster.IncendoPaster;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -97,6 +99,8 @@ public class WorldEditCommands {
|
||||
.getConfiguration()));
|
||||
//FAWE start
|
||||
Fawe.instance().setupConfigs();
|
||||
FaweLimit.MAX.CONFIRM_LARGE =
|
||||
Settings.settings().LIMITS.get("default").CONFIRM_LARGE || Settings.settings().GENERAL.LIMIT_UNLIMITED_CONFIRMS;
|
||||
//FAWE end
|
||||
actor.print(Caption.of("worldedit.reload.config"));
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class WorldConverter implements ArgumentConverter<World> {
|
||||
@Override
|
||||
public List<String> getSuggestions(String input, InjectedValueAccess context) {
|
||||
return getWorlds()
|
||||
.map(World::getId)
|
||||
.map(World::id)
|
||||
.filter(world -> world.startsWith(input))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@ -73,7 +73,7 @@ public class WorldConverter implements ArgumentConverter<World> {
|
||||
@Override
|
||||
public ConversionResult<World> convert(String s, InjectedValueAccess injectedValueAccess) {
|
||||
World result = getWorlds()
|
||||
.filter(world -> world.getId().equals(s))
|
||||
.filter(world -> world.id().equals(s))
|
||||
.findAny().orElse(null);
|
||||
return result == null
|
||||
? FailedConversion.from(new IllegalArgumentException(
|
||||
|
@ -66,7 +66,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
|
||||
if (!config.allowedDataCycleBlocks.isEmpty()
|
||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) {
|
||||
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().id())) {
|
||||
player.print(Caption.of("worldedit.tool.data-cycler.block-not-permitted"));
|
||||
return true;
|
||||
}
|
||||
|
@ -23,11 +23,16 @@ import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.factory.parser.DefaultBlockParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -67,4 +72,21 @@ public class BlockFactory extends AbstractFactory<BaseBlock> {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public BaseBlock parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
BaseBlock match;
|
||||
|
||||
for (InputParser<BaseBlock> parser : parsers) {
|
||||
match = parser.parseFromInput(input, context);
|
||||
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,13 @@ package com.sk89q.worldedit.extension.factory;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.extension.factory.parser.DefaultItemParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
public class ItemFactory extends AbstractFactory<BaseItem> {
|
||||
|
||||
@ -35,4 +41,21 @@ public class ItemFactory extends AbstractFactory<BaseItem> {
|
||||
super(worldEdit, new DefaultItemParser(worldEdit));
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public BaseItem parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
BaseItem match;
|
||||
|
||||
for (InputParser<BaseItem> parser : parsers) {
|
||||
match = parser.parseFromInput(input, context);
|
||||
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.fastasyncworldedit.core.extension.factory.parser.mask.AngleMaskParser
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.BesideMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.ExtremaMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.FalseMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.HotbarMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.LiquidMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.ROCAngleMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.RadiusMaskParser;
|
||||
@ -52,16 +53,13 @@ import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -74,21 +72,13 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
|
||||
//FAWE start - rich mask parsing
|
||||
private final RichMaskParser richMaskParser;
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Create a new mask registry.
|
||||
*
|
||||
* @param worldEdit the WorldEdit instance
|
||||
*/
|
||||
public MaskFactory(WorldEdit worldEdit) {
|
||||
super(worldEdit, new BlocksMaskParser(worldEdit));
|
||||
|
||||
//FAWE start - rich mask parsing
|
||||
richMaskParser = new RichMaskParser(worldEdit);
|
||||
//FAWE end
|
||||
super(worldEdit, new BlocksMaskParser(worldEdit), new RichMaskParser(worldEdit));
|
||||
|
||||
register(new ExistingMaskParser(worldEdit));
|
||||
register(new AirMaskParser(worldEdit));
|
||||
@ -110,6 +100,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
register(new BesideMaskParser(worldEdit));
|
||||
register(new ExtremaMaskParser(worldEdit));
|
||||
register(new FalseMaskParser(worldEdit));
|
||||
register(new HotbarMaskParser(worldEdit));
|
||||
register(new LiquidMaskParser(worldEdit));
|
||||
register(new RadiusMaskParser(worldEdit));
|
||||
register(new RichOffsetMaskParser(worldEdit));
|
||||
@ -123,7 +114,6 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
register(new ZAxisMaskParser(worldEdit));
|
||||
register(new SurfaceAngleMaskParser(worldEdit));
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,85 +121,24 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
final String[] split = input.split(" ");
|
||||
if (split.length > 1) {
|
||||
String prev = input.substring(0, input.lastIndexOf(" ")) + " ";
|
||||
return super.getSuggestions(split[split.length - 1], parserContext).stream().map(s -> prev + s).collect(Collectors.toList());
|
||||
return super
|
||||
.getSuggestions(split[split.length - 1], parserContext)
|
||||
.stream()
|
||||
.map(s -> prev + s)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return super.getSuggestions(input, parserContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
List<Mask> masks = new ArrayList<>();
|
||||
|
||||
for (String component : input.split(" ")) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//FAWE start - rich mask parsing
|
||||
Mask match = richMaskParser.parseFromInput(component, context);
|
||||
if (match != null) {
|
||||
masks.add(match);
|
||||
continue;
|
||||
}
|
||||
parseFromParsers(context, masks, component);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
return getMask(input, masks);
|
||||
}
|
||||
|
||||
//FAWE start - rich mask parsing
|
||||
private void parseFromParsers(
|
||||
final ParserContext context,
|
||||
final List<Mask> masks,
|
||||
final String component
|
||||
) {
|
||||
Mask match = null;
|
||||
for (InputParser<Mask> parser : getParsers()) {
|
||||
match = parser.parseFromInput(component, context);
|
||||
|
||||
if (match != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match == null) {
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(component)));
|
||||
}
|
||||
masks.add(match);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a mask without considering parsing through the {@link RichMaskParser}, therefore not accepting
|
||||
* "richer" parsing where & and , are used. Exists to prevent stack overflows.
|
||||
*
|
||||
* @param input input string
|
||||
* @param context input context
|
||||
* @return parsed result
|
||||
* @throws InputParseException if no result found
|
||||
*/
|
||||
public Mask parseWithoutRich(String input, ParserContext context) throws InputParseException {
|
||||
List<Mask> masks = new ArrayList<>();
|
||||
|
||||
for (String component : input.split(" ")) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
parseFromParsers(context, masks, component);
|
||||
}
|
||||
|
||||
return getMask(input, masks);
|
||||
}
|
||||
|
||||
private Mask getMask(final String input, final List<Mask> masks) {
|
||||
switch (masks.size()) {
|
||||
case 0:
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
case 1:
|
||||
return masks.get(0).optimize();
|
||||
default:
|
||||
return new MaskIntersection(masks).optimize();
|
||||
}
|
||||
@Override
|
||||
protected Mask getParsed(final String input, final List<Mask> masks) {
|
||||
return switch (masks.size()) {
|
||||
case 0 -> throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
case 1 -> masks.get(0).optimize();
|
||||
default -> new MaskIntersection(masks).optimize();
|
||||
};
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
|
@ -30,6 +30,7 @@ import com.fastasyncworldedit.core.extension.factory.parser.pattern.DarkenPatter
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.DesaturatePatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExistingPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExpressionPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.HotbarPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.LightenPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear2DPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear3DPatternParser;
|
||||
@ -42,8 +43,6 @@ import com.fastasyncworldedit.core.extension.factory.parser.pattern.OffsetPatter
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.PerlinPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RandomFullClipboardPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RandomOffsetPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.TypeSwapPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RelativePatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RichPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RidgedMultiFractalPatternParser;
|
||||
@ -51,24 +50,22 @@ import com.fastasyncworldedit.core.extension.factory.parser.pattern.SaturatePatt
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.SimplexPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.SolidRandomOffsetPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.SurfaceRandomOffsetPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.TypeSwapPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.VoronoiPatternParser;
|
||||
import com.fastasyncworldedit.core.math.random.TrueRandom;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.SingleBlockPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.TypeOrStateApplyingPatternParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -80,20 +77,14 @@ import java.util.List;
|
||||
*/
|
||||
public final class PatternFactory extends AbstractFactory<Pattern> {
|
||||
|
||||
//FAWE start - rich pattern parsing
|
||||
private final RichPatternParser richPatternParser;
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit the WorldEdit instance
|
||||
*/
|
||||
public PatternFactory(WorldEdit worldEdit) {
|
||||
super(worldEdit, new SingleBlockPatternParser(worldEdit));
|
||||
|
||||
//FAWE start - rich pattern parsing
|
||||
richPatternParser = new RichPatternParser(worldEdit);
|
||||
super(worldEdit, new SingleBlockPatternParser(worldEdit), new RichPatternParser(worldEdit));
|
||||
//FAWE end
|
||||
|
||||
// split and parse each sub-pattern
|
||||
@ -116,6 +107,7 @@ public final class PatternFactory extends AbstractFactory<Pattern> {
|
||||
register(new DesaturatePatternParser(worldEdit));
|
||||
register(new ExistingPatternParser(worldEdit));
|
||||
register(new ExpressionPatternParser(worldEdit));
|
||||
register(new HotbarPatternParser(worldEdit));
|
||||
register(new LightenPatternParser(worldEdit));
|
||||
register(new Linear2DPatternParser(worldEdit));
|
||||
register(new Linear3DPatternParser(worldEdit));
|
||||
@ -136,75 +128,10 @@ public final class PatternFactory extends AbstractFactory<Pattern> {
|
||||
register(new SurfaceRandomOffsetPatternParser(worldEdit));
|
||||
register(new TypeSwapPatternParser(worldEdit));
|
||||
register(new VoronoiPatternParser(worldEdit));
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
List<Pattern> patterns = new ArrayList<>();
|
||||
|
||||
for (String component : input.split(" ")) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//FAWE start - rich pattern parsing
|
||||
Pattern match = richPatternParser.parseFromInput(component, context);
|
||||
if (match != null) {
|
||||
patterns.add(match);
|
||||
continue;
|
||||
}
|
||||
parseFromParsers(context, patterns, component);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
return getPattern(input, patterns);
|
||||
}
|
||||
|
||||
//FAWE start - rich pattern parsing
|
||||
private void parseFromParsers(
|
||||
final ParserContext context,
|
||||
final List<Pattern> patterns,
|
||||
final String component
|
||||
) {
|
||||
Pattern match = null;
|
||||
for (InputParser<Pattern> parser : getParsers()) {
|
||||
match = parser.parseFromInput(component, context);
|
||||
|
||||
if (match != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match == null) {
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(component)));
|
||||
}
|
||||
patterns.add(match);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a pattern without considering parsing through the {@link RichPatternParser}, therefore not accepting
|
||||
* "richer" parsing where & and , are used. Exists to prevent stack overflows.
|
||||
*
|
||||
* @param input input string
|
||||
* @param context input context
|
||||
* @return parsed result
|
||||
* @throws InputParseException if no result found
|
||||
*/
|
||||
public Pattern parseWithoutRich(String input, ParserContext context) throws InputParseException {
|
||||
List<Pattern> patterns = new ArrayList<>();
|
||||
|
||||
for (String component : input.split(" ")) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
parseFromParsers(context, patterns, component);
|
||||
}
|
||||
|
||||
return getPattern(input, patterns);
|
||||
}
|
||||
|
||||
private Pattern getPattern(final String input, final List<Pattern> patterns) {
|
||||
protected Pattern getParsed(final String input, final List<Pattern> patterns) {
|
||||
switch (patterns.size()) {
|
||||
case 0:
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
|
@ -135,42 +135,42 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
private String woolMapper(String string) {
|
||||
switch (string.toLowerCase(Locale.ROOT)) {
|
||||
case "white":
|
||||
return BlockTypes.WHITE_WOOL.getId();
|
||||
return BlockTypes.WHITE_WOOL.id();
|
||||
case "black":
|
||||
return BlockTypes.BLACK_WOOL.getId();
|
||||
return BlockTypes.BLACK_WOOL.id();
|
||||
case "blue":
|
||||
return BlockTypes.BLUE_WOOL.getId();
|
||||
return BlockTypes.BLUE_WOOL.id();
|
||||
case "brown":
|
||||
return BlockTypes.BROWN_WOOL.getId();
|
||||
return BlockTypes.BROWN_WOOL.id();
|
||||
case "cyan":
|
||||
return BlockTypes.CYAN_WOOL.getId();
|
||||
return BlockTypes.CYAN_WOOL.id();
|
||||
case "gray":
|
||||
case "grey":
|
||||
return BlockTypes.GRAY_WOOL.getId();
|
||||
return BlockTypes.GRAY_WOOL.id();
|
||||
case "green":
|
||||
return BlockTypes.GREEN_WOOL.getId();
|
||||
return BlockTypes.GREEN_WOOL.id();
|
||||
case "light_blue":
|
||||
case "lightblue":
|
||||
return BlockTypes.LIGHT_BLUE_WOOL.getId();
|
||||
return BlockTypes.LIGHT_BLUE_WOOL.id();
|
||||
case "light_gray":
|
||||
case "light_grey":
|
||||
case "lightgray":
|
||||
case "lightgrey":
|
||||
return BlockTypes.LIGHT_GRAY_WOOL.getId();
|
||||
return BlockTypes.LIGHT_GRAY_WOOL.id();
|
||||
case "lime":
|
||||
return BlockTypes.LIME_WOOL.getId();
|
||||
return BlockTypes.LIME_WOOL.id();
|
||||
case "magenta":
|
||||
return BlockTypes.MAGENTA_WOOL.getId();
|
||||
return BlockTypes.MAGENTA_WOOL.id();
|
||||
case "orange":
|
||||
return BlockTypes.ORANGE_WOOL.getId();
|
||||
return BlockTypes.ORANGE_WOOL.id();
|
||||
case "pink":
|
||||
return BlockTypes.PINK_WOOL.getId();
|
||||
return BlockTypes.PINK_WOOL.id();
|
||||
case "purple":
|
||||
return BlockTypes.PURPLE_WOOL.getId();
|
||||
return BlockTypes.PURPLE_WOOL.id();
|
||||
case "yellow":
|
||||
return BlockTypes.YELLOW_WOOL.getId();
|
||||
return BlockTypes.YELLOW_WOOL.id();
|
||||
case "red":
|
||||
return BlockTypes.RED_WOOL.getId();
|
||||
return BlockTypes.RED_WOOL.id();
|
||||
default:
|
||||
return string;
|
||||
}
|
||||
@ -194,7 +194,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
if (input.indexOf('[') == -1 && input.indexOf(']') == -1) {
|
||||
continue;
|
||||
}
|
||||
if (!type.getId().equalsIgnoreCase(input.substring(0, input.indexOf('[')))) {
|
||||
if (!type.id().equalsIgnoreCase(input.substring(0, input.indexOf('[')))) {
|
||||
continue;
|
||||
}
|
||||
String[] properties = input.substring(input.indexOf('[') + 1, input.indexOf(']')).split(",");
|
||||
@ -249,10 +249,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
throw new NoMatchException(Caption.of(
|
||||
"worldedit.error.parser.unknown-property",
|
||||
TextComponent.of(parts[0]),
|
||||
TextComponent.of(type.getId())
|
||||
TextComponent.of(type.id())
|
||||
));
|
||||
} else {
|
||||
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.getId());
|
||||
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.id());
|
||||
}
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
@ -516,20 +516,20 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
//FAWE start - per-limit disallowed blocks
|
||||
if (actor != null) {
|
||||
if (!actor.hasPermission("worldedit.anyblock")
|
||||
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
|
||||
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.id().toLowerCase(Locale.ROOT))) {
|
||||
throw new DisallowedUsageException(Caption.of(
|
||||
"worldedit.error.disallowed-block",
|
||||
TextComponent.of(blockType.getId())
|
||||
TextComponent.of(blockType.id())
|
||||
));
|
||||
}
|
||||
FaweLimit limit = actor.getLimit();
|
||||
if (!limit.isUnlimited()) {
|
||||
// No need to account for blocked states/properties as it will simply return false in the equality check
|
||||
// during contains.
|
||||
if (limit.DISALLOWED_BLOCKS.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
|
||||
if (limit.DISALLOWED_BLOCKS.contains(blockType.id().toLowerCase(Locale.ROOT))) {
|
||||
throw new DisallowedUsageException(Caption.of(
|
||||
"fawe.error.limit.disallowed-block",
|
||||
TextComponent.of(blockType.getId())
|
||||
TextComponent.of(blockType.id())
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -559,14 +559,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
if (ent == null) {
|
||||
throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
|
||||
}
|
||||
mobName = ent.getId();
|
||||
mobName = ent.id();
|
||||
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
||||
throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
|
||||
}
|
||||
return validate(context, new MobSpawnerBlock(state, mobName));
|
||||
} else {
|
||||
//noinspection ConstantConditions
|
||||
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId()));
|
||||
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.id()));
|
||||
}
|
||||
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
||||
// allow setting type/player/rotation
|
||||
|
@ -71,7 +71,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> implements
|
||||
|
||||
Set<BlockType> blocks = category.getAll();
|
||||
if (blocks.isEmpty()) {
|
||||
throw new InputParseException(Caption.of("worldedit.error.empty-tag", TextComponent.of(category.getId())));
|
||||
throw new InputParseException(Caption.of("worldedit.error.empty-tag", TextComponent.of(category.id())));
|
||||
}
|
||||
|
||||
if (anyState) {
|
||||
|
@ -23,6 +23,7 @@ import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.factory.MaskFactory;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
@ -217,6 +218,20 @@ public class ParserContext {
|
||||
return actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Player} set on this context.
|
||||
*
|
||||
* @return a player
|
||||
* @throws InputParseException thrown if no {@link Actor} is set
|
||||
*/
|
||||
public Player requirePlayer() throws InputParseException {
|
||||
Actor actor = getActor();
|
||||
if (!(actor instanceof Player player)) {
|
||||
throw new InputParseException(Caption.of("worldedit.error.missing-player"));
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether there should be restrictions (as a result of
|
||||
* limits or permissions) considered when parsing the input.
|
||||
|
@ -236,7 +236,7 @@ public interface Platform extends Keyed {
|
||||
*/
|
||||
@NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {})
|
||||
@Override
|
||||
default String getId() {
|
||||
default String id() {
|
||||
return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_");
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,8 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
@Override
|
||||
public IChunkSet processSet(final IChunk chunk, final IChunkGet get, final IChunkSet set) {
|
||||
final ChunkFilterBlock filter = getOrCreateFilterBlock.apply(Thread.currentThread().getId());
|
||||
return filter.filter(chunk, get, set, MaskingExtent.this);
|
||||
filter.initChunk(chunk.getX(), chunk.getZ());
|
||||
return filter.filter(chunk, get, set, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -423,7 +423,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
|
||||
if (pasteEntities) {
|
||||
for (Entity entity : this.getEntities()) {
|
||||
// skip players on pasting schematic
|
||||
if (entity.getState() != null && entity.getState().getType().getId()
|
||||
if (entity.getState() != null && entity.getState().getType().id()
|
||||
.equals("minecraft:player")) {
|
||||
continue;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
BlockVector3 pt = BlockVector3.at(x0, min.y(), z0);
|
||||
BiomeType biome = clipboard.getBiome(pt);
|
||||
|
||||
String biomeKey = biome.getId();
|
||||
String biomeKey = biome.id();
|
||||
int biomeId;
|
||||
if (palette.containsKey(biomeKey)) {
|
||||
biomeId = palette.get(biomeKey);
|
||||
@ -262,7 +262,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
values.putAll(rawData.getValue());
|
||||
}
|
||||
values.remove("id");
|
||||
values.put("Id", new StringTag(state.getType().getId()));
|
||||
values.put("Id", new StringTag(state.getType().id()));
|
||||
final Location location = e.getLocation();
|
||||
values.put("Pos", writeVector(location.toVector()));
|
||||
values.put("Rotation", writeRotation(location));
|
||||
|
@ -84,7 +84,7 @@ public class FlowerPotCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
} else {
|
||||
BlockState plantedWithData = LegacyMapper.getInstance().getBlockFromLegacy(newId, data);
|
||||
if (plantedWithData != null) {
|
||||
plantedName = plantedWithData.getBlockType().getId().substring(10); // remove "minecraft:"
|
||||
plantedName = plantedWithData.getBlockType().id().substring(10); // remove "minecraft:"
|
||||
}
|
||||
}
|
||||
if (plantedName != null) {
|
||||
|
@ -29,7 +29,7 @@ public class Pre13HangingCompatibilityHandler implements EntityNBTCompatibilityH
|
||||
|
||||
@Override
|
||||
public boolean isAffectedEntity(EntityType type, CompoundTag tag) {
|
||||
if (!type.getId().startsWith("minecraft:")) {
|
||||
if (!type.id().startsWith("minecraft:")) {
|
||||
return false;
|
||||
}
|
||||
boolean hasLegacyDirection = tag.containsKey("Dir") || tag.containsKey("Direction");
|
||||
|
@ -441,7 +441,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
if (Settings.settings().ENABLED_COMPONENTS.DEBUG) {
|
||||
LOGGER.warn(String.format(
|
||||
"Index outside direction array length found for block:{%s} property:{%s}",
|
||||
state.getBlockType().getId(),
|
||||
state.getBlockType().id(),
|
||||
property.getName()
|
||||
));
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class SnowSimulator implements LayerFunction {
|
||||
if (!above.getBlockType().getMaterial().isAir() && (!stack || above.getBlockType() != BlockTypes.SNOW)) {
|
||||
return false;
|
||||
//FAWE start
|
||||
} else if (!block.getBlockType().getId().toLowerCase(Locale.ROOT).contains("ice") && this.extent.getEmittedLight(
|
||||
} else if (!block.getBlockType().id().toLowerCase(Locale.ROOT).contains("ice") && this.extent.getEmittedLight(
|
||||
abovePosition) > 10) {
|
||||
return false;
|
||||
} else if (!block.getBlockType().getMaterial().isFullCube()) {
|
||||
@ -132,7 +132,7 @@ public class SnowSimulator implements LayerFunction {
|
||||
return false;
|
||||
}
|
||||
//FAWE end
|
||||
} else if (!block.getBlockType().getId().toLowerCase(Locale.ROOT).contains("ice") && block
|
||||
} else if (!block.getBlockType().id().toLowerCase(Locale.ROOT).contains("ice") && block
|
||||
.getBlockType()
|
||||
.getMaterial()
|
||||
.isTranslucent()) {
|
||||
|
@ -56,7 +56,7 @@ public class BlockOptimizedHistory extends ArrayListHistory {
|
||||
BlockChange blockChange = (BlockChange) change;
|
||||
BlockVector3 position = blockChange.getPosition();
|
||||
if (!previous.containsLocation(position)) {
|
||||
previous.add(position, blockChange.getPrevious());
|
||||
previous.add(position, blockChange.previous());
|
||||
}
|
||||
current.add(position, blockChange.getCurrent());
|
||||
} else {
|
||||
|
@ -165,7 +165,7 @@ public class ServerCUIHandler {
|
||||
structureTag.putString("mode", "SAVE");
|
||||
structureTag.putByte("ignoreEntities", (byte) 1);
|
||||
structureTag.putByte("showboundingbox", (byte) 1);
|
||||
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.getId());
|
||||
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.id());
|
||||
|
||||
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(structureTag.build());
|
||||
//FAWE end
|
||||
|
@ -21,6 +21,9 @@ package com.sk89q.worldedit.internal.registry;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.AliasedParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.FaweParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RichPatternParser;
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
@ -43,7 +46,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public abstract class AbstractFactory<E> {
|
||||
|
||||
protected final WorldEdit worldEdit;
|
||||
private final List<InputParser<E>> parsers = new ArrayList<>();
|
||||
//FAWE start
|
||||
protected final List<InputParser<E>> parsers = new ArrayList<>();
|
||||
private final FaweParser<E> richParser;
|
||||
//FWAE end
|
||||
|
||||
/**
|
||||
* Create a new factory.
|
||||
@ -52,11 +58,26 @@ public abstract class AbstractFactory<E> {
|
||||
* @param defaultParser the parser to fall back to
|
||||
*/
|
||||
protected AbstractFactory(WorldEdit worldEdit, InputParser<E> defaultParser) {
|
||||
//FAWE start
|
||||
this(worldEdit, defaultParser, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory with a given rich parser for FAWE rich parsing
|
||||
*
|
||||
* @param worldEdit the WorldEdit instance
|
||||
* @param defaultParser the parser to fall back to
|
||||
* @param richParser the rich parser
|
||||
* @since TODO
|
||||
*/
|
||||
protected AbstractFactory(WorldEdit worldEdit, InputParser<E> defaultParser, FaweParser<E> richParser) {
|
||||
checkNotNull(worldEdit);
|
||||
checkNotNull(defaultParser);
|
||||
this.worldEdit = worldEdit;
|
||||
this.parsers.add(defaultParser);
|
||||
this.richParser = richParser;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Gets an immutable list of parsers.
|
||||
@ -71,7 +92,7 @@ public abstract class AbstractFactory<E> {
|
||||
return Collections.unmodifiableList(parsers);
|
||||
}
|
||||
|
||||
//FAWE start - javadoc
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Parse a string and context to each {@link InputParser} added to this factory. If no result found, throws {@link InputParseException}
|
||||
@ -81,20 +102,26 @@ public abstract class AbstractFactory<E> {
|
||||
* @return parsed result
|
||||
* @throws InputParseException if no result found
|
||||
*/
|
||||
//FAWE end
|
||||
public E parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
E match;
|
||||
|
||||
for (InputParser<E> parser : parsers) {
|
||||
match = parser.parseFromInput(input, context);
|
||||
|
||||
if (match != null) {
|
||||
return match;
|
||||
List<E> parsed = new ArrayList<>();
|
||||
for (String component : StringUtil.split(input,' ', '[', ']')) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (richParser != null) {
|
||||
E match = richParser.parseFromInput(component, context);
|
||||
if (match != null) {
|
||||
parsed.add(match);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
parseFromParsers(context, parsed, component);
|
||||
}
|
||||
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
return getParsed(input, parsed);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Deprecated
|
||||
public List<String> getSuggestions(String input) {
|
||||
@ -133,4 +160,48 @@ public abstract class AbstractFactory<E> {
|
||||
});
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
protected void parseFromParsers(final ParserContext context, final List<E> parsed, final String component) {
|
||||
E match = null;
|
||||
for (InputParser<E> parser : getParsers()) {
|
||||
match = parser.parseFromInput(component, context);
|
||||
|
||||
if (match != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match == null) {
|
||||
throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(component)));
|
||||
}
|
||||
parsed.add(match);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a pattern without considering parsing through the {@link RichPatternParser}, therefore not accepting
|
||||
* "richer" parsing where & and , are used. Exists to prevent stack overflows.
|
||||
*
|
||||
* @param input input string
|
||||
* @param context input context
|
||||
* @return parsed result
|
||||
* @throws InputParseException if no result found
|
||||
*/
|
||||
public E parseWithoutRich(String input, ParserContext context) throws InputParseException {
|
||||
List<E> parsed = new ArrayList<>();
|
||||
|
||||
for (String component : StringUtil.split(input, ' ', '[', ']')) {
|
||||
if (component.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
parseFromParsers(context, parsed, component);
|
||||
}
|
||||
|
||||
return getParsed(input, parsed);
|
||||
}
|
||||
|
||||
protected E getParsed(final String input, final List<E> parsed) {
|
||||
return parsed.isEmpty() ? null : parsed.get(0);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
@ -755,7 +755,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
) {
|
||||
int chunkX = chunk.getX();
|
||||
int chunkZ = chunk.getZ();
|
||||
block = block.initChunk(chunkX, chunkZ);
|
||||
|
||||
//Chunk entry is an "interior chunk" in regards to the entire region, so filter the chunk whole instead of partially
|
||||
if ((minX + 15) >> 4 <= chunkX && (maxX - 15) >> 4 >= chunkX && (minZ + 15) >> 4 <= chunkZ && (maxZ - 15) >> 4 >= chunkZ) {
|
||||
|
@ -412,8 +412,6 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
return;
|
||||
}
|
||||
|
||||
block = block.initChunk(chunk.getX(), chunk.getZ());
|
||||
|
||||
// Get the solid layers
|
||||
int cy = center.y();
|
||||
int diffYFull = MathMan.usqrt(diffY2);
|
||||
|
@ -268,7 +268,6 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
||||
) {
|
||||
int minSection = Math.max(get.getMinSectionPosition(), getMinimumY() >> 4);
|
||||
int maxSection = Math.min(get.getMaxSectionPosition(), getMaximumY() >> 4);
|
||||
block = block.initChunk(chunk.getX(), chunk.getZ());
|
||||
for (int layer = minSection; layer <= maxSection; layer++) {
|
||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||
return;
|
||||
@ -483,7 +482,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
||||
}
|
||||
return set;
|
||||
} else {
|
||||
return null;
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ public class RegionIntersection extends AbstractRegion {
|
||||
BlockVector3 regMin = region.getMinimumPoint();
|
||||
BlockVector3 regMax = region.getMaximumPoint();
|
||||
if (tx >= regMin.x() && bx <= regMax.x() && tz >= regMin.z() && bz <= regMax.z()) {
|
||||
return region.processSet(chunk, get, set, true);
|
||||
set = region.processSet(chunk, get, set, true);
|
||||
}
|
||||
}
|
||||
return set; // default return set as no "blacklist" regions contained the chunk
|
||||
|
@ -25,7 +25,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
//FAWE start - implements RegistryItem
|
||||
public abstract class Category<T extends Keyed> implements RegistryItem {
|
||||
public abstract class Category<T extends Keyed> implements RegistryItem, Keyed {
|
||||
//FAWE end
|
||||
|
||||
private final Set<T> set = new HashSet<>();
|
||||
@ -36,7 +36,8 @@ public abstract class Category<T extends Keyed> implements RegistryItem {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public final String getId() {
|
||||
@Override
|
||||
public final String id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ public abstract class Category<T extends Keyed> implements RegistryItem {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
return id();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
||||
registerHelp = getBool("register-help", registerHelp);
|
||||
wandItem = getString("wand-item", wandItem);
|
||||
try {
|
||||
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();
|
||||
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).id();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop);
|
||||
@ -124,7 +124,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
||||
useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride);
|
||||
navigationWand = getString("nav-wand-item", navigationWand);
|
||||
try {
|
||||
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId();
|
||||
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).id();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance);
|
||||
|
@ -78,7 +78,7 @@ public class NullWorld extends AbstractWorld {
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
public String id() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren