use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project ViaVersion by ViaVersion.
the class EntityPackets method createOverworldEntry.
private static CompoundTag createOverworldEntry() {
CompoundTag tag = new CompoundTag();
tag.put("name", new StringTag("minecraft:overworld"));
tag.put("has_ceiling", new ByteTag((byte) 0));
addSharedOverwaldEntries(tag);
return tag;
}
use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project ViaVersion by ViaVersion.
the class CommandBlockStorage method getCommandBlock.
public Optional<CompoundTag> getCommandBlock(Position position) {
Pair<Integer, Integer> chunkCoords = getChunkCoords(position);
Map<Position, CompoundTag> blocks = storedCommandBlocks.get(chunkCoords);
if (blocks == null)
return Optional.empty();
CompoundTag tag = blocks.get(position);
if (tag == null)
return Optional.empty();
tag = tag.clone();
tag.put("powered", new ByteTag((byte) 0));
tag.put("auto", new ByteTag((byte) 0));
tag.put("conditionMet", new ByteTag((byte) 0));
return Optional.of(tag);
}
use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project DragonProxy by DragonetMC.
the class ItemBlockTranslator method translateRawNBT.
@SuppressWarnings("unchecked")
public static org.dragonet.common.data.nbt.tag.CompoundTag translateRawNBT(int id, Tag pcTag, org.dragonet.common.data.nbt.tag.CompoundTag target) {
if (pcTag != null) {
String name = pcTag.getName() != null ? pcTag.getName() : "";
if (target == null)
target = new org.dragonet.common.data.nbt.tag.CompoundTag(name);
switch(pcTag.getClass().getSimpleName()) {
case "ByteArrayTag":
target.putByteArray(name, (byte[]) pcTag.getValue());
break;
case "ByteTag":
target.putByte(name, (byte) pcTag.getValue());
break;
case "DoubleTag":
target.putDouble(name, (double) pcTag.getValue());
break;
case "FloatTag":
target.putFloat(name, (float) pcTag.getValue());
break;
case "IntArrayTag":
target.putIntArray(name, (int[]) pcTag.getValue());
break;
case "IntTag":
target.putInt(name, (int) pcTag.getValue());
break;
case "LongTag":
target.putLong(name, (long) pcTag.getValue());
break;
case "ShortTag":
target.putShort(name, (short) pcTag.getValue());
break;
case "StringTag":
target.putString(name, (String) pcTag.getValue());
break;
case "CompoundTag":
for (String subName : ((CompoundTag) pcTag).getValue().keySet()) translateRawNBT(0, ((CompoundTag) pcTag).getValue().get(subName), target);
break;
case "ListTag":
ListTag listTag = new ListTag();
for (Tag subTag : (List<Tag>) pcTag.getValue()) listTag.add(translateRawNBT(0, subTag, new org.dragonet.common.data.nbt.tag.CompoundTag()));
target.putList(listTag);
break;
default:
System.out.println("TAG not implemented : " + pcTag.getClass().getSimpleName());
break;
}
}
return target;
}
use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project Geyser by GeyserMC.
the class CrossbowTranslator method translateToBedrock.
@Override
public void translateToBedrock(GeyserSession session, CompoundTag itemTag, ItemMapping mapping) {
if (itemTag.get("ChargedProjectiles") != null) {
ListTag chargedProjectiles = itemTag.get("ChargedProjectiles");
if (!chargedProjectiles.getValue().isEmpty()) {
CompoundTag projectile = (CompoundTag) chargedProjectiles.getValue().get(0);
ItemMapping projectileMapping = session.getItemMappings().getMapping((String) projectile.get("id").getValue());
if (projectileMapping == null)
return;
CompoundTag tag = projectile.get("tag");
ItemStack itemStack = new ItemStack(mapping.getJavaId(), (byte) projectile.get("Count").getValue(), tag);
ItemData itemData = ItemTranslator.translateToBedrock(session, itemStack);
CompoundTag newProjectile = new CompoundTag("chargedItem");
newProjectile.put(new ByteTag("Count", (byte) itemData.getCount()));
newProjectile.put(new StringTag("Name", projectileMapping.getBedrockIdentifier()));
newProjectile.put(new ShortTag("Damage", (short) itemData.getDamage()));
itemTag.put(newProjectile);
}
}
}
use of com.github.steveice10.opennbt.tag.builtin.ByteTag in project Geyser by GeyserMC.
the class FireworkBaseTranslator method translateExplosionToBedrock.
protected CompoundTag translateExplosionToBedrock(CompoundTag explosion, String newName) {
CompoundTag newExplosionData = new CompoundTag(newName);
if (explosion.get("Type") != null) {
newExplosionData.put(new ByteTag("FireworkType", MathUtils.getNbtByte(explosion.get("Type").getValue())));
}
if (explosion.get("Colors") != null) {
int[] oldColors = (int[]) explosion.get("Colors").getValue();
byte[] colors = new byte[oldColors.length];
int i = 0;
for (int color : oldColors) {
colors[i++] = FireworkColor.fromJavaRGB(color);
}
newExplosionData.put(new ByteArrayTag("FireworkColor", colors));
}
if (explosion.get("FadeColors") != null) {
int[] oldColors = (int[]) explosion.get("FadeColors").getValue();
byte[] colors = new byte[oldColors.length];
int i = 0;
for (int color : oldColors) {
colors[i++] = FireworkColor.fromJavaRGB(color);
}
newExplosionData.put(new ByteArrayTag("FireworkFade", colors));
}
if (explosion.get("Trail") != null) {
newExplosionData.put(new ByteTag("FireworkTrail", MathUtils.getNbtByte(explosion.get("Trail").getValue())));
}
if (explosion.get("Flicker") != null) {
newExplosionData.put(new ByteTag("FireworkFlicker", MathUtils.getNbtByte(explosion.get("Flicker").getValue())));
}
return newExplosionData;
}
Aggregations