Skip to content

Commit

Permalink
Merge pull request #264 from FTBTeam/1.19/dev
Browse files Browse the repository at this point in the history
1.19/dev
  • Loading branch information
desht authored Aug 29, 2023
2 parents 84e7a53 + 4e4fd27 commit c139121
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ 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.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1902.4.2]

### Fixes
* Fixed "Show waypoints in world" client config setting being ignored for waypoint icons
* It was only working to suppress beacons when set to false, now it suppresses icons too
* Fixed NPE when checking for fake players which had a null name or UUID in their GameProfile
* Client memory fix; eliminated some unnecessary region data loading when players change chunk settings (claiming, forceloading)

## [1902.4.1]

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ public void renderHud(PoseStack matrixStack, float tickDelta) {

RenderSystem.enableDepthTest();

if (worldMatrix != null) {
if (worldMatrix != null && FTBChunksClientConfig.IN_WORLD_WAYPOINTS.get()) {
drawInWorldIcons(mc, matrixStack, tickDelta, playerX, playerY, playerZ, scaledWidth, scaledHeight);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ public MapChunk getOrCreateMapChunk(XZ xz) {
return chunks.computeIfAbsent(xz, p -> new MapChunk(this, p).created());
}

public MapChunk getChunkForAbsoluteChunkPos(XZ pos) {
XZ effectivePos = pos.x != (pos.x & 31) || pos.z != (pos.z & 31) ?
XZ.of(pos.x & 31, pos.z & 31) :
pos;

synchronized (dimension.manager.lock) {
return getOrCreateMapChunk(effectivePos);
}
}

public void addMapChunk(MapChunk mapChunk) {
chunks.put(mapChunk.pos, mapChunk);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,29 @@
* @author LatvianModder
*/
public class MapRegionData {
// WLLLLBBB BBBBBBBB - waterLightAndBiome
// W - Water (x & 1) << 15
// L - Light (x & 15) << 11
// B - Biome (x & 0b111_11111111)

public final MapRegion region;

// a region is a 512x512 block area

// 16 bits per block pos; the height of the highest non-air block
public final short[] height = new short[512 * 512];

// WLLLLBBB BBBBBBBB - waterLightAndBiome is packed into a 16-bit short
// W - Water - 1 bit (water/no water) - (x & 1) << 15
// L - Light - 4 bits (16 light levels) - (x & 15) << 11
// B - Biome - 11 bits (2048 possible biomes) - (x & 0b111_11111111)
public final short[] waterLightAndBiome = new short[512 * 512];

// top 8 bits are bits 16-23 of the block index
// bottom 24 bits are the biome-tinted RGB of foliage
public final int[] foliage = new int[512 * 512];

// top 8 bits are bits 8-15 of the block index
// bottom 24 bits are the biome-tinted RGB of grass
public final int[] grass = new int[512 * 512];

// top 8 bits are bits 0-7 of the block index
// bottom 24 bits are the biome-tinted RGB of water
public final int[] water = new int[512 * 512];

public MapRegionData(MapRegion r) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public UpdateChunkFromServerTask(MapDimension d, SendChunkPacket.SingleChunk c,

@Override
public void runMapTask() {
dimension.getRegion(XZ.regionFromChunk(chunk.x, chunk.z)).getDataBlocking().getChunk(XZ.of(chunk.x, chunk.z)).updateFrom(now, chunk, teamId);
dimension.getRegion(XZ.regionFromChunk(chunk.x, chunk.z)).getChunkForAbsoluteChunkPos(XZ.of(chunk.x, chunk.z)).updateFrom(now, chunk, teamId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.ftb.mods.ftbchunks.data;

import com.mojang.authlib.GameProfile;
import dev.architectury.hooks.level.entity.PlayerHooks;
import dev.ftb.mods.ftbchunks.FTBChunks;
import dev.ftb.mods.ftbchunks.FTBChunksExpected;
Expand Down Expand Up @@ -304,16 +305,19 @@ private boolean canFakePlayerUse(Player player, PrivacyMode mode) {

boolean checkById = team.getProperty(FTBChunksTeamData.ALLOW_FAKE_PLAYERS_BY_ID) && player.getUUID() != null;
if (mode == PrivacyMode.ALLIES) {
return checkById && isAlly(player.getUUID())
|| getCachedFakePlayerNames().contains(player.getGameProfile().getName().toLowerCase(Locale.ROOT))
|| getCachedFakePlayerNames().contains(player.getGameProfile().getId().toString().toLowerCase(Locale.ROOT));
return checkById && isAlly(player.getUUID()) || fakePlayerMatches(player.getGameProfile());
} else if (mode == PrivacyMode.PRIVATE) {
return checkById && team.isMember(player.getUUID());
}

return false;
}

private boolean fakePlayerMatches(GameProfile profile) {
return profile.getName() != null && getCachedFakePlayerNames().contains(profile.getName().toLowerCase(Locale.ROOT))
|| profile.getId() != null && getCachedFakePlayerNames().contains(profile.getId().toString().toLowerCase(Locale.ROOT));
}

private Set<String> getCachedFakePlayerNames() {
if (fakePlayerNameCache == null) {
fakePlayerNameCache = team.getProperty(FTBChunksTeamData.ALLOW_NAMED_FAKE_PLAYERS).stream()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false
mod_id=ftbchunks
archives_base_name=ftb-chunks
maven_group=dev.ftb.mods
mod_version=1902.4.1
mod_version=1902.4.2
mod_author=FTB Team
minecraft_version=1.19.2
forge_version=43.2.8
Expand Down

0 comments on commit c139121

Please sign in to comment.