Skip to content

Commit

Permalink
Remove config for loot hexes, hardcode for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Robotgiggle committed Jan 24, 2025
1 parent f37f3c7 commit 3bd51de
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public interface ServerConfigAccess {

boolean trueNameHasAmbit();

List<String> getRandomLootHex(RandomSource rand);

int DEFAULT_MAX_OP_COUNT = 100_000;
int DEFAULT_MAX_SPELL_CIRCLE_LENGTH = 1024;
int DEFAULT_OP_BREAK_HARVEST_LEVEL = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;

import java.util.ArrayList;
import java.util.List;
import com.mojang.datafixers.util.Pair;

/**
* Add a random preset hex to the ancient cypher, and select a random variant.
Expand All @@ -39,17 +40,17 @@ public AddHexToAncientCypherFunc(LootItemCondition[] lootItemConditions) {
* This doesn't actually have any params so extract behaviour out for the benefit of forge
*/
public static ItemStack doStatic(ItemStack stack, RandomSource rand) {
var fullHex = HexConfig.server().getRandomLootHex(rand);
var hex = LOOT_HEXES.get(rand.nextInt(16));
var patsTag = new ListTag();
// skip first element since it's the name, not a pattern
for (var patString : fullHex.subList(1,fullHex.size())){
for (var patString : hex.getSecond()){
var pieces = patString.split(" ");
var pat = HexPattern.fromAngles(pieces[1],HexDir.fromString(pieces[0]));
patsTag.add(IotaType.serialize(new PatternIota(pat)));
}

var tag = new CompoundTag();
tag.putString(ItemAncientCypher.TAG_HEX_NAME, fullHex.get(0));
tag.putString(ItemAncientCypher.TAG_HEX_NAME, hex.getFirst());
tag.putLong(ItemAncientCypher.TAG_MEDIA, 32*MediaConstants.SHARD_UNIT);
tag.putLong(ItemAncientCypher.TAG_MAX_MEDIA, 32*MediaConstants.SHARD_UNIT);
tag.putInt(VariantItem.TAG_VARIANT, rand.nextInt(8));
Expand Down Expand Up @@ -81,4 +82,24 @@ public AddHexToAncientCypherFunc deserialize(JsonObject object, JsonDeserializat
return new AddHexToAncientCypherFunc(conditions);
}
}

// TODO: make this datapackable
private static final List<Pair<String, String[]>> LOOT_HEXES = List.of(
new Pair<>("hexcasting.loot_hex.shatter", new String[] {"NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST wqaawdd","EAST qaqqqqq"}),
new Pair<>("hexcasting.loot_hex.kindle", new String[] {"NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST wqaawdd","SOUTH_EAST aaqawawa"}),
new Pair<>("hexcasting.loot_hex.illuminate", new String[] {"NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST aadadaaw","EAST wqaawdd","NORTH_EAST ddqdd","EAST weddwaa","NORTH_EAST waaw","NORTH_EAST qqd"}),
new Pair<>("hexcasting.loot_hex.growth", new String[] {"NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST aadadaaw","EAST wqaawdd","NORTH_EAST ddqdd","EAST weddwaa","NORTH_EAST waaw","SOUTH_EAST aqaaedwd","EAST aadaadaa","NORTH_EAST wqaqwawqaqw","NORTH_EAST wqaqwawqaqw","NORTH_EAST wqaqwawqaqw"}),
new Pair<>("hexcasting.loot_hex.lunge", new String[] {"NORTH_EAST qaq","EAST aadaa","NORTH_EAST wa","SOUTH_EAST aqaawa","SOUTH_EAST waqaw","SOUTH_WEST awqqqwaqw"}),
new Pair<>("hexcasting.loot_hex.sidestep", new String[] {"NORTH_EAST qaq","EAST aadaa","NORTH_EAST wa","NORTH_WEST eqqq","SOUTH_EAST aqaawd","SOUTH_EAST e","NORTH_WEST qqqqqew","SOUTH_WEST eeeeeqw","SOUTH_EAST awdd","NORTH_EAST wdedw","SOUTH_WEST awqqqwaqw"}),
new Pair<>("hexcasting.loot_hex.ascend", new String[] {"NORTH_EAST qaq","SOUTH_EAST aqaae","WEST qqqqqawwawawd"}),
new Pair<>("hexcasting.loot_hex.blink", new String[] {"NORTH_EAST qaq","EAST aadaa","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST wqaawdd","NORTH_EAST qaq","EAST aa","NORTH_WEST wddw","NORTH_EAST wqaqw","SOUTH_EAST aqaaw","NORTH_WEST wddw","SOUTH_WEST awqqqwaq"}),
new Pair<>("hexcasting.loot_hex.blastoff", new String[] {"NORTH_EAST qaq","NORTH_WEST qqqqqew","SOUTH_EAST aqaawaa","SOUTH_EAST waqaw","SOUTH_WEST awqqqwaqw"}),
new Pair<>("hexcasting.loot_hex.radar", new String[] {"WEST qqq","EAST aadaa","EAST aa","SOUTH_EAST aqaawa","SOUTH_WEST ewdqdwe","NORTH_EAST de","EAST eee","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaaeaqq","SOUTH_EAST qqqqqwdeddwd","NORTH_EAST dadad"}),
new Pair<>("hexcasting.loot_hex.beckon", new String[] {"NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST weaqa","EAST aadaa","EAST dd","NORTH_EAST qaq","EAST aa","EAST aawdd","NORTH_WEST wddw","EAST aadaa","NORTH_EAST wqaqw","NORTH_EAST wdedw","SOUTH_EAST aqaawa","SOUTH_EAST waqaw","SOUTH_WEST awqqqwaqw"}),
new Pair<>("hexcasting.loot_hex.detonate", new String[] {"NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaaedwd","EAST ddwddwdd"}),
new Pair<>("hexcasting.loot_hex.shockwave", new String[] {"NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaawaa","EAST aadaadaa","SOUTH_EAST aqawqadaq","SOUTH_EAST aqaaedwd","EAST aawaawaa","NORTH_EAST qqa","EAST qaqqqqq"}),
new Pair<>("hexcasting.loot_hex.heat_wave", new String[] {"WEST qqq","SOUTH_EAST aaqawawa","EAST eee","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaae","SOUTH_EAST qqqqqwded","SOUTH_WEST aaqwqaa","SOUTH_EAST a","NORTH_EAST dadad"}),
new Pair<>("hexcasting.loot_hex.wither_wave", new String[] {"WEST qqq","SOUTH_EAST aqaae","SOUTH_EAST aqaaw","SOUTH_WEST qqqqqaewawawe","EAST eee","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaae","SOUTH_EAST qqqqqwdeddwd","SOUTH_WEST aaqwqaa","SOUTH_EAST a","NORTH_EAST dadad"}),
new Pair<>("hexcasting.loot_hex.flight_zone", new String[] {"NORTH_EAST qaq","SOUTH_EAST aqaaq","SOUTH_WEST awawaawq"})
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;

import java.util.List;

import static at.petrak.hexcasting.api.HexAPI.modLoc;

// https://github.com/VazkiiMods/Botania/blob/1.18.x/Xplat/src/main/java/vazkii/botania/common/loot/LootHandler.java
Expand Down Expand Up @@ -73,25 +71,6 @@ public class HexLootHandler {
new ResourceLocation("minecraft", "chests/nether_bridge")
);

public static final ImmutableList<List<String>> DEFAULT_LOOT_HEXES = ImmutableList.of(
List.of("hexcasting.loot_hex.shatter","NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST wqaawdd","EAST qaqqqqq"),
List.of("hexcasting.loot_hex.kindle","NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST wqaawdd","SOUTH_EAST aaqawawa"),
List.of("hexcasting.loot_hex.illuminate","NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST aadadaaw","EAST wqaawdd","NORTH_EAST ddqdd","EAST weddwaa","NORTH_EAST waaw","NORTH_EAST qqd"),
List.of("hexcasting.loot_hex.growth","NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST aadadaaw","EAST wqaawdd","NORTH_EAST ddqdd","EAST weddwaa","NORTH_EAST waaw","SOUTH_EAST aqaaedwd","EAST aadaadaa","NORTH_EAST wqaqwawqaqw","NORTH_EAST wqaqwawqaqw","NORTH_EAST wqaqwawqaqw"),
List.of("hexcasting.loot_hex.lunge","NORTH_EAST qaq","EAST aadaa","NORTH_EAST wa","SOUTH_EAST aqaawa","SOUTH_EAST waqaw","SOUTH_WEST awqqqwaqw"),
List.of("hexcasting.loot_hex.sidestep","NORTH_EAST qaq","EAST aadaa","NORTH_EAST wa","NORTH_WEST eqqq","SOUTH_EAST aqaawd","SOUTH_EAST e","NORTH_WEST qqqqqew","SOUTH_WEST eeeeeqw","SOUTH_EAST awdd","NORTH_EAST wdedw","SOUTH_WEST awqqqwaqw"),
List.of("hexcasting.loot_hex.ascend","NORTH_EAST qaq","SOUTH_EAST aqaae","WEST qqqqqawwawawd"),
List.of("hexcasting.loot_hex.blink","NORTH_EAST qaq","EAST aadaa","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST wqaawdd","NORTH_EAST qaq","EAST aa","NORTH_WEST wddw","NORTH_EAST wqaqw","SOUTH_EAST aqaaw","NORTH_WEST wddw","SOUTH_WEST awqqqwaq"),
List.of("hexcasting.loot_hex.blastoff","NORTH_EAST qaq","NORTH_WEST qqqqqew","SOUTH_EAST aqaawaa","SOUTH_EAST waqaw","SOUTH_WEST awqqqwaqw"),
List.of("hexcasting.loot_hex.radar","WEST qqq","EAST aadaa","EAST aa","SOUTH_EAST aqaawa","SOUTH_WEST ewdqdwe","NORTH_EAST de","EAST eee","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaaeaqq","SOUTH_EAST qqqqqwdeddwd","NORTH_EAST dadad"),
List.of("hexcasting.loot_hex.beckon","NORTH_EAST qaq","EAST aa","NORTH_EAST qaq","NORTH_EAST wa","EAST weaqa","EAST aadaa","EAST dd","NORTH_EAST qaq","EAST aa","EAST aawdd","NORTH_WEST wddw","EAST aadaa","NORTH_EAST wqaqw","NORTH_EAST wdedw","SOUTH_EAST aqaawa","SOUTH_EAST waqaw","SOUTH_WEST awqqqwaqw"),
List.of("hexcasting.loot_hex.detonate","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaaedwd","EAST ddwddwdd"),
List.of("hexcasting.loot_hex.shockwave","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaawaa","EAST aadaadaa","SOUTH_EAST aqawqadaq","SOUTH_EAST aqaaedwd","EAST aawaawaa","NORTH_EAST qqa","EAST qaqqqqq"),
List.of("hexcasting.loot_hex.heat_wave","WEST qqq","SOUTH_EAST aaqawawa","EAST eee","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaae","SOUTH_EAST qqqqqwded","SOUTH_WEST aaqwqaa","SOUTH_EAST a","NORTH_EAST dadad"),
List.of("hexcasting.loot_hex.wither_wave","WEST qqq","SOUTH_EAST aqaae","SOUTH_EAST aqaaw","SOUTH_WEST qqqqqaewawawe","EAST eee","NORTH_EAST qaq","EAST aa","SOUTH_EAST aqaae","SOUTH_EAST qqqqqwdeddwd","SOUTH_WEST aaqwqaa","SOUTH_EAST a","NORTH_EAST dadad"),
List.of("hexcasting.loot_hex.flight_zone","NORTH_EAST qaq","SOUTH_EAST aqaaq","SOUTH_WEST awawaawq")
);

public static int getScrollCount(int range, RandomSource random) {
return Math.max(random.nextIntBetweenInclusive(-range, range), 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,6 @@
"": "Ancient Cypher Chance",
"@Tooltip": "The chance for ancient cyphers to appear in any of the above loot tables.",
},
lootHexList: {
"": "Preset Loot Hex List",
"@Tooltip": "Lists the preset hexes that can be found in ancient cyphers. The first item in each list is the name of the hex, and the others are the patterns. The name is treated as a translation key if possible, but if you add your own they should be human-readable.",
},
amethystShardModification: {
"": "Amethyst Shard Drop Rate Change",
"@Tooltip": "How much the number of amethyst shards dropped from clusters is increased/decreased.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ public static final class Server implements HexConfig.ServerConfigAccess, Config
private transient List<ResourceLocation> cypherInjections;
@ConfigEntry.Gui.Tooltip
private double cypherChance = HexLootHandler.DEFAULT_CYPHER_CHANCE;
@ConfigEntry.Gui.Tooltip
private List<List<String>> lootHexList = HexLootHandler.DEFAULT_LOOT_HEXES;


@Override
Expand Down Expand Up @@ -328,10 +326,5 @@ public boolean shouldInjectCyphers(ResourceLocation lootTable) {
public double cypherChance() {
return cypherChance;
}

public List<String> getRandomLootHex(RandomSource rand) {
var index = rand.nextInt(this.lootHexList.size());
return this.lootHexList.get(index);
}
}
}
12 changes: 0 additions & 12 deletions Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public static class Server implements HexConfig.ServerConfigAccess {
private static ForgeConfigSpec.ConfigValue<List<? extends String>> fewScrollTables;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> someScrollTables;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> manyScrollTables;
private static ForgeConfigSpec.ConfigValue<List<? extends List<String>>> lootHexList;


public Server(ForgeConfigSpec.Builder builder) {
Expand All @@ -174,11 +173,6 @@ public Server(ForgeConfigSpec.Builder builder) {
.defineList("circleActionDenyList", List.of(), Server::isValidReslocArg);
builder.pop();

lootHexList = builder.comment(
"List of preset hexes found in loot cyphers. First element is the name, other elements are the patterns." +
"The default names use hardcoded translation keys, but custom ones should be human-readable.")
.defineList("lootHexList", HexLootHandler.DEFAULT_LOOT_HEXES, Server::isValidReslocArg);

actionDenyList = builder.comment(
"Resource locations of disallowed actions. Trying to cast one of these will result in a mishap.")
.defineList("actionDenyList", List.of(), Server::isValidReslocArg);
Expand Down Expand Up @@ -235,12 +229,6 @@ public boolean trueNameHasAmbit() {
return doesTrueNameHaveAmbit.get();
}

@Override
public List<String> getRandomLootHex(RandomSource rand) {
var index = rand.nextInt(lootHexList.get().size());
return lootHexList.get().get(index);
}

private static boolean isValidReslocArg(Object o) {
return o instanceof String s && ResourceLocation.isValidResourceLocation(s);
}
Expand Down

0 comments on commit 3bd51de

Please sign in to comment.