Skip to content

Commit

Permalink
Hotfix building placement (#10165)
Browse files Browse the repository at this point in the history
Hotfix building placement
  • Loading branch information
Nightenom authored Aug 25, 2024
1 parent 8a3cc52 commit 74eef59
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public record ColonyId(int id, ResourceKey<Level> dimension)
ColonyId::id, ResourceKey.streamCodec(Registries.DIMENSION), ColonyId::dimension,
ColonyId::new);

public boolean hasColonyId()
{
return id != EMPTY.id;
}

public void writeToItemStack(final ItemStack itemStack)
{
itemStack.set(ModDataComponents.COLONY_ID_COMPONENT, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void render(final WorldEventContext ctx)
}

final ColonyId component = ColonyId.readFromItemStack(ctx.mainHandItem);
if (component.id() == -1 || component.dimension() != ctx.clientLevel.dimension())
if (!component.hasColonyId() || component.dimension() != ctx.clientLevel.dimension())
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void onExecute(final IPayloadContext ctxIn, final ServerPlayer player)
if ((colony == null && state.getBlock() == ModBlocks.blockHutTownHall) || (colony != null && colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)))
{
final ColonyId colonyId = ColonyId.readFromItemStack(stack);
if (colony != null && colonyId != null && colony.getID() != colonyId.id())
if (colony != null && colonyId.hasColonyId() && colony.getID() != colonyId.id())
{
MessageUtils.format(WRONG_COLONY, colonyId.id()).sendTo(player);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void handle(
final ItemStack inventoryStack = slot == -1 ? stack : player.getInventory().getItem(slot);

final ColonyId colonyComponent = ColonyId.readFromItemStack(stack);
if (colonyComponent != null && tempColony != null && tempColony.getID() != colonyComponent.id())
if (colonyComponent.hasColonyId() && tempColony != null && tempColony.getID() != colonyComponent.id())
{
MessageUtils.format(WRONG_COLONY, colonyComponent.id()).sendTo(player);
SoundUtils.playErrorSound(player, player.blockPosition());
Expand Down

0 comments on commit 74eef59

Please sign in to comment.