Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/need-branch-for-this-methinks' i…
Browse files Browse the repository at this point in the history
…nto need-branch-for-this-methinks
  • Loading branch information
enjarai committed Nov 8, 2024
2 parents c67b28c + af11d66 commit 919f484
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/main/java/dev/enjarai/trickster/ModLoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
import net.minecraft.registry.RegistryKey;

public class ModLoot {
private static final Set<RegistryKey<LootTable>> UNSTABLE_SPELL_CORE_LOOT_TABLES = Set.of(
private static final Set<RegistryKey<LootTable>> RUSTED_SPELL_CORE_LOOT_TABLES = Set.of(
LootTables.SIMPLE_DUNGEON_CHEST, LootTables.ABANDONED_MINESHAFT_CHEST, LootTables.ANCIENT_CITY_CHEST,
LootTables.BASTION_TREASURE_CHEST, LootTables.DESERT_PYRAMID_CHEST, LootTables.JUNGLE_TEMPLE_CHEST,
LootTables.END_CITY_TREASURE_CHEST, LootTables.STRONGHOLD_CORRIDOR_CHEST, LootTables.STRONGHOLD_CROSSING_CHEST
);

public static void register() {
LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> {
if (UNSTABLE_SPELL_CORE_LOOT_TABLES.contains(key)) {
if (RUSTED_SPELL_CORE_LOOT_TABLES.contains(key)) {
tableBuilder.pool(LootPool.builder()
.with(ItemEntry.builder(ModItems.UNSTABLE_SPELL_CORE)
.with(ItemEntry.builder(ModItems.RUSTED_SPELL_CORE)
.conditionally(RandomChanceLootCondition.builder(0.25f)))
.rolls(UniformLootNumberProvider.create(0, 2))).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void generateItemModels(ItemModelGenerator itemModelGenerator) {
itemModelGenerator.register(ModItems.DIAMOND_MANA_CRYSTAL, Models.GENERATED);
itemModelGenerator.register(ModItems.ECHO_MANA_CRYSTAL, Models.GENERATED);
itemModelGenerator.register(ModItems.SPELL_CORE, Models.GENERATED);
itemModelGenerator.register(ModItems.UNSTABLE_SPELL_CORE, Models.GENERATED);
itemModelGenerator.register(ModItems.RUSTED_SPELL_CORE, Models.GENERATED);

ModItems.DYED_VARIANTS.forEach(v -> {
itemModelGenerator.register(v.variant(), Models.GENERATED);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/enjarai/trickster/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class ModItems {
new FoodComponent.StatusEffectEntry(new StatusEffectInstance(StatusEffects.GLOWING, 60 * 20), 1),
new FoodComponent.StatusEffectEntry(new StatusEffectInstance(StatusEffects.BLINDNESS, 60 * 20), 1))))));
public static final SpellCoreItem SPELL_CORE = register("spell_core", new SpellCoreItem());
public static final UnstableSpellCoreItem UNSTABLE_SPELL_CORE = register("unstable_spell_core", new UnstableSpellCoreItem());
public static final RustedSpellCoreItem RUSTED_SPELL_CORE = register("rusted_spell_core", new RustedSpellCoreItem());
public static final BlockItem SPELL_RESONATOR_BLOCK_ITEM = register("spell_resonator", new BlockItem(ModBlocks.SPELL_RESONATOR, new Item.Settings()));
public static final BlockItem SPELL_CIRCLE_BLOCK_ITEM = register("spell_circle", new BlockItem(ModBlocks.SPELL_CIRCLE, new Item.Settings()));
public static final BlockItem MULTI_SPELL_CIRCLE_BLOCK_ITEM = register("multi_spell_circle", new BlockItem(ModBlocks.MULTI_SPELL_CIRCLE, new Item.Settings()));
Expand Down Expand Up @@ -129,7 +129,7 @@ public class ModItems {
entries.add(SPELL_CIRCLE_BLOCK_ITEM);
entries.add(MULTI_SPELL_CIRCLE_BLOCK_ITEM);
entries.add(SPELL_CORE);
entries.add(UNSTABLE_SPELL_CORE);
entries.add(RUSTED_SPELL_CORE);
entries.add(AMETHYST_MANA_CRYSTAL);
entries.add(EMERALD_MANA_CRYSTAL);
entries.add(DIAMOND_MANA_CRYSTAL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package dev.enjarai.trickster.item;

import java.util.List;

import dev.enjarai.trickster.Trickster;
import dev.enjarai.trickster.item.component.ModComponents;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World.ExplosionSourceType;

public class UnstableSpellCoreItem extends SpellCoreItem {
public class RustedSpellCoreItem extends SpellCoreItem {
@Override
public int getExecutionBonus() {
return (int) Math.ceil(0.25 * Trickster.CONFIG.maxExecutionsPerSpellPerTick());
Expand All @@ -24,4 +30,9 @@ public boolean onRemoved(ServerWorld world, BlockPos pos, ItemStack stack) {

return false;
}

@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
tooltip.add(Text.literal("CAUTION: DO NOT DISCONNECT WHILE RUNNING").setStyle(Style.EMPTY.withItalic(true).withColor(Formatting.RED)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,32 @@ public Fragment activate(SpellContext ctx, List<Fragment> fragments) throws Blun

throw new MissingItemBlunder(this);
});
var glass = ctx.getStack(
this,
supposeInput(fragments, FragmentType.SLOT, 1),
(item) -> item.equals(Items.GLASS)
).orElseThrow(() -> new MissingItemBlunder(this));
var sourceItem = sourceSlot.getItem(this, ctx);
var type = types.get(sourceItem);

if (type == null) {
throw new ItemInvalidBlunder(this);
}

ctx.useMana(this, type.getCreationCost());
try {
var input = sourceSlot.move(this, ctx, 1);

sourceSlot.move(this, ctx, 1);
ctx.source().offerOrDropItem(type.createStack());

//TODO: smth else?
return VoidFragment.INSTANCE;
try {
ctx.useMana(this, type.getCreationCost());
ctx.source().offerOrDropItem(type.createStack());
return VoidFragment.INSTANCE;
} catch (Exception e) {
ctx.source().offerOrDropItem(input);
throw e;
}
} catch (Exception e) {
ctx.source().offerOrDropItem(glass);
throw e;
}
}
}

0 comments on commit 919f484

Please sign in to comment.