Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ Unless otherwise specified, any version comparison below is the comparison of th
- (API) Changed `BucketFillSound` and `BucketEmptySound` from `boolean water` to `Type` enum (`WATER`, `LAVA`, `POWDER_SNOW`, `FISH`).
- (API) Changed `EntityPhysicsComponent.updateMotion(boolean)` to `updateMotion(LiquidState)` for richer liquid state information.
- Improved physics engine motion threshold handling: small forces (e.g. buoyancy) now accumulate across ticks instead of being zeroed out.
- (API) The return type of Pack.getVersion() is changed from `SemVersion` to `Semver` from the `semver4j`. This is because the support of semver in package manifest version fields.

### Fixed

- Fixed block collision shapes being clamped to a maximum height of 1.0. Blocks such as fences, fence gates, walls, and border blocks now correctly use their vanilla collision height of 1.5, preventing players from jumping over them.
- Fixed door collision shapes not changing based on block state. Doors now correctly compute their collision and selection shapes based on cardinal direction, open state, and hinge side.
- Fixed a bug where permission node `Permissions.ABILITY_OPERATOR_COMMAND_QUICK_BAR` does not have effect.
- Fixed a bug where player permission in the player list is always visitor even if the player is already an operator.
- Allay now support semver in package manifest version fields.

### Removed

Expand Down
3 changes: 2 additions & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ dependencies {
exclude(group = "org.joml", module = "joml")
}
api(libs.snakeyaml)
api(libs.semver4j)
}

tasks.withType<Javadoc>().configureEach {
enabled = true;
enabled = true
isFailOnError = false

(options as StandardJavadocDocletOptions).apply {
Expand Down
12 changes: 3 additions & 9 deletions api/src/main/java/org/allaymc/api/pack/Pack.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.allaymc.api.utils.SemVersion;
import org.semver4j.Semver;

import java.nio.ByteBuffer;
import java.security.MessageDigest;
Expand Down Expand Up @@ -48,18 +48,12 @@ public UUID getId() {
return this.manifest.getHeader().getUuid();
}

public SemVersion getVersion() {
public Semver getVersion() {
return this.manifest.getHeader().getVersion();
}

public String getStringVersion() {
var version = this.getVersion();
return String.join(
".",
String.valueOf(version.major()),
String.valueOf(version.minor()),
String.valueOf(version.patch())
);
return this.getVersion().getVersion();
}

public int getSize() {
Expand Down
9 changes: 4 additions & 5 deletions api/src/main/java/org/allaymc/api/pack/PackManifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.gson.stream.JsonReader;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.allaymc.api.utils.SemVersion;

import java.io.InputStreamReader;
import java.util.*;
Expand All @@ -26,8 +25,8 @@ public class PackManifest {
static {
var builder = new GsonBuilder();
builder.disableHtmlEscaping();
builder.registerTypeAdapter(SemVersion.class, new SemVersion.Serializer());
builder.registerTypeAdapter(SemVersion.class, new SemVersion.Deserializer());
builder.registerTypeAdapter(PackVersion.class, new PackVersion.Deserializer());
builder.registerTypeAdapter(PackVersion.class, new PackVersion.Serializer());
builder.registerTypeAdapter(Pack.Type.class, new Pack.Type.Deserializer());
builder.registerTypeAdapter(Pack.Type.class, new Pack.Type.Serializer());
builder.registerTypeAdapter(PackManifest.Capability.class, new PackManifest.Capability.Deserializer());
Expand Down Expand Up @@ -111,15 +110,15 @@ public static class Header {
private String name;
private String description;
private UUID uuid;
private SemVersion version;
private PackVersion version;
}

@Data
public static class Module {

private UUID uuid;
private String description;
private SemVersion version;
private PackVersion version;
private Pack.Type type;
}
}
72 changes: 72 additions & 0 deletions api/src/main/java/org/allaymc/api/pack/PackVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.allaymc.api.pack;


import com.google.gson.*;
import org.semver4j.Semver;

/**
* This class is not for public use! It has been mark as public just for the convenience of Gson serialization and deserialization.
* A version for pack manifest, which store the version in either an array format or a string format.
*
* @author harry-xi
*/
public class PackVersion extends Semver {
private final PackVersionType type;

PackVersion(String version, PackVersionType type) {
super(version);
this.type = type;
}

PackVersion(String version) {
this(version, PackVersionType.Arr);
}

PackVersion(int major, int minor, int patch) {
this( String.format("%d.%d.%d", major, minor, patch), PackVersionType.Arr);
}

enum PackVersionType {
Arr,
Str
}

protected static class Serializer implements JsonSerializer<PackVersion> {
@Override
public JsonElement serialize(PackVersion src, java.lang.reflect.Type typeOfSrc, JsonSerializationContext context) {
if(src.type == PackVersionType.Arr) {
var arr = new JsonArray();
arr.add(src.getMajor());
arr.add(src.getMinor());
arr.add(src.getPatch());
return arr;
} else {
return new JsonPrimitive(src.toString());
}
}
}

protected static class Deserializer implements JsonDeserializer<PackVersion> {
@Override
public PackVersion deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if(json.isJsonArray()) {
var arr = json.getAsJsonArray();
if(arr.size() != 3) {
throw new JsonParseException("Version array must have at least 3 elements");
}
var major = arr.get(0).getAsInt();
var minor = arr.get(1).getAsInt();
var patch = arr.get(2).getAsInt();
return new PackVersion(major, minor, patch);
} else if(json.isJsonPrimitive() && json.getAsJsonPrimitive().isString()) {
try {
return new PackVersion(json.getAsJsonPrimitive().getAsString());
} catch (Exception e) {
throw new JsonParseException("Invalid version string: " + json.getAsString(), e);
}
} else {
throw new JsonParseException("Invalid version format: " + json);
}
}
}
}
2 changes: 1 addition & 1 deletion api/src/main/java/org/allaymc/api/utils/SemVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.lang.reflect.Type;

/**
* Represents a semantic version.
* A semantic like version for Minecraft.
*
* @see <a href="https://semver.org/">Semantic Versioning</a>
*/
Expand Down