NPCEditorPlugin class

Пакет: com.hypixel.hytale.builtin.npceditor

Файл: com/hypixel/hytale/builtin/npceditor/NPCEditorPlugin.java

extends: JavaPlugin

Поля (14)

МодификаторыТипИмя
final AssetEditorPreviewCameraSettings DEFAULT_PREVIEW_CAMERA_SETTINGS
return
return
return
return
String var1
com.hypixel.hytale.protocol.Model var10
NPCPlugin var2
String var3
int var4
BuilderInfo var5
Builder var6
SpawningContext var8
Model var9

Методы (7)

МодификаторыВозвратСигнатура
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Can't find a matching role builder")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Can't find a matching role builder")
if if(var5 == null)
if if(var6 == null)
if if(var9 == null)
static void onSelectAssetvoid onSelectAsset(@Nonnull AssetEditorSelectAssetEvent var0)
abstract super super(var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.npceditor;

class="kw">import com.hypixel.hytale.builtin.asseteditor.AssetEditorPlugin;
class="kw">import com.hypixel.hytale.builtin.asseteditor.event.AssetEditorSelectAssetEvent;
class="kw">import com.hypixel.hytale.protocol.packets.asseteditor.AssetEditorPreviewCameraSettings;
class="kw">import com.hypixel.hytale.protocol.packets.asseteditor.AssetEditorUpdateModelPreview;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.Model;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.ModelAsset;
class="kw">import com.hypixel.hytale.server.core.command.system.exceptions.GeneralCommandException;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPlugin;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
class="kw">import com.hypixel.hytale.server.npc.NPCPlugin;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.Builder;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderInfo;
class="kw">import com.hypixel.hytale.server.npc.role.Role;
class="kw">import com.hypixel.hytale.server.spawning.ISpawnableWithModel;
class="kw">import com.hypixel.hytale.server.spawning.SpawningContext;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3f;

class="kw">public class NPCEditorPlugin class="kw">extends JavaPlugin {
   class="kw">private class="kw">static class="kw">final AssetEditorPreviewCameraSettings DEFAULT_PREVIEW_CAMERA_SETTINGS = new AssetEditorPreviewCameraSettings(
      0.25F, new Vector3f(0.0F, 75.0F, 0.0F), new Vector3f(0.0F, 0.7853F, 0.0F)
   );

   class="kw">public NPCEditorPlugin(@Nonnull JavaPluginInit var1) {
      super(var1);
   }

   @Override
   class="kw">protected void setup() {
      AssetEditorPlugin.get().getAssetTypeRegistry().registerAssetType(new NPCRoleAssetTypeHandler());
      this.getEventRegistry().register(AssetEditorSelectAssetEvent.class, NPCEditorPlugin::onSelectAsset);
   }

   class="kw">private class="kw">static void onSelectAsset(@Nonnull AssetEditorSelectAssetEvent var0) {
      String var1 = var0.getAssetType();
      if ("NPCRole".equals(var1)) {
         NPCPlugin var2 = NPCPlugin.get();
         String var3 = ModelAsset.getAssetStore().decodeFilePathKey(var0.getAssetFilePath().path());
         int var4 = var2.getIndex(var3);
         var2.forceValidation(var4);
         BuilderInfo var5 = var2.getRoleBuilderInfo(var4);
         if (var5 == null) {
            throw new IllegalStateException("Can't find a matching role builder");
         }

         if (!var2.testAndValidateRole(var5)) {
            throw new GeneralCommandException(Message.translation("server.commands.npc.spawn.validation_failed"));
         }

         Builder var6 = var2.tryGetCachedValidRole(var4);
         if (var6 == null) {
            throw new IllegalArgumentException("Can't find a matching role builder");
         }

         if (!(var6 class="kw">instanceof ISpawnableWithModel var7)) {
            class="kw">return;
         }

         if (!var6.isSpawnable()) {
            class="kw">return;
         }

         SpawningContext var8 = new SpawningContext();
         if (!var8.setSpawnable(var7)) {
            class="kw">return;
         }

         Model var9 = var8.getModel();
         if (var9 == null) {
            class="kw">return;
         }

         com.hypixel.hytale.protocol.Model var10 = var9.toPacket();
         var0.getEditorClient()
            .getPacketHandler()
            .write(new AssetEditorUpdateModelPreview(var0.getAssetFilePath().toPacket(), var10, null, DEFAULT_PREVIEW_CAMERA_SETTINGS));
      }
   }
}