Working ECS block event test
Some checks failed
Verifying Everything Compiles / build (push) Has been cancelled
Some checks failed
Verifying Everything Compiles / build (push) Has been cancelled
This commit is contained in:
@@ -29,7 +29,7 @@ manifest_group = HytaleModding
|
|||||||
mod_name = Replace Me
|
mod_name = Replace Me
|
||||||
|
|
||||||
# Fully-qualified plugin entry point class.
|
# 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.
|
# Comma-separated author entries. Author names cannot contain spaces.
|
||||||
# Each entry supports: Name, Name|Email, or Name|Email|Url.
|
# 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
|
mod_author = Your_Name|your.email@example.com|https://your-website.com
|
||||||
|
|
||||||
# Unique lowercase mod identifier.
|
# Unique lowercase mod identifier.
|
||||||
mod_id = ExamplePlugin
|
mod_id = RitualPlugin
|
||||||
|
|
||||||
# SPDX-style license identifier or Proprietary.
|
# SPDX-style license identifier or Proprietary.
|
||||||
mod_license = MIT
|
mod_license = MIT
|
||||||
@@ -62,10 +62,10 @@ disabled_by_default = false
|
|||||||
patchline = release
|
patchline = release
|
||||||
|
|
||||||
# Server version mirrored for tooling compatibility.
|
# Server version mirrored for tooling compatibility.
|
||||||
server_version = 0.5.3
|
server_version = 0.6.5
|
||||||
|
|
||||||
# Server version range written into manifest.json.
|
# 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=*
|
# Required manifest dependencies. Format: Group:Name=Version,Other:Mod=*
|
||||||
manifest_dependencies = Hytale:AssetModule=*
|
manifest_dependencies = Hytale:AssetModule=*
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
networkTimeout=10000
|
||||||
retries=0
|
retries=0
|
||||||
retryBackOffMs=500
|
retryBackOffMs=500
|
||||||
|
|||||||
4
gradlew
vendored
4
gradlew
vendored
@@ -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:
|
# Important for running:
|
||||||
#
|
#
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
# bash, then to run this script, type that shell name before the whole
|
# bash, then to run this script, type that shell name before the whole
|
||||||
# command line, like:
|
# command line, like:
|
||||||
#
|
#
|
||||||
# ksh Gradle
|
# ksh gradlew
|
||||||
#
|
#
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
|
|||||||
4
gradlew.bat
vendored
4
gradlew.bat
vendored
@@ -19,7 +19,7 @@
|
|||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem gradlew startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@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 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
|
@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
|
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
|
||||||
|
|||||||
@@ -1,33 +1,53 @@
|
|||||||
package dev.hytalemodding;
|
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.event.events.player.PlayerReadyEvent;
|
||||||
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||||
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||||
import com.hypixel.hytale.server.core.util.Config;
|
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.commands.ExampleCommand;
|
||||||
import dev.hytalemodding.config.ExampleConfig;
|
import dev.hytalemodding.config.ExampleConfig;
|
||||||
import dev.hytalemodding.events.ExampleEvent;
|
import dev.hytalemodding.events.ExampleEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
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;
|
private static Config<ExampleConfig> config = null;
|
||||||
|
|
||||||
public ExamplePlugin(@Nonnull JavaPluginInit init) {
|
public RitualPlugin(@Nonnull JavaPluginInit init) {
|
||||||
super(init);
|
super(init);
|
||||||
config = this.withConfig("example_config", ExampleConfig.CODEC);
|
config = this.withConfig("example_config", ExampleConfig.CODEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setup() {
|
protected void setup() {
|
||||||
|
LOGGER.atInfo().log("ritual mod loaded");
|
||||||
config.save();
|
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"));
|
this.getCommandRegistry().registerCommand(new ExampleCommand("example", "An example command"));
|
||||||
if (getConfig().get().isEnabledWelcomeMessage()) {
|
if (getConfig().get().isEnabledWelcomeMessage()) {
|
||||||
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
|
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void start() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shutdown() {
|
||||||
|
}
|
||||||
|
|
||||||
public static Config<ExampleConfig> getConfig() {
|
public static Config<ExampleConfig> getConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
9
src/main/java/dev/hytalemodding/RitualSpawner.java
Normal file
9
src/main/java/dev/hytalemodding/RitualSpawner.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package dev.hytalemodding;
|
||||||
|
|
||||||
|
import org.joml.Vector3i;
|
||||||
|
|
||||||
|
public class RitualSpawner {
|
||||||
|
public void blockChangeEvent(String blockId, Vector3i targetPosition) {
|
||||||
|
RitualPlugin.LOGGER.atInfo().log("a block got placed with the id: %s", blockId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
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.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();
|
||||||
|
ritualSpawner.blockChangeEvent(itemHolding, blockPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NullableDecl
|
||||||
|
@Override
|
||||||
|
public Query<EntityStore> getQuery() {
|
||||||
|
return Archetype.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
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 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();
|
||||||
|
ritualSpawner.blockChangeEvent(blockId, targetPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NullableDecl
|
||||||
|
@Override
|
||||||
|
public Query<EntityStore> getQuery() {
|
||||||
|
return Archetype.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Group": "HytaleModding",
|
"Group": "HytaleModding",
|
||||||
"Name": "ExamplePlugin",
|
"Name": "RitualPlugin",
|
||||||
"Version": "0.0.0",
|
"Version": "0.0.0",
|
||||||
"Description": "Description of your plugin",
|
"Description": "Description of your plugin",
|
||||||
"Authors": [
|
"Authors": [
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
"OptionalDependencies": {
|
"OptionalDependencies": {
|
||||||
|
|
||||||
},
|
},
|
||||||
"ServerVersion": ">=0.5.3 <0.6.0",
|
"ServerVersion": ">=0.6.5 <0.7.0",
|
||||||
"Main": "dev.hytalemodding.ExamplePlugin",
|
"Main": "dev.hytalemodding.RitualPlugin",
|
||||||
"UpdateChecker": {
|
"UpdateChecker": {
|
||||||
"CurseForge": ""
|
"CurseForge": ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user