Skip to content

Commit

Permalink
Merge pull request #265 from FTBTeam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
desht authored Aug 29, 2023
2 parents 4077037 + 4396ac1 commit 6440e2f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 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).

## [2001.2.1]

### 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)

## [2001.2.0]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ public void renderHud(GuiGraphics graphics, float tickDelta) {

RenderSystem.enableDepthTest();

if (worldMatrix != null) {
if (worldMatrix != null && FTBChunksClientConfig.IN_WORLD_WAYPOINTS.get()) {
drawInWorldIcons(mc, graphics, tickDelta, playerX, playerY, playerZ, scaledWidth, scaledHeight);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,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.getManager().lock) {
return getOrCreateMapChunk(effectivePos);
}
}

public void addMapChunk(MapChunk mapChunk) {
chunks.put(mapChunk.getPos(), mapChunk);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,29 @@
import java.util.zip.ZipOutputStream;

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 @@ -22,8 +22,7 @@ public UpdateChunkFromServerTask(MapDimension d, SendChunkPacket.SingleChunk c,
@Override
public void runMapTask() {
dimension.getRegion(XZ.regionFromChunk(chunk.getX(), chunk.getZ()))
.getDataBlocking()
.getChunk(XZ.of(chunk.getX(), chunk.getZ()))
.getChunkForAbsoluteChunkPos(XZ.of(chunk.getX(), chunk.getZ()))
.updateFromServer(now, chunk, teamId);
}

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 com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import dev.architectury.hooks.level.entity.PlayerHooks;
Expand Down Expand Up @@ -311,16 +312,19 @@ private boolean canFakePlayerUse(Player player, PrivacyMode mode) {

boolean checkById = team.getProperty(FTBChunksProperties.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.getRankForPlayer(player.getUUID()).isMemberOrBetter();
}

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(FTBChunksProperties.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=2001.2.0
mod_version=2001.2.1
mod_author=FTB Team

minecraft_version=1.20.1
Expand Down

0 comments on commit 6440e2f

Please sign in to comment.