mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
完善家具的渲染元素类型
This commit is contained in:
@@ -8,10 +8,12 @@ import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityEl
|
|||||||
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfigFactory;
|
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfigFactory;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.item.Item;
|
import net.momirealms.craftengine.core.item.Item;
|
||||||
|
import net.momirealms.craftengine.core.item.ItemKeys;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
import net.momirealms.craftengine.core.world.BlockPos;
|
import net.momirealms.craftengine.core.world.BlockPos;
|
||||||
import net.momirealms.craftengine.core.world.World;
|
import net.momirealms.craftengine.core.world.World;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -22,20 +24,20 @@ import java.util.function.Function;
|
|||||||
public class ArmorStandBlockEntityElementConfig implements BlockEntityElementConfig<ArmorStandBlockEntityElement> {
|
public class ArmorStandBlockEntityElementConfig implements BlockEntityElementConfig<ArmorStandBlockEntityElement> {
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
private final Function<Player, List<Object>> lazyMetadataPacket;
|
private final Function<Player, List<Object>> lazyMetadataPacket;
|
||||||
private final Function<Player, Item<?>> item;
|
private final Key itemId;
|
||||||
private final Vector3f scale;
|
private final float scale;
|
||||||
private final Vector3f position;
|
private final Vector3f position;
|
||||||
private final float xRot;
|
private final float xRot;
|
||||||
private final float yRot;
|
private final float yRot;
|
||||||
private final boolean small;
|
private final boolean small;
|
||||||
|
|
||||||
public ArmorStandBlockEntityElementConfig(Function<Player, Item<?>> item,
|
public ArmorStandBlockEntityElementConfig(Key itemId,
|
||||||
Vector3f scale,
|
float scale,
|
||||||
Vector3f position,
|
Vector3f position,
|
||||||
float xRot,
|
float xRot,
|
||||||
float yRot,
|
float yRot,
|
||||||
boolean small) {
|
boolean small) {
|
||||||
this.item = item;
|
this.itemId = itemId;
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.xRot = xRot;
|
this.xRot = xRot;
|
||||||
@@ -79,10 +81,15 @@ public class ArmorStandBlockEntityElementConfig implements BlockEntityElementCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Item<?> item(Player player) {
|
public Item<?> item(Player player) {
|
||||||
return this.item.apply(player);
|
Item<ItemStack> wrappedItem = BukkitItemManager.instance().createWrappedItem(this.itemId, player);
|
||||||
|
return wrappedItem == null ? BukkitItemManager.instance().createWrappedItem(ItemKeys.BARRIER, player) : wrappedItem ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f scale() {
|
public Key itemId() {
|
||||||
|
return this.itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float scale() {
|
||||||
return this.scale;
|
return this.scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,10 +123,9 @@ public class ArmorStandBlockEntityElementConfig implements BlockEntityElementCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStandBlockEntityElementConfig create(Map<String, Object> arguments) {
|
public ArmorStandBlockEntityElementConfig create(Map<String, Object> arguments) {
|
||||||
Key itemId = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.block.state.entity_renderer.armor_stand.missing_item"));
|
|
||||||
return new ArmorStandBlockEntityElementConfig(
|
return new ArmorStandBlockEntityElementConfig(
|
||||||
player -> BukkitItemManager.instance().createWrappedItem(itemId, player),
|
Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.block.state.entity_renderer.armor_stand.missing_item")),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("scale", 1f), "scale"),
|
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("scale", 1f), "scale"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0.5f), "position"),
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0.5f), "position"),
|
||||||
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("pitch", 0f), "pitch"),
|
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("pitch", 0f), "pitch"),
|
||||||
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("yaw", 0f), "yaw"),
|
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("yaw", 0f), "yaw"),
|
||||||
|
|||||||
@@ -6,29 +6,36 @@ import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityEl
|
|||||||
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfigFactory;
|
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfigFactory;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.item.Item;
|
import net.momirealms.craftengine.core.item.Item;
|
||||||
|
import net.momirealms.craftengine.core.item.ItemKeys;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
import net.momirealms.craftengine.core.world.BlockPos;
|
import net.momirealms.craftengine.core.world.BlockPos;
|
||||||
import net.momirealms.craftengine.core.world.World;
|
import net.momirealms.craftengine.core.world.World;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class ItemBlockEntityElementConfig implements BlockEntityElementConfig<ItemBlockEntityElement> {
|
public class ItemBlockEntityElementConfig implements BlockEntityElementConfig<ItemBlockEntityElement> {
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
private final Function<Player, List<Object>> lazyMetadataPacket;
|
private final Function<Player, List<Object>> lazyMetadataPacket;
|
||||||
private final Function<Player, Item<?>> item;
|
private final Key itemId;
|
||||||
private final Vector3f position;
|
private final Vector3f position;
|
||||||
|
|
||||||
public ItemBlockEntityElementConfig(Function<Player, Item<?>> item, Vector3f position) {
|
public ItemBlockEntityElementConfig(Key itemId, Vector3f position) {
|
||||||
this.item = item;
|
this.itemId = itemId;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.lazyMetadataPacket = player -> {
|
this.lazyMetadataPacket = player -> {
|
||||||
List<Object> dataValues = new ArrayList<>();
|
List<Object> dataValues = new ArrayList<>();
|
||||||
ItemEntityData.Item.addEntityData(item.apply(player).getLiteralObject(), dataValues);
|
Item<ItemStack> wrappedItem = BukkitItemManager.instance().createWrappedItem(itemId, player);
|
||||||
|
if (wrappedItem == null) {
|
||||||
|
wrappedItem = Objects.requireNonNull(BukkitItemManager.instance().createWrappedItem(ItemKeys.BARRIER, player));
|
||||||
|
}
|
||||||
|
ItemEntityData.Item.addEntityData(wrappedItem.getLiteralObject(), dataValues);
|
||||||
ItemEntityData.NoGravity.addEntityData(true, dataValues);
|
ItemEntityData.NoGravity.addEntityData(true, dataValues);
|
||||||
return dataValues;
|
return dataValues;
|
||||||
};
|
};
|
||||||
@@ -61,8 +68,8 @@ public class ItemBlockEntityElementConfig implements BlockEntityElementConfig<It
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item<?> item(Player player) {
|
public Key itemId() {
|
||||||
return this.item.apply(player);
|
return itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Object> metadataValues(Player player) {
|
public List<Object> metadataValues(Player player) {
|
||||||
@@ -77,9 +84,8 @@ public class ItemBlockEntityElementConfig implements BlockEntityElementConfig<It
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemBlockEntityElementConfig create(Map<String, Object> arguments) {
|
public ItemBlockEntityElementConfig create(Map<String, Object> arguments) {
|
||||||
Key itemId = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.block.state.entity_renderer.item_display.missing_item"));
|
|
||||||
return new ItemBlockEntityElementConfig(
|
return new ItemBlockEntityElementConfig(
|
||||||
player -> BukkitItemManager.instance().createWrappedItem(itemId, player),
|
Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.block.state.entity_renderer.item.missing_item")),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0.5f), "position")
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0.5f), "position")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.bukkit.block.entity.renderer.element;
|
|||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import net.momirealms.craftengine.bukkit.entity.data.ItemDisplayEntityData;
|
import net.momirealms.craftengine.bukkit.entity.data.ItemDisplayEntityData;
|
||||||
import net.momirealms.craftengine.bukkit.entity.data.TextDisplayEntityData;
|
|
||||||
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||||
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfig;
|
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfig;
|
||||||
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfigFactory;
|
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfigFactory;
|
||||||
@@ -10,11 +9,13 @@ import net.momirealms.craftengine.core.entity.display.Billboard;
|
|||||||
import net.momirealms.craftengine.core.entity.display.ItemDisplayContext;
|
import net.momirealms.craftengine.core.entity.display.ItemDisplayContext;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.item.Item;
|
import net.momirealms.craftengine.core.item.Item;
|
||||||
|
import net.momirealms.craftengine.core.item.ItemKeys;
|
||||||
import net.momirealms.craftengine.core.util.Color;
|
import net.momirealms.craftengine.core.util.Color;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
import net.momirealms.craftengine.core.world.BlockPos;
|
import net.momirealms.craftengine.core.world.BlockPos;
|
||||||
import net.momirealms.craftengine.core.world.World;
|
import net.momirealms.craftengine.core.world.World;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
@@ -28,7 +29,7 @@ import java.util.function.Function;
|
|||||||
public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementConfig<ItemDisplayBlockEntityElement> {
|
public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementConfig<ItemDisplayBlockEntityElement> {
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
private final Function<Player, List<Object>> lazyMetadataPacket;
|
private final Function<Player, List<Object>> lazyMetadataPacket;
|
||||||
private final Function<Player, Item<?>> item;
|
private final Key itemId;
|
||||||
private final Vector3f scale;
|
private final Vector3f scale;
|
||||||
private final Vector3f position;
|
private final Vector3f position;
|
||||||
private final Vector3f translation;
|
private final Vector3f translation;
|
||||||
@@ -44,7 +45,7 @@ public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementCo
|
|||||||
private final int skyLight;
|
private final int skyLight;
|
||||||
private final float viewRange;
|
private final float viewRange;
|
||||||
|
|
||||||
public ItemDisplayBlockEntityElementConfig(Function<Player, Item<?>> item,
|
public ItemDisplayBlockEntityElementConfig(Key itemId,
|
||||||
Vector3f scale,
|
Vector3f scale,
|
||||||
Vector3f position,
|
Vector3f position,
|
||||||
Vector3f translation,
|
Vector3f translation,
|
||||||
@@ -59,7 +60,7 @@ public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementCo
|
|||||||
int blockLight,
|
int blockLight,
|
||||||
int skyLight,
|
int skyLight,
|
||||||
float viewRange) {
|
float viewRange) {
|
||||||
this.item = item;
|
this.itemId = itemId;
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.translation = translation;
|
this.translation = translation;
|
||||||
@@ -83,7 +84,11 @@ public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementCo
|
|||||||
ItemDisplayEntityData.SharedFlags.addEntityData((byte) 0x0, dataValues);
|
ItemDisplayEntityData.SharedFlags.addEntityData((byte) 0x0, dataValues);
|
||||||
ItemDisplayEntityData.GlowColorOverride.addEntityData(-1, dataValues);
|
ItemDisplayEntityData.GlowColorOverride.addEntityData(-1, dataValues);
|
||||||
}
|
}
|
||||||
ItemDisplayEntityData.DisplayedItem.addEntityData(item.apply(player).getLiteralObject(), dataValues);
|
Item<ItemStack> wrappedItem = BukkitItemManager.instance().createWrappedItem(itemId, player);
|
||||||
|
if (wrappedItem == null) {
|
||||||
|
wrappedItem = java.util.Objects.requireNonNull(BukkitItemManager.instance().createWrappedItem(ItemKeys.BARRIER, player));
|
||||||
|
}
|
||||||
|
ItemDisplayEntityData.DisplayedItem.addEntityData(wrappedItem.getLiteralObject(), dataValues);
|
||||||
ItemDisplayEntityData.Scale.addEntityData(this.scale, dataValues);
|
ItemDisplayEntityData.Scale.addEntityData(this.scale, dataValues);
|
||||||
ItemDisplayEntityData.RotationLeft.addEntityData(this.rotation, dataValues);
|
ItemDisplayEntityData.RotationLeft.addEntityData(this.rotation, dataValues);
|
||||||
ItemDisplayEntityData.BillboardConstraints.addEntityData(this.billboard.id(), dataValues);
|
ItemDisplayEntityData.BillboardConstraints.addEntityData(this.billboard.id(), dataValues);
|
||||||
@@ -128,8 +133,12 @@ public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementCo
|
|||||||
return ItemDisplayBlockEntityElement.class;
|
return ItemDisplayBlockEntityElement.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item<?> item(Player player) {
|
public Color glowColor() {
|
||||||
return this.item.apply(player);
|
return glowColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Key itemId() {
|
||||||
|
return itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f scale() {
|
public Vector3f scale() {
|
||||||
@@ -188,10 +197,9 @@ public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemDisplayBlockEntityElementConfig create(Map<String, Object> arguments) {
|
public ItemDisplayBlockEntityElementConfig create(Map<String, Object> arguments) {
|
||||||
Key itemId = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.block.state.entity_renderer.item_display.missing_item"));
|
|
||||||
Map<String, Object> brightness = ResourceConfigUtils.getAsMap(arguments.getOrDefault("brightness", Map.of()), "brightness");
|
Map<String, Object> brightness = ResourceConfigUtils.getAsMap(arguments.getOrDefault("brightness", Map.of()), "brightness");
|
||||||
return new ItemDisplayBlockEntityElementConfig(
|
return new ItemDisplayBlockEntityElementConfig(
|
||||||
player -> BukkitItemManager.instance().createWrappedItem(itemId, player),
|
Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.block.state.entity_renderer.item_display.missing_item")),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("scale", 1f), "scale"),
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("scale", 1f), "scale"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0.5f), "position"),
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0.5f), "position"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.get("translation"), "translation"),
|
ResourceConfigUtils.getAsVector3f(arguments.get("translation"), "translation"),
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.bukkit.block.entity.renderer.element;
|
|||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.momirealms.craftengine.bukkit.entity.data.ItemDisplayEntityData;
|
|
||||||
import net.momirealms.craftengine.bukkit.entity.data.TextDisplayEntityData;
|
import net.momirealms.craftengine.bukkit.entity.data.TextDisplayEntityData;
|
||||||
import net.momirealms.craftengine.bukkit.util.ComponentUtils;
|
import net.momirealms.craftengine.bukkit.util.ComponentUtils;
|
||||||
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfig;
|
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfig;
|
||||||
@@ -10,7 +9,7 @@ import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityEl
|
|||||||
import net.momirealms.craftengine.core.entity.display.Billboard;
|
import net.momirealms.craftengine.core.entity.display.Billboard;
|
||||||
import net.momirealms.craftengine.core.entity.display.TextDisplayAlignment;
|
import net.momirealms.craftengine.core.entity.display.TextDisplayAlignment;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.plugin.context.PlayerOptionalContext;
|
import net.momirealms.craftengine.core.plugin.context.NetworkTextReplaceContext;
|
||||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||||
import net.momirealms.craftengine.core.util.Color;
|
import net.momirealms.craftengine.core.util.Color;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
@@ -139,8 +138,12 @@ public class TextDisplayBlockEntityElementConfig implements BlockEntityElementCo
|
|||||||
return TextDisplayBlockEntityElement.class;
|
return TextDisplayBlockEntityElement.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String text() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
public Component text(Player player) {
|
public Component text(Player player) {
|
||||||
return AdventureHelper.miniMessage().deserialize(this.text, PlayerOptionalContext.of(player).tagResolvers());
|
return AdventureHelper.miniMessage().deserialize(this.text, NetworkTextReplaceContext.of(player).tagResolvers());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f scale() {
|
public Vector3f scale() {
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package net.momirealms.craftengine.bukkit.entity.furniture.element;
|
||||||
|
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
|
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||||
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||||
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.FurnitureColorSource;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElement;
|
||||||
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
|
import net.momirealms.craftengine.core.world.Vec3d;
|
||||||
|
import net.momirealms.craftengine.core.world.WorldPosition;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class ArmorStandFurnitureElement implements FurnitureElement {
|
||||||
|
private final ArmorStandFurnitureElementConfig config;
|
||||||
|
public final int entityId;
|
||||||
|
private final FurnitureColorSource colorSource;
|
||||||
|
public final Object cachedSpawnPacket;
|
||||||
|
public final Object cachedDespawnPacket;
|
||||||
|
|
||||||
|
public ArmorStandFurnitureElement(Furniture furniture, ArmorStandFurnitureElementConfig config) {
|
||||||
|
this.config = config;
|
||||||
|
this.entityId = CoreReflections.instance$Entity$ENTITY_COUNTER.incrementAndGet();
|
||||||
|
WorldPosition furniturePos = furniture.position();
|
||||||
|
Vec3d position = Furniture.getRelativePosition(furniturePos, config.position());
|
||||||
|
this.cachedSpawnPacket = FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(
|
||||||
|
entityId, UUID.randomUUID(), position.x, position.y, position.z,
|
||||||
|
furniturePos.xRot, furniturePos.yRot, MEntityTypes.ARMOR_STAND, 0, CoreReflections.instance$Vec3$Zero, furniturePos.yRot
|
||||||
|
);
|
||||||
|
this.colorSource = furniture.dataAccessor.getColorSource();
|
||||||
|
this.cachedDespawnPacket = FastNMS.INSTANCE.constructor$ClientboundRemoveEntitiesPacket(IntList.of(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show(Player player) {
|
||||||
|
player.sendPackets(List.of(this.cachedSpawnPacket, FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(this.entityId, this.config.metadata.apply(player))), false);
|
||||||
|
player.sendPacket(FastNMS.INSTANCE.constructor$ClientboundSetEquipmentPacket(this.entityId, List.of(
|
||||||
|
Pair.of(CoreReflections.instance$EquipmentSlot$HEAD, this.config.item(player, this.colorSource).getLiteralObject())
|
||||||
|
)), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide(Player player) {
|
||||||
|
player.sendPacket(this.cachedDespawnPacket, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] virtualEntityIds() {
|
||||||
|
return new int[] {this.entityId};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectVirtualEntityId(Consumer<Integer> collector) {
|
||||||
|
collector.accept(this.entityId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package net.momirealms.craftengine.bukkit.entity.furniture.element;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
import net.momirealms.craftengine.bukkit.entity.data.ArmorStandData;
|
||||||
|
import net.momirealms.craftengine.bukkit.entity.data.BaseEntityData;
|
||||||
|
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.FurnitureColorSource;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfig;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfigFactory;
|
||||||
|
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.Key;
|
||||||
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class ArmorStandFurnitureElementConfig implements FurnitureElementConfig<ArmorStandFurnitureElement> {
|
||||||
|
public static final Factory FACTORY = new Factory();
|
||||||
|
public final Function<Player, List<Object>> metadata;
|
||||||
|
public final Key itemId;
|
||||||
|
public final float scale;
|
||||||
|
public final boolean applyDyedColor;
|
||||||
|
public final Vector3f position;
|
||||||
|
public final boolean small;
|
||||||
|
|
||||||
|
public ArmorStandFurnitureElementConfig(Key itemId,
|
||||||
|
float scale,
|
||||||
|
Vector3f position,
|
||||||
|
boolean applyDyedColor,
|
||||||
|
boolean small) {
|
||||||
|
this.position = position;
|
||||||
|
this.applyDyedColor = applyDyedColor;
|
||||||
|
this.small = small;
|
||||||
|
this.scale = scale;
|
||||||
|
this.itemId = itemId;
|
||||||
|
this.metadata = (player) -> {
|
||||||
|
List<Object> dataValues = new ArrayList<>(2);
|
||||||
|
BaseEntityData.SharedFlags.addEntityData((byte) 0x20, dataValues);
|
||||||
|
if (small) {
|
||||||
|
ArmorStandData.ArmorStandFlags.addEntityData((byte) 0x01, dataValues);
|
||||||
|
}
|
||||||
|
return dataValues;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item<?> item(Player player, FurnitureColorSource colorSource) {
|
||||||
|
Item<ItemStack> wrappedItem = BukkitItemManager.instance().createWrappedItem(itemId, player);
|
||||||
|
if (applyDyedColor && colorSource != null && wrappedItem != null) {
|
||||||
|
Optional.ofNullable(colorSource.dyedColor()).ifPresent(wrappedItem::dyedColor);
|
||||||
|
Optional.ofNullable(colorSource.fireworkColors()).ifPresent(colors -> wrappedItem.fireworkExplosion(new FireworkExplosion(
|
||||||
|
FireworkExplosion.Shape.SMALL_BALL,
|
||||||
|
new IntArrayList(colors),
|
||||||
|
new IntArrayList(),
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(wrappedItem).orElseGet(() -> BukkitItemManager.instance().createWrappedItem(ItemKeys.BARRIER, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
public float scale() {
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean small() {
|
||||||
|
return small;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f position() {
|
||||||
|
return this.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean applyDyedColor() {
|
||||||
|
return this.applyDyedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Key itemId() {
|
||||||
|
return this.itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArmorStandFurnitureElement create(@NotNull Furniture furniture) {
|
||||||
|
return new ArmorStandFurnitureElement(furniture, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory implements FurnitureElementConfigFactory<ArmorStandFurnitureElement> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArmorStandFurnitureElementConfig create(Map<String, Object> arguments) {
|
||||||
|
return new ArmorStandFurnitureElementConfig(
|
||||||
|
Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.furniture.element.armor_stand.missing_item")),
|
||||||
|
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("scale", 1f), "scale"),
|
||||||
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0f), "position"),
|
||||||
|
ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("apply-dyed-color", true), "apply-dyed-color"),
|
||||||
|
ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("small", false), "small")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ public class BukkitFurnitureElementConfigs extends FurnitureElementConfigs {
|
|||||||
static {
|
static {
|
||||||
register(ITEM_DISPLAY, ItemDisplayFurnitureElementConfig.FACTORY);
|
register(ITEM_DISPLAY, ItemDisplayFurnitureElementConfig.FACTORY);
|
||||||
register(TEXT_DISPLAY, TextDisplayFurnitureElementConfig.FACTORY);
|
register(TEXT_DISPLAY, TextDisplayFurnitureElementConfig.FACTORY);
|
||||||
|
register(ITEM, ItemFurnitureElementConfig.FACTORY);
|
||||||
|
register(ARMOR_STAND, ArmorStandFurnitureElementConfig.FACTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BukkitFurnitureElementConfigs() {}
|
private BukkitFurnitureElementConfigs() {}
|
||||||
|
|||||||
@@ -194,11 +194,9 @@ public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemDisplayFurnitureElementConfig create(Map<String, Object> arguments) {
|
public ItemDisplayFurnitureElementConfig create(Map<String, Object> arguments) {
|
||||||
Key itemId = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.furniture.element.item_display.missing_item"));
|
|
||||||
boolean applyDyedColor = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("apply-dyed-color", true), "apply-dyed-color");
|
|
||||||
Map<String, Object> brightness = ResourceConfigUtils.getAsMap(arguments.getOrDefault("brightness", Map.of()), "brightness");
|
Map<String, Object> brightness = ResourceConfigUtils.getAsMap(arguments.getOrDefault("brightness", Map.of()), "brightness");
|
||||||
return new ItemDisplayFurnitureElementConfig(
|
return new ItemDisplayFurnitureElementConfig(
|
||||||
itemId,
|
Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.furniture.element.item_display.missing_item")),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("scale", 1f), "scale"),
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("scale", 1f), "scale"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0f), "position"),
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0f), "position"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.get("translation"), "translation"),
|
ResourceConfigUtils.getAsVector3f(arguments.get("translation"), "translation"),
|
||||||
@@ -209,7 +207,7 @@ public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig
|
|||||||
ResourceConfigUtils.getAsEnum(arguments.get("billboard"), Billboard.class, Billboard.FIXED),
|
ResourceConfigUtils.getAsEnum(arguments.get("billboard"), Billboard.class, Billboard.FIXED),
|
||||||
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("shadow-radius", 0f), "shadow-radius"),
|
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("shadow-radius", 0f), "shadow-radius"),
|
||||||
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("shadow-strength", 1f), "shadow-strength"),
|
ResourceConfigUtils.getAsFloat(arguments.getOrDefault("shadow-strength", 1f), "shadow-strength"),
|
||||||
applyDyedColor,
|
ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("apply-dyed-color", true), "apply-dyed-color"),
|
||||||
Optional.ofNullable(arguments.get("glow-color")).map(it -> Color.fromStrings(it.toString().split(","))).orElse(null),
|
Optional.ofNullable(arguments.get("glow-color")).map(it -> Color.fromStrings(it.toString().split(","))).orElse(null),
|
||||||
ResourceConfigUtils.getAsInt(brightness.getOrDefault("block-light", -1), "block-light"),
|
ResourceConfigUtils.getAsInt(brightness.getOrDefault("block-light", -1), "block-light"),
|
||||||
ResourceConfigUtils.getAsInt(brightness.getOrDefault("sky-light", -1), "sky-light"),
|
ResourceConfigUtils.getAsInt(brightness.getOrDefault("sky-light", -1), "sky-light"),
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package net.momirealms.craftengine.bukkit.entity.furniture.element;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||||
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||||
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.FurnitureColorSource;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElement;
|
||||||
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
|
import net.momirealms.craftengine.core.world.Vec3d;
|
||||||
|
import net.momirealms.craftengine.core.world.WorldPosition;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class ItemFurnitureElement implements FurnitureElement {
|
||||||
|
private final ItemFurnitureElementConfig config;
|
||||||
|
public final int entityId1;
|
||||||
|
public final int entityId2;
|
||||||
|
private final Object despawnPacket;
|
||||||
|
private final FurnitureColorSource colorSource;
|
||||||
|
public final Object cachedSpawnPacket1;
|
||||||
|
public final Object cachedSpawnPacket2;
|
||||||
|
public final Object cachedRidePacket;
|
||||||
|
|
||||||
|
public ItemFurnitureElement(Furniture furniture, ItemFurnitureElementConfig config) {
|
||||||
|
this.config = config;
|
||||||
|
this.entityId1 = CoreReflections.instance$Entity$ENTITY_COUNTER.incrementAndGet();
|
||||||
|
this.entityId2 = CoreReflections.instance$Entity$ENTITY_COUNTER.incrementAndGet();
|
||||||
|
WorldPosition furniturePos = furniture.position();
|
||||||
|
Vec3d position = Furniture.getRelativePosition(furniturePos, config.position());
|
||||||
|
this.cachedSpawnPacket1 = FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(
|
||||||
|
entityId1, UUID.randomUUID(), position.x, position.y, position.z,
|
||||||
|
0, 0, MEntityTypes.ITEM_DISPLAY, 0, CoreReflections.instance$Vec3$Zero, 0
|
||||||
|
);
|
||||||
|
this.cachedSpawnPacket2 = FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(
|
||||||
|
entityId2, UUID.randomUUID(), position.x, position.y, position.z,
|
||||||
|
0, 0, MEntityTypes.ITEM, 0, CoreReflections.instance$Vec3$Zero, 0
|
||||||
|
);
|
||||||
|
this.cachedRidePacket = FastNMS.INSTANCE.constructor$ClientboundSetPassengersPacket(entityId1, entityId2);
|
||||||
|
this.despawnPacket = FastNMS.INSTANCE.constructor$ClientboundRemoveEntitiesPacket(MiscUtils.init(new IntArrayList(),
|
||||||
|
a -> {
|
||||||
|
a.add(entityId1);
|
||||||
|
a.add(entityId2);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
this.colorSource = furniture.dataAccessor.getColorSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show(Player player) {
|
||||||
|
player.sendPackets(List.of(
|
||||||
|
this.cachedSpawnPacket1,
|
||||||
|
this.cachedSpawnPacket2,
|
||||||
|
this.cachedRidePacket,
|
||||||
|
FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(this.entityId2, this.config.metadata().apply(player, this.colorSource)
|
||||||
|
)), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide(Player player) {
|
||||||
|
player.sendPacket(this.despawnPacket, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] virtualEntityIds() {
|
||||||
|
return new int[] {this.entityId1, this.entityId2};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectVirtualEntityId(Consumer<Integer> collector) {
|
||||||
|
collector.accept(this.entityId1);
|
||||||
|
collector.accept(this.entityId2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package net.momirealms.craftengine.bukkit.entity.furniture.element;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
import net.momirealms.craftengine.bukkit.entity.data.ItemEntityData;
|
||||||
|
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.FurnitureColorSource;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfig;
|
||||||
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfigFactory;
|
||||||
|
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.Key;
|
||||||
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
public class ItemFurnitureElementConfig implements FurnitureElementConfig<ItemFurnitureElement> {
|
||||||
|
public static final Factory FACTORY = new Factory();
|
||||||
|
public final BiFunction<Player, FurnitureColorSource, List<Object>> metadata;
|
||||||
|
public final Key itemId;
|
||||||
|
public final boolean applyDyedColor;
|
||||||
|
public final Vector3f position;
|
||||||
|
|
||||||
|
public ItemFurnitureElementConfig(Key itemId,
|
||||||
|
Vector3f position,
|
||||||
|
boolean applyDyedColor) {
|
||||||
|
this.position = position;
|
||||||
|
this.applyDyedColor = applyDyedColor;
|
||||||
|
this.itemId = itemId;
|
||||||
|
BiFunction<Player, FurnitureColorSource, Item<?>> itemFunction = (player, colorSource) -> {
|
||||||
|
Item<ItemStack> wrappedItem = BukkitItemManager.instance().createWrappedItem(itemId, player);
|
||||||
|
if (applyDyedColor && colorSource != null && wrappedItem != null) {
|
||||||
|
Optional.ofNullable(colorSource.dyedColor()).ifPresent(wrappedItem::dyedColor);
|
||||||
|
Optional.ofNullable(colorSource.fireworkColors()).ifPresent(colors -> wrappedItem.fireworkExplosion(new FireworkExplosion(
|
||||||
|
FireworkExplosion.Shape.SMALL_BALL,
|
||||||
|
new IntArrayList(colors),
|
||||||
|
new IntArrayList(),
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(wrappedItem).orElseGet(() -> BukkitItemManager.instance().createWrappedItem(ItemKeys.BARRIER, null));
|
||||||
|
};
|
||||||
|
this.metadata = (player, source) -> {
|
||||||
|
List<Object> dataValues = new ArrayList<>();
|
||||||
|
ItemEntityData.Item.addEntityData(itemFunction.apply(player, source).getLiteralObject(), dataValues);
|
||||||
|
ItemEntityData.NoGravity.addEntityData(true, dataValues);
|
||||||
|
return dataValues;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f position() {
|
||||||
|
return this.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean applyDyedColor() {
|
||||||
|
return this.applyDyedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiFunction<Player, FurnitureColorSource, List<Object>> metadata() {
|
||||||
|
return this.metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Key itemId() {
|
||||||
|
return this.itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemFurnitureElement create(@NotNull Furniture furniture) {
|
||||||
|
return new ItemFurnitureElement(furniture, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory implements FurnitureElementConfigFactory<ItemFurnitureElement> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemFurnitureElementConfig create(Map<String, Object> arguments) {
|
||||||
|
return new ItemFurnitureElementConfig(
|
||||||
|
Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("item"), "warning.config.furniture.element.item.missing_item")),
|
||||||
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0f), "position"),
|
||||||
|
ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("apply-dyed-color", true), "apply-dyed-color")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
|||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.FurnitureColorSource;
|
|
||||||
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElement;
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElement;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
|
|||||||
@@ -221,10 +221,9 @@ public class TextDisplayFurnitureElementConfig implements FurnitureElementConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextDisplayFurnitureElementConfig create(Map<String, Object> arguments) {
|
public TextDisplayFurnitureElementConfig create(Map<String, Object> arguments) {
|
||||||
String text = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("text"), "warning.config.furniture.element.text_display.missing_text");
|
|
||||||
Map<String, Object> brightness = ResourceConfigUtils.getAsMap(arguments.getOrDefault("brightness", Map.of()), "brightness");
|
Map<String, Object> brightness = ResourceConfigUtils.getAsMap(arguments.getOrDefault("brightness", Map.of()), "brightness");
|
||||||
return new TextDisplayFurnitureElementConfig(
|
return new TextDisplayFurnitureElementConfig(
|
||||||
text,
|
ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("text"), "warning.config.furniture.element.text_display.missing_text"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("scale", 1f), "scale"),
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("scale", 1f), "scale"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0f), "position"),
|
ResourceConfigUtils.getAsVector3f(arguments.getOrDefault("position", 0f), "position"),
|
||||||
ResourceConfigUtils.getAsVector3f(arguments.get("translation"), "translation"),
|
ResourceConfigUtils.getAsVector3f(arguments.get("translation"), "translation"),
|
||||||
|
|||||||
@@ -237,6 +237,8 @@ warning.config.furniture.missing_variants: "<yellow>Issue found in file <arg:0>
|
|||||||
warning.config.furniture.element.invalid_type: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an invalid element type '<arg:2>'.</yellow>"
|
warning.config.furniture.element.invalid_type: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an invalid element type '<arg:2>'.</yellow>"
|
||||||
warning.config.furniture.element.item_display.missing_item: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'item' argument for 'item_display' element.</yellow>"
|
warning.config.furniture.element.item_display.missing_item: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'item' argument for 'item_display' element.</yellow>"
|
||||||
warning.config.furniture.element.text_display.missing_text: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'text' argument for 'text_display' element.</yellow>"
|
warning.config.furniture.element.text_display.missing_text: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'text' argument for 'text_display' element.</yellow>"
|
||||||
|
warning.config.furniture.element.item.missing_item: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'item' argument for 'item' element.</yellow>"
|
||||||
|
warning.config.furniture.element.armor_stand.missing_item: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'item' argument for 'armor_stand' element.</yellow>"
|
||||||
warning.config.furniture.settings.unknown: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an unknown setting type '<arg:2>'.</yellow>"
|
warning.config.furniture.settings.unknown: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an unknown setting type '<arg:2>'.</yellow>"
|
||||||
warning.config.furniture.hitbox.invalid_type: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an invalid hitbox type '<arg:2>'.</yellow>"
|
warning.config.furniture.hitbox.invalid_type: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an invalid hitbox type '<arg:2>'.</yellow>"
|
||||||
warning.config.furniture.hitbox.custom.invalid_entity: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using a custom hitbox with invalid entity type '<arg:2>'.</yellow>"
|
warning.config.furniture.hitbox.custom.invalid_entity: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using a custom hitbox with invalid entity type '<arg:2>'.</yellow>"
|
||||||
@@ -351,6 +353,8 @@ warning.config.block.state.entity_renderer.item_display.missing_item: "<yellow>I
|
|||||||
warning.config.block.state.entity_renderer.text_display.missing_text: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'text' argument for 'text_display' entity renderer.</yellow>"
|
warning.config.block.state.entity_renderer.text_display.missing_text: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'text' argument for 'text_display' entity renderer.</yellow>"
|
||||||
warning.config.block.state.entity_renderer.better_model.missing_model: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'model' argument for 'better_model' entity renderer.</yellow>"
|
warning.config.block.state.entity_renderer.better_model.missing_model: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'model' argument for 'better_model' entity renderer.</yellow>"
|
||||||
warning.config.block.state.entity_renderer.model_engine.missing_model: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'model' argument for 'model_engine' entity renderer.</yellow>"
|
warning.config.block.state.entity_renderer.model_engine.missing_model: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'model' argument for 'model_engine' entity renderer.</yellow>"
|
||||||
|
warning.config.block.state.entity_renderer.armor_stand.missing_item: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'item' argument for 'armor_stand' entity renderer.</yellow>"
|
||||||
|
warning.config.block.state.entity_renderer.item.missing_item: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'item' argument for 'item' entity renderer.</yellow>"
|
||||||
warning.config.block.state.variant.invalid_appearance: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' has an error that the variant '<arg:2>' is using a non-existing appearance '<arg:3>'.</yellow>"
|
warning.config.block.state.variant.invalid_appearance: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' has an error that the variant '<arg:2>' is using a non-existing appearance '<arg:3>'.</yellow>"
|
||||||
warning.config.block.state.invalid_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid vanilla block state '<arg:2>'.</yellow>"
|
warning.config.block.state.invalid_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid vanilla block state '<arg:2>'.</yellow>"
|
||||||
warning.config.block.state.invalid_auto_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid auto-state '<arg:2>'. Allowed values: [<arg:3>].</yellow>"
|
warning.config.block.state.invalid_auto_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid auto-state '<arg:2>'. Allowed values: [<arg:3>].</yellow>"
|
||||||
|
|||||||
@@ -237,6 +237,8 @@ warning.config.furniture.missing_variants: "<yellow>在文件 <arg:0> 发现问
|
|||||||
warning.config.furniture.element.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 使用了无效的元素类型 '<arg:2>'</yellow>"
|
warning.config.furniture.element.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 使用了无效的元素类型 '<arg:2>'</yellow>"
|
||||||
warning.config.furniture.element.item_display.missing_item: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的 'item_display' 元素缺少必需的 'item' 参数</yellow>"
|
warning.config.furniture.element.item_display.missing_item: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的 'item_display' 元素缺少必需的 'item' 参数</yellow>"
|
||||||
warning.config.furniture.element.text_display.missing_text: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的 'text_display' 元素缺少必需的 'text' 参数</yellow>"
|
warning.config.furniture.element.text_display.missing_text: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的 'text_display' 元素缺少必需的 'text' 参数</yellow>"
|
||||||
|
warning.config.furniture.element.item.missing_item: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的 'item' 元素缺少必需的 'item' 参数</yellow>"
|
||||||
|
warning.config.furniture.element.armor_stand.missing_item: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的 'armor_stand' 元素缺少必需的 'item' 参数</yellow>"
|
||||||
warning.config.furniture.settings.unknown: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 使用了未知的设置类型 '<arg:2>'</yellow>"
|
warning.config.furniture.settings.unknown: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 使用了未知的设置类型 '<arg:2>'</yellow>"
|
||||||
warning.config.furniture.hitbox.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 使用了无效的碰撞箱类型 '<arg:2>'</yellow>"
|
warning.config.furniture.hitbox.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 使用了无效的碰撞箱类型 '<arg:2>'</yellow>"
|
||||||
warning.config.furniture.hitbox.custom.invalid_entity: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的自定义碰撞箱使用了无效的实体类型 '<arg:2>'</yellow>"
|
warning.config.furniture.hitbox.custom.invalid_entity: "<yellow>在文件 <arg:0> 发现问题 - 家具 '<arg:1>' 的自定义碰撞箱使用了无效的实体类型 '<arg:2>'</yellow>"
|
||||||
@@ -351,6 +353,8 @@ warning.config.block.state.entity_renderer.item_display.missing_item: "<yellow>
|
|||||||
warning.config.block.state.entity_renderer.text_display.missing_text: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'text_display' 实体渲染器所需的 'text' 参数</yellow>"
|
warning.config.block.state.entity_renderer.text_display.missing_text: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'text_display' 实体渲染器所需的 'text' 参数</yellow>"
|
||||||
warning.config.block.state.entity_renderer.better_model.missing_model: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'better_model' 实体渲染器所需的 'model' 参数</yellow>"
|
warning.config.block.state.entity_renderer.better_model.missing_model: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'better_model' 实体渲染器所需的 'model' 参数</yellow>"
|
||||||
warning.config.block.state.entity_renderer.model_engine.missing_model: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'model_engine' 实体渲染器所需的 'model' 参数</yellow>"
|
warning.config.block.state.entity_renderer.model_engine.missing_model: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'model_engine' 实体渲染器所需的 'model' 参数</yellow>"
|
||||||
|
warning.config.block.state.entity_renderer.armor_stand.missing_item: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'armor_stand' 实体渲染器所需的 'item' 参数</yellow>"
|
||||||
|
warning.config.block.state.entity_renderer.item.missing_item: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 缺少 'item' 实体渲染器所需的 'item' 参数</yellow>"
|
||||||
warning.config.block.state.variant.invalid_appearance: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的变体 '<arg:2>' 使用了不存在的 appearance '<arg:3>'</yellow>"
|
warning.config.block.state.variant.invalid_appearance: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的变体 '<arg:2>' 使用了不存在的 appearance '<arg:3>'</yellow>"
|
||||||
warning.config.block.state.invalid_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的原版方块状态 '<arg:2>'</yellow>"
|
warning.config.block.state.invalid_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的原版方块状态 '<arg:2>'</yellow>"
|
||||||
warning.config.block.state.invalid_auto_state: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的自动状态 '<arg:2>'. 允许的值: [<arg:3>]</yellow>"
|
warning.config.block.state.invalid_auto_state: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的自动状态 '<arg:2>'. 允许的值: [<arg:3>]</yellow>"
|
||||||
|
|||||||
Reference in New Issue
Block a user