Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: marggx
29 changes: 14 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,43 @@ jobs:
java-version: '25'
distribution: 'temurin'

- name: Read patchline from gradle.properties
id: patchline
run: |
PATCHLINE=$(grep '^patchline=' gradle.properties | cut -d= -f2)
echo "patchline=${PATCHLINE}" >> $GITHUB_OUTPUT
echo "Patchline: ${PATCHLINE}"

- name: Fetch latest Hytale Server version
id: hytale-version
run: |
LATEST_VERSION=$(curl -s https://maven.hytale.com/release/com/hypixel/hytale/Server/maven-metadata.xml \
PATCH_LINE="${{ steps.patchline.outputs.patchline }}"
LATEST_VERSION=$(curl -s https://maven.hytale.com/${PATCH_LINE}/com/hypixel/hytale/Server/maven-metadata.xml \
| grep -o '<latest>[^<]*</latest>' | sed 's/<[^>]*>//g')
echo "version=${LATEST_VERSION}" >> $GITHUB_OUTPUT
echo "Fetched Hytale Server version: $LATEST_VERSION"

- name: Update versions in gradle.properties
run: |
VERSION="${GITHUB_REF_NAME}"
SERVER_VERSION="${{ steps.hytale-version.outputs.version }}"
sed -i "s/^version=.*/version=${VERSION}/" gradle.properties
sed -i "s/^server_version=.*/server_version=${SERVER_VERSION}/" gradle.properties
echo "Building version: ${VERSION}, Server version: ${SERVER_VERSION}"

- name: Cache Hytale Server JAR
id: cache-hytale
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/hytale-home
key: hytale-server-${{ steps.hytale-version.outputs.version }}
echo "Building version: ${VERSION}"

- name: Download Hytale Server JAR
if: steps.cache-hytale.outputs.cache-hit != 'true'
run: |
LATEST_VERSION="${{ steps.hytale-version.outputs.version }}"
JAR_DIR="${{ runner.temp }}/hytale-home/"
PATCH_LINE="${{ steps.patchline.outputs.patchline }}"
JAR_DIR="${{ runner.temp }}/hytale-home/install/${PATCH_LINE}/package/game/latest/Server/"
mkdir -p "$JAR_DIR"
echo "Downloading Hytale Server version: $LATEST_VERSION"
curl -L "https://maven.hytale.com/release/com/hypixel/hytale/Server/${LATEST_VERSION}/Server-${LATEST_VERSION}.jar" \
curl -L "https://maven.hytale.com/${PATCH_LINE}/com/hypixel/hytale/Server/${LATEST_VERSION}/Server-${LATEST_VERSION}.jar" \
-o "$JAR_DIR/HytaleServer.jar"

- name: Make gradlew executable
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -Pjar_dir="${{ runner.temp }}/hytale-home"
run: ./gradlew build -Phytale_home="${{ runner.temp }}/hytale-home"

- name: Commit and push updated files
run: |
Expand Down
48 changes: 6 additions & 42 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ plugins {

import org.gradle.internal.os.OperatingSystem

patchline = "release"

ext {
if (project.hasProperty('hytale_home')) {
hytaleHome = project.findProperty('hytale_home')
Expand All @@ -23,26 +21,21 @@ ext {
}
}
}
if (project.hasProperty('jar_dir')) {
jarDir = project.findProperty('jar_dir')
} else if (System.getenv('HYTALE_JAR_DIR') != null) {
jarDir = System.getenv('HYTALE_JAR_DIR')

if (project.hasProperty('patchline')) {
patchline = project.findProperty('patchline')
} else {
jarDir = "${hytaleHome}/install/${patchline}/package/game/latest/Server"
patchline = "pre-release"
}
}


if (!project.hasProperty('hytaleHome')) {
throw new GradleException('Your Hytale install could not be detected automatically. If you are on an unsupported platform or using a custom install location, please define the install location using the hytale_home property.')
} else if (!file(project.findProperty('jarDir')).exists()) {
throw new GradleException("Failed to find Hytale at the expected location. Please make sure you have installed the game. The expected location can be changed using the hytale_home property. Currently looking in ${project.findProperty('hytaleHome')}")
throw new GradleException('Your Hytale install could not be detected automatically. If you are on an unsupported platform or using a custom install location, please define the install location using the hytale_home property.');
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
withSourcesJar()
withJavadocJar()
}

// Quiet warnings about missing Javadocs.
Expand All @@ -54,7 +47,7 @@ javadoc {
// compile against their code. This requires you to have Hytale installed using
// the official launcher for now.
dependencies {
implementation(files("$jarDir/HytaleServer.jar"))
implementation(files("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar"))
}

// Create the working directory to run the server if it does not already exist.
Expand All @@ -74,39 +67,10 @@ tasks.register('updatePluginManifest') {
}
def manifestJson = new groovy.json.JsonSlurper().parseText(manifestFile.text)
manifestJson.Version = version
manifestJson.ServerVersion = "^${server_version}"
manifestJson.IncludesAssetPack = includes_pack.toBoolean()
manifestFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(manifestJson))
}
}

tasks.register('fetchLatestServerVersion') {
def metadataUrl = "https://maven.hytale.com/$patchline/com/hypixel/hytale/Server/maven-metadata.xml"
def propsFile = file('gradle.properties')
def manifestFile = file('src/main/resources/manifest.json')
doLast {
def metadata = new URI(metadataUrl).toURL().text
def matcher = (metadata =~ /<latest>([^<]*)<\/latest>/)
if (!matcher.find()) {
throw new GradleException("Could not parse latest version from Hytale Maven metadata at ${metadataUrl}")
}
def latestVersion = matcher.group(1)
println "Latest Hytale Server version: ${latestVersion}"

def content = propsFile.text
content = content.replaceAll(/(?m)^server_version=.*$/, "server_version=${latestVersion}")
propsFile.text = content

println "Updated gradle.properties and manifest.json with server_version=${latestVersion}"
}
}

// Makes sure the plugin manifest is up to date.
tasks.named('processResources') {
dependsOn 'fetchLatestServerVersion'
dependsOn 'updatePluginManifest'
}

def createServerRunArguments(String srcDir) {
def programParameters = '--allow-op --disable-sentry --assets="' + "${hytaleHome}/install/$patchline/package/game/latest/Assets.zip" + '"'
def modPaths = []
Expand Down
9 changes: 1 addition & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# The current version of your project. Please use semantic versioning!
version=1.2.10
# The Hytale server version this plugin was built against. This is fetched
# automatically from the Hytale Maven repository during a release build and
# written into manifest.json as ServerVersion.
server_version=0.5.7
# The group ID used for maven publishing. Usually the same as your package name
# but not the same as your plugin group!
maven_group=dev.marggx
version=1.2.12
# The version of Java used by your plugin. The game is built on Java 21 but
# actually runs on Java 25.
java_version=25
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.math.util.TrigMathUtil;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Quaterniond;
import org.joml.Quaterniondc;
import org.joml.Vector3d;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -37,26 +39,26 @@ public BlockymodelQuaternion(double x, double y, double z, double w) {
this.w = w;
}

public static BlockymodelQuaternion fromRotation3f(Rotation3f rot) {
Vector3d rotV3 = new Vector3d(rot.x(), rot.y(), rot.z());
rotV3.rotateY((float) Math.PI);

Quaterniond quat = new Quaterniond().rotationYXZ(rotV3.y(), rotV3.x(), rotV3.z());
return new BlockymodelQuaternion(quat.x(), quat.y(), quat.z(), quat.w());
public BlockymodelQuaternion(Quaterniondc quad) {
this.x = quad.x();
this.y = quad.y();
this.z = quad.z();
this.w = quad.w();
}

public static Quaterniond fromVector3d(Vector3d rot) {
return new Quaterniond().rotationYXZ(rot.y(), rot.x(), rot.z());
}

public static BlockymodelQuaternion getLocalQuat(Rotation3f baseRotation, Rotation3f toLocalRotation) {
Vector3d baseOrientation = new Vector3d(baseRotation.x(), baseRotation.y(), baseRotation.z());
baseOrientation.rotateY((float) Math.PI);

public static BlockymodelQuaternion getLocalQuat(Quaterniond baseQuad, Rotation3f toLocalRotation) {
Vector3d toLocal = new Vector3d(toLocalRotation.x(), toLocalRotation.y(), toLocalRotation.z());
toLocal.rotateY((float) Math.PI);
toLocal.rotateY(TrigMathUtil.PI);

Quaterniond originalQuat = new Quaterniond().rotationYXZ(baseOrientation.y(), baseOrientation.x(), baseOrientation.z());
Quaterniond originalQuat = new Quaterniond(baseQuad);
originalQuat.invert();
Quaterniond toLocalQuat = new Quaterniond().rotationYXZ(toLocal.y(), toLocal.x(), toLocal.z());
Quaterniond result = originalQuat.mul(toLocalQuat);
return new BlockymodelQuaternion(result.x(), result.y(), result.z(), result.w());
Quaterniond toLocalQuat = BlockymodelQuaternion.fromVector3d(toLocal);
originalQuat.mul(toLocalQuat);
return new BlockymodelQuaternion(originalQuat);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public BlockymodelBase createBlockymodelBase(BaseModel model) {
List<Blockymodel> blockymodels = model.blockymodels();
if (blockymodels.isEmpty()) return null;

return new BlockymodelBase(null, blockymodels.toArray(Blockymodel[]::new));
return new BlockymodelBase("prop", blockymodels.toArray(Blockymodel[]::new));
}

public boolean saveBlockymodelBase(BaseModel base) {
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/dev/marggx/mcreator/services/GroupService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.hypixel.hytale.server.core.modules.entity.component.EntityScaleComponent;
import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent;
import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
Expand Down Expand Up @@ -166,7 +167,7 @@ public void moveGroup(
assert memberTransformComponent != null;

memberTransformComponent.getPosition().sub(diff);
memberTransformComponent.markChunkDirty(componentAccessor);
//memberTransformComponent.markChunkDirty(componentAccessor);
}, targetRef);
});
}
Expand Down Expand Up @@ -331,14 +332,17 @@ private Box getModelHitBox(Ref<EntityStore> entityRef, Store<EntityStore> store)

double scale;
EntityScaleComponent scaleComp = store.getComponent(entityRef, EntityScaleComponent.getComponentType());
ItemComponent itemComp = store.getComponent(entityRef, ItemComponent.getComponentType());
if (scaleComp == null) {
ModelComponent modelComp = store.getComponent(entityRef, ModelComponent.getComponentType());
if (modelComp == null) {
return box;
}
scale = modelComp.getModel().getScale() / 2;
} else if (itemComp != null && itemComp.getItemStack() != null && itemComp.getItemStack().getBlockKey() == null) {
scale = scaleComp.getScale() / 2.5;
} else {
scale = scaleComp.getScale() / 2;
scale = scaleComp.getScale();
}

Vector3d min = new Vector3d(box.getMin());
Expand All @@ -358,14 +362,17 @@ private Box getModelHitBox(Holder<EntityStore> holder) {

double scale;
EntityScaleComponent scaleComp = holder.getComponent(EntityScaleComponent.getComponentType());
ItemComponent itemComp = holder.getComponent(ItemComponent.getComponentType());
if (scaleComp == null) {
ModelComponent modelComp = holder.getComponent(ModelComponent.getComponentType());
if (modelComp == null) {
return box;
}
scale = modelComp.getModel().getScale() / 2;
} else if (itemComp != null && itemComp.getItemStack() != null && itemComp.getItemStack().getBlockKey() == null) {
scale = scaleComp.getScale() / 2.5;
} else {
scale = scaleComp.getScale() / 2;
scale = scaleComp.getScale();
}

Vector3d min = new Vector3d(box.getMin());
Expand Down Expand Up @@ -464,13 +471,18 @@ public boolean tryAddMember(T entity) {
}

public Box getHitbox() {
Vector3d fullBlockMin = new Vector3d(min).ceil();
fullBlockMin.sub(min);
fullBlockMin.div(2);

Vector3d minRelative = new Vector3d(min).sub(center);
Vector3d maxRelative = new Vector3d(max).sub(center);
return new Box(new Vector3d(0, 0, 0), new Vector3d(maxRelative).sub(minRelative));
return new Box(new Vector3d(0, 0, 0).add(fullBlockMin), new Vector3d(maxRelative).sub(minRelative).add(fullBlockMin));
}

public Vector3d getCenter() {
return new Vector3d(max).sub(min).div(2.0);
Vector3d center = new Vector3d(max).sub(min).div(2);
return center;
}
}
}
28 changes: 19 additions & 9 deletions src/main/java/dev/marggx/mcreator/services/HytaleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
import com.hypixel.hytale.server.core.entity.UUIDComponent;
import com.hypixel.hytale.server.core.entity.entities.BlockEntity;
import com.hypixel.hytale.server.core.inventory.ItemStack;
import com.hypixel.hytale.server.core.modules.entity.component.EntityScaleComponent;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
import com.hypixel.hytale.server.core.modules.entity.component.PropComponent;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.modules.entity.component.*;
import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent;
import com.hypixel.hytale.server.core.modules.entity.item.PreventItemMerging;
import com.hypixel.hytale.server.core.modules.entity.item.PreventPickup;
Expand Down Expand Up @@ -131,7 +128,7 @@ public List<Model> deduplicateModels(List<Model> models) {

BlockymodelVector3d position = BlockymodelVector3d.from(transform.getPosition());
HeadRotation headRotation = holder.getComponent(HeadRotation.getComponentType());
Rotation3f rotationVector = MapperService.get().createRotationVector(model, headRotation, transform);
Vector3d rotationVector = MapperService.get().createRotationVector(model, headRotation, transform);
String cacheKey = model.id() + position + rotationVector;
if (modelCache.containsKey(cacheKey)) {
continue;
Expand Down Expand Up @@ -255,15 +252,28 @@ public void createNewHitbox(BaseModel baseModel) throws IOException {
}

public void replaceEntitiesWithNewItem(Vector3d pos, String modelId, BlockSelection selection, Store<EntityStore> store) {
this.removeEntitiesInSelection(selection, store);
this.removeEntitiesInSelection(selection, store, null);
this.placeNewItem(pos, modelId, store);
}

public List<Holder<EntityStore>> removeEntitiesInSelection(BlockSelection selection, Store<EntityStore> store) {
public List<Holder<EntityStore>> removeEntitiesInSelection(BlockSelection selection, Store<EntityStore> store, List<Model> modelsToFilter) {
List<Ref<EntityStore>> refs = this.getRefsFromBlockSelection(selection, store);
List<Holder<EntityStore>> holders = new ObjectArrayList<>();
for (Ref<EntityStore> ref : refs) {
holders.add(store.removeEntity(ref, RemoveReason.REMOVE));
if (modelsToFilter != null) {
UUIDComponent uuid = store.getComponent(ref, UUIDComponent.getComponentType());
assert uuid != null;
String uuiString = uuid.getUuid().toString();
for (Model model : modelsToFilter) {
UUIDComponent uuidModel = model.holder().getComponent(UUIDComponent.getComponentType());
if (uuidModel != null && uuidModel.getUuid().toString().equals(uuiString)) {
holders.add(store.removeEntity(ref, RemoveReason.REMOVE));
break;
}
}
} else {
holders.add(store.removeEntity(ref, RemoveReason.REMOVE));
}
}
return holders;
}
Expand All @@ -272,7 +282,7 @@ public Ref<EntityStore> placeNewItem(Vector3d pos, String modelId, Store<EntityS
Holder<EntityStore> holder = store.getRegistry().newHolder();
holder.addComponent(BlockEntity.getComponentType(), new BlockEntity(modelId));
holder.addComponent(TransformComponent.getComponentType(), new TransformComponent(pos, new Rotation3f()));
holder.addComponent(EntityScaleComponent.getComponentType(), new EntityScaleComponent(2.0F));
holder.addComponent(EntityScaleComponent.getComponentType(), new EntityScaleComponent(1.0F));
ItemStack itemStack = new ItemStack(modelId, 1);
itemStack.setOverrideDroppedItemAnimation(true);
holder.addComponent(ItemComponent.getComponentType(), new ItemComponent(itemStack));
Expand Down
Loading