All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.block.customblock.data.Geometry Maven / Gradle / Ivy

package cn.nukkit.block.customblock.data;

import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;
import cn.nukkit.nbt.tag.CompoundTag;
import com.google.common.base.Preconditions;
import org.jetbrains.annotations.NotNull;

import java.util.LinkedHashMap;
import java.util.Map;

@PowerNukkitXOnly
@Since("1.19.80-r1")
public class Geometry implements NBTData {
    private final String geometryName;
    private final Map boneVisibilities = new LinkedHashMap<>();

    public Geometry(@NotNull String name) {
        Preconditions.checkNotNull(name);
        Preconditions.checkArgument(!name.isBlank());
        this.geometryName = name;
    }

    /**
     * 控制模型对应骨骼是否显示
     * 

* Control the visibility that the bone of geometry */ public Geometry boneVisibility(@NotNull String boneName, boolean isVisibility) { Preconditions.checkNotNull(boneName); Preconditions.checkArgument(!boneName.isBlank()); this.boneVisibilities.put(boneName, isVisibility ? "true" : "false"); return this; } /** * 控制模型对应骨骼是否显示 *

* Control the visibility that the bone of geometry */ public Geometry boneVisibility(@NotNull String boneName, String condition) { Preconditions.checkNotNull(boneName); Preconditions.checkArgument(!boneName.isBlank()); this.boneVisibilities.put(boneName, condition); return this; } @Override public CompoundTag toCompoundTag() { var boneVisibility = new CompoundTag(); for (var entry : boneVisibilities.entrySet()) { boneVisibility.putString(entry.getKey(), entry.getValue()); } CompoundTag compoundTag = new CompoundTag("minecraft:geometry") .putString("identifier", geometryName) .putByte("legacyBlockLightAbsorption", 0) .putByte("legacyTopRotation", 0); if (boneVisibilities.size() > 0) { compoundTag.putCompound("bone_visibility", boneVisibility); } return compoundTag; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy