Compare commits

...

2 Commits

Author SHA1 Message Date
5feb2b851f Proper block type detection & chunk data access
Some checks failed
Verifying Everything Compiles / build (push) Has been cancelled
2026-09-13 02:26:06 +02:00
2b0e178704 Working ECS block event test
Some checks failed
Verifying Everything Compiles / build (push) Has been cancelled
2026-09-13 01:37:07 +02:00
10 changed files with 129 additions and 14 deletions

View File

@@ -29,7 +29,7 @@ manifest_group = HytaleModding
mod_name = Replace Me
# Fully-qualified plugin entry point class.
main_class = dev.hytalemodding.ExamplePlugin
main_class = dev.hytalemodding.RitualPlugin
# Comma-separated author entries. Author names cannot contain spaces.
# Each entry supports: Name, Name|Email, or Name|Email|Url.
@@ -37,7 +37,7 @@ main_class = dev.hytalemodding.ExamplePlugin
mod_author = Your_Name|your.email@example.com|https://your-website.com
# Unique lowercase mod identifier.
mod_id = ExamplePlugin
mod_id = RitualPlugin
# SPDX-style license identifier or Proprietary.
mod_license = MIT
@@ -62,10 +62,10 @@ disabled_by_default = false
patchline = release
# Server version mirrored for tooling compatibility.
server_version = 0.5.3
server_version = 0.6.5
# Server version range written into manifest.json.
manifestServerVersion = >=0.5.3 <0.6.0
manifestServerVersion = >=0.6.5 <0.7.0
# Required manifest dependencies. Format: Group:Name=Version,Other:Mod=*
manifest_dependencies = Hytale:AssetModule=*

Binary file not shown.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500

4
gradlew vendored
View File

@@ -20,7 +20,7 @@
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
# gradlew start up script for POSIX generated by Gradle.
#
# Important for running:
#
@@ -29,7 +29,7 @@
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
# ksh gradlew
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:

4
gradlew.bat vendored
View File

@@ -19,7 +19,7 @@
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem gradlew startup script for Windows
@rem
@rem ##########################################################################
@@ -72,7 +72,7 @@ echo location of your Java installation. 1>&2
@rem Execute Gradle
@rem Execute gradlew
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel

View File

@@ -1,33 +1,53 @@
package dev.hytalemodding;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import com.hypixel.hytale.server.core.util.Config;
import dev.hytalemodding.events.RitualBreakBlockEvent;
import dev.hytalemodding.events.RitualPlaceBlockEvent;
import dev.hytalemodding.commands.ExampleCommand;
import dev.hytalemodding.config.ExampleConfig;
import dev.hytalemodding.events.ExampleEvent;
import javax.annotation.Nonnull;
public class ExamplePlugin extends JavaPlugin {
public class RitualPlugin extends JavaPlugin {
public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
private static Config<ExampleConfig> config = null;
public ExamplePlugin(@Nonnull JavaPluginInit init) {
public RitualPlugin(@Nonnull JavaPluginInit init) {
super(init);
config = this.withConfig("example_config", ExampleConfig.CODEC);
}
@Override
protected void setup() {
LOGGER.atInfo().log("ritual mod loaded");
config.save();
RitualSpawner ritualSpawner = new RitualSpawner();
this.getEntityStoreRegistry().registerSystem(new RitualPlaceBlockEvent(ritualSpawner));
this.getEntityStoreRegistry().registerSystem(new RitualBreakBlockEvent(ritualSpawner));
// Example
this.getCommandRegistry().registerCommand(new ExampleCommand("example", "An example command"));
if (getConfig().get().isEnabledWelcomeMessage()) {
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
}
}
@Override
protected void start() {
}
@Override
protected void shutdown() {
}
public static Config<ExampleConfig> getConfig() {
return config;
}

View File

@@ -0,0 +1,13 @@
package dev.hytalemodding;
import com.hypixel.hytale.server.core.universe.world.World;
import org.joml.Vector3i;
public class RitualSpawner {
public void blockChangeEvent(String itemId, Vector3i targetPosition, World world) {
String blockId = world.getBlockType(targetPosition).getId();
RitualPlugin.LOGGER.atInfo().log(
"a block got placed or removed at the position: %d - %d - %d with the block id: %s and with the item id in hand: %s",
targetPosition.x, targetPosition.y, targetPosition.z, blockId, itemId);
}
}

View File

@@ -0,0 +1,41 @@
package dev.hytalemodding.events;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.EntityEventSystem;
import com.hypixel.hytale.server.core.event.events.ecs.BreakBlockEvent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import dev.hytalemodding.RitualSpawner;
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
import org.joml.Vector3i;
public class RitualBreakBlockEvent extends EntityEventSystem<EntityStore, BreakBlockEvent> {
private final RitualSpawner ritualSpawner;
public RitualBreakBlockEvent(RitualSpawner ritualSpawner) {
super(BreakBlockEvent.class);
this.ritualSpawner = ritualSpawner;
}
@Override
public void handle(int index,
@NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
@NonNullDecl Store<EntityStore> store,
@NonNullDecl CommandBuffer<EntityStore> commandBuffer,
@NonNullDecl BreakBlockEvent breakBlockEvent) {
String itemHolding = breakBlockEvent.getItemInHand().getItemId();
Vector3i blockPosition = breakBlockEvent.getTargetBlock();
World world = store.getExternalData().getWorld();
ritualSpawner.blockChangeEvent(itemHolding, blockPosition, world);
}
@NullableDecl
@Override
public Query<EntityStore> getQuery() {
return Archetype.empty();
}
}

View File

@@ -0,0 +1,41 @@
package dev.hytalemodding.events;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.server.core.event.events.ecs.PlaceBlockEvent;
import com.hypixel.hytale.server.core.universe.world.World;
import dev.hytalemodding.RitualSpawner;
import com.hypixel.hytale.component.system.EntityEventSystem;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
import org.joml.Vector3i;
public class RitualPlaceBlockEvent extends EntityEventSystem<EntityStore, PlaceBlockEvent> {
private final RitualSpawner ritualSpawner;
public RitualPlaceBlockEvent(RitualSpawner ritualSpawner) {
super(PlaceBlockEvent.class);
this.ritualSpawner = ritualSpawner;
}
@Override
public void handle(int index,
@NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
@NonNullDecl Store<EntityStore> store,
@NonNullDecl CommandBuffer<EntityStore> commandBuffer,
@NonNullDecl PlaceBlockEvent placeBlockEvent) {
String blockId = placeBlockEvent.getItemInHand().getItemId();
Vector3i targetPosition = placeBlockEvent.getTargetBlock();
World world = store.getExternalData().getWorld();
ritualSpawner.blockChangeEvent(blockId, targetPosition, world);
}
@NullableDecl
@Override
public Query<EntityStore> getQuery() {
return Archetype.empty();
}
}

View File

@@ -1,6 +1,6 @@
{
"Group": "HytaleModding",
"Name": "ExamplePlugin",
"Name": "RitualPlugin",
"Version": "0.0.0",
"Description": "Description of your plugin",
"Authors": [
@@ -19,8 +19,8 @@
"OptionalDependencies": {
},
"ServerVersion": ">=0.5.3 <0.6.0",
"Main": "dev.hytalemodding.ExamplePlugin",
"ServerVersion": ">=0.6.5 <0.7.0",
"Main": "dev.hytalemodding.RitualPlugin",
"UpdateChecker": {
"CurseForge": ""
}