Skip to content

Commit

Permalink
cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Raycoms committed Dec 19, 2024
1 parent 0a4cf2b commit 34f683c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

/**
Expand Down Expand Up @@ -90,7 +89,6 @@ public boolean displayHat(final AbstractEntityCitizen citizen)
{
return false;
}

return citizen.getCitizenDataView() == null || (citizen.getCitizenDataView().getDisplayArmor(EquipmentSlot.HEAD).isEmpty() && citizen.getCitizenDataView().getCustomTextureUUID() == null);
}
}
19 changes: 8 additions & 11 deletions src/main/java/com/minecolonies/core/colony/CitizenDataView.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class CitizenDataView implements ICitizenDataView
/**
* Santa Hat.
*/
private static ItemStack displaySantaHat = null;
private static ItemStack cachedDisplaySantaHat = null;

private static final String TAG_HELD_ITEM_SLOT = "HeldItemSlot";

Expand Down Expand Up @@ -630,27 +630,24 @@ public boolean equals(final Object o)
@Override
public ItemStack getDisplayArmor(final EquipmentSlot equipmentSlot)
{
if (displaySantaHat == null)
if (cachedDisplaySantaHat == null)
{
if (MineColonies.getConfig().getServer().holidayFeatures.get() && LocalDate.now(Clock.systemDefaultZone()).getMonth() == Month.DECEMBER)
{
displaySantaHat = new ItemStack(ModItems.santaHat);
cachedDisplaySantaHat = new ItemStack(ModItems.santaHat);
}
else
{
displaySantaHat = ItemStack.EMPTY;
cachedDisplaySantaHat = ItemStack.EMPTY;
}
}

final ItemStack currentHat = getInventory().getArmorInSlot(equipmentSlot);
if (!currentHat.isEmpty())
if (currentHat.isEmpty() && cachedDisplaySantaHat != null && cachedDisplaySantaHat != ItemStack.EMPTY && equipmentSlot == EquipmentSlot.HEAD)
{
return currentHat;
return cachedDisplaySantaHat;
}
if (displaySantaHat != ItemStack.EMPTY && equipmentSlot == EquipmentSlot.HEAD)
{
return displaySantaHat;
}
return getInventory().getArmorInSlot(equipmentSlot);

return currentHat;
}
}

0 comments on commit 34f683c

Please sign in to comment.