9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 09:59:20 +00:00

improve comparison

This commit is contained in:
iqtester
2025-07-17 16:32:23 -04:00
parent b0e435a2eb
commit 84725e177e
3 changed files with 4 additions and 3 deletions

View File

@@ -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");
}
}

View File

@@ -2,12 +2,12 @@ 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.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;
import net.momirealms.craftengine.core.item.ItemKeys;
import net.momirealms.craftengine.core.item.context.BlockPlaceContext;
import net.momirealms.craftengine.core.world.BlockInWorld;
import net.momirealms.craftengine.core.world.World;
@@ -32,7 +32,7 @@ public class BukkitBlockInWorld implements BlockInWorld {
if (customState != null && !customState.isEmpty()) {
return customState.behavior().canBeReplaced(context, customState);
}
if (BlockStateUtils.getBlockOwnerIdFromState(state).equals(ItemKeys.SNOW)) {
if (BlockStateUtils.getBlockOwner(state) == MBlocks.SNOW) {
Snow snow = (Snow) BlockStateUtils.fromBlockData(state);
return snow.getLayers() == 1;
}

View File

@@ -33,7 +33,6 @@ public class ItemKeys {
public static final Key BARRIER = Key.of("minecraft:barrier");
public static final Key CACTUS = Key.of("minecraft:cactus");
public static final Key REDSTONE = Key.of("minecraft:redstone");
public static final Key SNOW = Key.of("minecraft:snow");
public static final Key[] AXES = new Key[] {
WOODEN_AXE, STONE_AXE, IRON_AXE, GOLDEN_AXE, DIAMOND_AXE, NETHERITE_AXE