Skip to content

Commit

Permalink
Merge branch 'EngineHub:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomamaeatstoes authored Jul 21, 2024
2 parents 0f96784 + c9fdcc6 commit ec5c256
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
7.3.4
- Added support for 1.21
- Fixed an issue where //drawsel can prevent using //world overrides in some situation
- Improved performance of repeatedly getting string representations of a block

7.3.3
- [Sponge] Re-add Sponge support
Expand Down
2 changes: 1 addition & 1 deletion crowdin-distributor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

# For snapshots, please specify the full version (with date and time)
cdist_version="0.1.0-20210612.072458-9"
cdist_version="0.1.0-20240706.110724-10"
cdist_path_version="$cdist_version"

if [ -n "${cdist_version#*-}" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public static <B extends BlockStateHolder<B>> BlockData adapt(B block) {
if (cacheKey == BlockStateIdAccess.invalidId()) {
cacheKey = block.hashCode();
}
return blockDataCache.computeIfAbsent(cacheKey, input -> Bukkit.createBlockData(block.getAsString())).clone();
return blockDataCache.computeIfAbsent(cacheKey, input -> Bukkit.createBlockData(block.toImmutableState().getAsString())).clone();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.Tag;
import org.bukkit.block.Biome;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -208,14 +208,14 @@ private void setupWorldData() {
@SuppressWarnings({ "unchecked" })
private void initializeRegistries() {
// Biome
for (Biome biome : Biome.values()) {
Registry.BIOME.forEach(biome -> {
if (!biome.name().equals("CUSTOM")) {
String key = biome.getKey().toString();
BiomeType.REGISTRY.register(key, new BiomeType(key));
}
}
});
// Block & Item
for (Material material : Material.values()) {
Registry.MATERIAL.forEach(material -> {
if (material.isBlock()) {
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
// TODO Use something way less hacky than this.
Expand All @@ -242,16 +242,13 @@ private void initializeRegistries() {
if (material.isItem()) {
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
}
}
});
// Entity
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
if (entityType == org.bukkit.entity.EntityType.UNKNOWN) {
// This doesn't have a key - skip it
continue;
}
Registry.ENTITY_TYPE.forEach(entityType -> {
String key = entityType.getKey().toString();
EntityType.REGISTRY.register(key, new EntityType(key));
}
});

// ... :|
GameModes.get("");
WeatherTypes.get("");
Expand Down Expand Up @@ -327,6 +324,7 @@ public void onDisable() {
config.unload();
}
this.getServer().getScheduler().cancelTasks(this);
worldEdit.getExecutorService().shutdown();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public void onStopped() {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
worldEdit.getPlatformManager().unregister(platform);
WorldEdit.getInstance().getExecutorService().shutdown();
}

public FileRegistries getFileRegistries() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2433,9 +2433,12 @@ public int deformRegion(final Region region, final Vector3 zero, final Vector3 u

final DoubleArrayList<BlockVector3, BaseBlock> queue = new DoubleArrayList<>(false);

for (BlockVector3 position : region) {
for (BlockVector3 targetBlockPosition : region) {
final Vector3 targetPosition = targetBlockPosition.toVector3();
environment.setCurrentBlock(targetPosition);

// offset, scale
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
final Vector3 scaled = targetPosition.subtract(zero).divide(unit);

// transform
expression.evaluate(new double[]{ scaled.x(), scaled.y(), scaled.z() }, timeout);
Expand All @@ -2446,7 +2449,7 @@ public int deformRegion(final Region region, final Vector3 zero, final Vector3 u
final BaseBlock material = world.getFullBlock(sourcePosition);

// queue operation
queue.put(position, material);
queue.put(targetBlockPosition, material);
}

int affected = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.RegionSelector;
Expand All @@ -47,10 +46,7 @@ private ServerCUIHandler() {
}

public static int getMaxServerCuiSize() {
int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion();

// 1.16 increased maxSize to 48.
return dataVersion >= 2566 ? 48 : 32;
return 48;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,18 @@ public int hashCode() {
return ret;
}

/**
* Gets a string representation of this BaseBlock, in the format expected by WorldEdit's block parsers.
*
* <p>
* If NBT data is present, it will be included in the string. If you only want the underlying block state, call
* this method on the return value from {@link #toImmutableState()} instead.
* </p>
*
* @return The string representation
*/
@Override
public String toString() {
public String getAsString() {
String nbtString = "";
if (nbtData != null) {
nbtString = LinStringIO.writeToString(nbtData.getValue());
Expand All @@ -202,4 +212,9 @@ public String toString() {
return blockState.getAsString() + nbtString;
}

@Override
public String toString() {
return getAsString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void setInternalId(BlockState blockState, int internalId) {
private final Map<Property<?>, Object> values;

private final BaseBlock emptyBaseBlock;
private final LazyReference<String> lazyStringRepresentation;

// Neighbouring state table.
private Table<Property<?>, Object, BlockState> states;
Expand All @@ -79,6 +80,7 @@ public void setInternalId(BlockState blockState, int internalId) {
this.blockType = blockType;
this.values = new LinkedHashMap<>();
this.emptyBaseBlock = new BaseBlock(this);
this.lazyStringRepresentation = LazyReference.from(BlockStateHolder.super::getAsString);
}

/**
Expand Down Expand Up @@ -270,6 +272,11 @@ BlockState setState(final Property<?> property, final Object value) {
return this;
}

@Override
public String getAsString() {
return lazyStringRepresentation.getValue();
}

@Override
public String toString() {
return getAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ default BaseBlock applyBlock(BlockVector3 position) {
return toBaseBlock();
}

/**
* Gets a String representation of this BlockStateHolder, in the format expected by WorldEdit's block parsers.
*
* @return a string representation
*/
default String getAsString() {
if (getStates().isEmpty()) {
return this.getBlockType().id();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ private void onStopServer(MinecraftServer minecraftServer) {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform));
WorldEdit.getInstance().getExecutorService().shutdown();
}

private boolean skipEvents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public void serverStopping(ServerStoppingEvent event) {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform));
WorldEdit.getInstance().getExecutorService().shutdown();
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public void serverStopping(StoppingEngineEvent<Server> event) {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform));
WorldEdit.getInstance().getExecutorService().shutdown();
}

@Listener
Expand Down

0 comments on commit ec5c256

Please sign in to comment.