mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 04:46:37 +00:00
更新版本
This commit is contained in:
@@ -23,7 +23,7 @@ dependencies {
|
||||
// NMS
|
||||
compileOnly("net.momirealms:craft-engine-nms-helper:${rootProject.properties["nms_helper_version"]}")
|
||||
// Platform
|
||||
compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||
// OpenGL Math
|
||||
compileOnly("org.joml:joml:${rootProject.properties["joml_version"]}")
|
||||
// Gson
|
||||
|
||||
@@ -15,7 +15,7 @@ dependencies {
|
||||
compileOnly(project(":core"))
|
||||
compileOnly("net.momirealms:sparrow-nbt:${rootProject.properties["sparrow_nbt_version"]}")
|
||||
// Platform
|
||||
compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||
// NeigeItems
|
||||
compileOnly("pers.neige.neigeitems:NeigeItems:1.21.42")
|
||||
// Placeholder
|
||||
|
||||
@@ -9,7 +9,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
// Platform
|
||||
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.momirealms.craftengine.bukkit.util;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class LegacyEntityUtils {
|
||||
|
||||
public static Entity spawnEntity(World world, Location loc, EntityType type, Consumer<Entity> function) {
|
||||
return world.spawnEntity(loc, type, CreatureSpawnEvent.SpawnReason.CUSTOM, function::accept);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
// Platform
|
||||
compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||
|
||||
implementation(project(":shared"))
|
||||
implementation(project(":core"))
|
||||
|
||||
@@ -92,8 +92,15 @@ public class BukkitServerPlayer extends Player {
|
||||
}
|
||||
|
||||
public void setPlayer(org.bukkit.entity.Player player) {
|
||||
playerRef = new WeakReference<>(player);
|
||||
serverPlayerRef = new WeakReference<>(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player));
|
||||
this.playerRef = new WeakReference<>(player);
|
||||
this.serverPlayerRef = new WeakReference<>(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player));
|
||||
if (Reflections.method$CraftPlayer$setSimplifyContainerDesyncCheck != null) {
|
||||
try {
|
||||
Reflections.method$CraftPlayer$setSimplifyContainerDesyncCheck.invoke(player, true);
|
||||
} catch (Exception e) {
|
||||
this.plugin.logger().warn("Failed to setSimplifyContainerDesyncCheck", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.craftengine.bukkit.util;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.BlockPos;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -9,6 +10,8 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EntityUtils {
|
||||
|
||||
private EntityUtils() {}
|
||||
@@ -23,12 +26,11 @@ public class EntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Entity spawnEntity(World world, Location loc, EntityType type, org.bukkit.util.Consumer<Entity> function) {
|
||||
try {
|
||||
return (Entity) Reflections.method$World$spawnEntity.invoke(world, loc, type, CreatureSpawnEvent.SpawnReason.CUSTOM, function);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException("Failed to spawn entity", e);
|
||||
public static Entity spawnEntity(World world, Location loc, EntityType type, Consumer<Entity> function) {
|
||||
if (VersionHelper.isVersionNewerThan1_20_2()) {
|
||||
return world.spawnEntity(loc, type, CreatureSpawnEvent.SpawnReason.CUSTOM, function);
|
||||
} else {
|
||||
return LegacyEntityUtils.spawnEntity(world, loc, type, function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4000,12 +4000,12 @@ public class Reflections {
|
||||
)
|
||||
);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static final Method method$World$spawnEntity = requireNonNull(
|
||||
VersionHelper.isVersionNewerThan1_20_2() ?
|
||||
ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, Consumer.class) :
|
||||
ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, org.bukkit.util.Consumer.class)
|
||||
);
|
||||
// @SuppressWarnings("deprecation")
|
||||
// public static final Method method$World$spawnEntity = requireNonNull(
|
||||
// VersionHelper.isVersionNewerThan1_20_2() ?
|
||||
// ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, Consumer.class) :
|
||||
// ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, org.bukkit.util.Consumer.class)
|
||||
// );
|
||||
|
||||
// 1.21.4+
|
||||
public static final Class<?> clazz$ServerboundPickItemFromEntityPacket =
|
||||
@@ -6444,4 +6444,9 @@ public class Reflections {
|
||||
BukkitReflectionUtils.assembleMCClass("network.protocol.game.PacketPlayOutScoreboardScore")
|
||||
)
|
||||
);
|
||||
|
||||
public static final Method method$CraftPlayer$setSimplifyContainerDesyncCheck =
|
||||
ReflectionUtils.getMethod(
|
||||
clazz$CraftPlayer, new String[]{"setSimplifyContainerDesyncCheck"}, boolean.class
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user