Search in sources :

Example 1 with ByteTag

use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project Geyser by GeyserMC.

the class AxolotlBucketTranslator method translateToBedrock.

@Override
public void translateToBedrock(GeyserSession session, CompoundTag itemTag, ItemMapping mapping) {
    // Bedrock Edition displays the properties of the axolotl. Java does not.
    // To work around this, set the custom name to the Axolotl translation and it's displayed correctly
    itemTag.put(new ByteTag("AppendCustomName", (byte) 1));
    itemTag.put(new StringTag("CustomName", MinecraftLocale.getLocaleString("entity.minecraft.axolotl", session.getLocale())));
    // Boilerplate required so the nametag does not appear as "Bucket of "
    itemTag.put(new StringTag("ColorID", ""));
    itemTag.put(new StringTag("BodyID", ""));
}
Also used : StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag)

Example 2 with ByteTag

use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project Geyser by GeyserMC.

the class FireworkBaseTranslator method translateExplosionToJava.

protected CompoundTag translateExplosionToJava(CompoundTag explosion, String newName) {
    CompoundTag newExplosionData = new CompoundTag(newName);
    if (explosion.get("FireworkType") != null) {
        newExplosionData.put(new ByteTag("Type", MathUtils.getNbtByte(explosion.get("FireworkType").getValue())));
    }
    if (explosion.get("FireworkColor") != null) {
        byte[] oldColors = (byte[]) explosion.get("FireworkColor").getValue();
        int[] colors = new int[oldColors.length];
        int i = 0;
        for (byte color : oldColors) {
            colors[i++] = FireworkColor.fromBedrockId(color);
        }
        newExplosionData.put(new IntArrayTag("Colors", colors));
    }
    if (explosion.get("FireworkFade") != null) {
        byte[] oldColors = (byte[]) explosion.get("FireworkFade").getValue();
        int[] colors = new int[oldColors.length];
        int i = 0;
        for (byte color : oldColors) {
            colors[i++] = FireworkColor.fromBedrockId(color);
        }
        newExplosionData.put(new IntArrayTag("FadeColors", colors));
    }
    if (explosion.get("FireworkTrail") != null) {
        newExplosionData.put(new ByteTag("Trail", MathUtils.getNbtByte(explosion.get("FireworkTrail").getValue())));
    }
    if (explosion.get("FireworkFlicker") != null) {
        newExplosionData.put(new ByteTag("Flicker", MathUtils.getNbtByte(explosion.get("FireworkFlicker").getValue())));
    }
    return newExplosionData;
}
Also used : IntArrayTag(com.github.steveice10.opennbt.tag.builtin.IntArrayTag) ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag)

Example 3 with ByteTag

use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project Geyser by GeyserMC.

the class FireworkRocketTranslator method translateToJava.

@Override
public void translateToJava(CompoundTag itemTag, ItemMapping mapping) {
    CompoundTag fireworks = itemTag.get("Fireworks");
    if (fireworks == null) {
        return;
    }
    if (fireworks.contains("Flight")) {
        fireworks.put(new ByteTag("Flight", MathUtils.getNbtByte(fireworks.get("Flight").getValue())));
    }
    ListTag explosions = fireworks.get("Explosions");
    if (explosions == null) {
        return;
    }
    for (Tag effect : explosions.getValue()) {
        CompoundTag effectData = (CompoundTag) effect;
        CompoundTag newEffectData = translateExplosionToJava(effectData, "");
        explosions.remove(effect);
        explosions.add(newEffectData);
    }
}
Also used : ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag) ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag) Tag(com.github.steveice10.opennbt.tag.builtin.Tag) ListTag(com.github.steveice10.opennbt.tag.builtin.ListTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) ListTag(com.github.steveice10.opennbt.tag.builtin.ListTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag)

Example 4 with ByteTag

use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project ViaVersion by ViaVersion.

the class EntityPackets method createEndEntry.

private static CompoundTag createEndEntry() {
    CompoundTag tag = new CompoundTag();
    tag.put("piglin_safe", new ByteTag((byte) 0));
    tag.put("natural", new ByteTag((byte) 0));
    tag.put("ambient_light", new FloatTag(0));
    tag.put("infiniburn", new StringTag("minecraft:infiniburn_end"));
    tag.put("respawn_anchor_works", new ByteTag((byte) 0));
    tag.put("has_skylight", new ByteTag((byte) 0));
    tag.put("bed_works", new ByteTag((byte) 0));
    tag.put("fixed_time", new LongTag(6000));
    tag.put("has_raids", new ByteTag((byte) 1));
    tag.put("name", new StringTag("minecraft:the_end"));
    tag.put("logical_height", new IntTag(256));
    tag.put("shrunk", new ByteTag((byte) 0));
    tag.put("ultrawarm", new ByteTag((byte) 0));
    tag.put("has_ceiling", new ByteTag((byte) 0));
    return tag;
}
Also used : StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) FloatTag(com.github.steveice10.opennbt.tag.builtin.FloatTag) ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag)

Example 5 with ByteTag

use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project ViaVersion by ViaVersion.

the class EntityPackets method addSharedOverwaldEntries.

private static void addSharedOverwaldEntries(CompoundTag tag) {
    tag.put("piglin_safe", new ByteTag((byte) 0));
    tag.put("natural", new ByteTag((byte) 1));
    tag.put("ambient_light", new FloatTag(0));
    tag.put("infiniburn", new StringTag("minecraft:infiniburn_overworld"));
    tag.put("respawn_anchor_works", new ByteTag((byte) 0));
    tag.put("has_skylight", new ByteTag((byte) 1));
    tag.put("bed_works", new ByteTag((byte) 1));
    tag.put("has_raids", new ByteTag((byte) 1));
    tag.put("logical_height", new IntTag(256));
    tag.put("shrunk", new ByteTag((byte) 0));
    tag.put("ultrawarm", new ByteTag((byte) 0));
}
Also used : StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) FloatTag(com.github.steveice10.opennbt.tag.builtin.FloatTag) ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag)

Aggregations

ByteTag (com.github.steveice10.opennbt.tag.builtin.ByteTag)13 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)11 StringTag (com.github.steveice10.opennbt.tag.builtin.StringTag)8 IntTag (com.github.steveice10.opennbt.tag.builtin.IntTag)5 FloatTag (com.github.steveice10.opennbt.tag.builtin.FloatTag)4 Tag (com.github.steveice10.opennbt.tag.builtin.Tag)4 LongTag (com.github.steveice10.opennbt.tag.builtin.LongTag)3 ListTag (com.github.steveice10.opennbt.tag.builtin.ListTag)2 ItemStack (com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack)1 ByteArrayTag (com.github.steveice10.opennbt.tag.builtin.ByteArrayTag)1 DoubleTag (com.github.steveice10.opennbt.tag.builtin.DoubleTag)1 IntArrayTag (com.github.steveice10.opennbt.tag.builtin.IntArrayTag)1 ShortTag (com.github.steveice10.opennbt.tag.builtin.ShortTag)1 ItemData (com.nukkitx.protocol.bedrock.data.inventory.ItemData)1 Position (com.viaversion.viaversion.api.minecraft.Position)1 List (java.util.List)1 ListTag (org.dragonet.common.data.nbt.tag.ListTag)1 ItemMapping (org.geysermc.geyser.registry.type.ItemMapping)1