LoadLoopFromToolArgOperation class
Пакет: com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.sequential.flowcontrol.loops
Файл: com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/loops/LoadLoopFromToolArgOperation.java
extends: SequenceBrushOperation
Поля (11)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
int |
MAX_REPETITIONS |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
BuilderTool |
var5 |
|
ItemStack |
var6 |
|
BuilderTool.ArgData |
var7 |
|
Map |
var8 |
|
Object |
var9 |
Методы (6)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(this.repetitionsRemaining == -1) |
|
|
if if(var5 == null) |
|
|
if if(var6 == null) |
|
|
if if(var10 > 100 || var10 < 0) |
|
|
if if(this.repetitionsRemaining == 0) |
abstract |
|
super super("Loop Operations", "Loop the execution of instructions a variable amount of times", false) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.sequential.flowcontrol.loops;
class="kw">import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.BrushConfig;
class="kw">import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.BrushConfigCommandExecutor;
class="kw">import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.system.SequenceBrushOperation;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.server.core.asset.type.buildertool.config.BuilderTool;
class="kw">import com.hypixel.hytale.server.core.inventory.InventoryComponent;
class="kw">import com.hypixel.hytale.server.core.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;
class="kw">public class LoadLoopFromToolArgOperation class="kw">extends SequenceBrushOperation {
class="kw">public class="kw">static class="kw">final int MAX_REPETITIONS = 100;
class="kw">public class="kw">static class="kw">final int IDLE_STATE = -1;
class="kw">public class="kw">static class="kw">final BuilderCodec<LoadLoopFromToolArgOperation> CODEC = BuilderCodec.builder(
LoadLoopFromToolArgOperation.class, LoadLoopFromToolArgOperation::new
)
.append(new KeyedCodec<>("StoredIndexName", Codec.STRING), (var0, var1) -> var0.indexNameArg = var1, var0 -> var0.indexNameArg)
.documentation("The name of the previously stored index to begin the loop at. Note: This can only be an index previous to the current.")
.add()
.<String>append(new KeyedCodec<>("ArgName", Codec.STRING), (var0, var1) -> var0.argNameArg = var1, var0 -> var0.argNameArg)
.documentation("The amount of additional times to repeat the loop after the initial, normal execution")
.add()
.documentation("Loop the execution of instructions a set amount of times")
.build();
@Nonnull
class="kw">public String indexNameArg = "Undefined";
@Nonnull
class="kw">public String argNameArg = "";
class="kw">private int repetitionsRemaining = -1;
class="kw">public LoadLoopFromToolArgOperation() {
super("Loop Operations", "Loop the execution of instructions a variable amount of times", false);
}
@Override
class="kw">public void resetInternalState() {
this.repetitionsRemaining = -1;
}
@Override
class="kw">public void modifyBrushConfig(
@Nonnull Ref<EntityStore> var1, @Nonnull BrushConfig var2, @Nonnull BrushConfigCommandExecutor var3, @Nonnull ComponentAccessor<EntityStore> var4
) {
if (this.repetitionsRemaining == -1) {
BuilderTool var5 = BuilderTool.getActiveBuilderTool(var1, var4);
if (var5 == null) {
var2.setErrorFlag("LoadLoop: No active builder tool");
class="kw">return;
}
ItemStack var6 = InventoryComponent.getItemInHand(var4, var1);
if (var6 == null) {
var2.setErrorFlag("LoadLoop: No item in hand");
class="kw">return;
}
BuilderTool.ArgData var7 = var5.getItemArgData(var6);
Map var8 = var7.tool();
if (var8 == null || !var8.containsKey(this.argNameArg)) {
var2.setErrorFlag("LoadLoop: Tool arg '" + this.argNameArg + "' not found");
class="kw">return;
}
Object var9 = var8.get(this.argNameArg);
if (!(var9 class="kw">instanceof Integer var10)) {
var2.setErrorFlag("LoadLoop: Tool arg '" + this.argNameArg + "' is not an Int type (found " + var9.getClass().getSimpleName() + ")");
class="kw">return;
}
if (var10 > 100 || var10 < 0) {
var2.setErrorFlag("Cannot have more than 100 repetitions, or negative repetitions");
class="kw">return;
}
this.repetitionsRemaining = var10;
}
if (this.repetitionsRemaining == 0) {
this.repetitionsRemaining = -1;
} else {
this.repetitionsRemaining--;
var3.loadOperatingIndex(this.indexNameArg, false);
}
}
}