BlockEventView.java
package com.hypixel.hytale.server.npc.blackboard.view.event.block;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.protocol.InteractionType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.event.events.ecs.BreakBlockEvent;
import com.hypixel.hytale.server.core.event.events.ecs.DamageBlockEvent;
import com.hypixel.hytale.server.core.event.events.player.PlayerInteractEvent;
import com.hypixel.hytale.server.core.modules.blockset.BlockSetModule;
import com.hypixel.hytale.server.core.modules.entity.player.PlayerSettings;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.npc.blackboard.Blackboard;
import com.hypixel.hytale.server.npc.blackboard.view.event.EventNotification;
import com.hypixel.hytale.server.npc.blackboard.view.event.EventTypeRegistration;
import com.hypixel.hytale.server.npc.blackboard.view.event.EventView;
import com.hypixel.hytale.server.npc.entities.NPCEntity;
import it.unimi.dsi.fastutil.ints.IntSet;
import javax.annotation.Nonnull;
public class BlockEventView <BlockEventView, BlockEventType, EventNotification> {
{
(BlockEventType.class, BlockEventType.VALUES, (), world);
.eventRegistry.register((Class)PlayerInteractEvent.class, world.getName(), ::onPlayerInteraction);
(BlockEventType eventType : BlockEventType.VALUES) {
.entityMapsByEventType.put(eventType, (eventType, (set, blockId) -> BlockSetModule.getInstance().blockInSet(set, blockId), NPCEntity::notifyBlockChange));
}
}
BlockEventView {
((EntityStore)componentAccessor.getExternalData()).getWorld();
(!entityWorld.equals(.world)) {
(Blackboard)componentAccessor.getResource(Blackboard.getResourceType());
(BlockEventView)blackboardResource.getView(BlockEventView.class, ref, componentAccessor);
} {
;
}
}
{
( ; i < BlockEventType.VALUES.length; ++i) {
BlockEventType.VALUES[i];
npcComponent.getBlackboardBlockChangeSet(type);
(eventSets != ) {
((EventTypeRegistration).entityMapsByEventType.get(type)).initialiseEntity(npcComponent.getReference(), eventSets);
}
}
}
{
.onEvent(senderTypeId, x + , y + , z + , initiator, skip, componentAccessor, type);
}
{
(!event.isCancelled()) {
.processDamagedBlock(ref, event.getBlockType().getId(), event.getTargetBlock(), BlockEventType.DAMAGE);
}
}
{
(!event.isCancelled()) {
.processDamagedBlock(ref, event.getBlockType().getId(), event.getTargetBlock(), BlockEventType.DESTRUCTION);
}
}
{
Store<EntityStore> store = initiatorRef.getStore();
(Player)store.getComponent(initiatorRef, Player.getComponentType());
(playerComponent != && playerComponent.getGameMode() == GameMode.Creative) {
(PlayerSettings)store.getComponent(initiatorRef, PlayerSettings.getComponentType());
(playerSettingsComponent == || !playerSettingsComponent.creativeSettings().allowNPCDetection()) {
;
}
}
BlockType.getAssetMap().getIndex(block);
(blockId == -) {
( + block);
} {
.onEvent(blockId, ()position.x, ()position.y, ()position.z, initiatorRef, (Ref), store, (BlockEventType)type);
}
}
{
(!event.isCancelled()) {
event.getPlayer();
Ref<EntityStore> ref = event.getPlayerRef();
Store<EntityStore> store = ref.getStore();
(playerComponent.getGameMode() == GameMode.Creative) {
(PlayerSettings)store.getComponent(ref, PlayerSettings.getComponentType());
(playerSettingsComponent == || !playerSettingsComponent.creativeSettings().allowNPCDetection()) {
;
}
}
event.getTargetBlock();
(blockPosition != && event.getActionType() == InteractionType.Use) {
((EntityStore)store.getExternalData()).getWorld();
world.getBlock(blockPosition.x, blockPosition.y, blockPosition.z);
event.getTargetBlock();
.onEvent(blockId, ()targetBlock.x, ()targetBlock.y, ()targetBlock.z, ref, (Ref), store, (BlockEventType)BlockEventType.INTERACTION);
}
}
}
}