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:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user