mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
添加家具debug模式
This commit is contained in:
@@ -78,11 +78,6 @@ public class CustomFurnitureHitboxConfig extends AbstractFurnitureHitBoxConfig<C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void collectBoundingBox(Consumer<AABB> aabbConsumer) {
|
|
||||||
aabbConsumer.accept(AABB.makeBoundingBox(this.position, this.width, this.height));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomFurnitureHitbox create(Furniture furniture) {
|
public CustomFurnitureHitbox create(Furniture furniture) {
|
||||||
return new CustomFurnitureHitbox(furniture, this);
|
return new CustomFurnitureHitbox(furniture, this);
|
||||||
|
|||||||
@@ -63,11 +63,6 @@ public class HappyGhastFurnitureHitboxConfig extends AbstractFurnitureHitBoxConf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void collectBoundingBox(Consumer<AABB> aabbConsumer) {
|
|
||||||
aabbConsumer.accept(AABB.makeBoundingBox(this.position, 4 * this.scale, 4 * this.scale));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Factory implements FurnitureHitBoxConfigFactory<HappyGhastFurnitureHitbox> {
|
public static class Factory implements FurnitureHitBoxConfigFactory<HappyGhastFurnitureHitbox> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -77,11 +77,6 @@ public class InteractionFurnitureHitboxConfig extends AbstractFurnitureHitBoxCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void collectBoundingBox(Consumer<AABB> aabbConsumer) {
|
|
||||||
aabbConsumer.accept(AABB.makeBoundingBox(this.position, size.x, size.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionFurnitureHitbox create(Furniture furniture) {
|
public InteractionFurnitureHitbox create(Furniture furniture) {
|
||||||
return new InteractionFurnitureHitbox(furniture, this);
|
return new InteractionFurnitureHitbox(furniture, this);
|
||||||
|
|||||||
@@ -153,11 +153,6 @@ public class ShulkerFurnitureHitboxConfig extends AbstractFurnitureHitBoxConfig<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void collectBoundingBox(Consumer<AABB> aabbConsumer) {
|
|
||||||
aabbConsumer.accept(this.aabbCreator.create(position.x, position.y, position.z, 180, new Vector3f(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public float scale() {
|
public float scale() {
|
||||||
return this.scale;
|
return this.scale;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import net.momirealms.craftengine.core.world.WorldPosition;
|
|||||||
import net.momirealms.craftengine.core.world.collision.AABB;
|
import net.momirealms.craftengine.core.world.collision.AABB;
|
||||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -121,7 +120,14 @@ public class FurnitureItemBehavior extends ItemBehavior {
|
|||||||
if (!aabbs.isEmpty()) {
|
if (!aabbs.isEmpty()) {
|
||||||
if (!FastNMS.INSTANCE.checkEntityCollision(context.getLevel().serverWorld(), aabbs.stream().map(it -> FastNMS.INSTANCE.constructor$AABB(it.minX, it.minY, it.minZ, it.maxX, it.maxY, it.maxZ)).toList())) {
|
if (!FastNMS.INSTANCE.checkEntityCollision(context.getLevel().serverWorld(), aabbs.stream().map(it -> FastNMS.INSTANCE.constructor$AABB(it.minX, it.minY, it.minZ, it.maxX, it.maxY, it.maxZ)).toList())) {
|
||||||
if (player != null && player.enableFurnitureDebug() && VersionHelper.isPaper()) {
|
if (player != null && player.enableFurnitureDebug() && VersionHelper.isPaper()) {
|
||||||
// bukkitPlayer.getWorld().spawnParticle(Particle.FLAME, , List.of(bukkitPlayer), );
|
player.playSound(Key.of("minecraft:entity.villager.no"));
|
||||||
|
Key flame = Key.of("flame");
|
||||||
|
for (AABB aabb : aabbs) {
|
||||||
|
List<Vec3d> edgePoints = aabb.getEdgePoints(0.125);
|
||||||
|
for (Vec3d edgePoint : edgePoints) {
|
||||||
|
player.playParticle(flame, edgePoint.x(), edgePoint.y(), edgePoint.z());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import net.momirealms.craftengine.core.pack.obfuscation.ObfA;
|
|||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.TranslationManagerImpl;
|
|
||||||
import net.momirealms.craftengine.core.util.Base64Utils;
|
import net.momirealms.craftengine.core.util.Base64Utils;
|
||||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class BukkitCommandManager extends AbstractCommandManager<CommandSender>
|
|||||||
new DebugAppearanceStateUsageCommand(this, plugin),
|
new DebugAppearanceStateUsageCommand(this, plugin),
|
||||||
new DebugClearCooldownCommand(this, plugin),
|
new DebugClearCooldownCommand(this, plugin),
|
||||||
new DebugEntityIdCommand(this, plugin),
|
new DebugEntityIdCommand(this, plugin),
|
||||||
|
new DebugFurnitureCommand(this, plugin),
|
||||||
new DebugRealStateUsageCommand(this, plugin),
|
new DebugRealStateUsageCommand(this, plugin),
|
||||||
new DebugItemDataCommand(this, plugin),
|
new DebugItemDataCommand(this, plugin),
|
||||||
new DebugSetBlockCommand(this, plugin),
|
new DebugSetBlockCommand(this, plugin),
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package net.momirealms.craftengine.bukkit.plugin.command.feature;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.momirealms.craftengine.bukkit.api.BukkitAdaptors;
|
||||||
|
import net.momirealms.craftengine.bukkit.plugin.command.BukkitCommandFeature;
|
||||||
|
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
|
||||||
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
|
import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.incendo.cloud.Command;
|
||||||
|
|
||||||
|
public class DebugFurnitureCommand extends BukkitCommandFeature<CommandSender> {
|
||||||
|
|
||||||
|
public DebugFurnitureCommand(CraftEngineCommandManager<CommandSender> commandManager, CraftEngine plugin) {
|
||||||
|
super(commandManager, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Command.Builder<? extends CommandSender> assembleCommand(org.incendo.cloud.CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
|
||||||
|
return builder
|
||||||
|
.senderType(Player.class)
|
||||||
|
.handler(context -> {
|
||||||
|
BukkitServerPlayer serverPlayer = BukkitAdaptors.adapt(context.sender());
|
||||||
|
boolean b = !serverPlayer.enableFurnitureDebug();
|
||||||
|
serverPlayer.setEnableFurnitureDebug(b);
|
||||||
|
serverPlayer.sendMessage(Component.text("Furniture Debug Mode: ").append(Component.text(b ? "ON" : "OFF").color(b ? NamedTextColor.GREEN : NamedTextColor.RED)), false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFeatureID() {
|
||||||
|
return "debug_furniture";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.momirealms.craftengine.bukkit.plugin.network;
|
package net.momirealms.craftengine.bukkit.plugin.network;
|
||||||
|
|
||||||
import com.destroystokyo.paper.ParticleBuilder;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import io.netty.channel.Channel;
|
|||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.momirealms.craftengine.bukkit.api.CraftEngineBlocks;
|
import net.momirealms.craftengine.bukkit.api.CraftEngineBlocks;
|
||||||
|
import net.momirealms.craftengine.bukkit.api.CraftEngineFurniture;
|
||||||
import net.momirealms.craftengine.bukkit.block.entity.BlockEntityHolder;
|
import net.momirealms.craftengine.bukkit.block.entity.BlockEntityHolder;
|
||||||
|
import net.momirealms.craftengine.bukkit.entity.furniture.BukkitFurniture;
|
||||||
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||||
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
||||||
@@ -26,6 +28,8 @@ import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
|||||||
import net.momirealms.craftengine.core.block.entity.render.ConstantBlockEntityRenderer;
|
import net.momirealms.craftengine.core.block.entity.render.ConstantBlockEntityRenderer;
|
||||||
import net.momirealms.craftengine.core.entity.data.EntityData;
|
import net.momirealms.craftengine.core.entity.data.EntityData;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.FurnitureVariant;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBoxConfig;
|
||||||
import net.momirealms.craftengine.core.entity.player.GameMode;
|
import net.momirealms.craftengine.core.entity.player.GameMode;
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
@@ -156,6 +160,10 @@ public class BukkitServerPlayer extends Player {
|
|||||||
private Location eyeLocation;
|
private Location eyeLocation;
|
||||||
// 是否启用家具调试
|
// 是否启用家具调试
|
||||||
private boolean enableFurnitureDebug;
|
private boolean enableFurnitureDebug;
|
||||||
|
// 上一次对准的家具
|
||||||
|
private BukkitFurniture lastHitFurniture;
|
||||||
|
// 缓存的tick
|
||||||
|
private int lastHitFurnitureTick;
|
||||||
|
|
||||||
public BukkitServerPlayer(BukkitCraftEngine plugin, @Nullable Channel channel) {
|
public BukkitServerPlayer(BukkitCraftEngine plugin, @Nullable Channel channel) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
@@ -542,6 +550,33 @@ public class BukkitServerPlayer extends Player {
|
|||||||
this.updateGUI();
|
this.updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.enableFurnitureDebug) {
|
||||||
|
BukkitFurniture furniture = CraftEngineFurniture.rayTrace(platformPlayer());
|
||||||
|
boolean forceShow = furniture != this.lastHitFurniture;
|
||||||
|
if (forceShow) {
|
||||||
|
this.lastHitFurnitureTick = 0;
|
||||||
|
} else {
|
||||||
|
this.lastHitFurnitureTick++;
|
||||||
|
if (this.lastHitFurnitureTick % 30 == 0) {
|
||||||
|
forceShow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.lastHitFurniture = furniture;
|
||||||
|
if (furniture != null && forceShow) {
|
||||||
|
FurnitureVariant currentVariant = furniture.getCurrentVariant();
|
||||||
|
List<AABB> aabbs = new ArrayList<>();
|
||||||
|
for (FurnitureHitBoxConfig<?> config : currentVariant.hitBoxConfigs()) {
|
||||||
|
config.prepareForPlacement(furniture.position(), aabbs::add);
|
||||||
|
}
|
||||||
|
Key endRod = Key.of("end_rod");
|
||||||
|
for (AABB aabb : aabbs) {
|
||||||
|
for (Vec3d point : aabb.getEdgePoints(0.125)) {
|
||||||
|
this.playParticle(endRod, point.x, point.y, point.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 更新眼睛位置
|
// 更新眼睛位置
|
||||||
{
|
{
|
||||||
Location unsureEyeLocation = bukkitPlayer.getEyeLocation();
|
Location unsureEyeLocation = bukkitPlayer.getEyeLocation();
|
||||||
|
|||||||
@@ -270,6 +270,13 @@ debug_generate_internal_assets:
|
|||||||
- /craftengine debug generate-internal-assets
|
- /craftengine debug generate-internal-assets
|
||||||
- /ce debug generate-internal-assets
|
- /ce debug generate-internal-assets
|
||||||
|
|
||||||
|
debug_furniture:
|
||||||
|
enable: true
|
||||||
|
permission: ce.command.debug.furniture
|
||||||
|
usage:
|
||||||
|
- /craftengine debug furniture
|
||||||
|
- /ce debug furniture
|
||||||
|
|
||||||
debug_test:
|
debug_test:
|
||||||
enable: true
|
enable: true
|
||||||
permission: ce.command.debug.test
|
permission: ce.command.debug.test
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import net.momirealms.craftengine.core.util.GsonHelper;
|
|||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
import net.momirealms.craftengine.core.world.collision.AABB;
|
|
||||||
import org.incendo.cloud.suggestion.Suggestion;
|
import org.incendo.cloud.suggestion.Suggestion;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
@@ -166,8 +165,6 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
|
|||||||
AbstractFurnitureManager.this.byId.put(id, furniture);
|
AbstractFurnitureManager.this.byId.put(id, furniture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private CullingData parseCullingData(Object arguments) {
|
private CullingData parseCullingData(Object arguments) {
|
||||||
if (arguments instanceof Boolean b && !b)
|
if (arguments instanceof Boolean b && !b)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -24,5 +24,4 @@ public interface FurnitureHitBoxConfig<H extends FurnitureHitBox> {
|
|||||||
|
|
||||||
void prepareForPlacement(WorldPosition targetPos, Consumer<AABB> aabbConsumer);
|
void prepareForPlacement(WorldPosition targetPos, Consumer<AABB> aabbConsumer);
|
||||||
|
|
||||||
void collectBoundingBox(Consumer<AABB> aabbConsumer);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ import net.momirealms.craftengine.core.plugin.config.Config;
|
|||||||
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
||||||
import net.momirealms.craftengine.core.plugin.config.SectionConfigParser;
|
import net.momirealms.craftengine.core.plugin.config.SectionConfigParser;
|
||||||
import net.momirealms.craftengine.core.plugin.config.StringKeyConstructor;
|
import net.momirealms.craftengine.core.plugin.config.StringKeyConstructor;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.*;
|
import net.momirealms.craftengine.core.plugin.locale.LangData;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.plugin.logger.Debugger;
|
import net.momirealms.craftengine.core.plugin.logger.Debugger;
|
||||||
import net.momirealms.craftengine.core.sound.AbstractSoundManager;
|
import net.momirealms.craftengine.core.sound.AbstractSoundManager;
|
||||||
import net.momirealms.craftengine.core.sound.SoundEvent;
|
import net.momirealms.craftengine.core.sound.SoundEvent;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.core.plugin.entityculling;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
import net.momirealms.craftengine.core.world.ChunkPos;
|
import net.momirealms.craftengine.core.world.ChunkPos;
|
||||||
import net.momirealms.craftengine.core.world.MutableVec3d;
|
import net.momirealms.craftengine.core.world.MutableVec3d;
|
||||||
@@ -95,10 +94,6 @@ public final class EntityCulling {
|
|||||||
if (distanceSq > maxDistanceSq) {
|
if (distanceSq > maxDistanceSq) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 太近了,不剔除
|
|
||||||
else if (distanceSq < 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rayTracing || !cullable.rayTracing) {
|
if (!rayTracing || !cullable.rayTracing) {
|
||||||
|
|||||||
Reference in New Issue
Block a user