Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc changes #839

Closed
wants to merge 10 commits into from
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import at.petrak.hexcasting.api.casting.SpellList;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.api.mod.HexConfig;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand Down Expand Up @@ -131,10 +132,13 @@ public Component display(Tag tag) {
out.append(IotaType.getDisplay(csub));

// only add a comma between 2 non-patterns (commas don't look good with Inline patterns)
// TODO: maybe add a config? maybe add a method on IotaType to allow it to opt out of commas
if (i < list.size() - 1 && (IotaType.getTypeFromTag(csub) != PatternIota.TYPE
|| IotaType.getTypeFromTag(HexUtils.downcast(list.get(i+1), CompoundTag.TYPE)) != PatternIota.TYPE)) {
out.append(", ");
// TODO: maybe add a method on IotaType to allow it to opt out of commas?
if (i < list.size() - 1) {
var thisIotaNeedsComma = IotaType.getTypeFromTag(csub) != PatternIota.TYPE;
var nextIotaNeedsComma = IotaType.getTypeFromTag(HexUtils.downcast(list.get(i+1), CompoundTag.TYPE)) != PatternIota.TYPE;
var alwaysShowCommas = HexConfig.client().alwaysShowListCommas();
if (thisIotaNeedsComma || nextIotaNeedsComma || alwaysShowCommas)
out.append(", ");
}
}
return Component.translatable("hexcasting.tooltip.list_contents", out).withStyle(ChatFormatting.DARK_PURPLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ public interface ClientConfigAccess {

boolean clickingTogglesDrawing();

boolean alwaysShowListCommas();

boolean DEFAULT_CTRL_TOGGLES_OFF_STROKE_ORDER = false;
boolean DEFAULT_INVERT_SPELLBOOK_SCROLL = false;
boolean DEFAULT_INVERT_ABACUS_SCROLL = false;
double DEFAULT_GRID_SNAP_THRESHOLD = 0.5;
boolean DEFAULT_CLICKING_TOGGLES_DRAWING = false;
boolean DEFAULT_ALWAYS_SHOW_LIST_COMMAS = false;
}

public interface ServerConfigAccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class HexLootHandler {
// if you manage to find one of these things you deserve a lot of scrolls
new ScrollInjection(new ResourceLocation("minecraft", "chests/woodland_mansion"), 5),
new ScrollInjection(new ResourceLocation("minecraft", "chests/stronghold_library"), 5)

// you can use the table hexcasting:random_scroll to get exactly 1 scroll and nothing else
);

public static final ImmutableList<ResourceLocation> DEFAULT_LORE_INJECTS = ImmutableList.of(
Expand All @@ -69,6 +71,7 @@ public class HexLootHandler {
new ResourceLocation("minecraft", "chests/desert_pyramid"),
new ResourceLocation("minecraft", "chests/ancient_city"),
new ResourceLocation("minecraft", "chests/nether_bridge")
// you can use the table hexcasting:random_cypher to get exactly 1 cypher and nothing else
);

public static int getScrollCount(int range, RandomSource random) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@
"": "Clicking Toggles Drawing",
"@Tooltip": "Whether you click to start and stop drawing instead of clicking and dragging to draw",
},
alwaysShowListCommas: {
"": "Always Show List Commas",
"@Tooltip": "Whether all iota types should be comma-separated when displayed in lists (by default, pattern iotas do not use commas)",
},
},

server: {
Expand Down Expand Up @@ -1968,7 +1972,7 @@
conjure_light: "Conjure a magical light that softly glows with my pigment at the given position. Costs about one $(l:items/amethyst)$(item)Amethyst Dust/$.",
bonemeal: "Encourage a plant or sapling at the target position to grow, as if $(item)Bonemeal/$ was applied. Costs a bit more than one $(l:items/amethyst)$(item)Amethyst Dust/$.",
edify: "Forcibly infuse _media into the sapling at the target position, causing it to grow into an $(l:items/edified)$(thing)Edified Tree/$. Costs about one $(l:items/amethyst)$(item)Charged Amethyst/$.",
ignite: "Start a fire on top of the given location, as if a $(item)Fire Charge/$ was applied, or sets fire to a creature. Costs about one $(l:items/amethyst)$(item)Amethyst Dust/$.",
ignite: "Start a fire on top of the given location, as if a $(item)Fire Charge/$ was applied, or set fire to an entity. Costs about one $(l:items/amethyst)$(item)Amethyst Dust/$.",
extinguish: "Extinguish blocks in a large area. Costs about six $(l:items/amethyst)$(item)Amethyst Dust/$.",
},

Expand Down Expand Up @@ -2018,7 +2022,7 @@
"range.2": "The second argument is a horizontal radius, in meters, in which the spell is stable. Moving outside of that radius will end the spell, dropping me out of the sky. As long as I stay inside the safe zone, however, the spell lasts indefinitely. An additional shimmer of _media marks the origin point of the safe zone. $(br2)Costs about 1 $(l:items/amethyst)$(item)Amethyst Dust/$ per meter of safety.",

"time.1": "A flight limited in its duration.",
"time.2": "The second argument is an amount of time in seconds for which the spell is stable. After that time, the spell ends and I am dropped from the sky. $(br2)It is relatively expensive at about 1 $(l:items/amethyst)$(item)Charged Crystal/$ per second of flight; I believe it is best suited for travel.",
"time.2": "The second argument is an amount of time in seconds for which the spell is stable. After that time, the spell ends and I am dropped from the sky. $(br2)It is relatively expensive at about 1 $(l:items/amethyst)$(item)Amethyst Shard/$ per second of flight; I believe it is best suited for travel.",

// Putting this in this category instead of elsewhere -- see sentinel chapter also containing some reflections/nonspells
"can_fly.1": "Returns whether the given player is under the effects of $(l:patterns/spells/flight#hexcasting:flight/range)Anchorite's/$ or $(l:patterns/spells/flight#hexcasting:flight/time)Wayfarer's Flight/$.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pools": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pools": []
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2025-01-23T15:50:44.3944222 Hex Casting/Loot Tables
// 1.20.1 2025-02-03T18:26:54.5093046 Hex Casting/Loot Tables
4efd95d408d050c36ff21b18f3c37116491fef92 data\hexcasting\loot_tables\blocks\directrix\redstone.json
c81a5cb81141ab1fe09dd5dd3a0968b69dfffbd7 data\hexcasting\loot_tables\blocks\stripped_edified_log.json
a62ffbcec2aa40172e05cd9fcd8e70e295d008e9 data\hexcasting\loot_tables\blocks\edified_fence_gate.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2025-01-23T15:50:44.4049409 Hex Casting/Tags for minecraft:item
// 1.20.1 2025-02-03T18:26:54.5110333 Hex Casting/Tags for minecraft:item
e5df19a1dc6eadf14cd9b0f0fe45a74330b745e9 data\minecraft\tags\items\planks.json
c562b4be24d0b6b13f3c65599d3bfa3bf2c4ce21 data\minecraft\tags\items\logs.json
20183cd61968ff6548df2dde1100b6378d68d64b data\minecraft\tags\items\wooden_buttons.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2025-01-23T15:50:44.4152906 Hex Casting/Tags for hexcasting:action
// 1.20.1 2025-02-03T18:26:54.5270686 Hex Casting/Tags for hexcasting:action
6fe30f41e2bcd48589caab26d210a513dce1ab7c data\hexcasting\tags\action\per_world_pattern.json
6fe30f41e2bcd48589caab26d210a513dce1ab7c data\hexcasting\tags\action\can_start_enlighten.json
6fe30f41e2bcd48589caab26d210a513dce1ab7c data\hexcasting\tags\action\requires_enlightenment.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2025-01-23T15:50:44.400399 Hex Casting/Tags for minecraft:block
// 1.20.1 2025-02-03T18:26:54.5110333 Hex Casting/Tags for minecraft:block
e8d5ef7eabb567228b279b2419e4f042082d7491 data\minecraft\tags\blocks\fences.json
7e1e353cb7f561f086898f991ece48e047991934 data\minecraft\tags\blocks\fence_gates.json
fdb48f194d7937ab6b423fa4b90a4d438bf6dd90 data\minecraft\tags\blocks\doors.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2025-01-23T15:50:44.4089311 Hex Casting/Recipes
// 1.20.1 2025-02-03T18:26:54.5110333 Hex Casting/Recipes
1d1e73244fb3da633d8a5f84bad93c6022a94368 data\hexcasting\advancements\recipes\misc\pride_colorizer_demiboy.json
49e706193bb57a957091e419bd0d8aa58135da1f data\hexcasting\recipes\dye_colorizer_green.json
071e5875b13b60aac33bc97e408d2ca710ac5d02 data\hexcasting\advancements\recipes\building_blocks\stonecutting\amethyst_tiles.json
Expand Down Expand Up @@ -105,8 +105,8 @@ bc729ac7cf84d29a99cd34d50c152c0b9d20bd7a data\hexcasting\advancements\recipes\br
d7de5d626fd799a2522af36f0c62c52fe490e6d2 data\hexcasting\recipes\edified_door.json
c3f7b03fe184ed5e54a8ae06d130adf507b7683d data\hexcasting\recipes\staff\bamboo.json
6f2634e5588aede8e29157ecc859652d8a9f4065 data\hexcasting\advancements\recipes\misc\dye_colorizer_orange.json
b10d590e918e35b16578a8b739a1c4e7e2202e16 data\hexcasting\advancements\recipes\misc\dye_colorizer_cyan.json
0e792d49c81d2164e827d1bdedaa0fa358dfc437 data\hexcasting\advancements\recipes\misc\pride_colorizer_aromantic.json
b10d590e918e35b16578a8b739a1c4e7e2202e16 data\hexcasting\advancements\recipes\misc\dye_colorizer_cyan.json
afb422ad4a918ee0161bf077f09475bb1da2b4eb data\hexcasting\recipes\amethyst_dust_unpacking.json
98c0843e6a83b91820f1c720e206295eec20ff95 data\hexcasting\recipes\ancient_scroll_paper.json
011f8daf15148d4b77686c6d382d8f5c288a333d data\hexcasting\advancements\recipes\building_blocks\ancient_scroll_paper.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public static final class Client implements HexConfig.ClientConfigAccess, Config
private double gridSnapThreshold = DEFAULT_GRID_SNAP_THRESHOLD;
@ConfigEntry.Gui.Tooltip
private boolean clickingTogglesDrawing = DEFAULT_CLICKING_TOGGLES_DRAWING;
@ConfigEntry.Gui.Tooltip
private boolean alwaysShowListCommas = DEFAULT_ALWAYS_SHOW_LIST_COMMAS;

@Override
public void validatePostLoad() throws ValidationException {
Expand Down Expand Up @@ -166,6 +168,11 @@ public double gridSnapThreshold() {
public boolean clickingTogglesDrawing() {
return clickingTogglesDrawing;
}

@Override
public boolean alwaysShowListCommas() {
return alwaysShowListCommas;
}
}

@Config(name = "server")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@

public class FabricHexLootModJankery {
public static final ResourceLocation FUNC_AMETHYST_SHARD_REDUCER = modLoc("amethyst_shard_reducer");
public static final ResourceLocation RANDOM_SCROLL_TABLE = modLoc("random_scroll");
public static final ResourceLocation RANDOM_CYPHER_TABLE = modLoc("random_cypher");

public static void lootLoad(ResourceLocation id, Consumer<LootPool.Builder> addPool) {
if (id.equals(Blocks.AMETHYST_CLUSTER.getLootTable())) {
addPool.accept(makeAmethystInjectPool());
} else if (id.equals(RANDOM_SCROLL_TABLE)) {
// -1 weight = guaranteed spawn
addPool.accept(makeScrollAddPool(-1));
} else if (id.equals(RANDOM_CYPHER_TABLE)) {
// 1 chance = guaranteed spawn
addPool.accept(makeCypherAddPool(1));
}

int countRange = FabricHexInitializer.CONFIG.server.scrollRangeForLootTable(id);
Expand All @@ -50,7 +58,7 @@ private static LootPool.Builder makeAmethystInjectPool() {

private static LootPool.Builder makeScrollAddPool(int range) {
return LootPool.lootPool()
.setRolls(UniformGenerator.between(-range, range))
.setRolls(range < 0 ? ConstantValue.exactly(1) : UniformGenerator.between(-range, range))
.add(LootItem.lootTableItem(HexItems.SCROLL_LARGE))
.apply(() -> new AddPerWorldPatternToScrollFunc(new LootItemCondition[0]));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 1.20.1 2025-01-23T15:52:03.6220728 Global Loot Modifiers : hexcasting
ff299d5fca3672c5ca0684cf9db095de2bae279f data/forge/loot_modifiers/global_loot_modifiers.json
// 1.20.1 2024-12-11T19:01:35.255688 Global Loot Modifiers : hexcasting
aea957ba78a93cace2c9959df83ed396b66d732f data/forge/loot_modifiers/global_loot_modifiers.json
28ca895a27221312c2451f26646111a68aadbf6c data/hexcasting/loot_modifiers/amethyst_cluster.json
5dd05e6f8f0e406b529bc209b393410553584fdf data/hexcasting/loot_modifiers/cypher/hexcasting/random_cypher.json
009da1f70c3aaaa4f8474eb08217821638d8c02c data/hexcasting/loot_modifiers/cypher/minecraft/chests/abandoned_mineshaft.json
27481d7099d4914cd97e4ed7da8fd69327bb376a data/hexcasting/loot_modifiers/cypher/minecraft/chests/ancient_city.json
9cc4deb22f8d70d600587a48f2a1243a8040cb94 data/hexcasting/loot_modifiers/cypher/minecraft/chests/desert_pyramid.json
Expand All @@ -18,6 +19,7 @@ d1b282c57a8f5d1a37f3b87fbdba408b2a1b1415 data/hexcasting/loot_modifiers/lore/min
e52b9cba9d685a2ca7ea7db629c7c0990f12be26 data/hexcasting/loot_modifiers/lore/minecraft/chests/village/village_snowy_house.json
a59a9c55b02b76c0e3f6a2ee4fa7bcf3ab538595 data/hexcasting/loot_modifiers/lore/minecraft/chests/village/village_taiga_house.json
348688be7af2a3ea62c605428c958e62e449252d data/hexcasting/loot_modifiers/lore/minecraft/chests/woodland_mansion.json
479260c4206a3f664f5077a7c43e3ac93e3fdc87 data/hexcasting/loot_modifiers/scroll/hexcasting/random_scroll.json
a89a9e3113b83c6eb978f101aad42a6b37e7c1d8 data/hexcasting/loot_modifiers/scroll/minecraft/chests/abandoned_mineshaft.json
bfac0ff9e84cd974ccfb47edc9dce78476470103 data/hexcasting/loot_modifiers/scroll/minecraft/chests/ancient_city.json
0fcb299789a1b0162ab81a025a06b1aab5eb504b data/hexcasting/loot_modifiers/scroll/minecraft/chests/bastion_other.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
"hexcasting:lore/minecraft/chests/stronghold_library",
"hexcasting:scroll/minecraft/chests/bastion_other",
"hexcasting:lore/minecraft/chests/woodland_mansion",
"hexcasting:scroll/hexcasting/random_scroll",
"hexcasting:lore/minecraft/chests/village/village_desert_house",
"hexcasting:scroll/minecraft/chests/end_city_treasure",
"hexcasting:scroll/minecraft/chests/jungle_temple",
"hexcasting:scroll/minecraft/chests/bastion_treasure",
"hexcasting:cypher/hexcasting/random_cypher",
"hexcasting:lore/minecraft/chests/village/village_savanna_house",
"hexcasting:scroll/minecraft/chests/pillager_outpost",
"hexcasting:scroll/minecraft/chests/desert_pyramid",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "hexcasting:inject_cyphers",
"chance": 1.0,
"conditions": [
{
"condition": "forge:loot_table_id",
"loot_table_id": "hexcasting:random_cypher"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "hexcasting:inject_scrolls",
"conditions": [
{
"condition": "forge:loot_table_id",
"loot_table_id": "hexcasting:random_scroll"
}
],
"countRange": -1
}
20 changes: 15 additions & 5 deletions Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static class Client implements HexConfig.ClientConfigAccess {
private static ForgeConfigSpec.BooleanValue invertAbacusScrollDirection;
private static ForgeConfigSpec.DoubleValue gridSnapThreshold;
private static ForgeConfigSpec.BooleanValue clickingTogglesDrawing;
private static ForgeConfigSpec.BooleanValue alwaysShowListCommas;

public Client(ForgeConfigSpec.Builder builder) {
ctrlTogglesOffStrokeOrder = builder.comment(
Expand All @@ -103,6 +104,9 @@ public Client(ForgeConfigSpec.Builder builder) {
clickingTogglesDrawing = builder.comment(
"Whether you click to start and stop drawing instead of clicking and dragging")
.define("clickingTogglesDrawing", DEFAULT_CLICKING_TOGGLES_DRAWING);
alwaysShowListCommas = builder.comment(
"Whether all iota types should be comma-separated in lists (by default, pattern iotas don't use commas)")
.define("alwaysShowListCommas", DEFAULT_ALWAYS_SHOW_LIST_COMMAS);
}

@Override
Expand All @@ -129,6 +133,11 @@ public double gridSnapThreshold() {
public boolean clickingTogglesDrawing() {
return clickingTogglesDrawing.get();
}

@Override
public boolean alwaysShowListCommas() {
return alwaysShowListCommas.get();
}
}

public static class Server implements HexConfig.ServerConfigAccess {
Expand All @@ -141,10 +150,7 @@ public static class Server implements HexConfig.ServerConfigAccess {
private static ForgeConfigSpec.ConfigValue<List<? extends String>> tpDimDenyList;
private static ForgeConfigSpec.BooleanValue doesTrueNameHaveAmbit;
private static ForgeConfigSpec.DoubleValue traderScrollChance;

private static ForgeConfigSpec.ConfigValue<List<? extends String>> fewScrollTables;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> someScrollTables;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> manyScrollTables;
// scroll/lore/cypher pools and chances should go here


public Server(ForgeConfigSpec.Builder builder) {
Expand Down Expand Up @@ -172,6 +178,10 @@ public Server(ForgeConfigSpec.Builder builder) {
traderScrollChance = builder.comment("The chance for wandering traders to sell an Ancient Scroll")
.defineInRange("traderScrollChance", DEFAULT_TRADER_SCROLL_CHANCE, 0.0, 1.0);

// builders for scroll/lore/cypher pools and chances should go here

builder.pop();

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 All @@ -184,7 +194,7 @@ public Server(ForgeConfigSpec.Builder builder) {
.defineList("tpDimDenyList", DEFAULT_DIM_TP_DENYLIST, Server::isValidReslocArg);

doesTrueNameHaveAmbit = builder.comment(
"when false makes player reference iotas behave as normal entity reference iotas")
"When false, makes player reference iotas behave as normal entity reference iotas")
.define("doesTrueNameHaveAmbit", DEFAULT_TRUE_NAME_HAS_AMBIT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
import net.minecraftforge.common.data.GlobalLootModifierProvider;
import net.minecraftforge.common.loot.LootTableIdCondition;

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

public class ForgeHexLootModGen extends GlobalLootModifierProvider {
public static final ResourceLocation RANDOM_SCROLL_TABLE = modLoc("random_scroll");
public static final ResourceLocation RANDOM_CYPHER_TABLE = modLoc("random_cypher");

public ForgeHexLootModGen(PackOutput output) {
super(output, HexAPI.MOD_ID);
}
Expand Down Expand Up @@ -41,6 +46,14 @@ protected void start() {
}, HexLootHandler.DEFAULT_CYPHER_CHANCE));
}

add("scroll/hexcasting/random_scroll", new ForgeHexScrollLootMod(new LootItemCondition[]{
LootTableIdCondition.builder(RANDOM_SCROLL_TABLE).build()
}, -1)); // -1 weight = guaranteed spawn

add("cypher/hexcasting/random_cypher", new ForgeHexCypherLootMod(new LootItemCondition[]{
LootTableIdCondition.builder(RANDOM_CYPHER_TABLE).build()
}, 1)); // 1 chance = guaranteed spawn

add("amethyst_cluster", new ForgeHexAmethystLootMod(new LootItemCondition[]{
LootTableIdCondition.builder(Blocks.AMETHYST_CLUSTER.getLootTable()).build()
}, HexLootHandler.DEFAULT_SHARD_MODIFICATION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ForgeHexScrollLootMod(LootItemCondition[] conditionsIn, int countRange) {
@Override
protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot,
LootContext context) {
int count = HexLootHandler.getScrollCount(this.countRange, context.getRandom());
var count = this.countRange < 0 ? 1 : HexLootHandler.getScrollCount(this.countRange, context.getRandom());
for (int i = 0; i < count; i++) {
var newStack = new ItemStack(HexItems.SCROLL_LARGE);
AddPerWorldPatternToScrollFunc.doStatic(newStack, context.getRandom(), context.getLevel().getServer().overworld());
Expand Down
Loading