Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ minecraft_version=1.18.2
yarn_mappings=1.18.2+build.1
loader_version=0.13.3
# Mod Properties
mod_version=1.0.22
mod_version=1.0.23
maven_group=com.glisco
archives_base_name=conjuring
# Dependencies
fabric_version=0.47.8+1.18.2
fabric_version=0.55.1+1.18.2

# https://maven.blamejared.com/vazkii/patchouli/Patchouli/
patchouli_version=1.18.2-66-FABRIC
Expand All @@ -23,4 +23,4 @@ rei_version=8.0.438
modmenu_version=3.0.1

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.5.4+1.18
owo_version=0.5.4+1.18
37 changes: 26 additions & 11 deletions src/main/java/com/glisco/conjuring/Conjuring.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.fabric.api.object.builder.v1.advancement.CriterionRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
Expand All @@ -35,8 +35,13 @@
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.condition.InvertedLootCondition;
import net.minecraft.loot.condition.MatchToolLootCondition;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.function.ApplyBonusLootFunction;
import net.minecraft.predicate.NumberRange;
import net.minecraft.predicate.item.EnchantmentPredicate;
import net.minecraft.predicate.item.ItemPredicate;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -128,16 +133,26 @@ public void onInitialize() {

Registry.register(Registry.SOUND_EVENT, Conjuring.id("block.soul_weaver.weee"), WEEE);

if (CONFIG.conjurer_config.fortuneEnabled) {
LootTableLoadingCallback.EVENT.register((resourceManager, manager, id, supplier, setter) -> {
if (!new Identifier("blocks/spawner").equals(id)) return;
supplier.withPool(LootPool.builder().with(
ItemEntry.builder(ConjuringItems.CONJURATION_ESSENCE).apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE)))
.build());
});
} else {
LootOps.injectItem(ConjuringItems.CONJURATION_ESSENCE, 1, new Identifier("blocks/spawner"));
}
final var spawnerLootTableId = new Identifier("blocks/spawner");
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> {
if (!spawnerLootTableId.equals(id)) return;

var itemEntry = ItemEntry.builder(ConjuringItems.CONJURATION_ESSENCE);
if (CONFIG.conjurer_config.fortuneEnabled) {
itemEntry.apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE));
}

if (CONFIG.conjurer_config.respectSilkTouch) {
itemEntry.conditionally(InvertedLootCondition.builder(
MatchToolLootCondition.builder(ItemPredicate.Builder.create().enchantment(
new EnchantmentPredicate(Enchantments.SILK_TOUCH, NumberRange.IntRange.atLeast(1))
)))
);
}

tableBuilder.pool(LootPool.builder().with(itemEntry).build());
});


LootOps.injectItem(ConjuringItems.CONJURATION_ESSENCE, .35f, LootTables.SIMPLE_DUNGEON_CHEST);
LootOps.injectItem(ConjuringItems.CONJURATION_ESSENCE, .175f, LootTables.BASTION_TREASURE_CHEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public ConjuringConfig() {
public ToolsConfig tools_config = new ToolsConfig();

public static class ConjurerConfig {
@ConfigEntry.Gui.RequiresRestart
@Comment("Whether Fortune should affect the amount of Conjuration Essence you can get when breaking a spawner")
public boolean fortuneEnabled = false;

@Comment("Whether Conjuration Essence should only drop from spawners that were mined without Silk Touch")
public boolean respectSilkTouch = false;

@Comment("How many extra mobs to spawn per abundance charm")
public int abundance_multiplier = 2;

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/conjuring/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@

"text.autoconfig.conjuring.option.conjurer_config": "Conjurer",
"text.autoconfig.conjuring.option.conjurer_config.fortuneEnabled": "Fortune Enabled",
"text.autoconfig.conjuring.option.conjurer_config.respectSilkTouch": "Respect Silk Touch",
"text.autoconfig.conjuring.option.conjurer_config.abundance_multiplier": "Abundance Multiplier",
"text.autoconfig.conjuring.option.conjurer_config.haste_multiplier": "Haste Multiplier",
"text.autoconfig.conjuring.option.conjurer_config.scope_multiplier": "Scope Multiplier",
Expand Down