LayersOperation class

Пакет: com.hypixel.hytale.builtin.buildertools.tooloperations

Файл: com/hypixel/hytale/builtin/buildertools/tooloperations/LayersOperation.java

extends: ToolOperation

Поля (10)

МодификаторыТипИмя
break
break
break
break
break
break
break
final Vector3i depthDirection
WorldChunk var4
HeadRotation var6

Методы (6)

МодификаторыВозвратСигнатура
if if(!this.skipLayerOne)
if if(!this.skipLayerTwo && this.enableLayerTwo)
if if(!this.skipLayerThree && this.enableLayerThree)
if if(this.enableLayerThree && !this.enableLayerTwo)
if if(this.failed)
abstract super super(var1, var4, var5)

Исходный код

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

class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.vector.Vector3iUtil;
class="kw">import com.hypixel.hytale.protocol.packets.buildertools.BuilderToolOnUseInteraction;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.Pair;
class="kw">import java.util.ArrayList;
class="kw">import java.util.List;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3i;

class="kw">public class LayersOperation class="kw">extends ToolOperation {
   class="kw">private class="kw">final Vector3i depthDirection = new Vector3i();
   class="kw">private class="kw">final int layerOneLength;
   class="kw">private class="kw">final int layerTwoLength;
   class="kw">private class="kw">final boolean enableLayerTwo;
   class="kw">private class="kw">final int layerThreeLength;
   class="kw">private class="kw">final boolean enableLayerThree;
   class="kw">private class="kw">final String layerOneBlockPattern;
   class="kw">private class="kw">final String layerTwoBlockPattern;
   class="kw">private class="kw">final String layerThreeBlockPattern;
   class="kw">private class="kw">final int brushDensity;
   class="kw">private class="kw">final int maxDepthNecessary;
   class="kw">private boolean failed;
   class="kw">private class="kw">final boolean skipLayerOne;
   class="kw">private class="kw">final boolean skipLayerTwo;
   class="kw">private class="kw">final boolean skipLayerThree;
   class="kw">private List<Pair<Integer, String>> layers;

   class="kw">public LayersOperation(
      @Nonnull Ref<EntityStore> var1,
      @Nonnull Player var2,
      @Nonnull PlayerRef var3,
      @Nonnull BuilderToolOnUseInteraction var4,
      @Nonnull ComponentAccessor<EntityStore> var5
   ) {
      super(var1, var4, var5);
      HeadRotation var6 = var5.getComponent(var1, HeadRotation.getComponentType());
      assert var6 != null;
      class="kw">switch ((String)this.args.tool().get("aDirection")) {
         case "Up":
            this.depthDirection.set(Vector3iUtil.UP);
            break;
         case "Down":
            this.depthDirection.set(Vector3iUtil.DOWN);
            break;
         case "North":
            this.depthDirection.set(Vector3iUtil.NORTH);
            break;
         case "South":
            this.depthDirection.set(Vector3iUtil.SOUTH);
            break;
         case "East":
            this.depthDirection.set(Vector3iUtil.EAST);
            break;
         case "West":
            this.depthDirection.set(Vector3iUtil.WEST);
            break;
         case "Camera":
            this.depthDirection.set(var6.getAxisDirection());
            break;
         class="kw">default:
            this.depthDirection.set(Vector3iUtil.DOWN);
      }

      this.brushDensity = (Integer)this.args.tool().get("jBrushDensity");
      this.layerOneLength = (Integer)this.args.tool().get("bLayerOneLength");
      this.layerTwoLength = (Integer)this.args.tool().get("eLayerTwoLength");
      this.layerThreeLength = (Integer)this.args.tool().get("hLayerThreeLength");
      this.layerOneBlockPattern = this.args.tool().get("cLayerOneMaterial").toString();
      this.layerTwoBlockPattern = this.args.tool().get("fLayerTwoMaterial").toString();
      this.layerThreeBlockPattern = this.args.tool().get("iLayerThreeMaterial").toString();
      this.enableLayerTwo = (Boolean)this.args.tool().get("dEnableLayerTwo");
      this.enableLayerThree = (Boolean)this.args.tool().get("gEnableLayerThree");
      this.skipLayerOne = (Boolean)this.args.tool().getOrDefault("kSkipLayerOne", false);
      this.skipLayerTwo = (Boolean)this.args.tool().getOrDefault("lSkipLayerTwo", false);
      this.skipLayerThree = (Boolean)this.args.tool().getOrDefault("mSkipLayerThree", false);
      this.layers = new ArrayList<>();
      if (!this.skipLayerOne) {
         this.layers.add(Pair.of(this.layerOneLength, this.layerOneBlockPattern));
      }

      if (!this.skipLayerTwo && this.enableLayerTwo) {
         this.layers.add(Pair.of(this.layerTwoLength, this.layerTwoBlockPattern));
      }

      if (!this.skipLayerThree && this.enableLayerThree) {
         this.layers.add(Pair.of(this.layerThreeLength, this.layerThreeBlockPattern));
      }

      this.maxDepthNecessary = this.layerOneLength + (this.enableLayerTwo ? this.layerTwoLength : 0) + (this.enableLayerThree ? this.layerThreeLength : 0);
      if (this.enableLayerThree && !this.enableLayerTwo) {
         var3.sendMessage(Message.translation("server.builderTools.layerOperation.layerTwoRequired"));
         this.failed = true;
      }
   }

   @Override
   class="kw">protected boolean executeBlock(int var1, int var2, int var3) {
      if (this.failed) {
         class="kw">return false;
      }

      if (this.random.nextInt(100) > this.brushDensity) {
         class="kw">return true;
      }

      if (this.edit.getBlock(var1, var2, var3) <= 0) {
         class="kw">return true;
      }

      WorldChunk var4 = this.edit.getAccessor().getChunk(ChunkUtil.indexChunkFromBlock(var1, var3));
      this.builderState.layer(var1, var2, var3, this.layers, this.maxDepthNecessary, this.depthDirection, var4, this.edit.getBefore(), this.edit.getAfter());
      class="kw">return true;
   }
}