Skip to content

Commit

Permalink
more cleanup and translations
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Sep 13, 2021
1 parent 8b8eb29 commit 49cd3d9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ cloth_version=5.0.38
modmenu_version=2.0.10

# publishing
modrinth_id=0
modrinth_id=9QyjzbTh
modrinth_game_versions=1.17.1
api_package=dev.upcraft.soulbound.api
32 changes: 15 additions & 17 deletions src/main/java/dev/upcraft/soulbound/compat/TrinketsIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@
@SuppressWarnings("unused") // called by reflection
public class TrinketsIntegration {

static {
register();
}

private static void register() {
TrinketDropCallback.EVENT.register((rule, stack, ref, entity) -> {
if (SoulboundHooks.shouldKeepStack(stack, entity.getRandom())) {
@Nullable SoulboundContainer container = DUMMY_PROVIDER.getContainer(entity);
if (container != null && !SoulboundHooks.createItemProcessor(container).apply(stack).isEmpty()) {
return TrinketEnums.DropRule.KEEP;
}
}
return TrinketEnums.DropRule.DEFAULT;
});
Registry.register(SoulboundApi.CONTAINERS, new Identifier(Soulbound.MODID, "trinkets_integration"), DUMMY_PROVIDER);
}

public static final SoulboundContainerProvider<SoulboundContainer> DUMMY_PROVIDER = entity -> {
TrinketComponent component = TrinketsApi.getTrinketComponent(entity).orElse(null);
return component != null ? new SoulboundContainer() {
Expand All @@ -63,5 +46,20 @@ public void restoreFromNbt(NbtCompound nbt, UnaryOperator<ItemStack> itemProcess
} : null;
};

static {
register();
}

private static void register() {
TrinketDropCallback.EVENT.register((rule, stack, ref, entity) -> {
if (SoulboundHooks.shouldKeepStack(stack, entity.getRandom())) {
@Nullable SoulboundContainer container = DUMMY_PROVIDER.getContainer(entity);
if (container != null && !SoulboundHooks.createItemProcessor(container).apply(stack).isEmpty()) {
return TrinketEnums.DropRule.KEEP;
}
}
return TrinketEnums.DropRule.DEFAULT;
});
Registry.register(SoulboundApi.CONTAINERS, new Identifier(Soulbound.MODID, "trinkets_integration"), DUMMY_PROVIDER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import dev.upcraft.soulbound.Soulbound;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import net.minecraft.util.math.MathHelper;

@me.shedaniel.autoconfig.annotation.Config(name = Soulbound.MODID)
@Config(name = Soulbound.MODID)
public class SoulboundConfig implements ConfigData {

public double soulboundPreservationRate = 1.0F;
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/assets/soulbound/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"enchantment.soulbound.soulbound": "Soulbound"
}
"enchantment.soulbound.soulbound": "Soulbound",
"enchantment.soulbound.soulbound.desc": "Retains items upon death",
"text.autoconfig.soulbound.option.soulboundPreservationRate": "Soulbound Enchantment Preservation Rate",
"text.autoconfig.soulbound.option.soulboundDropChance": "Item Drop Chance"
}

0 comments on commit 49cd3d9

Please sign in to comment.