mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 12:56:28 +00:00
添加skript放置自定义方块
This commit is contained in:
@@ -112,6 +112,8 @@ public final class CraftEngineBlocks {
|
||||
Object worldServer = FastNMS.INSTANCE.field$CraftWorld$ServerLevel(location.getWorld());
|
||||
Object blockPos = FastNMS.INSTANCE.constructor$BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
Object blockState = block.customBlockState().handle();
|
||||
System.out.println(blockPos);
|
||||
System.out.println(blockState);
|
||||
Object oldBlockState = FastNMS.INSTANCE.method$BlockGetter$getBlockState(worldServer, blockPos);
|
||||
success = FastNMS.INSTANCE.method$LevelWriter$setBlock(worldServer, blockPos, blockState, option.flags());
|
||||
if (success) {
|
||||
@@ -120,6 +122,7 @@ public final class CraftEngineBlocks {
|
||||
location.getWorld().playSound(location, block.sounds().placeSound().toString(), SoundCategory.BLOCKS, block.sounds().placeSound().volume(), block.sounds().placeSound().pitch());
|
||||
}
|
||||
}
|
||||
System.out.println(success);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.craftengine.bukkit.util;
|
||||
|
||||
import net.momirealms.craftengine.core.util.ReflectionUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -66,4 +67,9 @@ public final class BukkitReflectionUtils {
|
||||
public static String assembleMCClass(String className) {
|
||||
return PREFIX_MC + className;
|
||||
}
|
||||
|
||||
public static Class<?> findReobfOrMojmapClass(String reobf, String mojmap) {
|
||||
if (VersionHelper.isMojmap()) return ReflectionUtils.getClazz(BukkitReflectionUtils.assembleMCClass(mojmap));
|
||||
else return ReflectionUtils.getClazz(BukkitReflectionUtils.assembleMCClass(reobf));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user