ProcessingBenchWindow class

Пакет: com.hypixel.hytale.builtin.crafting.window

Файл: com/hypixel/hytale/builtin/crafting/window/ProcessingBenchWindow.java

extends: BenchWindow

implements: ItemContainerWindow

Поля (18)

МодификаторыТипИмя
break
return
CraftingRecipe var10
float var11
float var12
JsonArray var13
JsonObject var18
int var19
int var2
int var2
ProcessingBench.ProcessingSlot[] var2
ShortIterator var3
ShortIterator var3
JsonArray var3
ProcessingBenchBlock var4
JsonObject var8
ProcessingBench var9
CraftingManager var9

Методы (22)

МодификаторыВозвратСигнатура
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Infinite fuelTime")
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Nan fuelTime")
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Infinite progress")
for for(ProcessingBench.ProcessingSlot var7 : var2)
if if(this.active != var1)
if if(this.fuelTime != var1)
if if(this.maxFuel != var1)
if if(this.progress != var1)
if if(var9 == null)
if if(var2 != null && var2.length > 0)
if if(var7 != null)
if if(this.inventoryRegistration != null)
public void setActivevoid setActive(boolean var1)
public void setFuelTimevoid setFuelTime(float var1)
public void setMaxFuelvoid setMaxFuel(int var1)
public void setProcessingFuelSlotsvoid setProcessingFuelSlots(@Nonnull ShortSet var1)
public void setProcessingSlotsvoid setProcessingSlots(@Nonnull ShortSet var1)
public void setProgressvoid setProgress(float var1)
abstract super super(WindowType.Processing, var4, var5, var6, var7, var8, var2)
switch switch(var3)
private void updateInputSlotsvoid updateInputSlots(int var1)
private void updateOutputSlotsvoid updateOutputSlots(int var1)

Исходный код

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

class="kw">import com.google.gson.JsonArray;
class="kw">import com.google.gson.JsonObject;
class="kw">import com.hypixel.hytale.builtin.crafting.CraftingPlugin;
class="kw">import com.hypixel.hytale.builtin.crafting.component.BenchBlock;
class="kw">import com.hypixel.hytale.builtin.crafting.component.CraftingManager;
class="kw">import com.hypixel.hytale.builtin.crafting.component.ProcessingBenchBlock;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.event.EventRegistration;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.protocol.packets.window.SetActiveAction;
class="kw">import com.hypixel.hytale.protocol.packets.window.TierUpgradeAction;
class="kw">import com.hypixel.hytale.protocol.packets.window.WindowAction;
class="kw">import com.hypixel.hytale.protocol.packets.window.WindowType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.Bench;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.ProcessingBench;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.CraftingRecipe;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.windows.ItemContainerWindow;
class="kw">import com.hypixel.hytale.server.core.inventory.container.CombinedItemContainer;
class="kw">import com.hypixel.hytale.server.core.modules.block.BlockModule;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.shorts.ShortIterator;
class="kw">import it.unimi.dsi.fastutil.shorts.ShortOpenHashSet;
class="kw">import it.unimi.dsi.fastutil.shorts.ShortSet;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class ProcessingBenchWindow class="kw">extends BenchWindow class="kw">implements ItemContainerWindow {
   @Nonnull
   class="kw">private class="kw">final ProcessingBenchBlock processingBenchState;
   @Nullable
   class="kw">private class="kw">final BlockModule.BlockStateInfo blockStateInfo;
   class="kw">private CombinedItemContainer itemContainer;
   @Nullable
   class="kw">private EventRegistration<?, ?> inventoryRegistration;
   class="kw">private float fuelTime;
   class="kw">private int maxFuel;
   class="kw">private float progress;
   class="kw">private boolean active;
   @Nonnull
   class="kw">private class="kw">final ShortSet processingSlots = new ShortOpenHashSet();
   @Nonnull
   class="kw">private class="kw">final ShortSet processingFuelSlots = new ShortOpenHashSet();

   class="kw">public ProcessingBenchWindow(
      @Nonnull ProcessingBenchBlock var1,
      @Nonnull BenchBlock var2,
      @Nullable BlockModule.BlockStateInfo var3,
      int var4,
      int var5,
      int var6,
      int var7,
      @Nonnull BlockType var8
   ) {
      super(WindowType.Processing, var4, var5, var6, var7, var8, var2);
      this.processingBenchState = var1;
      this.blockStateInfo = var3;
      ProcessingBench var9 = (ProcessingBench)var8.getBench();
      CraftingRecipe var10 = var1.getRecipe();
      float var11 = var1.getInputProgress();
      float var12 = var10 != null && var10.getTimeSeconds() > 0.0F ? var11 / var10.getTimeSeconds() : 0.0F;
      this.itemContainer = var1.getItemContainer();
      this.active = var1.isActive();
      this.progress = var12;
      this.windowData.addProperty("active", this.active);
      this.windowData.addProperty("progress", var12);
      if (var9.getFuel() != null && var9.getFuel().length > 0) {
         JsonArray var13 = new JsonArray();

         for (ProcessingBench.ProcessingSlot var17 : var9.getFuel()) {
            JsonObject var18 = new JsonObject();
            var18.addProperty("icon", var17.getIcon());
            var18.addProperty("resourceTypeId", var17.getResourceTypeId());
            var13.add(var18);
         }

         this.windowData.add("fuel", var13);
      }

      if (var9.getMaxFuel() > 0) {
         this.maxFuel = var9.getMaxFuel();
      }

      this.windowData.addProperty("maxFuel", this.maxFuel);
      this.windowData.addProperty("fuelTime", this.fuelTime);
      this.windowData.addProperty("progress", var12);
      this.windowData.addProperty("processingFuelSlots", 0);
      this.windowData.addProperty("processingSlots", 0);
      int var19 = this.getBenchTierLevel();
      this.updateInputSlots(var19);
      this.updateOutputSlots(var19);
   }

   @Nonnull
   @Override
   class="kw">public JsonObject getData() {
      class="kw">return this.windowData;
   }

   @Nonnull
   class="kw">public CombinedItemContainer getItemContainer() {
      class="kw">return this.itemContainer;
   }

   class="kw">public void setActive(boolean var1) {
      if (this.active != var1) {
         this.active = var1;
         this.windowData.addProperty("active", var1);
         this.invalidate();
      }
   }

   class="kw">public void setFuelTime(float var1) {
      if (Float.isInfinite(var1)) {
         throw new IllegalArgumentException("Infinite fuelTime");
      }

      if (Float.isNaN(var1)) {
         throw new IllegalArgumentException("Nan fuelTime");
      }

      if (this.fuelTime != var1) {
         this.fuelTime = var1;
         this.windowData.addProperty("fuelTime", var1);
         this.invalidate();
      }
   }

   class="kw">public void setMaxFuel(int var1) {
      if (this.maxFuel != var1) {
         this.maxFuel = var1;
         this.windowData.addProperty("maxFuel", var1);
         this.invalidate();
      }
   }

   class="kw">public void setProgress(float var1) {
      if (Float.isInfinite(var1)) {
         throw new IllegalArgumentException("Infinite progress");
      }

      if (Float.isNaN(var1)) {
         throw new IllegalArgumentException("Nan fuelTime");
      }

      if (this.progress != var1) {
         this.progress = var1;
         this.windowData.addProperty("progress", var1);
         this.invalidate();
      }
   }

   class="kw">public void setProcessingSlots(@Nonnull ShortSet var1) {
      if (!this.processingSlots.equals(var1)) {
         this.processingSlots.clear();
         this.processingSlots.addAll(var1);
         int var2 = 0;
         ShortIterator var3 = var1.iterator();

         while (var3.hasNext()) {
            var2 |= 1 << var3.nextShort();
         }

         this.windowData.addProperty("processingSlots", var2);
         this.invalidate();
      }
   }

   class="kw">public void setProcessingFuelSlots(@Nonnull ShortSet var1) {
      if (!this.processingFuelSlots.equals(var1)) {
         this.processingFuelSlots.clear();
         this.processingFuelSlots.addAll(var1);
         int var2 = 0;
         ShortIterator var3 = var1.iterator();

         while (var3.hasNext()) {
            var2 |= 1 << var3.nextShort();
         }

         this.windowData.addProperty("processingFuelSlots", var2);
         this.invalidate();
      }
   }

   @Override
   class="kw">public void handleAction(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull WindowAction var3) {
      ProcessingBenchBlock var4 = this.processingBenchState;
      class="kw">switch (var3) {
         case SetActiveAction var7:
            if (!var4.setActive(var7.state, this.benchBlock, this.blockStateInfo)) {
               this.invalidate();
            }
            break;
         case TierUpgradeAction var8:
            label17: {
               CraftingManager var9 = var2.getComponent(var1, CraftingManager.getComponentType());
               if (var9 == null) {
                  class="kw">return;
               }

               if (var9.startTierUpgrade(var1, var2, this) && this.bench.getBenchUpgradeSoundEventIndex() != 0) {
                  SoundUtil.playSoundEvent3d(this.bench.getBenchUpgradeSoundEventIndex(), SoundCategory.SFX, this.x + 0.5, this.y + 0.5, this.z + 0.5, var2);
               }
               break label17;
            }
         class="kw">default:
      }
   }

   class="kw">private void updateOutputSlots(int var1) {
      this.windowData.addProperty("outputSlotsCount", ((ProcessingBench)this.blockType.getBench()).getOutputSlotsCount(var1));
   }

   class="kw">private void updateInputSlots(int var1) {
      ProcessingBench.ProcessingSlot[] var2 = ((ProcessingBench)this.blockType.getBench()).getInput(var1);
      if (var2 != null && var2.length > 0) {
         JsonArray var3 = new JsonArray();

         for (ProcessingBench.ProcessingSlot var7 : var2) {
            if (var7 != null) {
               JsonObject var8 = new JsonObject();
               var8.addProperty("icon", var7.getIcon());
               var3.add(var8);
            }
         }

         this.windowData.add("input", var3);
      }
   }

   @Override
   class="kw">public void updateBenchTierLevel(int var1) {
      super.updateBenchTierLevel(var1);
      this.updateInputSlots(var1);
      this.updateOutputSlots(var1);
      this.itemContainer = this.processingBenchState.getItemContainer();
   }

   @Override
   class="kw">public void onClose0(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      super.onClose0(var1, var2);
      if (this.inventoryRegistration != null) {
         this.inventoryRegistration.unregister();
         this.inventoryRegistration = null;
      }
   }

   @Nonnull
   class="kw">private class="kw">static JsonArray generateInventoryHints(@Nonnull Bench var0, @Nonnull CombinedItemContainer var1) {
      class="kw">return CraftingManager.generateInventoryHints(CraftingPlugin.getBenchRecipes(var0), 0, var1);
   }
}