mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
Merge remote-tracking branch 'upstream/dev' into dev-hotfix
This commit is contained in:
@@ -49,7 +49,7 @@ public abstract class BukkitItemFactory<W extends ItemWrapper<ItemStack>> extend
|
||||
case "1.21.4" -> {
|
||||
return new ComponentItemFactory1_21_4(plugin);
|
||||
}
|
||||
case "1.21.5", "1.21.6", "1.21.7", "1.22", "1.22.1" -> {
|
||||
case "1.21.5", "1.21.6", "1.21.7", "1.21.8" -> {
|
||||
return new ComponentItemFactory1_21_5(plugin);
|
||||
}
|
||||
default -> throw new IllegalStateException("Unsupported server version: " + plugin.serverVersion());
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
|
||||
import net.momirealms.craftengine.core.plugin.command.FlagKeys;
|
||||
import net.momirealms.craftengine.core.plugin.locale.MessageConstants;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -74,9 +75,17 @@ public class GiveItemCommand extends BukkitCommandFeature<CommandSender> {
|
||||
ItemStack more = builtItem.clone();
|
||||
more.setAmount(perStackSize);
|
||||
if (toInv) {
|
||||
PlayerUtils.putItemsToInventory(player.getInventory(), more, more.getAmount());
|
||||
if (VersionHelper.isFolia()) {
|
||||
player.getScheduler().run(plugin().javaPlugin(), (t) -> PlayerUtils.putItemsToInventory(player.getInventory(), more, more.getAmount()), () -> {});
|
||||
} else {
|
||||
PlayerUtils.putItemsToInventory(player.getInventory(), more, more.getAmount());
|
||||
}
|
||||
} else {
|
||||
PlayerUtils.dropItem(player, more, false, true, false);
|
||||
if (VersionHelper.isFolia()) {
|
||||
player.getScheduler().run(plugin().javaPlugin(), (t) -> PlayerUtils.dropItem(player, more, false, true, false), () -> {});
|
||||
} else {
|
||||
PlayerUtils.dropItem(player, more, false, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3873,4 +3873,27 @@ public final class CoreReflections {
|
||||
throw new ReflectionInitException("Failed to initialize HashOps", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Class<?> clazz$SnowLayerBlock = requireNonNull(
|
||||
BukkitReflectionUtils.findReobfOrMojmapClass(
|
||||
"world.level.block.BlockSnow",
|
||||
"world.level.block.SnowLayerBlock"
|
||||
)
|
||||
);
|
||||
|
||||
public static final Field field$SnowLayerBlock$LAYERS = requireNonNull(
|
||||
ReflectionUtils.getDeclaredField(
|
||||
clazz$SnowLayerBlock, clazz$IntegerProperty, 0
|
||||
)
|
||||
);
|
||||
|
||||
public static final Object instance$SnowLayerBlock$LAYERS;
|
||||
|
||||
static {
|
||||
try {
|
||||
instance$SnowLayerBlock$LAYERS = field$SnowLayerBlock$LAYERS.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionInitException("Failed to initialize SnowLayerBlock$LAYERS", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public final class MBlocks {
|
||||
public static final Object SHORT_GRASS$defaultState;
|
||||
public static final Object SHULKER_BOX;
|
||||
public static final Object COMPOSTER;
|
||||
public static final Object SNOW;
|
||||
|
||||
private static Object getById(String id) {
|
||||
Object rl = FastNMS.INSTANCE.method$ResourceLocation$fromNamespaceAndPath("minecraft", id);
|
||||
@@ -35,5 +36,6 @@ public final class MBlocks {
|
||||
SHORT_GRASS$defaultState = FastNMS.INSTANCE.method$Block$defaultState(SHORT_GRASS);
|
||||
SHULKER_BOX = getById("shulker_box");
|
||||
COMPOSTER = getById("composter");
|
||||
SNOW = getById("snow");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.momirealms.craftengine.core.block.DelegatingBlockState;
|
||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -142,4 +143,10 @@ public class BlockStateUtils {
|
||||
Object blockOwner = getBlockOwner(state);
|
||||
return IGNITE_ODDS.getOrDefault(blockOwner, 0) > 0;
|
||||
}
|
||||
|
||||
public static Object getBlockState(Block block) {
|
||||
Object worldServer = FastNMS.INSTANCE.field$CraftWorld$ServerLevel(block.getWorld());
|
||||
Object blockPos = LocationUtils.toBlockPos(block.getX(), block.getY(), block.getZ());
|
||||
return FastNMS.INSTANCE.method$BlockGetter$getBlockState(worldServer, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package net.momirealms.craftengine.bukkit.world;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.api.CraftEngineBlocks;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBlocks;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MFluids;
|
||||
import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
@@ -21,11 +24,15 @@ public class BukkitBlockInWorld implements BlockInWorld {
|
||||
|
||||
@Override
|
||||
public boolean canBeReplaced(BlockPlaceContext context) {
|
||||
ImmutableBlockState customState = CraftEngineBlocks.getCustomBlockState(this.block);
|
||||
Object state = BlockStateUtils.getBlockState(this.block);
|
||||
ImmutableBlockState customState = BlockStateUtils.getOptionalCustomBlockState(state).orElse(null);
|
||||
if (customState != null && !customState.isEmpty()) {
|
||||
return customState.behavior().canBeReplaced(context, customState);
|
||||
}
|
||||
return this.block.isReplaceable();
|
||||
if (BlockStateUtils.getBlockOwner(state) == MBlocks.SNOW) {
|
||||
return (int) FastNMS.INSTANCE.method$StateHolder$getValue(state, CoreReflections.instance$SnowLayerBlock$LAYERS) == 1;
|
||||
}
|
||||
return BlockStateUtils.isReplaceable(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,8 @@ public final class MinecraftVersion implements Comparable<MinecraftVersion> {
|
||||
PACK_FORMATS.put(1_21_04, 46);
|
||||
PACK_FORMATS.put(1_21_05, 55);
|
||||
PACK_FORMATS.put(1_21_06, 63);
|
||||
PACK_FORMATS.put(1_21_07, 64); // TODO 1.21.7-rc2
|
||||
PACK_FORMATS.put(1_21_07, 64);
|
||||
PACK_FORMATS.put(1_21_08, 64);
|
||||
PACK_FORMATS.put(1_99_99, 1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,5 +18,6 @@ public final class MinecraftVersions {
|
||||
public static final MinecraftVersion V1_21_5 = new MinecraftVersion("1.21.5");
|
||||
public static final MinecraftVersion V1_21_6 = new MinecraftVersion("1.21.6");
|
||||
public static final MinecraftVersion V1_21_7 = new MinecraftVersion("1.21.7");
|
||||
public static final MinecraftVersion V1_21_8 = new MinecraftVersion("1.21.8");
|
||||
public static final MinecraftVersion FUTURE = new MinecraftVersion("1.99.99");
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class VersionHelper {
|
||||
private static final boolean v1_21_5;
|
||||
private static final boolean v1_21_6;
|
||||
private static final boolean v1_21_7;
|
||||
private static final boolean v1_21_8;
|
||||
|
||||
static {
|
||||
try (InputStream inputStream = Class.forName("net.minecraft.obfuscate.DontObfuscate").getResourceAsStream("/version.json")) {
|
||||
@@ -64,6 +65,7 @@ public class VersionHelper {
|
||||
v1_21_5 = version >= 12105;
|
||||
v1_21_6 = version >= 12106;
|
||||
v1_21_7 = version >= 12107;
|
||||
v1_21_8 = version >= 12108;
|
||||
|
||||
majorVersion = major;
|
||||
minorVersion = minor;
|
||||
@@ -215,4 +217,8 @@ public class VersionHelper {
|
||||
public static boolean isOrAbove1_21_7() {
|
||||
return v1_21_7;
|
||||
}
|
||||
|
||||
public static boolean isOrAbove1_21_8() {
|
||||
return v1_21_8;
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,17 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.60.2
|
||||
project_version=0.0.60.3
|
||||
config_version=42
|
||||
lang_version=22
|
||||
project_group=net.momirealms
|
||||
latest_supported_version=1.21.7
|
||||
latest_supported_version=1.21.8
|
||||
|
||||
# Supported languages
|
||||
supported_languages=en,zh_cn,zh_tw,es,tr,de,ru_ru
|
||||
|
||||
# Dependency settings
|
||||
paper_version=1.21.7
|
||||
paper_version=1.21.8
|
||||
jetbrains_annotations_version=26.0.2
|
||||
slf4j_version=2.0.17
|
||||
log4j_version=2.24.3
|
||||
@@ -50,7 +50,7 @@ byte_buddy_version=1.17.5
|
||||
ahocorasick_version=0.6.3
|
||||
snake_yaml_version=2.4
|
||||
anti_grief_version=0.18
|
||||
nms_helper_version=1.0.35
|
||||
nms_helper_version=1.0.37
|
||||
evalex_version=3.5.0
|
||||
reactive_streams_version=1.0.4
|
||||
amazon_awssdk_version=2.31.23
|
||||
|
||||
Reference in New Issue
Block a user