Skip to content

Commit aebb832

Browse files
authored
Merge pull request #305 from FTBTeam/dev
Dev
2 parents 6f7ad34 + 0168dfe commit aebb832

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1852
-455
lines changed

Diff for: CHANGELOG.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,34 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2001.1.1]
8+
9+
### Added
10+
* The waypoint manager screen has had a facelift
11+
* No longer a full-screen GUI
12+
* Added a delete button alongside the visibility toggle button on the manager screen
13+
* Added waypoint sharing; there is now a "Share" option on the context menus for waypoints on the large map, and in the waypoint manager screen
14+
* Player icon on the large map screen is now combined with a pointer indicating the player's facing direction
15+
* Added new entity tag: `ftbchunks:entity_mob_griefing_blacklist`
16+
* Prevents mob griefing by any entities in this tag if mob griefing protection is enabled in team settings
17+
* Note: only works on NeoForge at this time (Fabric remains limited to Endermen only)
18+
* Info text lines under the minimap are now highly configurable
19+
* Configure with the "Minimap Info" icon on the left of the large map screen
20+
* Entries can be enabled/disabled/reordered/configured
21+
* Added new real time, game time and FPS lines in addition to existing zone/biome/player-pos/debug lines
22+
23+
### Fixed
24+
* Fixed the `/ftbchunks waypoint add` command only working for loaded chunks
25+
* Fixed block/item/entity tags not being detected
26+
* If the minimap is being displayed in top-right of screen (the default), then any potion effect icons are moved to the left of the minimap to avoid overlap
27+
* Fixed the map keybind (by default 'M') not working to close an open map
28+
* In addition, Ctrl + M (or whatever the map key is bound to) no longer toggles minimap by default
29+
* This was always a kludge; minimap toggling is now its own keybind (unbound by default)
30+
731
## [2100.1.0]
832

933
### Changed
10-
* Ported to Minecraft 1.20.6. Support for Fabric and NeoForge.
34+
* Ported to Minecraft 1.21. Support for Fabric and NeoForge.
1135
* Forge support may be re-added if/when Architectury adds support for Forge
1236

1337
## [2006.1.1]

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ publishMods {
102102

103103
// TODO: Migrate to something else
104104
def tag = providers.environmentVariable("TAG").getOrElse("release")
105-
type = tag == "beta" ? BETA : (tag == "alpha" ? ALPHA : STABLE)
105+
type = tag.endsWith("-beta") ? BETA : (tag.endsWith("-alpha") ? ALPHA : STABLE)
106106

107107
def createOptions = (String projectName) -> {
108108
publishOptions {

Diff for: common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunksCommands.java

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.ftb.mods.ftbchunks;
22

33
import com.mojang.brigadier.CommandDispatcher;
4+
import com.mojang.brigadier.arguments.BoolArgumentType;
45
import com.mojang.brigadier.arguments.IntegerArgumentType;
56
import com.mojang.brigadier.arguments.StringArgumentType;
67
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
@@ -38,6 +39,7 @@
3839
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
3940
import net.minecraft.commands.arguments.coordinates.Coordinates;
4041
import net.minecraft.core.BlockPos;
42+
import net.minecraft.core.GlobalPos;
4143
import net.minecraft.network.chat.Component;
4244
import net.minecraft.resources.ResourceKey;
4345
import net.minecraft.resources.ResourceLocation;
@@ -189,9 +191,15 @@ public static void registerCommands(CommandDispatcher<CommandSourceStack> dispat
189191
.then(Commands.literal("add")
190192
.then(Commands.argument("name", StringArgumentType.string())
191193
.then(Commands.argument("position", BlockPosArgument.blockPos())
192-
.executes(context -> addWaypoint(context.getSource(), StringArgumentType.getString(context, "name"), BlockPosArgument.getLoadedBlockPos(context, "position")))
193-
.then(Commands.argument("color", ColorArgument.color())
194-
.executes(context -> addWaypoint(context.getSource(), StringArgumentType.getString(context, "name"), BlockPosArgument.getLoadedBlockPos(context, "position"), ColorArgument.getColor(context, "color")))
194+
.executes(context -> addWaypoint(context.getSource(), StringArgumentType.getString(context, "name"), BlockPosArgument.getBlockPos(context, "position")))
195+
.then(Commands.argument("dimension", DimensionArgument.dimension())
196+
.executes(context -> addWaypoint(context.getSource(), StringArgumentType.getString(context, "name"), DimensionArgument.getDimension(context, "dimension"), BlockPosArgument.getBlockPos(context, "position")))
197+
.then(Commands.argument("color", ColorArgument.color())
198+
.executes(context -> addWaypoint(context.getSource(), StringArgumentType.getString(context, "name"), DimensionArgument.getDimension(context, "dimension"), BlockPosArgument.getBlockPos(context, "position"), ColorArgument.getColor(context, "color")))
199+
.then(Commands.argument("gui", BoolArgumentType.bool())
200+
.executes(context -> addWaypoint(context.getSource(), StringArgumentType.getString(context, "name"), DimensionArgument.getDimension(context, "dimension"), BlockPosArgument.getBlockPos(context, "position"), ColorArgument.getColor(context, "color"), BoolArgumentType.getBool(context, "gui")))
201+
)
202+
)
195203
)
196204
)
197205
)
@@ -202,16 +210,25 @@ public static void registerCommands(CommandDispatcher<CommandSourceStack> dispat
202210
dispatcher.register(Commands.literal("chunks").redirect(command));
203211
}
204212

205-
private static int addWaypoint(CommandSourceStack source, String name, BlockPos position, ChatFormatting color) throws CommandSyntaxException {
213+
private static int addWaypoint(CommandSourceStack source, String name, ServerLevel level, BlockPos position, ChatFormatting color, boolean useGui) throws CommandSyntaxException {
206214
if (color.getColor() != null) {
207-
NetworkManager.sendToPlayer(source.getPlayerOrException(), new AddWaypointPacket(name, position, color.getColor()));
215+
NetworkManager.sendToPlayer(source.getPlayerOrException(), new AddWaypointPacket(name, new GlobalPos(level.dimension(), position), color.getColor(), useGui));
208216
}
209217
return 1;
210218
}
211219

220+
private static int addWaypoint(CommandSourceStack source, String name, ServerLevel level, BlockPos position, ChatFormatting color) throws CommandSyntaxException {
221+
return addWaypoint(source, name, level ,position, color, false);
222+
}
223+
212224
private static int addWaypoint(CommandSourceStack source, String name, BlockPos position) throws CommandSyntaxException {
213225
int idx = source.getPlayerOrException().getRandom().nextInt(ChatFormatting.values().length);
214-
return addWaypoint(source, name, position, ChatFormatting.values()[idx]);
226+
return addWaypoint(source, name, source.getLevel() ,position, ChatFormatting.values()[idx], false);
227+
}
228+
229+
private static int addWaypoint(CommandSourceStack source, String name, ServerLevel level, BlockPos position) throws CommandSyntaxException {
230+
int idx = source.getPlayerOrException().getRandom().nextInt(ChatFormatting.values().length);
231+
return addWaypoint(source, name, level ,position, ChatFormatting.values()[idx], false);
215232
}
216233

217234
private static int bypassProtection(CommandSourceStack source) throws CommandSyntaxException {

Diff for: common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunksWorldConfig.java

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public interface FTBChunksWorldConfig {
4848
DoubleValue MAX_IDLE_DAYS_BEFORE_UNFORCE = FORCE_LOADING.addDouble("max_idle_days_before_unforce", 0D, 0D, 3650D).comment("Maximum time (in real-world days) where if no player in a team logs in, any forceloaded chunks owned by the team are no longer forceloaded.", "Prevents chunks being forceloaded indefinitely by teams who no longer play.","Default of 0 means no automatic loss of forceloading.");
4949
IntValue HARD_TEAM_FORCE_LIMIT = FORCE_LOADING.addInt("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.");
5050

51+
SNBTConfig WAYPOINT_SHARING = CONFIG.addGroup("waypoint_sharing");
52+
BooleanValue WAYPOINT_SHARING_SERVER = WAYPOINT_SHARING.addBoolean("waypoint_sharing_server", true).comment("Allow players to share waypoints with the entire server.");
53+
BooleanValue WAYPOINT_SHARING_PARTY = WAYPOINT_SHARING.addBoolean("waypoint_sharing_party", true).comment("Allow players to share waypoints with their party.");
54+
BooleanValue WAYPOINT_SHARING_PLAYERS = WAYPOINT_SHARING.addBoolean("waypoint_sharing_players", true).comment("Allow players to share waypoints with other players.");
55+
5156
static int getMaxClaimedChunks(ChunkTeamData playerData, ServerPlayer player) {
5257
if (player != null) {
5358
return PermissionsHelper.getMaxClaimedChunks(player, MAX_CLAIMED_CHUNKS.get()) + playerData.getExtraClaimChunks();

Diff for: common/src/main/java/dev/ftb/mods/ftbchunks/api/ClaimResult.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ enum StandardProblem implements ClaimResult {
7272
NOT_LOADED("not_loaded"),
7373
;
7474

75-
public static final NameMap<StandardProblem> NAME_MAP = NameMap.of(NOT_OWNER, values()).create();
75+
public static final NameMap<StandardProblem> NAME_MAP = NameMap.of(NOT_OWNER, values()).baseNameKey("ftbchunks.standard_problem").create();
7676

7777
private final String resultName;
7878

Diff for: common/src/main/java/dev/ftb/mods/ftbchunks/api/FTBChunksTags.java

+2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ public static class Entities {
2626
= TagKey.create(Registries.ENTITY_TYPE, FTBChunksAPI.rl("entity_interact_whitelist"));
2727
public static final TagKey<EntityType<?>> NONLIVING_ENTITY_ATTACK_WHITELIST_TAG
2828
= TagKey.create(Registries.ENTITY_TYPE, FTBChunksAPI.rl("nonliving_entity_attack_whitelist"));
29+
public static final TagKey<EntityType<?>> ENTITY_MOB_GRIEFING_BLACKLIST_TAG
30+
= TagKey.create(Registries.ENTITY_TYPE, FTBChunksAPI.rl("entity_mob_griefing_blacklist"));
2931
}
3032
}

Diff for: common/src/main/java/dev/ftb/mods/ftbchunks/api/client/FTBChunksClientAPI.java

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.ftb.mods.ftbchunks.api.client;
22

3+
import com.google.common.collect.ImmutableList;
4+
import dev.ftb.mods.ftbchunks.api.client.minimap.MinimapInfoComponent;
35
import dev.ftb.mods.ftbchunks.api.client.waypoint.WaypointManager;
46
import net.minecraft.resources.ResourceKey;
57
import net.minecraft.world.level.Level;
@@ -27,4 +29,33 @@ public interface FTBChunksClientAPI {
2729
* entities...)
2830
*/
2931
void requestMinimapIconRefresh();
32+
33+
/**
34+
* Register a custom minimap info component {@link MinimapInfoComponent} to be rendered on the minimap.
35+
*
36+
* This should be called during mod initialization as this list will be finalized once Minecraft has "started"
37+
* per the client lifecycle events
38+
*
39+
* @param component the component to register
40+
*/
41+
void registerMinimapComponent(MinimapInfoComponent component);
42+
43+
44+
/**
45+
* @param component the component to check if it is enabled
46+
* @return is the component enabled and will render under the minimap
47+
*/
48+
boolean isMinimapComponentEnabled(MinimapInfoComponent component);
49+
50+
/**
51+
* Enable or disable a specific minimap component for rendering under the minimap
52+
* @param component the component to enable or disable to that shoul
53+
* @param enabled the state to set the component to
54+
*/
55+
void setMinimapComponentEnabled(MinimapInfoComponent component, boolean enabled);
56+
57+
/**
58+
* Provides an immutable list of all registered minimap components.
59+
*/
60+
ImmutableList<MinimapInfoComponent> getMinimapComponents();
3061
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package dev.ftb.mods.ftbchunks.api.client.minimap;
2+
3+
import dev.ftb.mods.ftbchunks.client.map.MapDimension;
4+
import dev.ftb.mods.ftblibrary.math.XZ;
5+
import net.minecraft.client.Minecraft;
6+
import net.minecraft.client.player.LocalPlayer;
7+
import net.minecraft.world.phys.Vec3;
8+
9+
import java.util.Map;
10+
11+
/**
12+
* Minimal context for Minimap Info Components
13+
*
14+
* @param minecraft The Minecraft instance (Helper)
15+
* @param player The client player
16+
* @param mapDimension The dimension of the players location
17+
* @param mapChunksPos The chunk for the players location
18+
* @param playerPos the players pos
19+
* @param infoSettings raw settings for this component
20+
*/
21+
public record MinimapContext(
22+
Minecraft minecraft,
23+
LocalPlayer player,
24+
MapDimension mapDimension,
25+
XZ mapChunksPos,
26+
Vec3 playerPos,
27+
Map<String, String> infoSettings
28+
) {
29+
30+
public String getSetting(MinimapInfoComponent infoComponent) {
31+
return infoSettings.getOrDefault(infoComponent.id().toString(), "");
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package dev.ftb.mods.ftbchunks.api.client.minimap;
2+
3+
import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig;
4+
import net.minecraft.client.Minecraft;
5+
import net.minecraft.client.gui.Font;
6+
import net.minecraft.client.gui.GuiGraphics;
7+
import net.minecraft.network.chat.Component;
8+
import net.minecraft.resources.ResourceLocation;
9+
10+
import java.util.Collections;
11+
import java.util.Set;
12+
13+
/**
14+
* An entry point for developers to create custom minimap info components.
15+
*/
16+
public interface MinimapInfoComponent {
17+
/**
18+
* The ID of this component.
19+
*/
20+
ResourceLocation id();
21+
22+
/**
23+
* Render your component here, the {@link com.mojang.blaze3d.vertex.PoseStack} will already be scaled and
24+
* translated to the correct position (centered by default). We do not provide an X and Y position as
25+
* 0, 0 is the center of the correct location. Use 0, 0 as the center of the component and {@link #height(MinimapContext)}
26+
* to allocate the correct height for the component.
27+
*
28+
* @param context The minimap context
29+
* @param graphics The graphics object see {@link GuiGraphics}
30+
* @param font The font object
31+
*/
32+
void render(MinimapContext context, GuiGraphics graphics, Font font);
33+
34+
/**
35+
* Set of Info {@link TranslatedOption} that are used to configure options for rendering the waypoint
36+
* this is exposed in the right click action of Minimap Info GUI
37+
* @return the set of {@link TranslatedOption}.
38+
*/
39+
default Set<TranslatedOption> getConfigComponents() {
40+
return Set.of();
41+
}
42+
43+
/**
44+
* The height of the component is used to allocate the correct space for the component. Failure to return the correct
45+
* height will result in the component overlapping with other components.
46+
*
47+
* @param context The minimap context
48+
* @return The height of the component
49+
*/
50+
default int height(MinimapContext context) {
51+
return computeLineHeight(context.minecraft(), 1) + 1;
52+
}
53+
54+
/**
55+
* Checked on each render frame to determine if the height for the component should be allocated
56+
*/
57+
default boolean shouldRender(MinimapContext context) {
58+
return true;
59+
}
60+
61+
/**
62+
* Helper method to compute the height of a text component whilst taking into account the font scale
63+
*/
64+
default int computeLineHeight(Minecraft minecraft, int lines) {
65+
final float fontScale = FTBChunksClientConfig.MINIMAP_FONT_SCALE.get().floatValue();
66+
return (int) ((minecraft.font.lineHeight + 2) * lines * fontScale);
67+
}
68+
69+
/**
70+
* Helper method to draw centered text without the faff of calculating the width of the text
71+
*/
72+
default void drawCenteredText(Font font, GuiGraphics graphics, Component text, int y) {
73+
int textWidth = font.width(text.getVisualOrderText());
74+
graphics.drawString(font, text, -textWidth / 2, y, 0xFFFFFFFF, true);
75+
}
76+
77+
78+
/**
79+
* @return display name render in the Minimap Info Settings GUI
80+
*/
81+
default Component displayName() {
82+
return Component.translatable("minimap.info." + id().getNamespace() + "." + id().getPath() + ".title");
83+
}
84+
85+
/**
86+
* @return hover texted displayed render in the Minimap Info Settings GUI
87+
*/
88+
default Component description() {
89+
return Component.translatable("minimap.info." + id().getNamespace() + "." + id().getPath() + ".description");
90+
}
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.ftb.mods.ftbchunks.api.client.minimap;
2+
3+
public record TranslatedOption(
4+
String optionName,
5+
String translationKey
6+
) {
7+
8+
public static TranslatedOption of(String optionName) {
9+
String translatedKey = optionName.toLowerCase().replaceAll("[^a-z0-9]", "_");
10+
return new TranslatedOption(optionName, "minimap.option." + translatedKey);
11+
}
12+
}

0 commit comments

Comments
 (0)