9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-24 09:29:33 +00:00

refactor(bukkit): 清理代码

This commit is contained in:
jhqwqmc
2025-09-17 18:43:56 +08:00
parent 5b1c12a3ae
commit 7d3029c193
4 changed files with 3 additions and 17 deletions

View File

@@ -231,7 +231,7 @@ public final class CraftEngineBlocks {
* @param sendParticles whether to send break particles
* @return success or not
*/
@Deprecated
@Deprecated(forRemoval = true)
public static boolean remove(@NotNull Block block,
@Nullable Player player,
boolean isMoving,

View File

@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
import net.momirealms.craftengine.bukkit.world.BukkitWorld;
import net.momirealms.craftengine.core.block.CustomBlock;
import net.momirealms.craftengine.core.block.ImmutableBlockState;
import net.momirealms.craftengine.core.world.BlockPos;
import net.momirealms.craftengine.core.world.Vec3d;
import net.momirealms.craftengine.core.world.WorldEvents;
import net.momirealms.craftengine.core.world.WorldPosition;
@@ -69,13 +68,8 @@ public abstract class AbstractCanSurviveBlockBehavior extends BukkitBlockBehavio
FastNMS.INSTANCE.method$ScheduledTickAccess$scheduleBlockTick(level, blockPos, thisBlock, this.delay);
return state;
}
if (!canSurvive(thisBlock, new Object[] {state, level, blockPos}, () -> true)) {
// BlockPos pos = LocationUtils.fromBlockPos(blockPos);
ImmutableBlockState customState = optionalCustomState.get();
// net.momirealms.craftengine.core.world.World world = new BukkitWorld(FastNMS.INSTANCE.method$Level$getCraftWorld(level));
// WorldPosition position = new WorldPosition(world, Vec3d.atCenterOf(pos));
// world.playBlockSound(position, customState.settings().sounds().breakSound()); // 下面触发事件也会有声音
FastNMS.INSTANCE.method$LevelAccessor$levelEvent(level, WorldEvents.BLOCK_BREAK_EFFECT, blockPos, customState.customBlockState().registryId());
if (!FastNMS.INSTANCE.method$BlockStateBase$canSurvive(state, level, blockPos)) {
FastNMS.INSTANCE.method$LevelAccessor$levelEvent(level, WorldEvents.BLOCK_BREAK_EFFECT, blockPos, optionalCustomState.get().customBlockState().registryId());
return MBlocks.AIR$defaultState;
}
return state;

View File

@@ -50,10 +50,6 @@ public class DoubleHighBlockBehavior extends BukkitBlockBehavior {
if (anotherHalfCustomState != null && !anotherHalfCustomState.isEmpty()) return blockState;
// 破坏
// BlockPos pos = LocationUtils.fromBlockPos(blockPos);
// net.momirealms.craftengine.core.world.World world = new BukkitWorld(FastNMS.INSTANCE.method$Level$getCraftWorld(level));
// WorldPosition position = new WorldPosition(world, Vec3d.atCenterOf(pos));
// world.playBlockSound(position, customState.settings().sounds().breakSound()); // 下面触发事件也会有声音
FastNMS.INSTANCE.method$LevelAccessor$levelEvent(level, WorldEvents.BLOCK_BREAK_EFFECT, blockPos, customState.customBlockState().registryId());
return MBlocks.AIR$defaultState;
}

View File

@@ -66,10 +66,6 @@ public class PressurePlateBlockBehavior extends BukkitBlockBehavior {
return MBlocks.AIR$defaultState;
}
ImmutableBlockState customState = optionalCustomState.get();
// BlockPos pos = LocationUtils.fromBlockPos(blockPos);
// net.momirealms.craftengine.core.world.World world = new BukkitWorld(FastNMS.INSTANCE.method$Level$getCraftWorld(level));
// WorldPosition position = new WorldPosition(world, Vec3d.atCenterOf(pos));
// world.playBlockSound(position, customState.settings().sounds().breakSound()); // 下面触发事件也会有声音
FastNMS.INSTANCE.method$LevelAccessor$levelEvent(level, WorldEvents.BLOCK_BREAK_EFFECT, blockPos, customState.customBlockState().registryId());
return MBlocks.AIR$defaultState;
}