Skip to content

Commit

Permalink
Rename most names to "official" ones except when unclear or name clash
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenStack committed Aug 29, 2024
1 parent 7ca1bde commit 322ac4c
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 219 deletions.
54 changes: 27 additions & 27 deletions src/main/java/net/goldenstack/loot/LootEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public interface LootEntry {
@NotNull BinaryTagSerializer<LootEntry> SERIALIZER = Template.registry("type",
Template.entry("empty", Empty.class, Empty.SERIALIZER),
Template.entry("item", Item.class, Item.SERIALIZER),
Template.entry("loot_table", Table.class, Table.SERIALIZER),
Template.entry("loot_table", LootTable.class, LootTable.SERIALIZER),
Template.entry("dynamic", Dynamic.class, Dynamic.SERIALIZER),
Template.entry("tag", Tag.class, Tag.SERIALIZER),
Template.entry("alternatives", Alternative.class, Alternative.SERIALIZER),
Template.entry("alternatives", Alternatives.class, Alternatives.SERIALIZER),
Template.entry("sequence", Sequence.class, Sequence.SERIALIZER),
Template.entry("group", Group.class, Group.SERIALIZER)
);
Expand Down Expand Up @@ -104,12 +104,12 @@ interface Single extends LootEntry, LootEntry.Choice, Standard {

}

record Alternative(@NotNull List<LootPredicate> predicates, @NotNull List<LootEntry> children) implements LootEntry {
record Alternatives(@NotNull List<LootPredicate> predicates, @NotNull List<LootEntry> children) implements LootEntry {

public static final @NotNull BinaryTagSerializer<Alternative> SERIALIZER = Template.template(
"conditions", LootPredicate.SERIALIZER.list().optional(List.of()), Alternative::predicates,
"children", Serial.lazy(() -> LootEntry.SERIALIZER).list().optional(List.of()), Alternative::children,
Alternative::new
public static final @NotNull BinaryTagSerializer<Alternatives> SERIALIZER = Template.template(
"conditions", LootPredicate.SERIALIZER.list().optional(List.of()), Alternatives::predicates,
"children", Serial.lazy(() -> LootEntry.SERIALIZER).list().optional(List.of()), Alternatives::children,
Alternatives::new
);

@Override
Expand Down Expand Up @@ -171,32 +171,32 @@ record Group(@NotNull List<LootPredicate> predicates, @NotNull List<LootEntry> c
}

record Item(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction> functions,
long weight, long quality, @NotNull Material material) implements Choice.Single {
long weight, long quality, @NotNull Material name) implements Choice.Single {

public static final @NotNull BinaryTagSerializer<Item> SERIALIZER = Template.template(
"conditions", LootPredicate.SERIALIZER.list().optional(List.of()), Item::predicates,
"functions", LootFunction.SERIALIZER.list().optional(List.of()), Item::functions,
"weight", Serial.LONG.optional(1L), Item::weight,
"quality", Serial.LONG.optional(0L), Item::quality,
"name", Material.NBT_TYPE, Item::material,
"name", Material.NBT_TYPE, Item::name,
Item::new
);

@Override
public @NotNull List<ItemStack> apply(@NotNull LootContext context) {
return List.of(LootFunction.apply(functions, ItemStack.of(material), context));
return List.of(LootFunction.apply(functions, ItemStack.of(name), context));
}
}

record Dynamic(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction> functions,
long weight, long quality, @NotNull NamespaceID choiceID) implements Choice.Single {
long weight, long quality, @NotNull NamespaceID name) implements Choice.Single {

public static final @NotNull BinaryTagSerializer<Dynamic> SERIALIZER = Template.template(
"conditions", LootPredicate.SERIALIZER.list().optional(List.of()), Dynamic::predicates,
"functions", LootFunction.SERIALIZER.list().optional(List.of()), Dynamic::functions,
"weight", Serial.LONG.optional(1L), Dynamic::weight,
"quality", Serial.LONG.optional(0L), Dynamic::quality,
"name", Serial.KEY, Dynamic::choiceID,
"name", Serial.KEY, Dynamic::name,
Dynamic::new
);

Expand All @@ -209,7 +209,7 @@ record Dynamic(@NotNull List<LootPredicate> predicates, @NotNull List<LootFuncti
CompoundBinaryTag nbt = block.hasNbt() ? block.nbt() : CompoundBinaryTag.empty();

VanillaInterface vanilla = context.require(LootContext.VANILLA_INTERFACE);
return vanilla.getDynamicDrops(choiceID, nbt);
return vanilla.getDynamicDrops(name, nbt);
}
}

Expand All @@ -230,39 +230,39 @@ record Empty(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction
}
}

record Table(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction> functions,
long weight, long quality, @NotNull NamespaceID tableID) implements Choice.Single {
record LootTable(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction> functions,
long weight, long quality, @NotNull NamespaceID value) implements Choice.Single {

public static final @NotNull BinaryTagSerializer<Table> SERIALIZER = Template.template(
"conditions", LootPredicate.SERIALIZER.list().optional(List.of()), Table::predicates,
"functions", LootFunction.SERIALIZER.list().optional(List.of()), Table::functions,
"weight", Serial.LONG.optional(1L), Table::weight,
"quality", Serial.LONG.optional(0L), Table::quality,
"value", Serial.KEY, Table::tableID,
Table::new
public static final @NotNull BinaryTagSerializer<LootTable> SERIALIZER = Template.template(
"conditions", LootPredicate.SERIALIZER.list().optional(List.of()), LootTable::predicates,
"functions", LootFunction.SERIALIZER.list().optional(List.of()), LootTable::functions,
"weight", Serial.LONG.optional(1L), LootTable::weight,
"quality", Serial.LONG.optional(0L), LootTable::quality,
"value", Serial.KEY, LootTable::value,
LootTable::new
);

@Override
public @NotNull List<ItemStack> apply(@NotNull LootContext context) {
var tables = context.get(LootContext.REGISTERED_TABLES);
if (tables == null) return List.of();

LootTable table = tables.apply(tableID);
net.goldenstack.loot.LootTable table = tables.apply(value);
if (table == null) return List.of();

return LootFunction.apply(functions, table.apply(context), context);
}
}

record Tag(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction> functions,
long weight, long quality, @NotNull net.minestom.server.gamedata.tags.Tag tag, boolean expand) implements Choice.Single {
long weight, long quality, @NotNull net.minestom.server.gamedata.tags.Tag name, boolean expand) implements Choice.Single {

public static final @NotNull BinaryTagSerializer<Tag> SERIALIZER = Template.template(
"conditions", LootPredicate.SERIALIZER.list().optional(List.of()), Tag::predicates,
"functions", LootFunction.SERIALIZER.list().optional(List.of()), Tag::functions,
"weight", Serial.LONG.optional(1L), Tag::weight,
"quality", Serial.LONG.optional(0L), Tag::quality,
"name", Serial.tag(net.minestom.server.gamedata.tags.Tag.BasicType.ITEMS), Tag::tag,
"name", Serial.tag(net.minestom.server.gamedata.tags.Tag.BasicType.ITEMS), Tag::name,
"expand", BinaryTagSerializer.BOOLEAN, Tag::expand,
Tag::new
);
Expand All @@ -276,7 +276,7 @@ record Tag(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction>
}

List<Choice> choices = new ArrayList<>();
for (var key : tag.getValues()) {
for (var key : name.getValues()) {
Material material = Material.fromNamespaceId(key);
if (material == null) continue;
choices.add(new Choice() {
Expand All @@ -298,7 +298,7 @@ record Tag(@NotNull List<LootPredicate> predicates, @NotNull List<LootFunction>
@Override
public @NotNull List<ItemStack> apply(@NotNull LootContext context) {
List<ItemStack> items = new ArrayList<>();
for (var key : tag.getValues()) {
for (var key : name.getValues()) {
Material material = Material.fromNamespaceId(key);
if (material == null) continue;

Expand Down
Loading

0 comments on commit 322ac4c

Please sign in to comment.