Skip to content

Commit 15474e0

Browse files
Merge branch '1.21.1/dev' into 1.21.1/main
2 parents cbba06f + 7d05034 commit 15474e0

File tree

7 files changed

+92
-10
lines changed

7 files changed

+92
-10
lines changed

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ 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+
## [2101.1.13]
8+
9+
### Added
10+
* An API `CustomMinYEvent` event to register custom `min-y` providers
11+
12+
### Removed
13+
* Remove the previously added support for custom min-y per chunk scanning. This does not effect the global min-y already available
14+
715
## [2101.1.12]
816

917
### Added
@@ -314,7 +322,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
314322
* 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.
315323
* 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.
316324
* 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.
317-
* 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.
325+
* 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.
318326

319327
## [1902.3.20]
320328

@@ -335,7 +343,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
335343
## Fixed
336344
* Fixed a crash with fake player mods which use buckets to pick up water in protected chunks
337345
* Fixed interaction with Fabric mods which do block placement protection by firing the FAPI block break event directly (thanks @TelepathicGrunt)
338-
* Example mod: Bumblezone
346+
* Example mod: Bumblezone
339347
* Architectury currently handles this via its own mixin
340348

341349

@@ -431,7 +439,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
431439
* This means player heads will only be visible to team-mates and allies by default; if you're not in a party team but want to be visible on the map, set your "Location Visibility" to "Public" in team settings.
432440
* Player heads can now be tracked on the map at any range, not just inside the default entity tracking range
433441
* The same visibility restrictions apply as above, via "Location Visibility"
434-
* Added server-side config item `long_range_tracker_interval` which controls how frequently long-range tracking data is sent by the server to clients; default is every 20 ticks (for players who are moving).
442+
* Added server-side config item `long_range_tracker_interval` which controls how frequently long-range tracking data is sent by the server to clients; default is every 20 ticks (for players who are moving).
435443
* Set this to 0 to disable long-tracking entirely
436444
* Be careful about setting this to very low (non-zero) values; it can cause extra server and network load, especially on very busy servers
437445
* Added entity interaction protection as a Team setting
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package dev.ftb.mods.ftbchunks;
2+
3+
import dev.ftb.mods.ftbchunks.api.LevelMinYCalculator;
4+
import dev.ftb.mods.ftbchunks.api.event.CustomMinYEvent;
5+
import net.minecraft.core.BlockPos;
6+
import net.minecraft.world.level.Level;
7+
8+
import java.util.List;
9+
import java.util.OptionalInt;
10+
import java.util.concurrent.CopyOnWriteArrayList;
11+
12+
public class CustomMinYRegistryImpl implements CustomMinYEvent.CustomMinYRegistry {
13+
private static final CustomMinYRegistryImpl serverInstance = new CustomMinYRegistryImpl();
14+
private static final CustomMinYRegistryImpl clientInstance = new CustomMinYRegistryImpl();
15+
16+
private final List<LevelMinYCalculator> calculators = new CopyOnWriteArrayList<>(); // needs to be threadsafe
17+
18+
public static CustomMinYRegistryImpl getInstance(boolean isClientSide) {
19+
return isClientSide ? clientInstance : serverInstance;
20+
}
21+
22+
public void register(LevelMinYCalculator calculator) {
23+
calculators.add(calculator);
24+
}
25+
26+
public int getMinYAt(Level level, BlockPos pos) {
27+
for (var calc : calculators) {
28+
OptionalInt h = calc.getLevelMinY(level, pos);
29+
if (h.isPresent()) {
30+
return h.getAsInt();
31+
}
32+
}
33+
return level.getMinBuildHeight();
34+
}
35+
}

common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import dev.architectury.utils.EnvExecutor;
1515
import dev.architectury.utils.value.IntValue;
1616
import dev.ftb.mods.ftbchunks.api.*;
17+
import dev.ftb.mods.ftbchunks.api.event.CustomMinYEvent;
1718
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
1819
import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig;
1920
import dev.ftb.mods.ftbchunks.data.*;
@@ -133,6 +134,10 @@ public FTBChunks() {
133134
TickEvent.PLAYER_POST.register(this::playerTickPost);
134135

135136
EnvExecutor.runInEnv(Env.CLIENT, () -> FTBChunksClient.INSTANCE::init);
137+
138+
LifecycleEvent.SETUP.register(() ->
139+
CustomMinYEvent.REGISTER.invoker().register(CustomMinYRegistryImpl.getInstance(Platform.getEnvironment() == Env.CLIENT))
140+
);
136141
}
137142

138143
private EventResult playerAttackEntity(Player player, Level level, Entity entity, InteractionHand interactionHand, @Nullable EntityHitResult entityHitResult) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.ftb.mods.ftbchunks.api;
2+
3+
import dev.ftb.mods.ftbchunks.api.event.CustomMinYEvent;
4+
import net.minecraft.core.BlockPos;
5+
import net.minecraft.world.level.Level;
6+
7+
import java.util.OptionalInt;
8+
9+
/**
10+
* Functional interface to allow custom minimum Y levels to be returned for a given dimension and block position.
11+
* The intention of this is to allow for custom areas of a map to be concealed from FTB Chunks mapping.
12+
* <p>
13+
* Listen to the Architectury {@link CustomMinYEvent} event to register this method, on both client and server.
14+
*/
15+
@FunctionalInterface
16+
public interface LevelMinYCalculator {
17+
OptionalInt getLevelMinY(Level level, BlockPos pos);
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package dev.ftb.mods.ftbchunks.api.event;
2+
3+
import dev.architectury.event.Event;
4+
import dev.architectury.event.EventFactory;
5+
import dev.ftb.mods.ftbchunks.api.LevelMinYCalculator;
6+
7+
public interface CustomMinYEvent {
8+
Event<CustomMinYEvent> REGISTER = EventFactory.createLoop();
9+
10+
void register(CustomMinYRegistry registry);
11+
12+
interface CustomMinYRegistry {
13+
void register(LevelMinYCalculator calculator);
14+
}
15+
}

common/src/main/java/dev/ftb/mods/ftbchunks/util/HeightUtils.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package dev.ftb.mods.ftbchunks.util;
22

3+
import dev.ftb.mods.ftbchunks.CustomMinYRegistryImpl;
34
import dev.ftb.mods.ftbchunks.FTBChunksWorldConfig;
45
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
5-
import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig;
66
import dev.ftb.mods.ftbchunks.core.BlockStateFTBC;
77
import net.minecraft.core.BlockPos;
88
import net.minecraft.util.Mth;
@@ -43,14 +43,15 @@ public static int getHeight(Level level, @Nullable ChunkAccess chunkAccess, Bloc
4343
return UNKNOWN;
4444
}
4545

46-
int chunkX = pos.getX() >> 4;
47-
int chunkZ = pos.getZ() >> 4;
46+
// int chunkX = pos.getX() >> 4;
47+
// int chunkZ = pos.getZ() >> 4;
4848

4949
// Clamped within the dimensions build height limits
50-
int startY = FTBChunksWorldConfig.OVERRIDE_MIN_Y_LEVEL.get()
51-
? getMinYFromChunkOrConfig(chunkX, chunkZ)
52-
: chunkAccess.getMinBuildHeight();
50+
// int startY = FTBChunksWorldConfig.OVERRIDE_MIN_Y_LEVEL.get()
51+
// ? getMinYFromChunkOrConfig(chunkX, chunkZ)
52+
// : chunkAccess.getMinBuildHeight();
5353

54+
int startY = CustomMinYRegistryImpl.getInstance(level.isClientSide).getMinYAt(level, pos);
5455
int bottomY = Mth.clamp(startY, chunkAccess.getMinBuildHeight(), chunkAccess.getMaxBuildHeight());
5556

5657
int topY = pos.getY();

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ readable_name=FTB Chunks
88
maven_group=dev.ftb.mods
99
mod_author=FTB Team
1010

11-
mod_version=2101.1.12
11+
mod_version=2101.1.13
1212
minecraft_version=1.21.1
1313

1414
# Deps

0 commit comments

Comments
 (0)