mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
更改发光方案
This commit is contained in:
@@ -23,7 +23,7 @@ public class ItemDisplayFurnitureElement implements FurnitureElement {
|
||||
private final int entityId;
|
||||
private final Object despawnPacket;
|
||||
private final FurnitureColorSource colorSource;
|
||||
private final LegacyChatFormatter glowColor;
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
|
||||
public ItemDisplayFurnitureElement(Furniture furniture, ItemDisplayFurnitureElementConfig config) {
|
||||
this.config = config;
|
||||
@@ -33,26 +33,18 @@ public class ItemDisplayFurnitureElement implements FurnitureElement {
|
||||
this.position = new WorldPosition(furniturePos.world, position.x, position.y, position.z, furniturePos.xRot, furniturePos.yRot);
|
||||
this.despawnPacket = FastNMS.INSTANCE.constructor$ClientboundRemoveEntitiesPacket(new IntArrayList() {{ add(entityId); }});
|
||||
this.colorSource = furniture.dataAccessor.getColorSource();
|
||||
this.glowColor = config.glowColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(Player player) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
player.sendPacket(FastNMS.INSTANCE.constructor$ClientboundBundlePacket(List.of(
|
||||
FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(
|
||||
this.entityId, uuid,
|
||||
this.entityId, this.uuid,
|
||||
this.position.x, this.position.y, this.position.z, 0, this.position.yRot,
|
||||
MEntityTypes.ITEM_DISPLAY, 0, CoreReflections.instance$Vec3$Zero, 0
|
||||
),
|
||||
FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(this.entityId, this.config.metadata.apply(player, this.colorSource))
|
||||
)), false);
|
||||
if (this.glowColor != null) {
|
||||
Object team = BukkitTeamManager.instance().getTeamByColor(this.glowColor);
|
||||
if (team != null) {
|
||||
FastNMS.INSTANCE.method$ClientboundSetPlayerTeamPacket$createMultiplePlayerPacket(team, List.of(uuid.toString()), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,6 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import net.momirealms.craftengine.bukkit.entity.data.BaseEntityData;
|
||||
import net.momirealms.craftengine.bukkit.entity.data.ItemDisplayEntityData;
|
||||
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||
import net.momirealms.craftengine.core.entity.Glowing;
|
||||
import net.momirealms.craftengine.core.entity.display.Billboard;
|
||||
import net.momirealms.craftengine.core.entity.display.ItemDisplayContext;
|
||||
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||
@@ -15,8 +14,8 @@ import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.ItemKeys;
|
||||
import net.momirealms.craftengine.core.item.data.FireworkExplosion;
|
||||
import net.momirealms.craftengine.core.util.Color;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.LegacyChatFormatter;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,7 +29,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig<ItemDisplayFurnitureElement>, Glowing {
|
||||
public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig<ItemDisplayFurnitureElement> {
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public final BiFunction<Player, FurnitureColorSource, List<Object>> metadata;
|
||||
public final Key itemId;
|
||||
@@ -45,7 +44,7 @@ public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig
|
||||
public final float shadowRadius;
|
||||
public final float shadowStrength;
|
||||
public final boolean applyDyedColor;
|
||||
public final LegacyChatFormatter glowColor;
|
||||
public final Color glowColor;
|
||||
|
||||
public ItemDisplayFurnitureElementConfig(Key itemId,
|
||||
Vector3f scale,
|
||||
@@ -59,7 +58,7 @@ public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig
|
||||
float shadowRadius,
|
||||
float shadowStrength,
|
||||
boolean applyDyedColor,
|
||||
@Nullable LegacyChatFormatter glowColor) {
|
||||
@Nullable Color glowColor) {
|
||||
this.scale = scale;
|
||||
this.position = position;
|
||||
this.translation = translation;
|
||||
@@ -91,6 +90,7 @@ public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig
|
||||
List<Object> dataValues = new ArrayList<>();
|
||||
if (glowColor != null) {
|
||||
BaseEntityData.SharedFlags.addEntityData((byte) 0x40, dataValues);
|
||||
ItemDisplayEntityData.GlowColorOverride.addEntityData(glowColor.color(), dataValues);
|
||||
}
|
||||
ItemDisplayEntityData.DisplayedItem.addEntityData(itemFunction.apply(player, source).getLiteralObject(), dataValues);
|
||||
ItemDisplayEntityData.Scale.addEntityData(this.scale, dataValues);
|
||||
@@ -153,8 +153,7 @@ public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LegacyChatFormatter glowColor() {
|
||||
public Color glowColor() {
|
||||
return this.glowColor;
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig
|
||||
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("shadow-radius", 0f), "shadow-radius"),
|
||||
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("shadow-strength", 1f), "shadow-strength"),
|
||||
applyDyedColor,
|
||||
ResourceConfigUtils.getAsEnum(arguments.get("glow-color"), LegacyChatFormatter.class, null)
|
||||
Optional.ofNullable(arguments.get("glow-color")).map(it -> Color.fromStrings(it.toString().split(","))).orElse(null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.momirealms.craftengine.core.entity;
|
||||
|
||||
import net.momirealms.craftengine.core.util.LegacyChatFormatter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface Glowing {
|
||||
|
||||
@Nullable
|
||||
LegacyChatFormatter glowColor();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.momirealms.craftengine.core.entity.furniture;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.momirealms.craftengine.core.entity.Glowing;
|
||||
import net.momirealms.craftengine.core.entity.furniture.behavior.FurnitureBehaviorTypes;
|
||||
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfig;
|
||||
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfigs;
|
||||
@@ -220,13 +219,6 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
|
||||
Optional<Vector3f> optionalLootSpawnOffset = Optional.ofNullable(variantArguments.get("loot-spawn-offset")).map(it -> ResourceConfigUtils.getAsVector3f(it, "loot-spawn-offset"));
|
||||
List<FurnitureElementConfig<?>> elements = ResourceConfigUtils.parseConfigAsList(variantArguments.get("elements"), FurnitureElementConfigs::fromMap);
|
||||
|
||||
// 收集发光颜色类型
|
||||
for (FurnitureElementConfig<?> element : elements) {
|
||||
if (element instanceof Glowing glowing) {
|
||||
Optional.ofNullable(glowing.glowColor()).ifPresent(color -> AbstractFurnitureManager.this.plugin.teamManager().setColorInUse(color));
|
||||
}
|
||||
}
|
||||
|
||||
// 外部模型
|
||||
Optional<ExternalModel> externalModel;
|
||||
if (variantArguments.containsKey("model-engine")) {
|
||||
|
||||
Reference in New Issue
Block a user