Skip to content

Commit

Permalink
Fix mob item overrides registry loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Jun 15, 2024
1 parent 55ade71 commit 715c728
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/main/java/ladysnake/requiem/common/RequiemRegistries.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@
@API(status = EXPERIMENTAL)
public final class RequiemRegistries {

public static final RegistryKey<Registry<PossessionItemAction>> MOB_ACTIONS_KEY = RegistryKey.ofRegistry(Requiem.id("mob_actions"));
public static final SimpleRegistry<PossessionItemAction> MOB_ACTIONS =
FabricRegistryBuilder.createSimple(PossessionItemAction.class, Requiem.id("mob_actions")).buildAndRegister();
FabricRegistryBuilder.createSimple(MOB_ACTIONS_KEY).buildAndRegister();
public static final RegistryKey<Registry<RemnantType>> REMNANT_STATES_KEY = RegistryKey.ofRegistry(Requiem.id("remnant_states"));
public static final DefaultedRegistry<RemnantType> REMNANT_STATES =
FabricRegistryBuilder.createDefaulted(RemnantType.class, Requiem.id("remnant_states"), new Identifier(RemnantState.NULL_STATE_ID))
FabricRegistryBuilder.createDefaulted(REMNANT_STATES_KEY, new Identifier(RemnantState.NULL_STATE_ID))
.attribute(RegistryAttribute.SYNCED)
.buildAndRegister();

public static final RegistryKey<Registry<PossessionItemOverrideWrapper>> MOB_ITEM_OVERRIDE_KEY = RegistryKey.ofRegistry(Requiem.id("requiem/mob_items"));
public static final RegistryKey<Registry<PossessionItemOverrideWrapper>> MOB_ITEM_OVERRIDE_KEY = RegistryKey.ofRegistry(Requiem.id("mob_items"));

public static void init() {
Registry.register(REMNANT_STATES, new Identifier(RemnantState.NULL_STATE_ID), RemnantTypes.MORTAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;

public record PossessionItemOverrideWrapper(
int priority,
Expand Down Expand Up @@ -138,7 +137,7 @@ public static Optional<TypedActionResult<ItemStack>> tryFinishUsingOverride(Worl

public static Optional<InstancedItemOverride> findOverride(World world, PlayerEntity player, MobEntity possessedEntity, ItemStack heldStack) {
Optional<InstancedItemOverride> fallback = Optional.empty();
for (PossessionItemOverrideWrapper wrapper : world.getRegistryManager().get(RequiemRegistries.MOB_ITEM_OVERRIDE_KEY).stream().sorted().collect(Collectors.toList())) {
for (PossessionItemOverrideWrapper wrapper : world.getRegistryManager().get(RequiemRegistries.MOB_ITEM_OVERRIDE_KEY).stream().sorted().toList()) {
Optional<InstancedItemOverride> tested = wrapper.test(player, possessedEntity, heldStack);
if (tested.isPresent()) {
if (tested.get().shortCircuits()) {
Expand All @@ -153,7 +152,7 @@ public static Optional<InstancedItemOverride> findOverride(World world, PlayerEn

public static List<Text> buildTooltip(World world, PlayerEntity player, MobEntity possessedEntity, ItemStack heldStack) {
List<Text> lines = new ArrayList<>();
for (PossessionItemOverrideWrapper wrapper : world.getRegistryManager().get(RequiemRegistries.MOB_ITEM_OVERRIDE_KEY).stream().sorted().collect(Collectors.toList())) {
for (PossessionItemOverrideWrapper wrapper : world.getRegistryManager().get(RequiemRegistries.MOB_ITEM_OVERRIDE_KEY).stream().sorted().toList()) {
Optional<InstancedItemOverride> tested = wrapper.test(player, possessedEntity, heldStack);
if (tested.isPresent()) {
InstancedItemOverride override = tested.get();
Expand Down

0 comments on commit 715c728

Please sign in to comment.