Skip to content

Commit 80a4dd3

Browse files
authored
Merge pull request #282 from FTBTeam/dev
Dev
2 parents c61673f + 7e17f98 commit 80a4dd3

File tree

57 files changed

+729
-961
lines changed

Some content is hidden

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

57 files changed

+729
-961
lines changed

Diff for: .github/workflows/build.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
with:
1919
curse-publish-task: ""
2020
maven-snapshots: true
21+
java-version: 21
2122
secrets:
2223
ftb-maven-token: ${{ secrets.FTB_MAVEN_TOKEN }}
23-
saps-token: ${{ secrets.SAPS_TOKEN }}
24+
saps-token: ${{ secrets.SAPS_TOKEN }}

Diff for: .github/workflows/release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ jobs:
1111
uses: FTBTeam/mods-meta/.github/workflows/standard-release.yml@main
1212
with:
1313
curse-publish-task: curseforge
14+
java-version: 21
1415
secrets:
1516
ftb-maven-token: ${{ secrets.FTB_MAVEN_TOKEN }}
1617
saps-token: ${{ secrets.SAPS_TOKEN }}
17-
curse-token: ${{ secrets.CURSEFORGE_KEY }}
18+
curse-token: ${{ secrets.CURSEFORGE_KEY }}

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ 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+
## [2006.1.0]
8+
9+
### Changed
10+
* Ported to Minecraft 1.20.6. Support for Fabric and NeoForge.
11+
* Forge support may be re-added if/when Architectury adds support for Forge
12+
713
## [2004.1.3]
814

915
### Fixed

Diff for: build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "architectury-plugin" version "3.4-SNAPSHOT"
3-
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
3+
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
44
}
55

66
architectury {
@@ -18,6 +18,10 @@ subprojects {
1818
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
1919
mappings loom.officialMojangMappings()
2020
}
21+
22+
configurations.configureEach {
23+
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
24+
}
2125
}
2226

2327
allprojects {
@@ -33,7 +37,7 @@ allprojects {
3337
// needs to be done AFTER version is set
3438
apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/publishing.gradle"
3539

36-
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = 17
40+
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = 21
3741

3842
compileJava {
3943
options.encoding = "UTF-8"

Diff for: common/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
def ENV = System.getenv()
1010

1111
architectury {
12-
common("forge", "fabric", "neoforge")
12+
common(/* "forge", */ "fabric", "neoforge")
1313
}
1414

1515
configurations {

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

+19-14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import dev.architectury.event.EventResult;
77
import dev.architectury.event.events.common.*;
88
import dev.architectury.hooks.level.entity.PlayerHooks;
9+
import dev.architectury.networking.NetworkManager;
910
import dev.architectury.registry.registries.Registrar;
1011
import dev.architectury.registry.registries.RegistrarManager;
1112
import dev.architectury.utils.Env;
@@ -18,6 +19,7 @@
1819
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
1920
import dev.ftb.mods.ftbchunks.data.*;
2021
import dev.ftb.mods.ftbchunks.net.*;
22+
import dev.ftb.mods.ftbchunks.data.ChunkSyncInfo;
2123
import dev.ftb.mods.ftblibrary.integration.stages.StageHelper;
2224
import dev.ftb.mods.ftblibrary.math.ChunkDimPos;
2325
import dev.ftb.mods.ftblibrary.math.MathUtils;
@@ -181,7 +183,7 @@ private void serverLevelLoad(ServerLevel level) {
181183
if (ClaimedChunkManagerImpl.getInstance() != null) {
182184
ClaimedChunkManagerImpl.getInstance().initForceLoadedChunks(level);
183185
} else {
184-
FTBChunks.LOGGER.warn("Level " + level.dimension().location() + " loaded before FTB Chunks manager was initialized! Unable to force-load chunks");
186+
FTBChunks.LOGGER.warn("Level {} loaded before FTB Chunks manager was initialized! Unable to force-load chunks", level.dimension().location() );
185187
}
186188
}
187189

@@ -205,24 +207,24 @@ private void loggedIn(PlayerLoggedInAfterTeamEvent event) {
205207
SNBTCompoundTag config = new SNBTCompoundTag();
206208
FTBChunksWorldConfig.CONFIG.write(config);
207209
UUID managerId = FTBTeamsAPI.api().getManager().getId();
208-
new LoginDataPacket(managerId, config).sendTo(player);
210+
NetworkManager.sendToPlayer(player, new LoginDataPacket(managerId, config));
209211
SendGeneralDataPacket.send(data, player);
210212
FTBChunks.LOGGER.debug("server config and team data sent to {}", playerId);
211213

212214
long now = System.currentTimeMillis();
213-
Map<Pair<ResourceKey<Level>, UUID>, List<SendChunkPacket.SingleChunk>> chunksToSend = new HashMap<>();
215+
Map<Pair<ResourceKey<Level>, UUID>, List<ChunkSyncInfo>> chunksToSend = new HashMap<>();
214216

215217
for (ClaimedChunkImpl chunk : ClaimedChunkManagerImpl.getInstance().getAllClaimedChunks()) {
216218
chunksToSend.computeIfAbsent(Pair.of(chunk.getPos().dimension(), chunk.getTeamData().getTeamId()), s -> new ArrayList<>())
217-
.add(new SendChunkPacket.SingleChunk(now, chunk.getPos().x(), chunk.getPos().z(), chunk));
219+
.add(ChunkSyncInfo.create(now, chunk.getPos().x(), chunk.getPos().z(), chunk));
218220
}
219221

220222
chunksToSend.forEach((dimensionAndId, chunkPackets) -> {
221223
FTBTeamsAPI.api().getManager().getTeamByID(dimensionAndId.getRight()).ifPresent(team -> {
222224
ChunkTeamDataImpl teamData = ClaimedChunkManagerImpl.getInstance().getOrCreateData(team);
223225
if (teamData.canPlayerUse(player, FTBChunksProperties.CLAIM_VISIBILITY)) {
224226
SendManyChunksPacket packet = new SendManyChunksPacket(dimensionAndId.getLeft(), dimensionAndId.getRight(), chunkPackets);
225-
packet.sendTo(player);
227+
NetworkManager.sendToPlayer(player, packet);
226228
}
227229
});
228230
});
@@ -414,7 +416,7 @@ private void playerCloned(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolea
414416
if (!wonGame) {
415417
newPlayer.getLastDeathLocation().ifPresent(loc -> {
416418
int num = newPlayer.getStats().getValue(Stats.CUSTOM.get(Stats.DEATHS));
417-
new PlayerDeathPacket(loc, num).sendTo(newPlayer);
419+
NetworkManager.sendToPlayer(newPlayer, new PlayerDeathPacket(loc, num));
418420
});
419421
}
420422
}
@@ -425,7 +427,8 @@ private void playerChangedDimension(ServerPlayer serverPlayer, ResourceKey<Level
425427
StageHelper.INSTANCE.getProvider().sync(serverPlayer);
426428
}
427429

428-
private void teamConfig(TeamCollectPropertiesEvent event) {
430+
@SuppressWarnings("UnreachableCode")
431+
private void teamConfig(TeamCollectPropertiesEvent event) {
429432
event.add(FTBChunksProperties.ALLOW_EXPLOSIONS);
430433
event.add(FTBChunksProperties.ALLOW_MOB_GRIEFING);
431434
event.add(FTBChunksProperties.ALLOW_ALL_FAKE_PLAYERS);
@@ -484,7 +487,8 @@ private void playerLeftParty(PlayerLeftPartyTeamEvent event) {
484487
});
485488
}
486489

487-
private void transferClaims(ChunkTeamDataImpl transferFrom, ChunkTeamDataImpl transferTo, Collection<ClaimedChunkImpl> chunksToTransfer) {
490+
@SuppressWarnings("UnreachableCode")
491+
private void transferClaims(ChunkTeamDataImpl transferFrom, ChunkTeamDataImpl transferTo, Collection<ClaimedChunkImpl> chunksToTransfer) {
488492
CommandSourceStack sourceStack = ClaimedChunkManagerImpl.getInstance().getMinecraftServer().createCommandSourceStack();
489493

490494
String fromName = transferFrom.getTeam().getShortName();
@@ -495,8 +499,8 @@ private void transferClaims(ChunkTeamDataImpl transferFrom, ChunkTeamDataImpl tr
495499

496500
int nChunks = transferTo.getClaimedChunks().size();
497501

498-
Map<ResourceKey<Level>, List<SendChunkPacket.SingleChunk>> chunksToSend = new HashMap<>();
499-
Map<ResourceKey<Level>, List<SendChunkPacket.SingleChunk>> chunksToUnclaim = new HashMap<>();
502+
Map<ResourceKey<Level>, List<ChunkSyncInfo>> chunksToSend = new HashMap<>();
503+
Map<ResourceKey<Level>, List<ChunkSyncInfo>> chunksToUnclaim = new HashMap<>();
500504
int transferred = 0;
501505
int unclaimed = 0;
502506
long now = System.currentTimeMillis();
@@ -508,11 +512,11 @@ private void transferClaims(ChunkTeamDataImpl transferFrom, ChunkTeamDataImpl tr
508512
ChunkDimPos cdp = chunk.getPos();
509513
if (total >= transferTo.getMaxClaimChunks()) {
510514
chunk.unclaim(sourceStack, false);
511-
chunksToUnclaim.computeIfAbsent(cdp.dimension(), s -> new ArrayList<>()).add(new SendChunkPacket.SingleChunk(now, cdp.x(), cdp.z(), null));
515+
chunksToUnclaim.computeIfAbsent(cdp.dimension(), s -> new ArrayList<>()).add(ChunkSyncInfo.create(now, cdp.x(), cdp.z(), null));
512516
unclaimed++;
513517
} else {
514518
chunk.setTeamData(transferTo);
515-
chunksToSend.computeIfAbsent(cdp.dimension(), s -> new ArrayList<>()).add(new SendChunkPacket.SingleChunk(now, cdp.x(), cdp.z(), chunk));
519+
chunksToSend.computeIfAbsent(cdp.dimension(), s -> new ArrayList<>()).add(ChunkSyncInfo.create(now, cdp.x(), cdp.z(), chunk));
516520
transferred++;
517521
}
518522

@@ -536,13 +540,14 @@ private void transferClaims(ChunkTeamDataImpl transferFrom, ChunkTeamDataImpl tr
536540
if (transferred > 0 || unclaimed > 0) {
537541
chunksToSend.forEach((dimension, chunkPackets) -> {
538542
if (!chunkPackets.isEmpty()) {
539-
ChunkSendingUtils.sendManyChunksToAll(sourceStack.getServer(), transferTo, new SendManyChunksPacket(dimension, transferTo.getTeamId(), chunkPackets));
543+
new SendManyChunksPacket(dimension, transferTo.getTeamId(), chunkPackets)
544+
.sendToAll(sourceStack.getServer(), transferTo);
540545
}
541546
});
542547

543548
chunksToUnclaim.forEach((dimension, chunkPackets) -> {
544549
if (!chunkPackets.isEmpty()) {
545-
new SendManyChunksPacket(dimension, Util.NIL_UUID, chunkPackets).sendToAll(sourceStack.getServer());
550+
NetworkManager.sendToPlayers(sourceStack.getServer().getPlayerList().getPlayers(), new SendManyChunksPacket(dimension, Util.NIL_UUID, chunkPackets));
546551
}
547552
});
548553
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.mojang.brigadier.exceptions.CommandSyntaxException;
99
import com.mojang.brigadier.tree.LiteralCommandNode;
1010
import com.mojang.util.UndashedUuid;
11+
import dev.architectury.networking.NetworkManager;
1112
import dev.ftb.mods.ftbchunks.api.ChunkTeamData;
1213
import dev.ftb.mods.ftbchunks.api.ClaimResult;
1314
import dev.ftb.mods.ftbchunks.api.ClaimedChunk;
@@ -180,7 +181,7 @@ public static void registerCommands(CommandDispatcher<CommandSourceStack> dispat
180181
.then(Commands.literal("block_color")
181182
// .requires(source -> source.getServer().isSingleplayer())
182183
.executes(context -> {
183-
new RequestBlockColorPacket().sendTo(context.getSource().getPlayerOrException());
184+
NetworkManager.sendToPlayer(context.getSource().getPlayerOrException(), new RequestBlockColorPacket());
184185
return 1;
185186
})
186187
)
@@ -203,8 +204,7 @@ public static void registerCommands(CommandDispatcher<CommandSourceStack> dispat
203204

204205
private static int addWaypoint(CommandSourceStack source, String name, BlockPos position, ChatFormatting color) throws CommandSyntaxException {
205206
if (color.getColor() != null) {
206-
ServerPlayer player = source.getPlayerOrException();
207-
new AddWaypointPacket(name, position, color.getColor()).sendTo(player);
207+
NetworkManager.sendToPlayer(source.getPlayerOrException(), new AddWaypointPacket(name, position, color.getColor()));
208208
}
209209
return 1;
210210
}
@@ -465,13 +465,13 @@ private static int viewLoadedChunks(CommandSourceStack source, ServerLevel level
465465
}
466466

467467
source.sendSuccess(() -> Component.literal(String.format("Chunks Loaded: %d. Check the map to see loaded chunks", chunks.size())), false);
468-
new LoadedChunkViewPacket(level.dimension(), chunks).sendTo(source.getPlayerOrException());
468+
NetworkManager.sendToPlayer(source.getPlayerOrException(), new LoadedChunkViewPacket(level.dimension(), chunks));
469469

470470
return 1;
471471
}
472472

473473
private static int resetLoadedChunks(CommandSourceStack source, ServerLevel level) throws CommandSyntaxException {
474-
new LoadedChunkViewPacket(level.dimension(), Long2IntMaps.EMPTY_MAP).sendTo(source.getPlayerOrException());
474+
NetworkManager.sendToPlayer(source.getPlayerOrException(), new LoadedChunkViewPacket(level.dimension(), Long2IntMaps.EMPTY_MAP));
475475
return 1;
476476
}
477477

0 commit comments

Comments
 (0)