Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #337

Merged
merged 13 commits into from
Dec 2, 2024
Merged

Dev #337

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ 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).

## [2101.1.4]

### Added
* Added protection for pistons moving blocks, including large block structure (e.g. vanilla-style flying machines)
* Enabled by default; can be disabled via 'piston_protection' server setting
* When enabled, pistons cannot push blocks from the chunk the piston is in to another chunk if the new chunk is owned by a different team, and that team does not have public block-edit permissions
* Similar restrictions apply to blocks which would be destroyed by piston moving
* Add client config setting "Pointer Icon Mode" to control the appearance of the player pointer icon on maps
* Can display the player face, a heading arrow, or both
* Displayed component values for the minimap can now be configured via the client config screen

### Fixed
* Possibly fixed an issue leading to hangs on server shutdown (hard to know for certain; the issue is difficult to reproduce)
* Fixed output of `/ftbchunks admin unload_everything` being misleading
* The command ran correctly, un-forceloading all forceloaded chunks, but reported the number of _all_ claimed chunks, not just the forceloaded ones
* Fixed colouring for some blocks (primarily redstone-related) on the map/minimap leading to an ugly-looking artifacts on the map
* Integrated Dynamics Menril Leaves now show up as light blue on the map instead of the default green

## [2101.1.3]

### Changed
Expand Down
9 changes: 2 additions & 7 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
import dev.architectury.utils.Env;
import dev.architectury.utils.EnvExecutor;
import dev.architectury.utils.value.IntValue;
import dev.ftb.mods.ftbchunks.api.ClaimedChunk;
import dev.ftb.mods.ftbchunks.api.FTBChunksAPI;
import dev.ftb.mods.ftbchunks.api.FTBChunksProperties;
import dev.ftb.mods.ftbchunks.api.Protection;
import dev.ftb.mods.ftbchunks.api.*;
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
import dev.ftb.mods.ftbchunks.data.*;
import dev.ftb.mods.ftbchunks.net.*;
Expand Down Expand Up @@ -62,14 +59,11 @@
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FTBChunks {
public static final String MOD_ID = "ftbchunks";
public static final Logger LOGGER = LogManager.getLogger("FTB Chunks");
public static final Gson GSON = new GsonBuilder().disableHtmlEscaping().setLenient().create();
public static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor();

public static FTBChunks instance;

Expand Down Expand Up @@ -600,4 +594,5 @@ private void serverTickPost(MinecraftServer minecraftServer) {
ClaimExpirationManager.INSTANCE.tick(minecraftServer);
LongRangePlayerTracker.INSTANCE.tick(minecraftServer);
}

}
22 changes: 12 additions & 10 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunksCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,8 @@ private static int setExtraForceLoadChunks(CommandSourceStack source, ServerPlay

private static int unclaimEverything(CommandSourceStack source) {
int claimedChunks = 0;
for (ClaimedChunkImpl c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
for (ClaimedChunk c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
c.getTeamData().unclaim(source, c.getPos(), false);
c.getTeamData().markDirty();
claimedChunks++;
}
int finalClaimedChunks = claimedChunks;
Expand All @@ -516,10 +515,9 @@ private static int unclaimEverything(CommandSourceStack source) {

private static int unclaimDimension(CommandSourceStack source, ResourceKey<Level> dim) {
int claimedChunks = 0;
for (ClaimedChunkImpl c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
for (ClaimedChunk c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
if (source.getLevel().dimension().equals(dim)) {
c.getTeamData().unclaim(source, c.getPos(), false);
c.getTeamData().markDirty();
claimedChunks++;
}
}
Expand All @@ -534,13 +532,17 @@ private static int unclaimDimension(CommandSourceStack source) {

private static int unloadEverything(CommandSourceStack source) {
int unloadedChunks = 0;
for (ClaimedChunkImpl c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
c.getTeamData().unForceLoad(source, c.getPos(), false);
c.getTeamData().markDirty();
unloadedChunks++;
int totalChunks = 0;
for (ClaimedChunk c : claimManager().getAllClaimedChunks()) {
if (c.isForceLoaded()) {
c.getTeamData().unForceLoad(source, c.getPos(), false);
unloadedChunks++;
}
totalChunks++;
}
int finalUnloadedChunks = unloadedChunks;
source.sendSuccess(() -> Component.translatable("ftbchunks.command.unloaded", finalUnloadedChunks), true);
final int finalUnloadedChunks = unloadedChunks;
final int finalTotalChunks = totalChunks;
source.sendSuccess(() -> Component.translatable("ftbchunks.commands.unloaded", finalUnloadedChunks, finalTotalChunks), true);
return Command.SINGLE_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public interface FTBChunksWorldConfig {
.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.");
BooleanValue LOCATION_MODE_OVERRIDE = CONFIG.addBoolean("location_mode_override", false)
.comment("If true, \"Location Visibility\" team settings are ignored, and all players can see each other anywhere on the map.");
BooleanValue PISTON_PROTECTION = CONFIG.addBoolean("piston_protection", true)
.comment("If true, pistons are prevented from pushing/pulling blocks across claims owned by different teams (unless the target claim has public 'edit block' permissions defined). If 'disable_protection' is set to true, this setting is ignored.");

SNBTConfig FAKE_PLAYERS = CONFIG.addGroup("fake_players");
EnumValue<ProtectionPolicy> ALLOW_FAKE_PLAYERS = FAKE_PLAYERS.addEnum("fake_players", NameMap.of(ProtectionPolicy.CHECK, ProtectionPolicy.values()).create())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,16 @@
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Function;
import java.util.stream.Collectors;

public enum FTBChunksClient {
INSTANCE;

public static final ExecutorService MAP_EXECUTOR = Executors.newSingleThreadExecutor();

public static final ResourceLocation WAYPOINT_BEAM = FTBChunksAPI.rl("textures/waypoint_beam.png");
private static final ResourceLocation BUTTON_ID_MAP = FTBChunksAPI.rl("open_gui");
private static final ResourceLocation BUTTON_ID_CLAIM = FTBChunksAPI.rl("open_claim_gui");
Expand Down Expand Up @@ -1106,8 +1110,15 @@ private void mapIcons(MapIconEvent event) {
}

if (!event.getMapType().isMinimap()) {
event.add(new EntityMapIcon(mc.player, FaceIcon.getFace(mc.player.getGameProfile())));
event.add(new PointerIcon());
PointerIconMode pointerIconMode = FTBChunksClientConfig.POINTER_ICON_MODE.get();

if (pointerIconMode.showFace()) {
event.add(new EntityMapIcon(mc.player, FaceIcon.getFace(mc.player.getGameProfile())));
}

if (pointerIconMode.showPointer()) {
event.add(new PointerIcon());
}
}
}

Expand Down Expand Up @@ -1158,7 +1169,7 @@ public void handlePacket(ClientboundLevelChunkWithLightPacket p) {

public void queueOrExecute(MapTask task) {
// Implement this config later
FTBChunks.EXECUTOR.execute(task);
MAP_EXECUTOR.execute(task);
}

public void handlePacket(ClientboundBlockUpdatePacket p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import dev.architectury.networking.NetworkManager;
import dev.architectury.platform.Platform;
import dev.ftb.mods.ftbchunks.EntityTypeBoolMapValue;
import dev.ftb.mods.ftbchunks.FTBChunks;
import dev.ftb.mods.ftbchunks.FTBChunksWorldConfig;
import dev.ftb.mods.ftbchunks.EntityTypeBoolMapValue;
import dev.ftb.mods.ftbchunks.client.map.BiomeBlendMode;
import dev.ftb.mods.ftbchunks.client.map.MapManager;
import dev.ftb.mods.ftbchunks.client.map.MapMode;
import dev.ftb.mods.ftbchunks.client.minimap.MinimapComponentConfig;
import dev.ftb.mods.ftbchunks.client.minimap.components.BiomeComponent;
import dev.ftb.mods.ftbchunks.client.minimap.components.DebugComponent;
import dev.ftb.mods.ftbchunks.client.minimap.components.FPSComponent;
Expand All @@ -19,7 +20,13 @@
import dev.ftb.mods.ftblibrary.config.ConfigGroup;
import dev.ftb.mods.ftblibrary.config.ui.EditConfigScreen;
import dev.ftb.mods.ftblibrary.snbt.SNBTCompoundTag;
import dev.ftb.mods.ftblibrary.snbt.config.*;
import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue;
import dev.ftb.mods.ftblibrary.snbt.config.DoubleValue;
import dev.ftb.mods.ftblibrary.snbt.config.EnumValue;
import dev.ftb.mods.ftblibrary.snbt.config.IntValue;
import dev.ftb.mods.ftblibrary.snbt.config.SNBTConfig;
import dev.ftb.mods.ftblibrary.snbt.config.StringListValue;
import dev.ftb.mods.ftblibrary.snbt.config.StringMapValue;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -82,8 +89,9 @@ public interface FTBChunksClientConfig {
BooleanValue MINIMAP_PROPORTIONAL = MINIMAP.addBoolean("proportional", true).comment("Size minimap proportional to screen width (and scale)");
StringListValue MINIMAP_INFO_ORDER = MINIMAP.addStringList("info_order", Stream.of(PlayerPosInfoComponent.ID, BiomeComponent.ID, ZoneInfoComponent.ID, FPSComponent.ID, GameTimeComponent.ID, RealTimeComponent.ID, DebugComponent.ID).map(ResourceLocation::toString).toList()).excluded().comment("Info displayed under minimap");
StringListValue MINIMAP_INFO_HIDDEN = MINIMAP.addStringList("info_hidden", Stream.of(FPSComponent.ID, GameTimeComponent.ID, RealTimeComponent.ID, DebugComponent.ID).map(ResourceLocation::toString).toList()).excluded().comment("Info hidden under minimap");
StringMapValue MINIMAP_SETTINGS = MINIMAP.add(new StringMapValue(MINIMAP, "info_settings", Collections.emptyMap())).comment("Settings for minimap info components");
StringMapValue MINIMAP_SETTINGS = MINIMAP.add(new MinimapComponentConfig(MINIMAP, "info_settings", Collections.emptyMap())).comment("Settings for minimap info components");
EntityTypeBoolMapValue ENTITY_ICON = MINIMAP.add(new EntityTypeBoolMapValue(MINIMAP, "entity_icon", Collections.emptyMap())).comment("Entity icons on minimap");
EnumValue<PointerIconMode> POINTER_ICON_MODE = MINIMAP.addEnum("pointer_icon_mode", PointerIconMode.NAME_MAP).comment("Mode for the pointer icon to render on full screen minimap");

SNBTConfig ADVANCED = CONFIG.addGroup("advanced", 3);
BooleanValue DEBUG_INFO = ADVANCED.addBoolean("debug_info", false).comment("Enables debug info");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.ftb.mods.ftbchunks.client;

import dev.ftb.mods.ftblibrary.config.NameMap;

public enum PointerIconMode {
FACE(true, false),
POINTER(false, true),
BOTH(true, true),
;

public static final NameMap<PointerIconMode> NAME_MAP = NameMap.of(BOTH, values()).baseNameKey("ftbchunks.minimap.pointer_icon_mode").create();

private final boolean face;
private final boolean pointer;

PointerIconMode(boolean face, boolean pointer) {
this.face = face;
this.pointer = pointer;
}

public boolean showFace() {
return face;
}

public boolean showPointer() {
return pointer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected class CustomTopPanel extends Panel {
public CustomTopPanel() {
super(ChunkScreen.this);

closeButton = new SimpleButton(this, Component.translatable("gui.close"), Icons.CLOSE,
closeButton = new SimpleButton(this, Component.translatable("gui.close"), Icons.CANCEL,
(btn, mb) -> doCancel())
.setForceButtonSize(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public Component getTitle() {

private class ClearDeathPointButton extends SimpleButton {
public ClearDeathPointButton(Panel panel) {
super(panel, Component.translatable("ftbchunks.gui.clear_deathpoints"), Icons.CLOSE, (b, m) -> {
super(panel, Component.translatable("ftbchunks.gui.clear_deathpoints"), Icons.CANCEL, (b, m) -> {
if (getWaypointManager().removeIf(wp -> wp.getType() == WaypointType.DEATH)) {
refreshWidgets();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static Optional<ContextMenuItem> makeShareMenu(Player sharingPlayer, Wayp
b -> shareWaypoint(waypoint, ShareWaypointPacket.ShareType.SERVER, List.of())));
}
if (FTBChunksWorldConfig.WAYPOINT_SHARING_PARTY.get()) {
items.add(new ContextMenuItem(Component.translatable("ftbchunks.waypoint.share.party"), Icons.BELL,
items.add(new ContextMenuItem(Component.translatable("ftbchunks.waypoint.share.party"), Icons.FRIENDS_GROUP,
b -> shareWaypoint(waypoint, ShareWaypointPacket.ShareType.PARTY, List.of())));
}
if (FTBChunksWorldConfig.WAYPOINT_SHARING_PLAYERS.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dev.ftb.mods.ftbchunks.FTBChunks;
import dev.ftb.mods.ftbchunks.api.FTBChunksAPI;
import dev.ftb.mods.ftbchunks.client.ClientTaskQueue;
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
import dev.ftb.mods.ftblibrary.math.XZ;
import it.unimi.dsi.fastutil.longs.Long2IntMap;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
Expand Down Expand Up @@ -169,7 +170,7 @@ public void runMapTask() throws Exception {
List<MapRegion> regionList = ImmutableList.copyOf(getRegions().values());

if (!waypoints.isEmpty() || !regionList.isEmpty()) {
FTBChunks.EXECUTOR.execute(() -> {
FTBChunksClient.MAP_EXECUTOR.execute(() -> {
try {
writeData(waypoints, regionList);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void runMapTask() throws Exception {
.map(key -> String.format("#%03X %s", key.getIntKey(), key.getValue().location()))
.collect(Collectors.toList());

FTBChunks.EXECUTOR.execute(() -> {
FTBChunksClient.MAP_EXECUTOR.execute(() -> {
try {
Files.write(directory.resolve("dimensions.txt"), dimensionsList);
Files.write(directory.resolve("block_map.txt"), blockColorIndexMapList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public MapRegionData getDataBlockingNoSync() {
public MapRegionData getData() {
if (data == null && !isLoadingData) {
isLoadingData = true;
FTBChunks.EXECUTOR.execute(this::getDataBlocking);
FTBChunksClient.MAP_EXECUTOR.execute(this::getDataBlocking);
}

if (data != null) {
Expand All @@ -115,7 +115,7 @@ public NativeImage getRenderedMapImage() {
updateRenderedMapImage = false;
mapImageLoaded = false;
renderingMapImage = true;
FTBChunks.EXECUTOR.execute(new RenderMapImageTask(this));
FTBChunksClient.MAP_EXECUTOR.execute(new RenderMapImageTask(this));
}

return renderedMapImage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.ftb.mods.ftbchunks.client.map;

import dev.ftb.mods.ftbchunks.FTBChunks;
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
import dev.ftb.mods.ftbchunks.util.HeightUtils;
import dev.ftb.mods.ftblibrary.math.XZ;

Expand Down Expand Up @@ -160,7 +161,7 @@ public void write() throws IOException {
}
}

FTBChunks.EXECUTOR.execute(() -> {
FTBChunksClient.MAP_EXECUTOR.execute(() -> {
try {
writeData(chunkList, dataImage, foliageImage, grassImage, waterImage, blocksImage);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package dev.ftb.mods.ftbchunks.client.minimap;

import dev.ftb.mods.ftbchunks.client.gui.MinimapInfoSortScreen;
import dev.ftb.mods.ftblibrary.config.ConfigCallback;
import dev.ftb.mods.ftblibrary.config.ConfigGroup;
import dev.ftb.mods.ftblibrary.config.ConfigValue;
import dev.ftb.mods.ftblibrary.snbt.config.SNBTConfig;
import dev.ftb.mods.ftblibrary.snbt.config.StringMapValue;
import dev.ftb.mods.ftblibrary.ui.Widget;
import dev.ftb.mods.ftblibrary.ui.input.MouseButton;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

public class MinimapComponentConfig extends StringMapValue {

public MinimapComponentConfig(@Nullable SNBTConfig c, String n, Map<String, String> def) {
super(c, n, def);
}


@Override
public void createClientConfig(ConfigGroup group) {
group.add(key, new MinimapComponentConfigValue(), get(), stringBooleanMap -> {
}, defaultValue);
}

public static class MinimapComponentConfigValue extends ConfigValue<Map<String, String>> {

@Override
public void onClicked(Widget clickedWidget, MouseButton button, ConfigCallback callback) {
new MinimapInfoSortScreen().openGui();
}

@Override
public Component getStringForGUI(@Nullable Map<String, String> v) {
if (v == null) {
return super.getStringForGUI(null);
}
return Component.translatable("ftbchunks.gui.sort_minimap_info");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dev.ftb.mods.ftbchunks.core.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import dev.architectury.platform.Platform;
import dev.ftb.mods.ftbchunks.api.FTBChunksProperties;
import dev.ftb.mods.ftbchunks.util.PistonHelper;
import dev.ftb.mods.ftbteams.api.property.PrivacyProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.piston.PistonBaseBlock;
import net.minecraft.world.level.block.piston.PistonStructureResolver;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PistonBaseBlock.class)
public class PistonBaseBlockMixin {
@Inject(method = "moveBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/piston/PistonStructureResolver;getToPush()Ljava/util/List;"), cancellable = true)
public void onMoveBlocks(Level level, BlockPos blockPos, Direction direction, boolean extending, CallbackInfoReturnable<Boolean> cir, @Local PistonStructureResolver pistonStructureResolver) {
if (PistonHelper.shouldPreventPistonMovement(level, blockPos, pistonStructureResolver)) {
cir.setReturnValue(false);
}
}
}
Loading