Skip to content

Commit 0320950

Browse files
committed
Update to Minecraft 26.1
1 parent 2083c87 commit 0320950

13 files changed

Lines changed: 131 additions & 146 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ jobs:
5555
- name: Upload AzLink-Forge.jar
5656
uses: actions/upload-artifact@v4
5757
with:
58-
name: AzLink-NeoForge
59-
path: neoforge/build/libs/AzLink-Forge-*.jar
58+
name: AzLink-Forge
59+
path: forge/build/libs/AzLink-Forge-*.jar
6060
overwrite: true
6161

6262
- name: Upload AzLink-NeoForge.jar

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ subprojects {
77
apply plugin: 'java'
88

99
java {
10-
sourceCompatibility = JavaVersion.VERSION_1_8
11-
targetCompatibility = JavaVersion.VERSION_1_8
10+
sourceCompatibility = JavaVersion.VERSION_25
11+
targetCompatibility = JavaVersion.VERSION_25
1212
}
1313

1414
tasks.withType(JavaCompile) {

fabric/build.gradle

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
plugins {
2-
id 'fabric-loom' version '1.14-SNAPSHOT'
2+
id 'net.fabricmc.fabric-loom' version '1.15-SNAPSHOT'
33
id 'com.gradleup.shadow' version '9.3.1'
44
}
55

6-
java {
7-
sourceCompatibility = JavaVersion.VERSION_21
8-
targetCompatibility = JavaVersion.VERSION_21
9-
}
10-
116
ext {
12-
minecraft_version = '1.21.11'
13-
yarn_mappings = '1.21.11+build.4'
14-
loader_version = '0.18.4'
15-
fabric_version = '0.141.1+1.21.11'
7+
minecraft_version = '26.1'
8+
loader_version = '0.18.5'
9+
fabric_api_version = '0.144.4+26.1'
1610
}
1711

1812
dependencies {
1913
implementation project(':azlink-common')
2014
minecraft "com.mojang:minecraft:${project.ext.minecraft_version}"
21-
mappings "net.fabricmc:yarn:${project.ext.yarn_mappings}:v2"
22-
modImplementation "net.fabricmc:fabric-loader:${project.ext.loader_version}"
23-
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.ext.fabric_version}"
15+
implementation "net.fabricmc:fabric-loader:${project.ext.loader_version}"
16+
implementation "net.fabricmc.fabric-api:fabric-api:${project.ext.fabric_api_version}"
17+
}
18+
19+
configurations {
20+
shade
21+
implementation.extendsFrom shade
2422
}
2523

2624
loom {
@@ -29,25 +27,20 @@ loom {
2927

3028
processResources {
3129
filesMatching('**/*.json') {
32-
expand 'version': project.version
30+
expand 'version': version
3331
}
3432
}
3533

3634
shadowJar {
35+
archiveFileName = "AzLink-Fabric-${project.version}-${project.ext.minecraft_version}.jar"
36+
configurations = [project.configurations.shade]
37+
3738
dependencies {
3839
exclude 'net.fabricmc:.*'
3940
include dependency('com.azuriom:.*')
4041
}
4142
}
4243

43-
remapJar {
44-
dependsOn tasks.shadowJar
45-
mustRunAfter tasks.shadowJar
46-
inputFile = shadowJar.archiveFile
47-
addNestedDependencies = true
48-
archiveFileName = "AzLink-Fabric-${project.version}-${project.ext.minecraft_version}.jar"
49-
}
50-
5144
build {
52-
dependsOn remapJar
45+
dependsOn shadowJar
5346
}

fabric/src/main/java/com/azuriom/azlink/fabric/AzLinkFabricMod.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
2222
import net.fabricmc.loader.api.FabricLoader;
2323
import net.fabricmc.loader.api.ModContainer;
24+
import net.minecraft.commands.CommandSourceStack;
25+
import net.minecraft.commands.Commands;
2426
import net.minecraft.server.MinecraftServer;
25-
import net.minecraft.server.command.ServerCommandSource;
2627
import org.slf4j.Logger;
2728
import org.slf4j.LoggerFactory;
2829

@@ -112,37 +113,39 @@ public Path getDataDirectory() {
112113

113114
@Override
114115
public Optional<WorldData> getWorldData() {
115-
int loadedChunks = Streams.stream(getServer().getWorlds())
116-
.mapToInt(w -> w.getChunkManager().getLoadedChunkCount())
116+
int loadedChunks = Streams.stream(getServer().getAllLevels())
117+
.mapToInt(w -> w.getChunkSource().getLoadedChunksCount())
117118
.sum();
118-
int entities = Streams.stream(getServer().getWorlds())
119-
.mapToInt(w -> Iterables.size(w.iterateEntities()))
119+
int entities = Streams.stream(getServer().getAllLevels())
120+
.mapToInt(w -> Iterables.size(w.getAllEntities()))
120121
.sum();
121122

122123
return Optional.of(new WorldData(this.tpsTask.getTps(), loadedChunks, entities));
123124
}
124125

125126
@Override
126127
public Stream<CommandSender> getOnlinePlayers() {
127-
return getServer().getPlayerManager()
128-
.getPlayerList()
128+
return getServer().getPlayerList()
129+
.getPlayers()
129130
.stream()
130131
.map(FabricPlayer::new);
131132
}
132133

133134
@Override
134135
public void dispatchConsoleCommand(String command) {
135-
ServerCommandSource source = getServer().getCommandSource();
136-
getServer().getCommandManager().parseAndExecute(source, command);
136+
CommandSourceStack console = this.getServer().createCommandSourceStack();
137+
Commands commandManager = console.getServer().getCommands();
138+
var parsed = commandManager.getDispatcher().parse(command, console);
139+
commandManager.performCommand(parsed, command);
137140
}
138141

139142
@Override
140143
public int getMaxPlayers() {
141-
return getServer().getMaxPlayerCount();
144+
return getServer().getMaxPlayers();
142145
}
143146

144147
private SchedulerAdapter initScheduler() {
145-
return new JavaSchedulerAdapter(getServer()::executeSync);
148+
return new JavaSchedulerAdapter(getServer()::executeIfPossible);
146149
}
147150

148151
@SuppressWarnings("deprecation")
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.azuriom.azlink.fabric;
2+
3+
import com.azuriom.azlink.common.chat.TextColor;
4+
import com.azuriom.azlink.common.chat.TextComponent;
5+
import com.azuriom.azlink.common.chat.TextDecoration;
6+
import net.minecraft.ChatFormatting;
7+
import net.minecraft.network.chat.ClickEvent;
8+
import net.minecraft.network.chat.Component;
9+
import net.minecraft.network.chat.MutableComponent;
10+
import net.minecraft.network.chat.Style;
11+
12+
import java.net.URI;
13+
import java.util.EnumMap;
14+
import java.util.Map;
15+
16+
/**
17+
* Adapter to convert {@link TextComponent} to Minecraft {@link Component}.
18+
*/
19+
public final class MinecraftComponentAdapter {
20+
21+
private static final Map<TextColor, ChatFormatting> COLOR_MAP = new EnumMap<>(TextColor.class);
22+
private static final Map<TextDecoration, ChatFormatting> DECORATION_MAP = new EnumMap<>(TextDecoration.class);
23+
24+
static {
25+
for (TextColor color : TextColor.values()) {
26+
COLOR_MAP.put(color, ChatFormatting.valueOf(color.name()));
27+
}
28+
29+
for (TextDecoration decoration : TextDecoration.values()) {
30+
DECORATION_MAP.put(decoration, ChatFormatting.valueOf(decoration.name()));
31+
}
32+
}
33+
34+
private MinecraftComponentAdapter() {
35+
throw new UnsupportedOperationException();
36+
}
37+
38+
public static Component toComponent(TextComponent component) {
39+
MutableComponent result = Component.literal(component.content());
40+
41+
if (component.color() != null) {
42+
result.withStyle(COLOR_MAP.get(component.color()));
43+
}
44+
45+
for (TextDecoration decoration : component.decorations()) {
46+
result.withStyle(DECORATION_MAP.get(decoration));
47+
}
48+
49+
if (component.url() != null) {
50+
URI uri = URI.create(component.url());
51+
result.withStyle(Style.EMPTY.withClickEvent(new ClickEvent.OpenUrl(uri)));
52+
}
53+
54+
for (TextComponent child : component.children()) {
55+
result.append(toComponent(child));
56+
}
57+
58+
return result;
59+
}
60+
}

fabric/src/main/java/com/azuriom/azlink/fabric/MinecraftTextAdapter.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

fabric/src/main/java/com/azuriom/azlink/fabric/command/FabricCommandExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
import com.mojang.brigadier.suggestion.SuggestionProvider;
1212
import com.mojang.brigadier.suggestion.Suggestions;
1313
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
14-
import net.minecraft.server.command.ServerCommandSource;
14+
import net.minecraft.commands.CommandSourceStack;
1515

1616
import java.util.concurrent.CompletableFuture;
1717

18-
public class FabricCommandExecutor<S extends ServerCommandSource>
18+
public class FabricCommandExecutor<S extends CommandSourceStack>
1919
extends AzLinkCommand implements Command<S>, SuggestionProvider<S> {
2020

2121
public FabricCommandExecutor(AzLinkPlugin plugin) {

fabric/src/main/java/com/azuriom/azlink/fabric/command/FabricCommandSource.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22

33
import com.azuriom.azlink.common.chat.TextComponent;
44
import com.azuriom.azlink.common.command.CommandSender;
5-
import com.azuriom.azlink.fabric.MinecraftTextAdapter;
6-
import net.minecraft.command.permission.Permission;
7-
import net.minecraft.command.permission.PermissionLevel;
8-
import net.minecraft.entity.Entity;
9-
import net.minecraft.server.command.ServerCommandSource;
5+
import com.azuriom.azlink.fabric.MinecraftComponentAdapter;
6+
import net.minecraft.commands.CommandSourceStack;
7+
import net.minecraft.server.permissions.Permission;
8+
import net.minecraft.server.permissions.PermissionLevel;
9+
import net.minecraft.world.entity.Entity;
1010

1111
import java.util.UUID;
1212

1313
public class FabricCommandSource implements CommandSender {
1414

15-
private static final Permission PERMISSION_LEVEL_OWNERS = new Permission.Level(PermissionLevel.OWNERS);
15+
private static final Permission PERMISSION_LEVEL_OWNERS = new Permission.HasCommandLevel(PermissionLevel.OWNERS);
1616

17-
private final ServerCommandSource source;
17+
private final CommandSourceStack source;
1818

19-
public FabricCommandSource(ServerCommandSource source) {
19+
public FabricCommandSource(CommandSourceStack source) {
2020
this.source = source;
2121
}
2222

2323
@Override
2424
public String getName() {
25-
return this.source.getName();
25+
return this.source.getTextName();
2626
}
2727

2828
@Override
2929
public UUID getUuid() {
3030
Entity entity = this.source.getEntity();
3131

3232
return entity != null
33-
? entity.getUuid()
34-
: UUID.nameUUIDFromBytes(this.source.getName().getBytes());
33+
? entity.getUUID()
34+
: UUID.nameUUIDFromBytes(this.source.getTextName().getBytes());
3535
}
3636

3737
@Override
@@ -41,11 +41,11 @@ public void sendMessage(String message) {
4141

4242
@Override
4343
public void sendMessage(TextComponent message) {
44-
this.source.sendMessage(MinecraftTextAdapter.toText(message));
44+
this.source.sendSystemMessage(MinecraftComponentAdapter.toComponent(message));
4545
}
4646

4747
@Override
4848
public boolean hasPermission(String permission) {
49-
return this.source.getPermissions().hasPermission(PERMISSION_LEVEL_OWNERS);
49+
return this.source.permissions().hasPermission(PERMISSION_LEVEL_OWNERS);
5050
}
5151
}

0 commit comments

Comments
 (0)