diff options
Diffstat (limited to 'src/main/java/luckyblock/action/LuckyActionHolder.java')
| -rw-r--r-- | src/main/java/luckyblock/action/LuckyActionHolder.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/main/java/luckyblock/action/LuckyActionHolder.java b/src/main/java/luckyblock/action/LuckyActionHolder.java new file mode 100644 index 0000000..b18ad67 --- /dev/null +++ b/src/main/java/luckyblock/action/LuckyActionHolder.java @@ -0,0 +1,62 @@ +package luckyblock.action; + +import com.google.gson.JsonElement; +import com.google.gson.annotations.SerializedName; +import luckyblock.action.triggers.*; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; + +import java.util.ArrayList; +import java.util.List; + +public class LuckyActionHolder { + private static final List<ILuckyTrigger> cmdList = new ArrayList<>(); + + static { + cmdList.add(new BroadcastTrigger()); + cmdList.add(new SummonItemTrigger()); + cmdList.add(new SummonTrigger()); + cmdList.add(new TrappedRoomTrigger()); + } + + public String type = ""; + public int weight = -1; + public List<String> queue; + + @SerializedName("delay-queue") + public List<Integer> delay_queue; + public JsonElement json; + public List<String> items; + public List<String> mobs; + public int count = 1; + public int height = 0; + @SerializedName("is-powered") + public boolean is_powered = false; + @SerializedName("wall-block") + public String wall_block = "minecraft:stone_bricks"; + public int radius = 3; + + public void execute(Level level, BlockPos pos) { + if (!(level instanceof ServerLevel serverLevel)) { return; } + + for (ILuckyTrigger c : cmdList) { + if (this.type != null && this.type.equals(c.getName())) { + c.execute(serverLevel, pos, this, level.getRandom()); + break; + } + } + + if (this.queue != null && !this.queue.isEmpty()) { + for (int i=0;i<this.queue.size();i++) { + String next = this.queue.get(i); + int delayTicks = 0; + if (this.delay_queue != null && i<this.delay_queue.size()) { + delayTicks = this.delay_queue.get(i) * 20; + } + LuckyActionManager.enqueue(next, pos, serverLevel, delayTicks); + } + } + } + +} |
