mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 18:15:39 +01:00
Fixes
This commit is contained in:
parent
5c8fb13e56
commit
7a6d3d42f1
@ -839,9 +839,13 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
if (value.customColor() != null) {
|
if (value.customColor() != null) {
|
||||||
tag.putInt("custom_color", value.customColor());
|
tag.putInt("custom_color", value.customColor());
|
||||||
}
|
}
|
||||||
|
final ListTag<CompoundTag> customEffects = new ListTag<>(CompoundTag.class);
|
||||||
for (final PotionEffect effect : value.customEffects()) {
|
for (final PotionEffect effect : value.customEffects()) {
|
||||||
potionEffectToTag(tag, effect);
|
final CompoundTag effectTag = new CompoundTag();
|
||||||
|
potionEffectToTag(effectTag, effect);
|
||||||
|
customEffects.add(effectTag);
|
||||||
}
|
}
|
||||||
|
tag.put("custom_effects", customEffects);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,12 +854,14 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
|
|
||||||
final int potion = Potions1_20_5.keyToId(value.getString("potion", ""));
|
final int potion = Potions1_20_5.keyToId(value.getString("potion", ""));
|
||||||
final Integer customColor = value.getInt("custom_color");
|
final Integer customColor = value.getInt("custom_color");
|
||||||
final List<PotionEffect> effects = new ArrayList<>();
|
final ListTag<CompoundTag> customEffects = value.getListTag("custom_effects", CompoundTag.class);
|
||||||
for (final Map.Entry<String, Tag> entry : value.entrySet()) {
|
final List<PotionEffect> list = new ArrayList<>();
|
||||||
final PotionEffect effect = potionEffectFromTag((CompoundTag) entry.getValue());
|
if (customEffects != null) {
|
||||||
effects.add(effect);
|
for (final CompoundTag effectTag : customEffects) {
|
||||||
|
list.add(potionEffectFromTag(effectTag));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new PotionContents(potion, customColor, effects.toArray(PotionEffect[]::new));
|
return new PotionContents(potion, customColor, list.toArray(PotionEffect[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ListTag<CompoundTag> suspiciousStewEffectsToTag(final SuspiciousStewEffect[] value) {
|
protected ListTag<CompoundTag> suspiciousStewEffectsToTag(final SuspiciousStewEffect[] value) {
|
||||||
@ -1221,7 +1227,8 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
final CompoundTag value = (CompoundTag) tag;
|
final CompoundTag value = (CompoundTag) tag;
|
||||||
|
|
||||||
final String name = value.getString("name", null);
|
final String name = value.getString("name", null);
|
||||||
final UUID id = UUIDUtil.fromIntArray(value.getIntArrayTag("id").getValue());
|
final IntArrayTag idTag = value.getIntArrayTag("id");
|
||||||
|
final UUID id = idTag == null ? null : UUIDUtil.fromIntArray(idTag.getValue());
|
||||||
final GameProfile.Property[] properties = propertiesFromTag(value);
|
final GameProfile.Property[] properties = propertiesFromTag(value);
|
||||||
return new GameProfile(name, id, properties);
|
return new GameProfile(name, id, properties);
|
||||||
}
|
}
|
||||||
@ -1250,7 +1257,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
final BannerPatternLayer[] layers = new BannerPatternLayer[value.size()];
|
final BannerPatternLayer[] layers = new BannerPatternLayer[value.size()];
|
||||||
for (int i = 0; i < value.size(); i++) {
|
for (int i = 0; i < value.size(); i++) {
|
||||||
final CompoundTag layerTag = value.get(i);
|
final CompoundTag layerTag = value.get(i);
|
||||||
final Holder<BannerPattern> pattern = bannerPatternFromTag(layerTag.getCompoundTag("pattern"));
|
final Holder<BannerPattern> pattern = bannerPatternFromTag(layerTag.get("pattern"));
|
||||||
final int color = dyeColorFromTag(layerTag.get("color"));
|
final int color = dyeColorFromTag(layerTag.get("color"));
|
||||||
layers[i] = new BannerPatternLayer(pattern, color);
|
layers[i] = new BannerPatternLayer(pattern, color);
|
||||||
}
|
}
|
||||||
@ -1620,11 +1627,10 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
tag.put("pattern", patternTag);
|
tag.put("pattern", patternTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Holder<BannerPattern> bannerPatternFromTag(final CompoundTag tag) {
|
protected Holder<BannerPattern> bannerPatternFromTag(final Tag tag) {
|
||||||
final Tag patternTag = tag.get("pattern");
|
if (tag instanceof StringTag stringTag) {
|
||||||
if (patternTag instanceof StringTag stringTag) {
|
|
||||||
return Holder.of(BannerPatterns1_20_5.keyToId(stringTag.getValue()));
|
return Holder.of(BannerPatterns1_20_5.keyToId(stringTag.getValue()));
|
||||||
} else if (patternTag instanceof CompoundTag compoundTag) {
|
} else if (tag instanceof CompoundTag compoundTag) {
|
||||||
final String assetId = identifierFromTag(compoundTag.getStringTag("asset_id"));
|
final String assetId = identifierFromTag(compoundTag.getStringTag("asset_id"));
|
||||||
final String translationKey = compoundTag.getString("translation_key");
|
final String translationKey = compoundTag.getString("translation_key");
|
||||||
return Holder.of(new BannerPattern(assetId, translationKey));
|
return Holder.of(new BannerPattern(assetId, translationKey));
|
||||||
@ -1705,7 +1711,8 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
|
|
||||||
protected Tag componentFromTag(final Tag value, final int max) {
|
protected Tag componentFromTag(final Tag value, final int max) {
|
||||||
if (value instanceof StringTag stringTag) {
|
if (value instanceof StringTag stringTag) {
|
||||||
return serializerVersion().toTag(checkStringRange(0, max, stringTag.getValue()));
|
final String input = checkStringRange(0, max, stringTag.getValue());
|
||||||
|
return serializerVersion().toTag(serializerVersion().toComponent(input));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1721,13 +1728,13 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
return listTag;
|
return listTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Tag[] componentsFromTag(final Tag value, final int maxLength) { // TODO verify
|
protected Tag[] componentsFromTag(final Tag value, final int maxLength) {
|
||||||
final ListTag<StringTag> listTag = (ListTag<StringTag>) value;
|
final ListTag<StringTag> listTag = (ListTag<StringTag>) value;
|
||||||
checkIntRange(0, maxLength, listTag.size());
|
checkIntRange(0, maxLength, listTag.size());
|
||||||
|
|
||||||
final Tag[] components = new Tag[listTag.size()];
|
final Tag[] components = new Tag[listTag.size()];
|
||||||
for (int i = 0; i < listTag.size(); i++) {
|
for (int i = 0; i < listTag.size(); i++) {
|
||||||
components[i] = serializerVersion().toTag(listTag.get(i).getValue());
|
components[i] = serializerVersion().toTag(serializerVersion().toComponent(listTag.get(i).getValue()));
|
||||||
}
|
}
|
||||||
return components;
|
return components;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user