Skip to content

Commit

Permalink
Fix bug causing NPE's
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Apr 26, 2024
1 parent a016f1b commit c81a16b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fabric_version=0.95.6+1.20.5


# Mod Properties
mod_version = 3.3.0+1.20.5
mod_version = 3.3.1+1.20.5
maven_group = eu.pb4
archives_base_name = graves

Expand Down
15 changes: 11 additions & 4 deletions src/main/java/eu/pb4/graves/registry/GraveCompassItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
Expand Down Expand Up @@ -55,13 +56,14 @@ public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity pla
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (entity instanceof ServerPlayerEntity player && !stack.isEmpty()) {
if (stack.contains(GraveCompassComponent.TYPE)) {
var grave = GraveManager.INSTANCE.getId(stack.get(GraveCompassComponent.TYPE).graveId());
var compass = stack.get(GraveCompassComponent.TYPE);
var grave = GraveManager.INSTANCE.getId(compass.graveId());

if (grave == null) {
var count = stack.getCount();
stack.setCount(0);

if (stack.get(GraveCompassComponent.TYPE).convertToVanilla()) {
if (compass.convertToVanilla()) {
player.giveItemStack(new ItemStack(Items.COMPASS, count));
}
}
Expand All @@ -77,8 +79,13 @@ public void inventoryTick(ItemStack stack, World world, Entity entity, int slot,
}

@Override
public ItemStack getPolymerItemStack(ItemStack itemStack, TooltipType context, @Nullable ServerPlayerEntity player) {
var clientStack = PolymerItem.super.getPolymerItemStack(itemStack, context, player);
public boolean hasGlint(ItemStack stack) {
return true;
}

@Override
public ItemStack getPolymerItemStack(ItemStack itemStack, TooltipType context, RegistryWrapper.WrapperLookup lookup, @Nullable ServerPlayerEntity player) {
var clientStack = PolymerItem.super.getPolymerItemStack(itemStack, context, lookup, player);
if (player != null && itemStack.contains(GraveCompassComponent.TYPE)) {
var grave = GraveManager.INSTANCE.getId(itemStack.get(GraveCompassComponent.TYPE).graveId());
if (grave != null) {
Expand Down

0 comments on commit c81a16b

Please sign in to comment.