LoopOperation class
Пакет: com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.sequential.flowcontrol.loops
Файл: com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/loops/LoopOperation.java
extends: SequenceBrushOperation
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
int |
MAX_REPETITIONS |
|
|
return |
Методы (4)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(this.repetitionsRemaining == -1) |
|
|
if if(this.repetitionsArg > 100 || this.repetitionsArg < 0) |
|
|
if if(this.repetitionsRemaining == 0) |
abstract |
|
super super("Loop Operations", "Loop the execution of instructions a set 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.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">public class LoopOperation 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<LoopOperation> CODEC = BuilderCodec.builder(LoopOperation.class, LoopOperation::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()
.<Integer>append(new KeyedCodec<>("AdditionalRepetitions", Codec.INTEGER), (var0, var1) -> var0.repetitionsArg = var1, var0 -> var0.repetitionsArg)
.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 Integer repetitionsArg = 0;
class="kw">private int repetitionsRemaining = -1;
class="kw">public LoopOperation() {
super("Loop Operations", "Loop the execution of instructions a set 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) {
if (this.repetitionsArg > 100 || this.repetitionsArg < 0) {
var2.setErrorFlag("Cannot have more than 100 repetitions, or negative repetitions");
class="kw">return;
}
this.repetitionsRemaining = this.repetitionsArg;
}
if (this.repetitionsRemaining == 0) {
this.repetitionsRemaining = -1;
} else {
this.repetitionsRemaining--;
var3.loadOperatingIndex(this.indexNameArg, false);
}
}
}