40 lines
1.6 KiB
Java
40 lines
1.6 KiB
Java
|
|
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();
|
||
|
|
}
|
||
|
|
}
|