Skip to content

Commit

Permalink
Merge pull request #249 from FTBTeam/1.19/dev
Browse files Browse the repository at this point in the history
1.19/dev
  • Loading branch information
desht authored Apr 18, 2023
2 parents a21b088 + 9757c92 commit 32bea7d
Show file tree
Hide file tree
Showing 62 changed files with 940 additions and 206 deletions.
39 changes: 38 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@ 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.3.21]

### Added
* Fabric: FTB Chunks now acts as a protection provider for [Patbox's Common™ Protection API](https://github.com/Patbox/common-protection-api)
* Mods which support the Common Protection API will now benefit from FTB Chunks claim protection
* Player arrow icon is now shown on the minimap even when minimap rotation is not locked
* Added new "Show Player When Unlocked" client config setting to toggle this behaviour
* Added mob griefing protection (Enderman only for now, but maybe more in future)
* New "Mob Griefing" boolean property, which can be changed in the team properties manager (top right button in the FTB Teams window)
* True by default; prevents Endermen taking or placing blocks in claimed chunks
* Large map screen now supports more hotkeys, and hotkey tooltips have been added to buttons on this screen as appropriate
* "S" opens the settings GUI
* "Ctrl + S" opens the server settings GUI, if the player has permission
* The "Waypoint Manager" keybind now works in the large map screen too
* "C" still opens the chunk claiming GUI
* In-world waypoint dots can now be seen at any range; no more arbitrary cut-off at around 750 blocks
* Added new "Waypoints: max draw distance" setting in client config to control the maximum range
* Note: the vertical beacon still fades out when more than a couple of hundred blocks away
* Added some missing face icons for various vanilla entities (mostly new 1.19 mobs, but some older ones too)
* Added "Override Team Location Visibility" boolean server config setting, default false
* When true, all players can see everyone on the map, regardless of team location visibility preferences
* Added "Dimension Whitelist" setting to server config (in addition to existing "Dimension Blacklist")
* If whitelist is not empty, *only* dimension ID's in the whitelist may have chunks claimed, and only if those dimensions are not in the blacklist
* Wildcarded dimensions are now supported too, e.g. `somemod:*` matches all the dimensions added by the mod `somemod`
* When chunks are claimed/unclaimed/forceloaded/unforceloaded in the chunk GUI, feedback is now given on how many chunks were modified
* Also shows the reasons why any chunks could not be modified (e.g. dimension blacklisted, chunk owned by someone else...)

### Fixed

* Some significant client-side memory management work has been done
* Addressed some conditions which could lead to client-side memory starvation when the game has been running for a while
* Specifically, well-explored worlds where the player is either moving around the world a lot, or viewing the world with high map zoom-out
* Periodically, least-recently accessed region data is released from RAM, requiring reload from disk on the next access. Every 300 seconds by default; can be tuned in client config.
* When the large map screen is closed, regions furthest from the player are released from RAM, down to 32 loaded regions by default; also tunable in client config.
* Map zoom-out is limited where the ratio of the number of known (explored) regions to available JVM memory is poor. Limiting zoom-out reduces the number of regions which need to be loaded in memory at a given moment. This can be disabled in client config if you prefer.
* New client config settings are available in the "Memory Usage" section of the client config; tuning them is a trade-off between RAM usage and disk activity. However, even when tuned toward lower RAM usage, the level of disk activity should not be a major concern.

## [1902.3.20]

### Fixed
Expand All @@ -22,7 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Fixed
* Fixed a crash with fake player mods which use buckets to pick up water in protected chunks
* Fixed interaction with Fabric mods which do block placement protection by firing the FAPI block break event directly
* Fixed interaction with Fabric mods which do block placement protection by firing the FAPI block break event directly (thanks @TelepathicGrunt)
* Example mod: Bumblezone
* Architectury currently handles this via its own mixin

Expand Down
12 changes: 1 addition & 11 deletions common/src/main/java/dev/ftb/mods/ftbchunks/ColorMapLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.block.AirBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.FireBlock;
import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraft.world.level.block.GrassBlock;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.RedstoneTorchBlock;
import net.minecraft.world.level.block.TorchBlock;
import net.minecraft.world.level.block.VineBlock;
import net.minecraft.world.level.block.*;

import java.io.InputStreamReader;
import java.io.Reader;
Expand Down
12 changes: 4 additions & 8 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import dev.architectury.utils.value.IntValue;
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
import dev.ftb.mods.ftbchunks.data.*;
import dev.ftb.mods.ftbchunks.integration.stages.StageHelper;
import dev.ftb.mods.ftbchunks.integration.waystones.WaystonesCommon;
import dev.ftb.mods.ftbchunks.net.*;
import dev.ftb.mods.ftblibrary.math.ChunkDimPos;
Expand All @@ -31,7 +32,6 @@
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
Expand Down Expand Up @@ -127,7 +127,6 @@ public FTBChunks() {

EntityEvent.ENTER_SECTION.register(this::enterSection);
EntityEvent.LIVING_CHECK_SPAWN.register(this::checkSpawn);
// EntityEvent.ADD.register(this::entityAddedToWorld);

ExplosionEvent.DETONATE.register(this::explosionDetonate);

Expand Down Expand Up @@ -165,12 +164,6 @@ private void playerTickPost(Player player) {
private void serverBeforeStart(MinecraftServer server) {
var configPath = server.getWorldPath(ConfigUtil.SERVER_CONFIG_DIR);
ConfigUtil.loadDefaulted(FTBChunksWorldConfig.CONFIG, configPath, FTBChunks.MOD_ID);

FTBChunksWorldConfig.CLAIM_DIMENSION_BLACKLIST_SET.clear();

for (String s : FTBChunksWorldConfig.CLAIM_DIMENSION_BLACKLIST.get()) {
FTBChunksWorldConfig.CLAIM_DIMENSION_BLACKLIST_SET.add(ResourceKey.create(net.minecraft.core.Registry.DIMENSION_REGISTRY, new ResourceLocation(s)));
}
}

private void serverLevelLoad(ServerLevel level) {
Expand Down Expand Up @@ -441,10 +434,13 @@ private void playerCloned(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolea

private void playerChangedDimension(ServerPlayer serverPlayer, ResourceKey<Level> oldLevel, ResourceKey<Level> newLevel) {
LongRangePlayerTracker.INSTANCE.stopTracking(serverPlayer);

StageHelper.INSTANCE.get().sync(serverPlayer);
}

private void teamConfig(TeamCollectPropertiesEvent event) {
event.add(FTBChunksTeamData.ALLOW_EXPLOSIONS);
event.add(FTBChunksTeamData.ALLOW_MOB_GRIEFING);
event.add(FTBChunksTeamData.ALLOW_ALL_FAKE_PLAYERS);
event.add(FTBChunksTeamData.ALLOW_NAMED_FAKE_PLAYERS);
event.add(FTBChunksTeamData.ALLOW_FAKE_PLAYERS_BY_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import com.mojang.authlib.GameProfile;
import dev.ftb.mods.ftbchunks.client.map.RegionSyncKey;
import dev.ftb.mods.ftbchunks.net.LoginDataPacket;
import dev.ftb.mods.ftbchunks.net.PlayerDeathPacket;
import dev.ftb.mods.ftbchunks.net.SendChunkPacket;
import dev.ftb.mods.ftbchunks.net.SendGeneralDataPacket;
import dev.ftb.mods.ftbchunks.net.SendManyChunksPacket;
import dev.ftb.mods.ftbchunks.net.*;
import it.unimi.dsi.fastutil.longs.Long2IntMap;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
import dev.ftb.mods.ftbchunks.integration.stages.StageHelper;
import dev.ftb.mods.ftblibrary.config.NameMap;
import dev.ftb.mods.ftblibrary.snbt.config.*;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
* @author LatvianModder
Expand All @@ -26,7 +22,8 @@ public interface FTBChunksWorldConfig {
EnumValue<ForceLoadMode> FORCE_LOAD_MODE = CONFIG.getEnum("force_load_mode", ForceLoadMode.NAME_MAP).comment("Control how force-loaded chunks work.","NEVER: only allow chunk force-loading if the owning team has at least one online player.","ALWAYS: always allow force-loading, even if no players are online.","DEFAULT: allow force-loading IF the team has at least one player with the 'ftbchunks.chunk_load_offline' FTB Ranks permission OR 'chunk_load_offline' is true.");
BooleanValue DISABLE_PROTECTION = CONFIG.getBoolean("disable_protection", false).comment("Disables all land protection. Useful for private servers where everyone is trusted and claims are only used for force-loading");
EnumValue<AllyMode> ALLY_MODE = CONFIG.getEnum("ally_mode", AllyMode.NAME_MAP).comment("Forced modes won't let players change their ally settings");
StringListValue CLAIM_DIMENSION_BLACKLIST = CONFIG.getStringList("claim_dimension_blacklist", Collections.emptyList()).comment("Blacklist for dimensions where chunks can't be claimed. Add \"minecraft:the_end\" to this list if you want to disable chunk claiming in The End");
StringListValue CLAIM_DIMENSION_BLACKLIST = CONFIG.getStringList("claim_dimension_blacklist", Collections.emptyList()).comment("Dimension ID's where chunks may not be claimed. Add \"minecraft:the_end\" to this list if you want to disable chunk claiming in The End, or \"othermod:*\" to disable chunk claiming in *all* dimensions added by \"othermod\"");
StringListValue CLAIM_DIMENSION_WHITELIST = CONFIG.getStringList("claim_dimension_whitelist", Collections.emptyList()).comment("Dimension ID's where chunks may be claimed. If non-empty, chunks may be claimed *only* in these dimensions (and the dimension is not in \"claim_dimension_blacklist\"). Same syntax as for \"claim_dimension_blacklist\".");
BooleanValue NO_WILDERNESS = CONFIG.getBoolean("no_wilderness", false).comment("Requires you to claim chunks in order to edit and interact with blocks");
BooleanValue FORCE_DISABLE_MINIMAP = CONFIG.getBoolean("force_disable_minimap", false).comment("Minimap for clients connecting to this server will be disabled");
DoubleValue MAX_IDLE_DAYS_BEFORE_UNCLAIM = CONFIG.getDouble("max_idle_days_before_unclaim", 0D, 0D, 3650D).comment("Maximum time (in real-world days) where if no player in a team logs in, the team automatically loses their claims.", "Prevents chunks being claimed indefinitely by teams who no longer play.","Default of 0 means no automatic loss of claims.");
Expand All @@ -37,8 +34,7 @@ public interface FTBChunksWorldConfig {
IntValue HARD_TEAM_FORCE_LIMIT = CONFIG.getInt("hard_team_force_limit", 0, 0, Integer.MAX_VALUE).comment("Hard limit for the number of chunks a team can force-load, regardless of how many members. Default of 0 means no hard limit.");
EnumValue<PartyLimitMode> PARTY_LIMIT_MODE = CONFIG.getEnum("party_limit_mode", PartyLimitMode.NAME_MAP).comment("Method by which party claim & force-load limits are calculated.","LARGEST: use the limits of the member with the largest limits","SUM: add up all the members' limits","OWNER: use the party owner's limits only","AVERAGE: use the average of all members' limits.");
BooleanValue REQUIRE_GAME_STAGE = CONFIG.getBoolean("require_game_stage", false).comment("If true, the player must have the 'ftbchunks_mapping' Game stage to be able to use the map and minimap.\nRequires KubeJS and/or Gamestages to be installed.");

Set<ResourceKey<Level>> CLAIM_DIMENSION_BLACKLIST_SET = new HashSet<>();
BooleanValue LOCATION_MODE_OVERRIDE = CONFIG.getBoolean("location_mode_override", false).comment("If true, \"Location Visibility\" team settings are ignored, and all players can see each other anywhere on the map.");

static int getMaxClaimedChunks(FTBChunksTeamData playerData, ServerPlayer player) {
if (FTBChunks.ranksMod && player != null) {
Expand Down Expand Up @@ -76,4 +72,5 @@ static boolean playerHasMapStage(Player player) {
static boolean shouldShowMinimap(Player player) {
return !FORCE_DISABLE_MINIMAP.get() && playerHasMapStage(player);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ private boolean shouldTrack(ServerPlayer p1, ServerPlayer p2, int maxDistSq) {
// must be a different player, in the same dimension, and outside the standard vanilla player tracking distance
if (p1 == p2 || p1.distanceToSqr(p2) < maxDistSq) return false;

if (FTBChunksWorldConfig.LOCATION_MODE_OVERRIDE.get()) {
return true;
}

// and player 1 must be able to see player 2 (i.e. player 2's team settings must allow it)
FTBChunksTeamData p2Team = FTBChunksAPI.getManager().getData(p2);
return p2Team.canUse(p1, FTBChunksTeamData.LOCATION_MODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
import dev.ftb.mods.ftbchunks.client.map.MapChunk;
import dev.ftb.mods.ftbchunks.client.map.MapDimension;
import dev.ftb.mods.ftbchunks.client.map.MapManager;
import dev.ftb.mods.ftbchunks.data.ClaimResults;
import dev.ftb.mods.ftbchunks.net.RequestChunkChangePacket;
import dev.ftb.mods.ftbchunks.net.RequestMapDataPacket;
import dev.ftb.mods.ftbchunks.net.SendGeneralDataPacket;
import dev.ftb.mods.ftbchunks.net.UpdateForceLoadExpiryPacket;
import dev.ftb.mods.ftblibrary.icon.*;
import dev.ftb.mods.ftblibrary.icon.Color4I;
import dev.ftb.mods.ftblibrary.icon.FaceIcon;
import dev.ftb.mods.ftblibrary.icon.Icons;
import dev.ftb.mods.ftblibrary.icon.ImageIcon;
import dev.ftb.mods.ftblibrary.math.MathUtils;
import dev.ftb.mods.ftblibrary.math.XZ;
import dev.ftb.mods.ftblibrary.ui.*;
Expand Down Expand Up @@ -162,6 +166,7 @@ public void tick() {
public MapDimension dimension = MapDimension.getCurrent();
public List<ChunkButton> chunkButtons;
public Set<XZ> selectedChunks;
private ChunkUpdateInfo updateInfo;

public ChunkScreen() {
FTBChunksClient.alwaysRenderChunksOnMap = true;
Expand All @@ -176,6 +181,12 @@ public ChunkScreen() {
}
}

public static void notifyChunkUpdates(int totalChunks, int changedChunks, EnumMap<ClaimResults, Integer> problems) {
if (Minecraft.getInstance().screen instanceof ScreenWrapper sw && sw.getGui() instanceof ChunkScreen cs) {
cs.updateInfo = new ChunkUpdateInfo(totalChunks, changedChunks, problems, Minecraft.getInstance().level.getGameTime());
}
}

@Override
public boolean onInit() {
return setFullscreen();
Expand Down Expand Up @@ -215,8 +226,6 @@ public void addWidgets() {
addAll(chunkButtons);
new RequestMapDataPacket(chunkPos.x - FTBChunks.TILE_OFFSET, chunkPos.z - FTBChunks.TILE_OFFSET, chunkPos.x + FTBChunks.TILE_OFFSET, chunkPos.z + FTBChunks.TILE_OFFSET).sendToServer();
add(new SimpleButton(this, Component.translatable("ftbchunks.gui.large_map"), Icons.MAP, (simpleButton, mouseButton) -> new LargeMapScreen().openGui()).setPosAndSize(1, 1, 16, 16));

// add(new SimpleButton(this, Component.translatable("ftbchunks.gui.allies"), Icons.FRIENDS, (simpleButton, mouseButton) -> {}).setPosAndSize(1, 19, 16, 16));
}

@Override
Expand Down Expand Up @@ -305,5 +314,28 @@ public void drawBackground(PoseStack matrixStack, Theme theme, int x, int y, int
theme.drawString(matrixStack, list.get(i), 3, getScreen().getGuiScaledHeight() - fh * (list.size() - i) - 1, Color4I.WHITE, Theme.SHADOW);
}
}

if (updateInfo != null && updateInfo.shouldDisplay()) {
theme.drawString(matrixStack, updateInfo.summary(), sx + 2, sy + 2, Theme.SHADOW);
int line = 1;
for (Map.Entry<ClaimResults, Integer> entry : updateInfo.problems.entrySet()) {
ClaimResults problem = entry.getKey();
int count = entry.getValue();
theme.drawString(matrixStack, Component.translatable(problem.getTranslationKey()).append(": " + count), sx + 2, sy + 5 + theme.getFontHeight() * line++, Theme.SHADOW);
}
}
}

private record ChunkUpdateInfo(int totalChunks, int changedChunks, EnumMap<ClaimResults, Integer> problems, long timestamp) {
public boolean shouldDisplay() {
// display for 3 seconds + 1 second per line of problem data
long timeout = 60L + 20L * problems.size();
return Minecraft.getInstance().level.getGameTime() - timestamp < timeout;
}

public Component summary() {
ChatFormatting color = changedChunks == 0 ? ChatFormatting.RED : (changedChunks < totalChunks ? ChatFormatting.YELLOW : ChatFormatting.GREEN);
return Component.translatable("ftbchunks.claim_result", changedChunks, totalChunks).withStyle(ChatFormatting.UNDERLINE, color);
}
}
}
Loading

0 comments on commit 32bea7d

Please sign in to comment.