Skip to content

Commit

Permalink
Fix colony banners not being able to render if a flag was scanned in …
Browse files Browse the repository at this point in the history
…inside a colony (#10226)

When a colony banner is scanned in inside of a colony it already gets assigned a colony ID in the tile entity, causing them to, upon placement, no longer update their actual colony ID. Causing them to render the wrong or a nonexistent banner. Removed this condition so banners will always re-check the colony they are in upon placement.
Updated code to current day code style
  • Loading branch information
Thodor12 authored Oct 22, 2024
1 parent fe0d94e commit 02b51fb
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,27 @@ public BlockEntity newBlockEntity(@NotNull final BlockPos blockPos, @NotNull fin
@Override
public void setPlacedBy(final Level worldIn, final @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack)
{
if (worldIn.isClientSide) return;
if (worldIn.isClientSide)
{
return;
}

BlockEntity te = worldIn.getBlockEntity(pos);
if (te instanceof TileEntityColonyFlag && ((TileEntityColonyFlag) te).colonyId == -1 )
if (te instanceof TileEntityColonyFlag flagTileEntity)
{
IColony colony = IColonyManager.getInstance().getIColony(worldIn, pos);

// Allow the player to place their own beyond the colony
if (colony == null && placer instanceof Player)
{
colony = IColonyManager.getInstance().getIColonyByOwner(worldIn, (Player) placer);
}

if (colony != null)
((TileEntityColonyFlag) te).colonyId = colony.getID();
{
flagTileEntity.colonyId = colony.getID();
}
}

}

@NotNull
Expand Down

0 comments on commit 02b51fb

Please sign in to comment.