Skip to content

Commit 0efe28f

Browse files
committed
Backport to Minecraft 1.21.1
1 parent 2083c87 commit 0efe28f

File tree

23 files changed

+60
-80
lines changed

23 files changed

+60
-80
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
java-version: [ 25 ]
16+
java-version: [ 21 ]
1717

1818
steps:
1919
- name: Checkout repository
@@ -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

fabric/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
2-
id 'fabric-loom' version '1.14-SNAPSHOT'
3-
id 'com.gradleup.shadow' version '9.3.1'
2+
id 'fabric-loom' version '1.12-SNAPSHOT'
3+
id 'com.gradleup.shadow' version '9.2.2'
44
}
55

66
java {
@@ -9,10 +9,10 @@ java {
99
}
1010

1111
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'
12+
minecraft_version = '1.21.1'
13+
yarn_mappings = '1.21.1+build.3'
14+
loader_version = '0.18.5'
15+
fabric_version = '0.116.9+1.21.1'
1616
}
1717

1818
dependencies {
@@ -29,7 +29,7 @@ loom {
2929

3030
processResources {
3131
filesMatching('**/*.json') {
32-
expand 'version': project.version
32+
expand 'version': version
3333
}
3434
}
3535

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public Stream<CommandSender> getOnlinePlayers() {
133133
@Override
134134
public void dispatchConsoleCommand(String command) {
135135
ServerCommandSource source = getServer().getCommandSource();
136-
getServer().getCommandManager().parseAndExecute(source, command);
136+
getServer().getCommandManager().executeWithPrefix(source, command);
137137
}
138138

139139
@Override

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import net.minecraft.text.Text;
1111
import net.minecraft.util.Formatting;
1212

13-
import java.net.URI;
1413
import java.util.EnumMap;
1514
import java.util.Map;
1615

@@ -48,8 +47,8 @@ public static Text toText(TextComponent component) {
4847
}
4948

5049
if (component.url() != null) {
51-
URI uri = URI.create(component.url());
52-
result.fillStyle(Style.EMPTY.withClickEvent(new ClickEvent.OpenUrl(uri)));
50+
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, component.url());
51+
result.fillStyle(Style.EMPTY.withClickEvent(clickEvent));
5352
}
5453

5554
for (TextComponent child : component.children()) {

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
import com.azuriom.azlink.common.chat.TextComponent;
44
import com.azuriom.azlink.common.command.CommandSender;
55
import com.azuriom.azlink.fabric.MinecraftTextAdapter;
6-
import net.minecraft.command.permission.Permission;
7-
import net.minecraft.command.permission.PermissionLevel;
86
import net.minecraft.entity.Entity;
97
import net.minecraft.server.command.ServerCommandSource;
108

119
import java.util.UUID;
1210

1311
public class FabricCommandSource implements CommandSender {
1412

15-
private static final Permission PERMISSION_LEVEL_OWNERS = new Permission.Level(PermissionLevel.OWNERS);
16-
1713
private final ServerCommandSource source;
1814

1915
public FabricCommandSource(ServerCommandSource source) {
@@ -46,6 +42,6 @@ public void sendMessage(TextComponent message) {
4642

4743
@Override
4844
public boolean hasPermission(String permission) {
49-
return this.source.getPermissions().hasPermission(PERMISSION_LEVEL_OWNERS);
45+
return this.source.hasPermissionLevel(3);
5046
}
5147
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
import com.azuriom.azlink.common.chat.TextComponent;
44
import com.azuriom.azlink.common.command.CommandSender;
55
import com.azuriom.azlink.fabric.MinecraftTextAdapter;
6-
import net.minecraft.command.permission.Permission;
7-
import net.minecraft.command.permission.PermissionLevel;
86
import net.minecraft.server.network.ServerPlayerEntity;
97

108
import java.util.UUID;
119

1210
public class FabricPlayer implements CommandSender {
1311

14-
private static final Permission PERMISSION_LEVEL_OWNERS = new Permission.Level(PermissionLevel.OWNERS);
15-
1612
private final ServerPlayerEntity player;
1713

1814
public FabricPlayer(ServerPlayerEntity player) {
@@ -41,6 +37,6 @@ public void sendMessage(TextComponent message) {
4137

4238
@Override
4339
public boolean hasPermission(String permission) {
44-
return this.player.getPermissions().hasPermission(PERMISSION_LEVEL_OWNERS);
40+
return this.player.hasPermissionLevel(3);
4541
}
4642
}

forge/build.gradle

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
2-
id 'net.minecraftforge.gradle' version '[7.0.3,8)'
3-
id 'com.gradleup.shadow' version '9.3.1'
2+
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
3+
id 'com.gradleup.shadow' version '9.2.2'
44
}
55

66
java {
@@ -9,22 +9,25 @@ java {
99
}
1010

1111
ext {
12-
minecraft_version = '1.21.11'
13-
forge_version = '61.1.0'
14-
}
15-
16-
repositories {
17-
minecraft.mavenizer(it)
18-
maven fg.forgeMaven
19-
maven fg.minecraftLibsMaven
12+
minecraft_version = '1.21.1'
13+
forge_version = '52.1.0'
2014
}
2115

2216
dependencies {
2317
def forgeVersion = "${project.ext.minecraft_version}-${project.ext.forge_version}"
2418

2519
implementation project(':azlink-common')
26-
implementation minecraft.dependency("net.minecraftforge:forge:${forgeVersion}")
27-
annotationProcessor 'net.minecraftforge:eventbus-validator:7.0.1'
20+
minecraft "net.minecraftforge:forge:${forgeVersion}"
21+
}
22+
23+
minecraft {
24+
mappings channel: 'official', version: project.ext.minecraft_version
25+
}
26+
27+
processResources {
28+
filesMatching('**/*.toml') {
29+
expand 'version': version
30+
}
2831
}
2932

3033
shadowJar {

forge/src/main/java/com/azuriom/azlink/forge/AzLinkForgeMod.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import net.minecraftforge.event.TickEvent;
2424
import net.minecraftforge.event.server.ServerAboutToStartEvent;
2525
import net.minecraftforge.event.server.ServerStoppingEvent;
26-
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
26+
import net.minecraftforge.eventbus.api.SubscribeEvent;
2727
import net.minecraftforge.fml.ModList;
2828
import net.minecraftforge.fml.common.Mod;
2929
import net.minecraftforge.fml.loading.FMLLoader;
@@ -68,7 +68,6 @@ public AzLinkForgeMod() {
6868
}
6969

7070
MinecraftForge.EVENT_BUS.register(this);
71-
TickEvent.ServerTickEvent.Pre.BUS.addListener(e -> this.tpsTask.run());
7271
}
7372

7473
@SubscribeEvent
@@ -92,6 +91,11 @@ public void onRegisterCommands(RegisterCommandsEvent event) {
9291
command.register(event.getDispatcher());
9392
}
9493

94+
@SubscribeEvent
95+
public void onTickStart(TickEvent.ServerTickEvent.Pre event) {
96+
this.tpsTask.run();
97+
}
98+
9599
@Override
96100
public AzLinkPlugin getPlugin() {
97101
return this.plugin;

forge/src/main/java/com/azuriom/azlink/forge/MinecraftComponentAdapter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import net.minecraft.network.chat.MutableComponent;
1010
import net.minecraft.network.chat.Style;
1111

12-
import java.net.URI;
1312
import java.util.EnumMap;
1413
import java.util.Map;
1514

@@ -47,8 +46,8 @@ public static Component toComponent(TextComponent component) {
4746
}
4847

4948
if (component.url() != null) {
50-
URI uri = URI.create(component.url());
51-
result.withStyle(Style.EMPTY.withClickEvent(new ClickEvent.OpenUrl(uri)));
49+
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, component.url());
50+
result.withStyle(Style.EMPTY.withClickEvent(clickEvent));
5251
}
5352

5453
for (TextComponent child : component.children()) {

forge/src/main/java/com/azuriom/azlink/forge/command/ForgeCommandSource.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
import com.azuriom.azlink.common.command.CommandSender;
55
import com.azuriom.azlink.forge.MinecraftComponentAdapter;
66
import net.minecraft.commands.CommandSourceStack;
7-
import net.minecraft.server.permissions.Permission;
8-
import net.minecraft.server.permissions.PermissionLevel;
97
import net.minecraft.world.entity.Entity;
108

119
import java.util.UUID;
1210

1311
public class ForgeCommandSource implements CommandSender {
1412

15-
private static final Permission PERMISSION_LEVEL_OWNERS = new Permission.HasCommandLevel(PermissionLevel.OWNERS);
16-
1713
private final CommandSourceStack source;
1814

1915
public ForgeCommandSource(CommandSourceStack source) {
@@ -46,6 +42,6 @@ public void sendMessage(TextComponent message) {
4642

4743
@Override
4844
public boolean hasPermission(String permission) {
49-
return this.source.permissions().hasPermission(PERMISSION_LEVEL_OWNERS);
45+
return this.source.hasPermission(3);
5046
}
5147
}

0 commit comments

Comments
 (0)