ObjectLoot, ObjectVanillaLoot and PlacementMarker: the loot and marker lists of an object placement as module-owned types of IrisApi annotations and BlockSpec

This commit is contained in:
piexel committed 2026-10-10 18:21:31 +02:00
1 parent d18972048c
commit 4f852f9c47
11 files changed
+291 -252

No files matched your search

@@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.loot;
import com.volmit.block.BlockSpec;
import com.volmit.config.Desc;
import com.volmit.config.MinItems;
import com.volmit.config.MinNumber;
import com.volmit.config.Required;
import com.volmit.config.ResourceRef;
import com.volmit.config.Snippet;
import java.util.Collections;
import java.util.List;
@Snippet("object-loot")
@Desc("Represents loot within this object")
public final class ObjectLoot implements ObjectLootEntry {
@MinItems(1)
@Desc("The list of blocks this loot table should apply to")
private List<BlockSpec> filter = List.of();
@Desc("Exactly match the block data or not")
private boolean exact = false;
@Desc("The loot table name")
@Required
@ResourceRef(LootTable.class)
private String name;
@Desc("The weight of this loot table being chosen")
@MinNumber(1)
private int weight = 1;
public ObjectLoot() {
}
/** A table for every container of the placement. */
public ObjectLoot(String name, int weight) {
this.name = name;
this.weight = weight;
}
@Override
public String name() {
return name;
}
@Override
public int weight() {
return weight;
}
@Override
public boolean exact() {
return exact;
}
@Override
public List<BlockSpec> filter() {
return filter == null ? List.of() : Collections.unmodifiableList(filter);
}
}
@@ -0,0 +1,41 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.loot;
import com.volmit.block.BlockSpec;
import java.util.List;
/**
* One loot table an object placement gives its containers: which table, how often it is picked among the placement's
* tables, and which of the object's containers it is for.
*/
public interface ObjectLootEntry {
/** The table: a key of the pack's loot tables, or a key of the platform's. */
String name();
/** How often the table is picked among equals; a table with no weight is never picked. */
int weight();
/** Whether the table applies to the exact state of the blocks in {@link #filter}, not to every state of their kind of block. */
boolean exact();
/** The blocks the table is for; none means every container the placement holds. */
List<BlockSpec> filter();
}
@@ -0,0 +1,71 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.loot;
import com.volmit.block.BlockSpec;
import com.volmit.config.Desc;
import com.volmit.config.MinItems;
import com.volmit.config.MinNumber;
import com.volmit.config.Ref;
import com.volmit.config.Reference;
import com.volmit.config.Required;
import com.volmit.config.Snippet;
import java.util.Collections;
import java.util.List;
@Snippet("object-vanilla-loot")
@Desc("Represents vanilla loot within this object")
public final class ObjectVanillaLoot implements ObjectLootEntry {
@MinItems(1)
@Desc("The list of blocks this loot table should apply to")
private List<BlockSpec> filter = List.of();
@Desc("Exactly match the block data or not")
private boolean exact = false;
@Desc("The vanilla loot table key")
@Required
@Ref(Reference.LOOT_TABLE)
private String name;
@Desc("The weight of this loot table being chosen")
@MinNumber(1)
private int weight = 1;
public ObjectVanillaLoot() {
}
@Override
public String name() {
return name;
}
@Override
public int weight() {
return weight;
}
@Override
public boolean exact() {
return exact;
}
@Override
public List<BlockSpec> filter() {
return filter == null ? List.of() : Collections.unmodifiableList(filter);
}
}
@@ -0,0 +1,72 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.spawn;
import com.volmit.block.BlockSpec;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinItems;
import com.volmit.config.MinNumber;
import com.volmit.config.Required;
import com.volmit.config.ResourceRef;
import com.volmit.config.Snippet;
import java.util.Collections;
import java.util.List;
/** Blocks of an object placement that get a {@link SpawnMarker}, an entry of the placement's {@code markers}. */
@Snippet("object-marker")
@Desc("Find blocks to mark")
public final class PlacementMarker {
@MinItems(1)
@Required
@Desc("Find block types to mark")
private List<BlockSpec> mark = List.of();
@MinNumber(1)
@MaxNumber(16)
@Desc("The maximum amount of markers to place. Use these sparingly!")
private int maximumMarkers = 8;
@Desc("If true, markers will only be placed if the block matches the mark list perfectly.")
private boolean exact = false;
@Required
@ResourceRef(SpawnMarker.class)
@Desc("The marker to add")
private String marker;
public PlacementMarker() {
}
/** The blocks that get a marker. */
public List<BlockSpec> mark() {
return mark == null ? List.of() : Collections.unmodifiableList(mark);
}
public int maximumMarkers() {
return maximumMarkers;
}
public boolean exact() {
return exact;
}
/** The key of the {@link SpawnMarker} to place. */
public String marker() {
return marker;
}
}