Skip to content

Commit

Permalink
feat: Add nms module v1_21_R3 for Minecraft 1.21.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
SpraxDev committed Dec 7, 2024
1 parent 4db0dfb commit 81eef32
Show file tree
Hide file tree
Showing 22 changed files with 1,491 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup_project_workspace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ runs:

- uses: SpraxDev/Action-SpigotMC@v5
with:
versions: 1.20.6, 1.21.1, 1.21.3
versions: 1.20.6, 1.21.1, 1.21.3, 1.21.4
remapped: true
sftpCacheHost: ${{ inputs.spigot_buildtools_sftp_host }}
sftpCachePort: ${{ inputs.spigot_buildtools_sftp_port }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum ServerVersion {
V1_20, V1_20_1, V1_20_2, V1_20_3, V1_20_4, V1_20_5, V1_20_6,

// 1.21.x
V1_21, V1_21_1, V1_21_2, V1_21_3,
V1_21, V1_21_1, V1_21_2, V1_21_3, V1_21_4,

// 1.22.x
V1_22,
Expand Down Expand Up @@ -80,6 +80,7 @@ public enum ServerVersion {
VERSION_TO_REVISION.put("1.21", "v1_21_R1");
VERSION_TO_REVISION.put("1.21.1", "v1_21_R1");
VERSION_TO_REVISION.put("1.21.3", "v1_21_R2");
VERSION_TO_REVISION.put("1.21.4", "v1_21_R3");

if (Bukkit.getServer() != null) {
String srvPackage = Bukkit.getServer().getClass().getPackage().getName();
Expand Down
89 changes: 89 additions & 0 deletions NMS/NMS-v1_21_R3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.craftaro</groupId>
<artifactId>CraftaroCore-Modules</artifactId>
<version>3.6.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>CraftaroCore-NMS-v1_21_R3</artifactId>

<properties>
<java.version>21</java.version>
<java.release>21</java.release>

<nms.ver>1.21.4-R0.1-SNAPSHOT</nms.ver>
</properties>

<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>

<executions>
<execution>
<id>remap-obf</id>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>

<configuration>
<srgIn>org.spigotmc:minecraft-server:${nms.ver}:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:${nms.ver}:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>

<execution>
<id>remap-spigot</id>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>

<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:${nms.ver}:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:${nms.ver}:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${nms.ver}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>

<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>CraftaroCore-NMS-API</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>CraftaroCore-Compatibility</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.craftaro.core.nms.v1_21_R3;

import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_21_R3.anvil.AnvilCore;
import com.craftaro.core.nms.v1_21_R3.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_21_R3.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_21_R3.item.NmsItemImpl;
import com.craftaro.core.nms.v1_21_R3.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_21_R3.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_21_R3.world.WorldCoreImpl;
import com.craftaro.core.nms.world.NmsWorldBorder;
import com.craftaro.core.nms.world.WorldCore;
import org.jetbrains.annotations.NotNull;

public class NmsImplementationsImpl implements NmsImplementations {
private final NmsEntity entity;
private final NMSPlayer player;
private final WorldCore world;
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;

public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
this.player = new NMSPlayerImpl();
this.world = new WorldCoreImpl();
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}

@Override
public @NotNull NmsEntity getEntity() {
return this.entity;
}

@Override
public @NotNull NMSPlayer getPlayer() {
return this.player;
}

@Override
public @NotNull WorldCore getWorld() {
return this.world;
}

@Override
public @NotNull NmsWorldBorder getWorldBorder() {
return this.worldBorder;
}

@Override
public @NotNull com.craftaro.core.nms.anvil.AnvilCore getAnvil() {
return this.anvil;
}

@Override
public @NotNull NBTCore getNbt() {
return this.nbt;
}

@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.craftaro.core.nms.v1_21_R3.anvil;

import com.craftaro.core.nms.anvil.CustomAnvil;
import net.minecraft.server.level.ServerPlayer;
import org.bukkit.craftbukkit.v1_21_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;

public class AnvilCore implements com.craftaro.core.nms.anvil.AnvilCore {
@Override
public CustomAnvil createAnvil(Player player) {
ServerPlayer p = ((CraftPlayer) player).getHandle();
return new AnvilView(p.nextContainerCounter(), p, null);
}

@Override
public CustomAnvil createAnvil(Player player, InventoryHolder holder) {
ServerPlayer p = ((CraftPlayer) player).getHandle();
return new AnvilView(p.nextContainerCounter(), p, holder);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.craftaro.core.nms.v1_21_R3.anvil;

import net.minecraft.world.Container;
import net.minecraft.world.inventory.AnvilMenu;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_21_R3.inventory.CraftInventoryAnvil;
import org.bukkit.inventory.InventoryHolder;

public class AnvilInventoryCustom extends CraftInventoryAnvil {
final InventoryHolder holder;

public AnvilInventoryCustom(InventoryHolder holder, Location location, Container inventory, Container resultInventory, AnvilMenu container) {
super(location, inventory, resultInventory);

this.holder = holder;
}

@Override
public InventoryHolder getHolder() {
return this.holder;
}
}
Loading

0 comments on commit 81eef32

Please sign in to comment.