Skip to content

Commit

Permalink
## [1.0.4] - 2024-09-25
Browse files Browse the repository at this point in the history
### Fixed
- Fixed crash when dying with GPS equipped in Curio/Trinket/Accessories slot.
  • Loading branch information
lanAnderson committed Sep 26, 2024
1 parent 1a5f292 commit ecb14a4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [1.0.4] - 2024-09-25

### Fixed
- Fixed crash when dying with GPS equipped in Curio/Trinket/Accessories slot.

## [1.0.3] - 2024-09-22

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ private static boolean findCurio(Player player, Item item) {
return false;
}

int slot = 0;

if (PocketGps.curiosLoaded()) {
Optional<TrinketComponent> curiosInventory = TrinketsApi.getTrinketComponent(player);
if (curiosInventory.isPresent()) {
if (curiosInventory.get().isEquipped(item)) {
slot += 1;
}
Optional<TrinketComponent> trinketInventory = TrinketsApi.getTrinketComponent(player);
if (trinketInventory.isPresent()) {
return trinketInventory.get().isEquipped(item);
}
}
return slot > 0;
return false;
}

public static void register() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import club.iananderson.pocketgps.forge.registry.ForgeRegistration;
import club.iananderson.pocketgps.minimap.CurrentMinimap;
import io.wispforest.accessories.api.AccessoriesCapability;
import io.wispforest.accessories.api.AccessoriesContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import java.util.Optional;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraftforge.api.distmarker.Dist;
Expand All @@ -25,19 +23,21 @@ private static boolean findCurio(Player player, Item item) {
return false;
}

int slot = 0;

if (PocketGps.curiosLoaded()) {
ICuriosItemHandler curiosInventory = CuriosApi.getCuriosInventory(player).resolve().get();
if (curiosInventory.findFirstCurio(item).isPresent()) {
slot += 1;
Optional<ICuriosItemHandler> curiosInventory = CuriosApi.getCuriosInventory(player).resolve();
if (curiosInventory.isPresent()) {
return curiosInventory.get().isEquipped(item);
}
}

if (PocketGps.accessoriesLoaded() && !PocketGps.curiosLoaded()) {
AccessoriesContainer accessoriesContainer = AccessoriesCapability.get(player).getContainers().get("gps_slot");
slot += accessoriesContainer.getAccessories().countItem(item);
Optional<AccessoriesCapability> accessoriesInventory = AccessoriesCapability.getOptionally(player);
if (accessoriesInventory.isPresent()) {

return accessoriesInventory.get().isEquipped(item);
}
}
return slot > 0;
return false;
}

@SubscribeEvent
Expand All @@ -48,7 +48,7 @@ public static void onPlayerTickEvent(PlayerTickEvent event) {
boolean hasGpsInv = CurrentMinimap.hasGps(player, ForgeRegistration.POCKET_GPS.get());
boolean hasGpsCurio = findCurio(player, ForgeRegistration.POCKET_GPS.get());

CurrentMinimap.displayMinimap(player,hasGpsInv || hasGpsCurio);
CurrentMinimap.displayMinimap(player, hasGpsInv || hasGpsCurio);
}
}
}

0 comments on commit ecb14a4

Please sign in to comment.