Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/nms-groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ java21:

java25:
- "26.1.2" # 26_1_R1
- "26.2" # 26_2_R1
1 change: 1 addition & 0 deletions NEXT_RELEASE_CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added support for MC 26.2.
9 changes: 8 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,14 @@

<dependency>
<groupId>nl.pim16aap2.BigDoors</groupId>
<artifactId>v26_R1</artifactId>
<artifactId>v26_1_R1</artifactId>
<version>0.1.8.68-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>nl.pim16aap2.BigDoors</groupId>
<artifactId>v26_2_R1</artifactId>
<version>0.1.8.68-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/nl/pim16aap2/bigDoors/BigDoors.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactoryProvider_V1_21_R5;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactoryProvider_V1_21_R6;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactoryProvider_V1_21_R7;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactoryProvider_V26_2_R1;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactoryProvider_V26_R1;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactory_V1_11_R1;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactory_V1_12_R1;
Expand Down Expand Up @@ -930,7 +931,17 @@ public static boolean isOnFlattenedVersion()
case 1:
case 2:
return FallingBlockFactoryProvider_V26_R1.getFactory();
default:
logger.severe("Unexpected patch version '" + SERVER_VERSION.getPatch() + "' for 26.1.x!");
return null;
}
case 2:
{
return FallingBlockFactoryProvider_V26_2_R1.getFactory();
}
Comment thread
PimvanderLoos marked this conversation as resolved.
default:
logger.severe("Unexpected minor version '" + SERVER_VERSION.getMinor() + "' for 26.x!");
return null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private static FallingBlockFactory generateFallingBlockFactory()

try
{
ensureReflectionLookupSuccess();
final String mappingsVersion = getMappingsVersion();
final ClassGenerator entityFallingBlockClassGenerator =
new EntityFallingBlockClassGenerator(mappingsVersion);
Expand Down Expand Up @@ -106,6 +107,11 @@ private static FallingBlockFactory generateFallingBlockFactory()
}
}

private static void ensureReflectionLookupSuccess()
{
ReflectionRepository.noop();
}

@SuppressWarnings("unchecked")
private static String getPaperMappingsVersion()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ final class ReflectionRepository
public static final Class<?> classCraftBlockData;
public static final Class<?> classBlockStateEnum;
public static final Class<?> classEntityTypes;
public static final Class<?> classEntityType;
public static final Class<?> classRegistries;
public static final Class<?> classResourceKey;
public static final Class<?> classMinecraftKey;
Expand Down Expand Up @@ -187,7 +188,8 @@ final class ReflectionRepository
classEnumDirectionAxis = findClass("net.minecraft.core.Direction$Axis").get();
classEnumBlockRotation = findClass("net.minecraft.world.level.block.Rotation").get();
classBlockRotatable = findClass("net.minecraft.world.level.block.RotatedPillarBlock").get();
classEntityTypes = findClass("net.minecraft.world.entity.EntityType").get();
classEntityTypes = findClass("net.minecraft.world.entity.EntityTypes").get();
classEntityType = findClass("net.minecraft.world.entity.EntityType").get();
classRegistries = findClass("net.minecraft.core.registries.Registries").get();
classResourceKey = findClass("net.minecraft.resources.ResourceKey").get();
classIWorldReader = findClass("net.minecraft.world.level.LevelReader").get();
Expand All @@ -202,7 +204,7 @@ final class ReflectionRepository
.get();
cTorPublicNMSFallingBlockEntity = findConstructor()
.inClass(classEntityFallingBlock)
.withParameters(classEntityTypes, classNMSWorld)
.withParameters(classEntityType, classNMSWorld)
.get();
cTorVec3D = findConstructor()
.inClass(classVec3D)
Expand Down Expand Up @@ -565,6 +567,14 @@ final class ReflectionRepository
}
}

/**
* This method is used to ensure that the static initializer of this class is executed.
* <p>
* It does nothing and is only used for its side effect of triggering the static initializer.
*/
static void noop() {
}

private static Method getMethodCraftBockDataFromNMSBlockData()
{
Method method = findMethod()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ else if (executable instanceof Constructor)

try
{
return Objects.requireNonNull(
StaticFieldFinder staticFieldFinder = Objects.requireNonNull(
ASMUtil.processMethod(executable, null, (a, n, d, s, e) ->
StaticFieldFinder.create(a, n, d, s, e, fieldType, 1))
).fields[0];
);

return Objects.requireNonNull(
staticFieldFinder.fields[0]
);
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,15 @@ public enum ResourcePackDetails
"https://www.dropbox.com/scl/fi/drls9p9bhg28zbinty3d6/BigDoorsResourcePack-Format84.zip?rlkey=zrulj21mbwz4tzpbyys5pzq1f&st=v3vz19ml&dl=1",
"b10c21defae3548afd124e7dc48de1cfe1fe3ecc",
Semver.of(26, 0, 0),
Semver.of(26, 1, 1)
)
Semver.of(26, 1, 2)
),

FORMAT_88(
"https://www.dropbox.com/scl/fi/2ucdkpbyhhdr8wzomwnky/BigDoorsResourcePack-Format88.zip?rlkey=7m95e23vxtwqcwkw2atjuivs0&st=9k4wr5gg&dl=1",
"57789486b18b0d79de1e0f1ad68047580068ffb5",
Semver.of(26, 2, 0),
Semver.of(26, 2, 1)
),

;

Expand Down
3 changes: 2 additions & 1 deletion nms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
<module>v1_21_R6</module>
<module>v1_21_R7</module>

<module>v26_R1</module>
<module>v26_1_R1</module>
<module>v26_2_R1</module>
</modules>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion nms/v26_R1/pom.xml → nms/v26_1_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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>
<packaging>jar</packaging>
<artifactId>v26_R1</artifactId>
<artifactId>v26_1_R1</artifactId>

<parent>
<groupId>nl.pim16aap2.BigDoors</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import java.lang.reflect.Method;
import java.util.function.Function;

final class CraftBlockDataFactory
final class CraftBlockDataFactory_V26_1_R1
{
private static final Function<BlockState, CraftBlockData> FROM_STATE = findFromStateFunction();

private CraftBlockDataFactory()
private CraftBlockDataFactory_V26_1_R1()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public boolean isInWorld()
@Override
public @NotNull BlockData getBlockData()
{
return CraftBlockDataFactory.fromState(this.getHandle().getBlockState());
return CraftBlockDataFactory_V26_1_R1.fromState(this.getHandle().getBlockState());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static boolean checkPreconditions()
{
try
{
return CraftBlockDataFactory.isInitialized();
return CraftBlockDataFactory_V26_1_R1.isInitialized();
}
catch (Throwable t)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void updateBlockData()

private void updateCraftBlockData()
{
this.craftBlockData = CraftBlockDataFactory.fromState(blockData);
this.craftBlockData = CraftBlockDataFactory_V26_1_R1.fromState(blockData);
}

@Override
Expand Down
34 changes: 34 additions & 0 deletions nms/v26_2_R1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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>
<packaging>jar</packaging>
<artifactId>v26_2_R1</artifactId>

<parent>
<groupId>nl.pim16aap2.BigDoors</groupId>
<artifactId>nms</artifactId>
<version>0.1.8.68-SNAPSHOT</version>
</parent>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>26.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>nl.pim16aap2.BigDoors</groupId>
<artifactId>nms-api</artifactId>
<version>0.1.8.68-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package nl.pim16aap2.bigDoors.NMS;

import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.craftbukkit.block.data.CraftBlockData;

import java.lang.reflect.Method;
import java.util.function.Function;

final class CraftBlockDataFactory_V26_2_R1
{
private static final Function<BlockState, CraftBlockData> FROM_STATE = findFromStateFunction();

private CraftBlockDataFactory_V26_2_R1()
{
}

public static CraftBlockData fromState(BlockState state)
{
return FROM_STATE.apply(state);
}

static boolean isInitialized()
{
return true;
}

private static Function<BlockState, CraftBlockData> findFromStateFunction()
{
// On Spigot, we can use CraftBlockData#fromData(BlockState) without reflection.
// On Paper, it's CraftBlockData#createData(BlockState), which is not present in Spigot, so we'll use reflection.
try
{
CraftBlockData.class.getMethod("fromData", BlockState.class);
return CraftBlockData::fromData;
}
catch (NoSuchMethodException ignored)
{
// Ignored
}

try
{
Method method = CraftBlockData.class.getMethod("createData", BlockState.class);
method.setAccessible(true);
return state ->
{
try
{
return (CraftBlockData) method.invoke(null, state);
}
catch (Exception e)
{
throw new RuntimeException("Failed to create block data from state: " + state, e);
}
};
}
catch (NoSuchMethodException ignored)
{
// ignored
}
throw new IllegalStateException("Failed to find method to create CraftBlockData from state");
}
}
Loading