mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2026-11-04 17:00:16 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fed88c1a3 | ||
|
|
2df954de90 | ||
|
|
d3721307b1 | ||
|
|
0ed3efc643 | ||
|
|
4536ca41e2 | ||
|
|
09e862383a | ||
|
|
1413bd63ef | ||
|
|
136678b0b7 | ||
|
|
99618af747 | ||
|
|
ede8b877b5 | ||
|
|
b5319dbb32 | ||
|
|
94c755166c | ||
|
|
b6caa30c16 | ||
|
|
bb2f26a5eb | ||
|
|
b10b161fe7 | ||
|
|
c9d57aab8d | ||
|
|
7e08534f4f | ||
|
|
d7e7992ca4 | ||
|
|
e56920c7b1 | ||
|
|
e0ec308fa0 | ||
|
|
1c8438d2a6 | ||
|
|
33d8485852 | ||
|
|
16f1bdff02 | ||
|
|
dd6bc4f1db | ||
|
|
22508f6ab7 | ||
|
|
520552fe69 | ||
|
|
355ca898d7 | ||
|
|
2159dea31d | ||
|
|
793bedf4e2 | ||
|
|
2cb3fd186b | ||
|
|
7ccb5634ff | ||
|
|
f461a0b14c | ||
|
|
2daa1aa39e | ||
|
|
38af6f883b | ||
|
|
418357d8eb | ||
|
|
13a74f43ef | ||
|
|
a921337178 | ||
|
|
da5837d794 | ||
|
|
4dded860ce | ||
|
|
8e99dddb91 | ||
|
|
e662640377 | ||
|
|
bba0a3a3a6 | ||
|
|
4061e91e53 | ||
|
|
14e208e9d7 | ||
|
|
c5dacad81e |
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = false
|
||||
insert_final_newline = true
|
||||
tab_width = 4
|
||||
|
||||
[*.java]
|
||||
|
||||
@@ -10,8 +10,9 @@ Requires [ViaVersion](https://hangar.papermc.io/ViaVersion/ViaVersion) to be ins
|
||||
|
||||
Supported Versions
|
||||
-
|
||||
As a plugin, ViaBackwards runs on servers on releases 1.10-latest. Versions from the dev branch will also support the
|
||||
latest snapshot. You can also use ViaBackwards in ViaFabric or ViaFabricPlus.
|
||||
As a plugin, ViaBackwards runs on servers on releases 1.10-latest. You can also use ViaBackwards in ViaFabric or ViaFabricPlus.
|
||||
- in **ViaFabric**, put ViaBackwards into the `mods` folder
|
||||
- in **ViaFabricPlus**, put ViaBackwards into the `ViaFabricPlus/jars` folder
|
||||
|
||||
See [HERE](https://github.com/ViaVersion) for an overview of the different Via* projects.
|
||||
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ public final class BukkitAdvancementCriteriaProvider extends AdvancementCriteria
|
||||
private static final String[] EMPTY_CRITERIA = new String[0];
|
||||
|
||||
@Override
|
||||
public String[] getCriteria(final String key) {
|
||||
final Advancement advancement = Bukkit.getAdvancement(NamespacedKey.fromString(key));
|
||||
public String[] getCriteria(final String advancementKey) {
|
||||
final Advancement advancement = Bukkit.getAdvancement(NamespacedKey.fromString(advancementKey));
|
||||
return advancement == null ? EMPTY_CRITERIA : advancement.getCriteria().toArray(EMPTY_CRITERIA);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,8 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
private boolean alwaysShowOriginalMobName;
|
||||
private boolean fix1_13FormattedInventoryTitles;
|
||||
private boolean handlePingsAsInvAcknowledgements;
|
||||
private boolean bedrockAtY0;
|
||||
private boolean sculkShriekersToCryingObsidian;
|
||||
private boolean suppressEmulationWarnings;
|
||||
|
||||
public ViaBackwardsConfig(File configFile, Logger logger) {
|
||||
@@ -53,6 +55,8 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
fix1_13FormattedInventoryTitles = getBoolean("fix-formatted-inventory-titles", true);
|
||||
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
|
||||
handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false);
|
||||
bedrockAtY0 = getBoolean("bedrock-at-y-0", false);
|
||||
sculkShriekersToCryingObsidian = getBoolean("sculk-shriekers-to-crying-obsidian", false);
|
||||
suppressEmulationWarnings = getBoolean("suppress-emulation-warnings", false);
|
||||
}
|
||||
|
||||
@@ -86,6 +90,16 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
return handlePingsAsInvAcknowledgements || Boolean.getBoolean("com.viaversion.handlePingsAsInvAcknowledgements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bedrockAtY0() {
|
||||
return bedrockAtY0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sculkShriekerToCryingObsidian() {
|
||||
return sculkShriekersToCryingObsidian;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean suppressEmulationWarnings() {
|
||||
return suppressEmulationWarnings;
|
||||
|
||||
@@ -64,6 +64,20 @@ public interface ViaBackwardsConfig extends Config {
|
||||
*/
|
||||
boolean handlePingsAsInvAcknowledgements();
|
||||
|
||||
/**
|
||||
* Adds bedrock at y=0 for sub 1.17 clients.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean bedrockAtY0();
|
||||
|
||||
/**
|
||||
* Shows sculk shriekers as crying obsidian for 1.18.2 clients on 1.19+ servers. This fixes collision and block breaking issues.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean sculkShriekerToCryingObsidian();
|
||||
|
||||
/**
|
||||
* Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+).
|
||||
*
|
||||
|
||||
@@ -69,7 +69,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "5.0.0";
|
||||
String MINIMUM_VV_VERSION = "5.0.2";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class MappedLegacyBlockItem {
|
||||
@FunctionalInterface
|
||||
public interface BlockEntityHandler {
|
||||
|
||||
CompoundTag handleOrNewCompoundTag(int block, CompoundTag tag);
|
||||
void handleCompoundTag(int block, CompoundTag tag);
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
+15
-13
@@ -31,7 +31,7 @@ public class EntityReplacement {
|
||||
private final int replacementId;
|
||||
private final String key;
|
||||
private ComponentType componentType = ComponentType.NONE;
|
||||
private MetaCreator defaultMeta;
|
||||
private EntityDataCreator defaultData;
|
||||
|
||||
public EntityReplacement(BackwardsProtocol<?, ?, ?, ?> protocol, EntityType type, int replacementId) {
|
||||
this(protocol, type.name(), type.getId(), replacementId);
|
||||
@@ -59,13 +59,13 @@ public class EntityReplacement {
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityReplacement spawnMetadata(MetaCreator handler) {
|
||||
this.defaultMeta = handler;
|
||||
public EntityReplacement spawnEntityData(EntityDataCreator handler) {
|
||||
this.defaultData = handler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasBaseMeta() {
|
||||
return this.defaultMeta != null;
|
||||
public boolean hasBaseData() {
|
||||
return this.defaultData != null;
|
||||
}
|
||||
|
||||
public int typeId() {
|
||||
@@ -97,8 +97,8 @@ public class EntityReplacement {
|
||||
return replacementId;
|
||||
}
|
||||
|
||||
public @Nullable MetaCreator defaultMeta() {
|
||||
return defaultMeta;
|
||||
public @Nullable EntityDataCreator defaultData() {
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
public boolean isObjectType() {
|
||||
@@ -111,18 +111,20 @@ public class EntityReplacement {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EntityData{" +
|
||||
"id=" + id +
|
||||
", mobName='" + key + '\'' +
|
||||
return "EntityReplacement{" +
|
||||
"protocol=" + protocol +
|
||||
", id=" + id +
|
||||
", replacementId=" + replacementId +
|
||||
", defaultMeta=" + defaultMeta +
|
||||
", key='" + key + '\'' +
|
||||
", componentType=" + componentType +
|
||||
", defaultData=" + defaultData +
|
||||
'}';
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MetaCreator {
|
||||
public interface EntityDataCreator {
|
||||
|
||||
void createMeta(WrappedMetadata storage);
|
||||
void createData(WrappedEntityData storage);
|
||||
}
|
||||
|
||||
private enum ComponentType {
|
||||
|
||||
+8
-8
@@ -22,28 +22,28 @@ import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public record WrappedMetadata(List<EntityData> metadataList) {
|
||||
public record WrappedEntityData(List<EntityData> entityDataList) {
|
||||
|
||||
public boolean has(EntityData data) {
|
||||
return this.metadataList.contains(data);
|
||||
return this.entityDataList.contains(data);
|
||||
}
|
||||
|
||||
public void remove(EntityData data) {
|
||||
this.metadataList.remove(data);
|
||||
this.entityDataList.remove(data);
|
||||
}
|
||||
|
||||
public void remove(int index) {
|
||||
metadataList.removeIf(meta -> meta.id() == index);
|
||||
entityDataList.removeIf(data -> data.id() == index);
|
||||
}
|
||||
|
||||
public void add(EntityData data) {
|
||||
this.metadataList.add(data);
|
||||
this.entityDataList.add(data);
|
||||
}
|
||||
|
||||
public @Nullable EntityData get(int index) {
|
||||
for (EntityData meta : this.metadataList) {
|
||||
if (index == meta.id()) {
|
||||
return meta;
|
||||
for (EntityData data : this.entityDataList) {
|
||||
if (index == data.id()) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
+3
-9
@@ -67,14 +67,8 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
||||
|
||||
if (protocol.getComponentRewriter() != null) {
|
||||
// Handle name and lore components
|
||||
final StructuredData<Tag> customNameData = dataContainer.getNonEmpty(StructuredDataKey.CUSTOM_NAME);
|
||||
if (customNameData != null) {
|
||||
final Tag originalName = customNameData.value().copy();
|
||||
protocol.getComponentRewriter().processTag(connection, customNameData.value());
|
||||
if (!customNameData.value().equals(originalName)) {
|
||||
saveTag(createCustomTag(item), originalName, "Name");
|
||||
}
|
||||
}
|
||||
updateComponent(connection, item, StructuredDataKey.ITEM_NAME, "item_name");
|
||||
updateComponent(connection, item, StructuredDataKey.CUSTOM_NAME, "custom_name");
|
||||
|
||||
final StructuredData<Tag[]> loreData = dataContainer.getNonEmpty(StructuredDataKey.LORE);
|
||||
if (loreData != null) {
|
||||
@@ -115,7 +109,7 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
||||
// Set custom name - only done if there is no original one
|
||||
if (!dataContainer.contains(StructuredDataKey.CUSTOM_NAME)) {
|
||||
dataContainer.set(StructuredDataKey.CUSTOM_NAME, mappedItem.tagName());
|
||||
tag.putBoolean(nbtTagName("customName"), true);
|
||||
tag.putBoolean(nbtTagName("added_custom_name"), true);
|
||||
}
|
||||
|
||||
updateItemComponents(connection, dataContainer, this::handleItemToClient, itemIdRewriter, blockIdRewriter);
|
||||
|
||||
+8
-4
@@ -17,12 +17,12 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.utils.ChatUtil;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -35,6 +35,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class EnchantmentRewriter {
|
||||
|
||||
public static final String ENCHANTMENT_LEVEL_TRANSLATION = "enchantment.level.%s";
|
||||
|
||||
protected final Map<String, String> enchantmentMappings = new HashMap<>();
|
||||
protected final BackwardsItemRewriter<?, ?, ?> itemRewriter;
|
||||
private final boolean jsonFormat;
|
||||
@@ -103,9 +105,11 @@ public class EnchantmentRewriter {
|
||||
|
||||
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
||||
int level = levelTag != null ? levelTag.asInt() : 1;
|
||||
String loreValue = remappedName + " " + getRomanNumber(level);
|
||||
String loreValue;
|
||||
if (jsonFormat) {
|
||||
loreValue = ComponentUtil.legacyToJsonString(loreValue);
|
||||
loreValue = ChatUtil.legacyToJsonString(remappedName, ENCHANTMENT_LEVEL_TRANSLATION.formatted(level), true);
|
||||
} else {
|
||||
loreValue = remappedName + " " + getRomanNumber(level);
|
||||
}
|
||||
|
||||
loreToAdd.add(new StringTag(loreValue));
|
||||
@@ -157,7 +161,7 @@ public class EnchantmentRewriter {
|
||||
case 8 -> "VIII";
|
||||
case 9 -> "IX";
|
||||
case 10 -> "X";
|
||||
default -> Integer.toString(number);
|
||||
default -> ENCHANTMENT_LEVEL_TRANSLATION.formatted(number); // Fallback to translation to match vanilla style
|
||||
};
|
||||
}
|
||||
}
|
||||
+50
-50
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedEntityData;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
||||
@@ -50,24 +50,24 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
*/
|
||||
public abstract class EntityRewriterBase<C extends ClientboundPacketType, T extends BackwardsProtocol<C, ?, ?, ?>> extends EntityRewriter<C, T> {
|
||||
private final Int2ObjectMap<EntityReplacement> entityDataMappings = new Int2ObjectOpenHashMap<>();
|
||||
private final EntityDataType displayNameMetaType;
|
||||
private final EntityDataType displayVisibilityMetaType;
|
||||
private final EntityDataType displayNameDataType;
|
||||
private final EntityDataType displayVisibilityDataType;
|
||||
private final int displayNameIndex;
|
||||
private final int displayVisibilityIndex;
|
||||
|
||||
EntityRewriterBase(T protocol, EntityDataType displayNameMetaType, int displayNameIndex,
|
||||
EntityDataType displayVisibilityMetaType, int displayVisibilityIndex) {
|
||||
EntityRewriterBase(T protocol, EntityDataType displayNameDataType, int displayNameIndex,
|
||||
EntityDataType displayVisibilityDataType, int displayVisibilityIndex) {
|
||||
super(protocol, false);
|
||||
this.displayNameMetaType = displayNameMetaType;
|
||||
this.displayNameDataType = displayNameDataType;
|
||||
this.displayNameIndex = displayNameIndex;
|
||||
this.displayVisibilityMetaType = displayVisibilityMetaType;
|
||||
this.displayVisibilityDataType = displayVisibilityDataType;
|
||||
this.displayVisibilityIndex = displayVisibilityIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEntityData(int entityId, List<EntityData> entityDataList, UserConnection connection) {
|
||||
final TrackedEntity entity = tracker(connection).entity(entityId);
|
||||
final boolean initialMetadata = !(entity != null && entity.hasSentEntityData());
|
||||
final boolean initialEntityData = !(entity != null && entity.hasSentEntityData());
|
||||
|
||||
super.handleEntityData(entityId, entityDataList, connection);
|
||||
|
||||
@@ -80,37 +80,37 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
final Object displayNameObject;
|
||||
if (entityMapping != null && (displayNameObject = entityMapping.entityName()) != null) {
|
||||
final EntityData displayName = getData(displayNameIndex, entityDataList);
|
||||
if (initialMetadata) {
|
||||
if (initialEntityData) {
|
||||
if (displayName == null) {
|
||||
// Add it as new metadata
|
||||
entityDataList.add(new EntityData(displayNameIndex, displayNameMetaType, displayNameObject));
|
||||
addDisplayVisibilityMeta(entityDataList);
|
||||
// Add it as new entity data
|
||||
entityDataList.add(new EntityData(displayNameIndex, displayNameDataType, displayNameObject));
|
||||
addDisplayVisibilityData(entityDataList);
|
||||
} else if (displayName.getValue() == null || displayName.getValue().toString().isEmpty()) {
|
||||
// Overwrite the existing null/empty display name
|
||||
displayName.setValue(displayNameObject);
|
||||
addDisplayVisibilityMeta(entityDataList);
|
||||
addDisplayVisibilityData(entityDataList);
|
||||
}
|
||||
} else if (displayName != null && (displayName.getValue() == null || displayName.getValue().toString().isEmpty())) {
|
||||
// Overwrite null/empty display name
|
||||
displayName.setValue(displayNameObject);
|
||||
addDisplayVisibilityMeta(entityDataList);
|
||||
addDisplayVisibilityData(entityDataList);
|
||||
}
|
||||
}
|
||||
|
||||
// Add any other extra meta for mapped entities
|
||||
if (entityMapping != null && entityMapping.hasBaseMeta() && initialMetadata) {
|
||||
entityMapping.defaultMeta().createMeta(new WrappedMetadata(entityDataList));
|
||||
// Add any other extra data for mapped entities
|
||||
if (entityMapping != null && entityMapping.hasBaseData() && initialEntityData) {
|
||||
entityMapping.defaultData().createData(new WrappedEntityData(entityDataList));
|
||||
}
|
||||
}
|
||||
|
||||
private void addDisplayVisibilityMeta(List<EntityData> metadataList) {
|
||||
private void addDisplayVisibilityData(List<EntityData> entityDataList) {
|
||||
if (alwaysShowOriginalMobName()) {
|
||||
removeMeta(displayVisibilityIndex, metadataList);
|
||||
metadataList.add(new EntityData(displayVisibilityIndex, displayVisibilityMetaType, getDisplayVisibilityMetaValue()));
|
||||
removeData(displayVisibilityIndex, entityDataList);
|
||||
entityDataList.add(new EntityData(displayVisibilityIndex, displayVisibilityDataType, getDisplayVisibilityDataValue()));
|
||||
}
|
||||
}
|
||||
|
||||
protected Object getDisplayVisibilityMetaValue() {
|
||||
protected Object getDisplayVisibilityDataValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -118,17 +118,17 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
return ViaBackwards.getConfig().alwaysShowOriginalMobName();
|
||||
}
|
||||
|
||||
protected @Nullable EntityData getData(int metaIndex, List<EntityData> metadataList) {
|
||||
for (EntityData metadata : metadataList) {
|
||||
if (metadata.id() == metaIndex) {
|
||||
return metadata;
|
||||
protected @Nullable EntityData getData(int dataIndex, List<EntityData> entityDataList) {
|
||||
for (EntityData entityData : entityDataList) {
|
||||
if (entityData.id() == dataIndex) {
|
||||
return entityData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void removeMeta(int metaIndex, List<EntityData> metadataList) {
|
||||
metadataList.removeIf(meta -> meta.id() == metaIndex);
|
||||
protected void removeData(int dataIndex, List<EntityData> entityDataList) {
|
||||
entityDataList.removeIf(data -> data.id() == dataIndex);
|
||||
}
|
||||
|
||||
protected boolean hasData(EntityType type) {
|
||||
@@ -163,7 +163,7 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
return data;
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler(
|
||||
public void registerEntityDataTypeHandler(
|
||||
@Nullable EntityDataType itemType,
|
||||
@Nullable EntityDataType blockStateType,
|
||||
@Nullable EntityDataType optionalBlockStateType,
|
||||
@@ -171,28 +171,28 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
@Nullable EntityDataType componentType,
|
||||
@Nullable EntityDataType optionalComponentType
|
||||
) {
|
||||
filter().handler((event, meta) -> {
|
||||
EntityDataType type = meta.dataType();
|
||||
filter().handler((event, data) -> {
|
||||
EntityDataType type = data.dataType();
|
||||
if (type == itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(event.user(), meta.value());
|
||||
protocol.getItemRewriter().handleItemToClient(event.user(), data.value());
|
||||
} else if (type == blockStateType) {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
int value = data.value();
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(value));
|
||||
} else if (type == optionalBlockStateType) {
|
||||
int data = meta.value();
|
||||
if (data != 0) {
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
int value = data.value();
|
||||
if (value != 0) {
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(value));
|
||||
}
|
||||
} else if (type == particleType) {
|
||||
rewriteParticle(event.user(), meta.value());
|
||||
rewriteParticle(event.user(), data.value());
|
||||
} else if (type == optionalComponentType || type == componentType) {
|
||||
JsonElement text = meta.value();
|
||||
JsonElement text = data.value();
|
||||
protocol.getComponentRewriter().processText(event.user(), text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler1_20_3(
|
||||
public void registerEntityDataTypeHandler1_20_3(
|
||||
@Nullable EntityDataType itemType,
|
||||
@Nullable EntityDataType blockStateType,
|
||||
@Nullable EntityDataType optionalBlockStateType,
|
||||
@@ -201,27 +201,27 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
@Nullable EntityDataType componentType,
|
||||
@Nullable EntityDataType optionalComponentType
|
||||
) {
|
||||
filter().handler((event, meta) -> {
|
||||
EntityDataType type = meta.dataType();
|
||||
filter().handler((event, data) -> {
|
||||
EntityDataType type = data.dataType();
|
||||
if (type == itemType) {
|
||||
meta.setValue(protocol.getItemRewriter().handleItemToClient(event.user(), meta.value()));
|
||||
data.setValue(protocol.getItemRewriter().handleItemToClient(event.user(), data.value()));
|
||||
} else if (type == blockStateType) {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
int value = data.value();
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(value));
|
||||
} else if (type == optionalBlockStateType) {
|
||||
int data = meta.value();
|
||||
if (data != 0) {
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
int value = data.value();
|
||||
if (value != 0) {
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(value));
|
||||
}
|
||||
} else if (type == particleType) {
|
||||
rewriteParticle(event.user(), meta.value());
|
||||
rewriteParticle(event.user(), data.value());
|
||||
} else if (type == particlesType) {
|
||||
Particle[] particles = meta.value();
|
||||
Particle[] particles = data.value();
|
||||
for (final Particle particle : particles) {
|
||||
rewriteParticle(event.user(), particle);
|
||||
}
|
||||
} else if (type == optionalComponentType || type == componentType) {
|
||||
protocol.getComponentRewriter().processTag(event.user(), meta.value());
|
||||
protocol.getComponentRewriter().processTag(event.user(), data.value());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-3
@@ -51,7 +51,6 @@ import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -289,7 +288,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
|
||||
MappedLegacyBlockItem settings = getMappedBlock(block);
|
||||
if (settings != null && settings.hasBlockEntityHandler()) {
|
||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
settings.getBlockEntityHandler().handleCompoundTag(block, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +342,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
tag.putInt("y", y + (i << 4));
|
||||
tag.putInt("z", z + (chunk.getZ() << 4));
|
||||
|
||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
settings.getBlockEntityHandler().handleCompoundTag(block, tag);
|
||||
chunk.getBlockEntities().add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
+23
-23
@@ -18,9 +18,9 @@
|
||||
package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityObjectData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.ObjectType;
|
||||
@@ -90,64 +90,64 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSetEntityData(C packetType, Type<List<EntityData>> oldMetaType, Type<List<EntityData>> newMetaType) {
|
||||
public void registerSetEntityData(C packetType, Type<List<EntityData>> dataType, Type<List<EntityData>> mappedDataType) {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // 0 - Entity ID
|
||||
if (oldMetaType != null) {
|
||||
map(oldMetaType, newMetaType);
|
||||
if (dataType != null) {
|
||||
map(dataType, mappedDataType);
|
||||
} else {
|
||||
map(newMetaType);
|
||||
map(mappedDataType);
|
||||
}
|
||||
handler(wrapper -> {
|
||||
List<EntityData> metadata = wrapper.get(newMetaType, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
|
||||
List<EntityData> entityDataList = wrapper.get(mappedDataType, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), entityDataList, wrapper.user());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSetEntityData(C packetType, Type<List<EntityData>> metaType) {
|
||||
registerSetEntityData(packetType, null, metaType);
|
||||
public void registerSetEntityData(C packetType, Type<List<EntityData>> dataType) {
|
||||
registerSetEntityData(packetType, null, dataType);
|
||||
}
|
||||
|
||||
protected PacketHandler getMobSpawnRewriter(Type<List<EntityData>> metaType, IdSetter idSetter) {
|
||||
protected PacketHandler getMobSpawnRewriter(Type<List<EntityData>> dataType, IdSetter idSetter) {
|
||||
return wrapper -> {
|
||||
int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||
EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
|
||||
List<EntityData> metadata = wrapper.get(metaType, 0);
|
||||
handleEntityData(entityId, metadata, wrapper.user());
|
||||
List<EntityData> entityDataList = wrapper.get(dataType, 0);
|
||||
handleEntityData(entityId, entityDataList, wrapper.user());
|
||||
|
||||
EntityReplacement entityReplacement = entityDataForType(type);
|
||||
if (entityReplacement != null) {
|
||||
idSetter.setId(wrapper, entityReplacement.replacementId());
|
||||
if (entityReplacement.hasBaseMeta()) {
|
||||
entityReplacement.defaultMeta().createMeta(new WrappedMetadata(metadata));
|
||||
if (entityReplacement.hasBaseData()) {
|
||||
entityReplacement.defaultData().createData(new WrappedEntityData(entityDataList));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getMobSpawnRewriter(Type<List<EntityData>> metaType) {
|
||||
return getMobSpawnRewriter(metaType, (wrapper, id) -> wrapper.set(Types.UNSIGNED_BYTE, 0, (short) id));
|
||||
public PacketHandler getMobSpawnRewriter(Type<List<EntityData>> dataType) {
|
||||
return getMobSpawnRewriter(dataType, (wrapper, id) -> wrapper.set(Types.UNSIGNED_BYTE, 0, (short) id));
|
||||
}
|
||||
|
||||
public PacketHandler getMobSpawnRewriter1_11(Type<List<EntityData>> metaType) {
|
||||
return getMobSpawnRewriter(metaType, (wrapper, id) -> wrapper.set(Types.VAR_INT, 1, id));
|
||||
public PacketHandler getMobSpawnRewriter1_11(Type<List<EntityData>> dataType) {
|
||||
return getMobSpawnRewriter(dataType, (wrapper, id) -> wrapper.set(Types.VAR_INT, 1, id));
|
||||
}
|
||||
|
||||
protected PacketHandler getObjectTrackerHandler() {
|
||||
return wrapper -> addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), objectTypeFromId(wrapper.get(Types.BYTE, 0)));
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerAndMetaHandler(Type<List<EntityData>> metaType, EntityType entityType) {
|
||||
protected PacketHandler getTrackerAndDataHandler(Type<List<EntityData>> dataType, EntityType entityType) {
|
||||
return wrapper -> {
|
||||
addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), entityType);
|
||||
List<EntityData> metadata = wrapper.get(metaType, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
|
||||
List<EntityData> entityDataList = wrapper.get(dataType, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), entityDataList, wrapper.user());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
return wrapper -> {
|
||||
ObjectType type = objectGetter.apply(wrapper.get(Types.BYTE, 0));
|
||||
if (type == null) {
|
||||
protocol.getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0));
|
||||
protocol.getLogger().warning("Could not find entity type " + wrapper.get(Types.BYTE, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+16
-8
@@ -23,6 +23,7 @@ import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.utils.ChatUtil;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
@@ -30,7 +31,6 @@ import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntIntPair;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.ObjectIterator;
|
||||
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
@@ -38,6 +38,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter.ENCHANTMENT_LEVEL_TRANSLATION;
|
||||
|
||||
public class StructuredEnchantmentRewriter {
|
||||
|
||||
protected final BackwardsStructuredItemRewriter<?, ?, ?> itemRewriter;
|
||||
@@ -56,7 +58,7 @@ public class StructuredEnchantmentRewriter {
|
||||
};
|
||||
final DescriptionSupplier descriptionSupplier = (id, level) -> {
|
||||
final String remappedName = mappingData.mappedEnchantmentName(id);
|
||||
return ComponentUtil.jsonStringToTag(ComponentUtil.legacyToJsonString("§7" + remappedName + " " + EnchantmentRewriter.getRomanNumber(level), true));
|
||||
return ComponentUtil.jsonStringToTag(ChatUtil.legacyToJsonString("§7" + remappedName, ENCHANTMENT_LEVEL_TRANSLATION.formatted(level), true));
|
||||
};
|
||||
rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false);
|
||||
rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true);
|
||||
@@ -86,20 +88,20 @@ public class StructuredEnchantmentRewriter {
|
||||
boolean changed = false;
|
||||
|
||||
final ObjectIterator<Int2IntMap.Entry> iterator = enchantments.enchantments().int2IntEntrySet().iterator();
|
||||
final List<IntIntPair> updatedIds = new ArrayList<>();
|
||||
final List<PendingIdChange> updatedIds = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
final Int2IntMap.Entry entry = iterator.next();
|
||||
final int id = entry.getIntKey();
|
||||
final int mappedId = rewriteFunction.rewrite(id);
|
||||
final int level = entry.getIntValue();
|
||||
if (mappedId != -1) {
|
||||
if (rewriteIds) {
|
||||
// Update the map after to iteration to preserve the current ids before possibly saving the original, avoid CME
|
||||
updatedIds.add(IntIntPair.of(id, mappedId));
|
||||
updatedIds.add(new PendingIdChange(id, mappedId, level));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
final int level = entry.getIntValue();
|
||||
final Tag description = descriptionSupplier.get(id, level);
|
||||
if (description != null) {
|
||||
if (!changed) {
|
||||
@@ -113,9 +115,12 @@ public class StructuredEnchantmentRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
for (final IntIntPair pair : updatedIds) {
|
||||
final int level = enchantments.enchantments().remove(pair.firstInt());
|
||||
enchantments.add(pair.secondInt(), level);
|
||||
// Remove all first, then add the new ones
|
||||
for (final PendingIdChange change : updatedIds) {
|
||||
enchantments.remove(change.id());
|
||||
}
|
||||
for (final PendingIdChange change : updatedIds) {
|
||||
enchantments.add(change.mappedId(), change.level());
|
||||
}
|
||||
|
||||
if (loreToAdd.isEmpty()) {
|
||||
@@ -198,4 +203,7 @@ public class StructuredEnchantmentRewriter {
|
||||
|
||||
Tag get(int id, int level);
|
||||
}
|
||||
|
||||
private record PendingIdChange(int id, int mappedId, int level) {
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -87,7 +87,7 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
||||
return translatables.get(translationKey);
|
||||
}
|
||||
|
||||
public Map<String, String> getTranslatableMappings(final String sectionIdentifier) {
|
||||
public static Map<String, String> getTranslatableMappings(final String sectionIdentifier) {
|
||||
return TRANSLATABLES.get(sectionIdentifier);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -58,10 +58,10 @@ public class BlockItemPacketRewriter1_10 extends LegacyBlockItemRewriter<Clientb
|
||||
handleChunk(chunk);
|
||||
});
|
||||
|
||||
// Rewrite metadata items
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.dataType().type().equals(Types.ITEM1_8)) // Is Item
|
||||
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
|
||||
// Rewrite entity data items
|
||||
protocol.getEntityRewriter().filter().handler((event, data) -> {
|
||||
if (data.dataType().type().equals(Types.ITEM1_8)) // Is Item
|
||||
data.setValue(handleItemToClient(event.user(), (Item) data.getValue()));
|
||||
});
|
||||
|
||||
// Particle
|
||||
|
||||
+20
-20
@@ -19,7 +19,7 @@
|
||||
package com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedEntityData;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
@@ -80,25 +80,25 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
// Rewrite entity type / data
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||
EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
|
||||
List<EntityData> metadata = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), entityDataList, wrapper.user());
|
||||
|
||||
EntityReplacement entityReplacement = entityDataForType(type);
|
||||
if (entityReplacement != null) {
|
||||
WrappedMetadata storage = new WrappedMetadata(metadata);
|
||||
WrappedEntityData storage = new WrappedEntityData(entityDataList);
|
||||
wrapper.set(Types.UNSIGNED_BYTE, 0, (short) entityReplacement.replacementId());
|
||||
if (entityReplacement.hasBaseMeta())
|
||||
entityReplacement.defaultMeta().createMeta(storage);
|
||||
if (entityReplacement.hasBaseData())
|
||||
entityReplacement.defaultData().createData(storage);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -119,9 +119,9 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Metadata list
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -134,28 +134,28 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
mapEntityTypeWithData(EntityTypes1_10.EntityType.POLAR_BEAR, EntityTypes1_10.EntityType.SHEEP).plainName();
|
||||
|
||||
// Change the sheep color when the polar bear is standing up (index 13 -> Standing up)
|
||||
filter().type(EntityTypes1_10.EntityType.POLAR_BEAR).index(13).handler((event, meta) -> {
|
||||
boolean b = (boolean) meta.getValue();
|
||||
filter().type(EntityTypes1_10.EntityType.POLAR_BEAR).index(13).handler((event, data) -> {
|
||||
boolean b = (boolean) data.getValue();
|
||||
|
||||
meta.setTypeAndValue(EntityDataTypes1_9.BYTE, b ? (byte) (14 & 0x0F) : (byte) (0));
|
||||
data.setTypeAndValue(EntityDataTypes1_9.BYTE, b ? (byte) (14 & 0x0F) : (byte) (0));
|
||||
});
|
||||
|
||||
|
||||
// Handle husk (index 13 -> Zombie Type)
|
||||
filter().type(EntityTypes1_10.EntityType.ZOMBIE).index(13).handler((event, meta) -> {
|
||||
if ((int) meta.getValue() == 6) { // Is type Husk
|
||||
meta.setValue(0);
|
||||
filter().type(EntityTypes1_10.EntityType.ZOMBIE).index(13).handler((event, data) -> {
|
||||
if ((int) data.getValue() == 6) { // Is type Husk
|
||||
data.setValue(0);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Stray (index 12 -> Skeleton Type)
|
||||
filter().type(EntityTypes1_10.EntityType.SKELETON).index(12).handler((event, meta) -> {
|
||||
if ((int) meta.getValue() == 2) {
|
||||
meta.setValue(0); // Change to default skeleton
|
||||
filter().type(EntityTypes1_10.EntityType.SKELETON).index(12).handler((event, data) -> {
|
||||
if ((int) data.getValue() == 2) {
|
||||
data.setValue(0); // Change to default skeleton
|
||||
}
|
||||
});
|
||||
|
||||
// Handle the missing NoGravity tag for every metadata
|
||||
// Handle the missing NoGravity tag for every entity data
|
||||
filter().removeIndex(5);
|
||||
}
|
||||
|
||||
|
||||
+6
-7
@@ -23,7 +23,6 @@ import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
|
||||
@@ -73,12 +72,12 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
// Rewrite entity type / data
|
||||
handler(getMobSpawnRewriter1_11(Types1_9.ENTITY_DATA_LIST));
|
||||
}
|
||||
});
|
||||
@@ -97,9 +96,9 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Metadata list
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -109,10 +108,10 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Handle non-existing firework metadata (index 7 entity id for boosting)
|
||||
// Handle non-existing firework entity data (index 7 entity id for boosting)
|
||||
filter().type(EntityTypes1_11.EntityType.FIREWORK_ROCKET).cancel(7);
|
||||
|
||||
// Handle non-existing pig metadata (index 14 - boost time)
|
||||
// Handle non-existing pig entity data (index 14 - boost time)
|
||||
filter().type(EntityTypes1_11.EntityType.PIG).cancel(14);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -47,10 +47,10 @@ public class ItemPacketRewriter1_11_1 extends LegacyBlockItemRewriter<Clientboun
|
||||
registerContainerClick(ServerboundPackets1_9_3.CONTAINER_CLICK);
|
||||
registerSetCreativeModeSlot(ServerboundPackets1_9_3.SET_CREATIVE_MODE_SLOT);
|
||||
|
||||
// Handle item metadata
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.dataType().type().equals(Types.ITEM1_8)) { // Is Item
|
||||
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
|
||||
// Handle item entity data
|
||||
protocol.getEntityRewriter().filter().handler((event, data) -> {
|
||||
if (data.dataType().type().equals(Types.ITEM1_8)) { // Is Item
|
||||
data.setValue(handleItemToClient(event.user(), (Item) data.getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+4
-7
@@ -243,9 +243,9 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
|
||||
}
|
||||
});
|
||||
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.dataType().type().equals(Types.ITEM1_8)) // Is Item
|
||||
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
|
||||
protocol.getEntityRewriter().filter().handler((event, data) -> {
|
||||
if (data.dataType().type().equals(Types.ITEM1_8)) // Is Item
|
||||
data.setValue(handleItemToClient(event.user(), (Item) data.getValue()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -253,10 +253,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
|
||||
protected void registerRewrites() {
|
||||
// Handle spawner block entity (map to itself with custom handler)
|
||||
MappedLegacyBlockItem data = itemReplacements.computeIfAbsent(IdAndData.toRawData(52), s -> new MappedLegacyBlockItem(52));
|
||||
data.setBlockEntityHandler((b, tag) -> {
|
||||
EntityMappings1_11.toClientSpawner(tag, true);
|
||||
return tag;
|
||||
});
|
||||
data.setBlockEntityHandler((b, tag) -> EntityMappings1_11.toClientSpawner(tag, true));
|
||||
|
||||
enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName());
|
||||
enchantmentRewriter.registerEnchantment(71, "§cCurse of Vanishing");
|
||||
|
||||
+64
-64
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedEntityData;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
|
||||
import com.viaversion.viabackwards.protocol.v1_11to1_10.data.SplashPotionMappings1_10;
|
||||
@@ -104,19 +104,19 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
// Rewrite entity type / data
|
||||
handler(getMobSpawnRewriter(Types1_9.ENTITY_DATA_LIST));
|
||||
|
||||
// Sub 1.11 clients will error if the list is empty
|
||||
handler(wrapper -> {
|
||||
List<EntityData> metadata = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
if (metadata.isEmpty()) {
|
||||
metadata.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
if (entityDataList.isEmpty()) {
|
||||
entityDataList.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -136,14 +136,14 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Metadata list
|
||||
map(Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
|
||||
handler(wrapper -> {
|
||||
// Sub 1.11 clients will cry if the list is empty
|
||||
List<EntityData> metadata = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
if (metadata.isEmpty()) {
|
||||
metadata.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
|
||||
if (entityDataList.isEmpty()) {
|
||||
entityDataList.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -177,39 +177,39 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
// Guardian
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ELDER_GUARDIAN, EntityTypes1_11.EntityType.GUARDIAN);
|
||||
// Skeletons
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.WITHER_SKELETON, EntityTypes1_11.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.STRAY, EntityTypes1_11.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.WITHER_SKELETON, EntityTypes1_11.EntityType.SKELETON).spawnEntityData(storage -> storage.add(getSkeletonTypeData(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.STRAY, EntityTypes1_11.EntityType.SKELETON).plainName().spawnEntityData(storage -> storage.add(getSkeletonTypeData(2)));
|
||||
// Zombies
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.HUSK, EntityTypes1_11.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_VILLAGER, EntityTypes1_11.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.HUSK, EntityTypes1_11.EntityType.ZOMBIE).plainName().spawnEntityData(storage -> handleZombieType(storage, 6));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_VILLAGER, EntityTypes1_11.EntityType.ZOMBIE).spawnEntityData(storage -> handleZombieType(storage, 1));
|
||||
// Horses
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.DONKEY, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.MULE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.SKELETON_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.HORSE, EntityTypes1_11.EntityType.HORSE).spawnEntityData(storage -> storage.add(getHorseDataType(0))); // Nob able to ride the horse without having the EntityDataType sent.
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.DONKEY, EntityTypes1_11.EntityType.HORSE).spawnEntityData(storage -> storage.add(getHorseDataType(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.MULE, EntityTypes1_11.EntityType.HORSE).spawnEntityData(storage -> storage.add(getHorseDataType(2)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.SKELETON_HORSE, EntityTypes1_11.EntityType.HORSE).spawnEntityData(storage -> storage.add(getHorseDataType(4)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_HORSE, EntityTypes1_11.EntityType.HORSE).spawnEntityData(storage -> storage.add(getHorseDataType(3)));
|
||||
// New mobs
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOKER_FANGS, EntityTypes1_11.EntityType.SHULKER);
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOKER, EntityTypes1_11.EntityType.VILLAGER).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.VEX, EntityTypes1_11.EntityType.BAT).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.VINDICATOR, EntityTypes1_11.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new EntityData(13, EntityDataTypes1_9.VAR_INT, 4))); // Base Profession
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.LLAMA, EntityTypes1_11.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.VINDICATOR, EntityTypes1_11.EntityType.VILLAGER).plainName().spawnEntityData(storage -> storage.add(new EntityData(13, EntityDataTypes1_9.VAR_INT, 4))); // Base Profession
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.LLAMA, EntityTypes1_11.EntityType.HORSE).plainName().spawnEntityData(storage -> storage.add(getHorseDataType(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.LLAMA_SPIT, EntityTypes1_11.EntityType.SNOWBALL);
|
||||
|
||||
mapObjectType(EntityTypes1_11.ObjectType.LLAMA_SPIT, EntityTypes1_11.ObjectType.SNOWBALL, -1);
|
||||
// Replace with endertorchthingies
|
||||
mapObjectType(EntityTypes1_11.ObjectType.EVOKER_FANGS, EntityTypes1_11.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||
|
||||
// Handle ElderGuardian & target metadata
|
||||
filter().type(EntityTypes1_11.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
|
||||
boolean b = (boolean) meta.getValue();
|
||||
// Handle ElderGuardian & target entity data
|
||||
filter().type(EntityTypes1_11.EntityType.GUARDIAN).index(12).handler((event, data) -> {
|
||||
boolean b = (boolean) data.getValue();
|
||||
int bitmask = b ? 0x02 : 0;
|
||||
|
||||
if (event.entityType() == EntityTypes1_11.EntityType.ELDER_GUARDIAN) {
|
||||
bitmask |= 0x04;
|
||||
}
|
||||
|
||||
meta.setTypeAndValue(EntityDataTypes1_9.BYTE, (byte) bitmask);
|
||||
data.setTypeAndValue(EntityDataTypes1_9.BYTE, (byte) bitmask);
|
||||
});
|
||||
|
||||
// Handle skeleton swing
|
||||
@@ -218,34 +218,34 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
/*
|
||||
ZOMBIE CHANGES
|
||||
*/
|
||||
filter().type(EntityTypes1_11.EntityType.ZOMBIE).handler((event, meta) -> {
|
||||
switch (meta.id()) {
|
||||
filter().type(EntityTypes1_11.EntityType.ZOMBIE).handler((event, data) -> {
|
||||
switch (data.id()) {
|
||||
case 13 -> event.cancel();
|
||||
case 14 -> event.setIndex(15);
|
||||
case 15 -> event.setIndex(14);
|
||||
case 16 -> {
|
||||
// Profession
|
||||
event.setIndex(13);
|
||||
meta.setValue(1 + (int) meta.getValue());
|
||||
data.setValue(1 + (int) data.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Evocation Illager
|
||||
filter().type(EntityTypes1_11.EntityType.EVOKER).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.EVOKER).index(12).handler((event, data) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Byte) meta.getValue()).intValue()); // Change the profession for the states
|
||||
data.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Byte) data.getValue()).intValue()); // Change the profession for the states
|
||||
});
|
||||
|
||||
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
|
||||
filter().type(EntityTypes1_11.EntityType.VEX).index(12).handler((event, meta) -> {
|
||||
meta.setValue((byte) 0x00);
|
||||
filter().type(EntityTypes1_11.EntityType.VEX).index(12).handler((event, data) -> {
|
||||
data.setValue((byte) 0x00);
|
||||
});
|
||||
|
||||
// Handle VindicationIllager
|
||||
filter().type(EntityTypes1_11.EntityType.VINDICATOR).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.VINDICATOR).index(12).handler((event, data) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4);
|
||||
data.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Number) data.getValue()).intValue() == 1 ? 2 : 4);
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -253,20 +253,20 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
*/
|
||||
|
||||
// Handle horse flags
|
||||
filter().type(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
byte b = (byte) meta.getValue();
|
||||
if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) {
|
||||
filter().type(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(13).handler((event, data) -> {
|
||||
StoredEntityData entityData = storedEntityData(event);
|
||||
byte b = (byte) data.getValue();
|
||||
if (entityData.has(ChestedHorseStorage.class) && entityData.get(ChestedHorseStorage.class).isChested()) {
|
||||
b |= 0x08; // Chested
|
||||
meta.setValue(b);
|
||||
data.setValue(b);
|
||||
}
|
||||
});
|
||||
|
||||
// Create chested horse storage
|
||||
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ChestedHorseStorage.class)) {
|
||||
data.put(new ChestedHorseStorage());
|
||||
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).handler((event, data) -> {
|
||||
StoredEntityData entityData = storedEntityData(event);
|
||||
if (!entityData.has(ChestedHorseStorage.class)) {
|
||||
entityData.put(new ChestedHorseStorage());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -274,32 +274,32 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_11.EntityType.HORSE).index(16).toIndex(17);
|
||||
|
||||
// Handle chested horse
|
||||
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
boolean b = (boolean) meta.getValue();
|
||||
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).index(15).handler((event, data) -> {
|
||||
StoredEntityData entityData = storedEntityData(event);
|
||||
ChestedHorseStorage storage = entityData.get(ChestedHorseStorage.class);
|
||||
boolean b = (boolean) data.getValue();
|
||||
storage.setChested(b);
|
||||
event.cancel();
|
||||
});
|
||||
|
||||
// Get rid of Liama metadata
|
||||
filter().type(EntityTypes1_11.EntityType.LLAMA).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
// Get rid of Liama entity data
|
||||
filter().type(EntityTypes1_11.EntityType.LLAMA).handler((event, data) -> {
|
||||
StoredEntityData entityData = storedEntityData(event);
|
||||
ChestedHorseStorage storage = entityData.get(ChestedHorseStorage.class);
|
||||
|
||||
int index = event.index();
|
||||
// Store them for later (:
|
||||
switch (index) {
|
||||
case 16 -> {
|
||||
storage.setLiamaStrength((int) meta.getValue());
|
||||
storage.setLiamaStrength((int) data.getValue());
|
||||
event.cancel();
|
||||
}
|
||||
case 17 -> {
|
||||
storage.setLiamaCarpetColor((int) meta.getValue());
|
||||
storage.setLiamaCarpetColor((int) data.getValue());
|
||||
event.cancel();
|
||||
}
|
||||
case 18 -> {
|
||||
storage.setLiamaVariant((int) meta.getValue());
|
||||
storage.setLiamaVariant((int) data.getValue());
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
@@ -309,13 +309,13 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(14).toIndex(16);
|
||||
|
||||
// Handle villager - Change non-existing profession
|
||||
filter().type(EntityTypes1_11.EntityType.VILLAGER).index(13).handler((event, meta) -> {
|
||||
if ((int) meta.getValue() == 5) {
|
||||
meta.setValue(0);
|
||||
filter().type(EntityTypes1_11.EntityType.VILLAGER).index(13).handler((event, data) -> {
|
||||
if ((int) data.getValue() == 5) {
|
||||
data.setValue(0);
|
||||
}
|
||||
});
|
||||
|
||||
// handle new Shulker color meta
|
||||
// handle new Shulker color data
|
||||
filter().type(EntityTypes1_11.EntityType.SHULKER).cancel(15);
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
2 - Stray
|
||||
*/
|
||||
|
||||
private EntityData getSkeletonTypeMeta(int type) {
|
||||
private EntityData getSkeletonTypeData(int type) {
|
||||
return new EntityData(12, EntityDataTypes1_9.VAR_INT, type);
|
||||
}
|
||||
|
||||
@@ -334,14 +334,14 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
1-5 - Villager with profession
|
||||
6 - Husk
|
||||
*/
|
||||
private EntityData getZombieTypeMeta(int type) {
|
||||
private EntityData getZombieTypeData(int type) {
|
||||
return new EntityData(13, EntityDataTypes1_9.VAR_INT, type);
|
||||
}
|
||||
|
||||
private void handleZombieType(WrappedMetadata storage, int type) {
|
||||
private void handleZombieType(WrappedEntityData storage, int type) {
|
||||
EntityData meta = storage.get(13);
|
||||
if (meta == null) {
|
||||
storage.add(getZombieTypeMeta(type));
|
||||
storage.add(getZombieTypeData(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
Zombie horse 3
|
||||
Skeleton horse 4
|
||||
*/
|
||||
private EntityData getHorseMetaType(int type) {
|
||||
private EntityData getHorseDataType(int type) {
|
||||
return new EntityData(14, EntityDataTypes1_9.VAR_INT, type);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -150,9 +150,9 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
|
||||
}
|
||||
});
|
||||
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.dataType().type().equals(Types.ITEM1_8)) // Is Item
|
||||
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
|
||||
protocol.getEntityRewriter().filter().handler((event, data) -> {
|
||||
if (data.dataType().type().equals(Types.ITEM1_8)) // Is Item
|
||||
data.setValue(handleItemToClient(event.user(), (Item) data.getValue()));
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLIENT_COMMAND, new PacketHandlers() {
|
||||
|
||||
+26
-26
@@ -83,12 +83,12 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_12.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_12.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
// Rewrite entity type / data
|
||||
handler(getMobSpawnRewriter1_11(Types1_12.ENTITY_DATA_LIST));
|
||||
}
|
||||
});
|
||||
@@ -105,9 +105,9 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_12.ENTITY_DATA_LIST); // 7 - Metadata list
|
||||
map(Types1_12.ENTITY_DATA_LIST); // 7 - Entity data list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_12.ENTITY_DATA_LIST, EntityTypes1_12.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_12.ENTITY_DATA_LIST, EntityTypes1_12.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -186,42 +186,42 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
mapEntityTypeWithData(EntityTypes1_12.EntityType.PARROT, EntityTypes1_12.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new EntityData(12, EntityDataTypes1_12.BYTE, (byte) 0x00)));
|
||||
mapEntityTypeWithData(EntityTypes1_12.EntityType.PARROT, EntityTypes1_12.EntityType.BAT).plainName().spawnEntityData(storage -> storage.add(new EntityData(12, EntityDataTypes1_12.BYTE, (byte) 0x00)));
|
||||
mapEntityTypeWithData(EntityTypes1_12.EntityType.ILLUSIONER, EntityTypes1_12.EntityType.EVOKER).plainName();
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
if (meta.dataType() == EntityDataTypes1_12.COMPONENT) {
|
||||
protocol.getComponentRewriter().processText(event.user(), (JsonElement) meta.getValue());
|
||||
filter().handler((event, data) -> {
|
||||
if (data.dataType() == EntityDataTypes1_12.COMPONENT) {
|
||||
protocol.getComponentRewriter().processText(event.user(), (JsonElement) data.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Illager
|
||||
filter().type(EntityTypes1_12.EntityType.EVOKER).removeIndex(12);
|
||||
|
||||
filter().type(EntityTypes1_12.EntityType.ILLUSIONER).index(0).handler((event, meta) -> {
|
||||
byte mask = (byte) meta.getValue();
|
||||
filter().type(EntityTypes1_12.EntityType.ILLUSIONER).index(0).handler((event, data) -> {
|
||||
byte mask = (byte) data.getValue();
|
||||
|
||||
if ((mask & 0x20) == 0x20) {
|
||||
mask &= ~0x20;
|
||||
}
|
||||
|
||||
meta.setValue(mask);
|
||||
data.setValue(mask);
|
||||
});
|
||||
|
||||
// Create Parrot storage
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ParrotStorage.class)) {
|
||||
data.put(new ParrotStorage());
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).handler((event, data) -> {
|
||||
StoredEntityData entityData = storedEntityData(event);
|
||||
if (!entityData.has(ParrotStorage.class)) {
|
||||
entityData.put(new ParrotStorage());
|
||||
}
|
||||
});
|
||||
// Parrot remove animal metadata
|
||||
// Parrot remove animal entity data
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(12); // Is baby
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ParrotStorage storage = data.get(ParrotStorage.class);
|
||||
boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01;
|
||||
boolean isTamed = (((byte) meta.getValue()) & 0x04) == 0x04;
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).index(13).handler((event, data) -> {
|
||||
StoredEntityData entityData = storedEntityData(event);
|
||||
ParrotStorage storage = entityData.get(ParrotStorage.class);
|
||||
boolean isSitting = (((byte) data.getValue()) & 0x01) == 0x01;
|
||||
boolean isTamed = (((byte) data.getValue()) & 0x04) == 0x04;
|
||||
|
||||
if (!storage.isTamed() && isTamed) {
|
||||
// TODO do something to let the user know it's done
|
||||
@@ -231,11 +231,11 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
if (isSitting) {
|
||||
event.setIndex(12);
|
||||
meta.setValue((byte) 0x01);
|
||||
data.setValue((byte) 0x01);
|
||||
storage.setSitting(true);
|
||||
} else if (storage.isSitting()) {
|
||||
event.setIndex(12);
|
||||
meta.setValue((byte) 0x00);
|
||||
data.setValue((byte) 0x00);
|
||||
storage.setSitting(false);
|
||||
} else {
|
||||
event.cancel();
|
||||
@@ -245,8 +245,8 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(15); // Variant
|
||||
|
||||
// Left shoulder entity data
|
||||
filter().type(EntityTypes1_12.EntityType.PLAYER).index(15).handler((event, meta) -> {
|
||||
CompoundTag tag = (CompoundTag) meta.getValue();
|
||||
filter().type(EntityTypes1_12.EntityType.PLAYER).index(15).handler((event, data) -> {
|
||||
CompoundTag tag = (CompoundTag) data.getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
if (tag.isEmpty() && tracker.getLeftShoulder() != null) {
|
||||
@@ -264,7 +264,7 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
});
|
||||
|
||||
// Right shoulder entity data
|
||||
filter().type(EntityTypes1_12.EntityType.PLAYER).index(16).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_12.EntityType.PLAYER).index(16).handler((event, data) -> {
|
||||
CompoundTag tag = (CompoundTag) event.data().getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
|
||||
+16
-16
@@ -91,15 +91,15 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_13.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_13.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
// Track Entity
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite Metadata
|
||||
// Rewrite Entity data
|
||||
handler(wrapper -> {
|
||||
List<EntityData> metadata = wrapper.get(Types1_13.ENTITY_DATA_LIST, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_13.ENTITY_DATA_LIST, 0);
|
||||
handleEntityData(wrapper.get(Types.VAR_INT, 0), entityDataList, wrapper.user());
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -114,9 +114,9 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_13.ENTITY_DATA_LIST); // 7 - Metadata
|
||||
map(Types1_13.ENTITY_DATA_LIST); // 7 - Entity data
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_13.ENTITY_DATA_LIST, EntityTypes1_13.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_13.ENTITY_DATA_LIST, EntityTypes1_13.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -130,17 +130,17 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Rewrite items & blocks
|
||||
filter().handler((event, meta) -> {
|
||||
if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(event.user(), (Item) meta.getValue());
|
||||
} else if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.optionalBlockStateType) {
|
||||
filter().handler((event, data) -> {
|
||||
if (data.dataType() == Types1_13.ENTITY_DATA_TYPES.itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(event.user(), (Item) data.getValue());
|
||||
} else if (data.dataType() == Types1_13.ENTITY_DATA_TYPES.optionalBlockStateType) {
|
||||
// Convert to new block id
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.particleType) {
|
||||
rewriteParticle(event.user(), (Particle) meta.getValue());
|
||||
} else if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.optionalComponentType || meta.dataType() == Types1_13.ENTITY_DATA_TYPES.componentType) {
|
||||
JsonElement element = meta.value();
|
||||
int value = (int) data.getValue();
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(value));
|
||||
} else if (data.dataType() == Types1_13.ENTITY_DATA_TYPES.particleType) {
|
||||
rewriteParticle(event.user(), (Particle) data.getValue());
|
||||
} else if (data.dataType() == Types1_13.ENTITY_DATA_TYPES.optionalComponentType || data.dataType() == Types1_13.ENTITY_DATA_TYPES.componentType) {
|
||||
JsonElement element = data.value();
|
||||
protocol.translatableRewriter().processText(event.user(), element);
|
||||
}
|
||||
});
|
||||
|
||||
+9
-9
@@ -45,11 +45,11 @@ public class EntityPacketRewriter1_13_2 {
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
handler(wrapper -> {
|
||||
for (EntityData metadata : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
|
||||
metadata.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(metadata.dataType().typeId()));
|
||||
for (EntityData entityData : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
|
||||
entityData.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(entityData.dataType().typeId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -65,11 +65,11 @@ public class EntityPacketRewriter1_13_2 {
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 7 - Metadata
|
||||
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 7 - Entity data
|
||||
|
||||
handler(wrapper -> {
|
||||
for (EntityData metadata : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
|
||||
metadata.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(metadata.dataType().typeId()));
|
||||
for (EntityData entityData : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
|
||||
entityData.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(entityData.dataType().typeId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -79,11 +79,11 @@ public class EntityPacketRewriter1_13_2 {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 1 - Metadata list
|
||||
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 1 - Entity data list
|
||||
|
||||
handler(wrapper -> {
|
||||
for (EntityData metadata : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
|
||||
metadata.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(metadata.dataType().typeId()));
|
||||
for (EntityData entityData : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
|
||||
entityData.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(entityData.dataType().typeId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+3
-1
@@ -51,7 +51,9 @@ public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||
if (patternsTag != null) {
|
||||
for (CompoundTag pattern : patternsTag) {
|
||||
NumberTag colorTag = pattern.getNumberTag("Color");
|
||||
pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||
if (colorTag != null) {
|
||||
pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -145,7 +145,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
// Rewrite entity type / ddata
|
||||
handler(getMobSpawnRewriter1_11(Types1_12.ENTITY_DATA_LIST));
|
||||
}
|
||||
});
|
||||
@@ -162,7 +162,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.BYTE);
|
||||
map(Types1_13.ENTITY_DATA_LIST, Types1_12.ENTITY_DATA_LIST);
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_12.ENTITY_DATA_LIST, EntityTypes1_13.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_12.ENTITY_DATA_LIST, EntityTypes1_13.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -258,7 +258,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.TROPICAL_FISH, EntityTypes1_13.EntityType.SQUID).plainName();
|
||||
|
||||
// Phantom
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.PHANTOM, EntityTypes1_13.EntityType.PARROT).plainName().spawnMetadata(storage -> {
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.PHANTOM, EntityTypes1_13.EntityType.PARROT).plainName().spawnEntityData(storage -> {
|
||||
// The phantom is grey/blue so let's do yellow/blue
|
||||
storage.add(new EntityData(15, EntityDataTypes1_12.VAR_INT, 3));
|
||||
});
|
||||
@@ -269,32 +269,32 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
// Turtle
|
||||
mapEntityTypeWithData(EntityTypes1_13.EntityType.TURTLE, EntityTypes1_13.EntityType.OCELOT).plainName();
|
||||
|
||||
// Rewrite Meta types
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.dataType().typeId();
|
||||
// Rewrite Data types
|
||||
filter().handler((event, data) -> {
|
||||
int typeId = data.dataType().typeId();
|
||||
if (typeId == 4) {
|
||||
JsonElement element = meta.value();
|
||||
JsonElement element = data.value();
|
||||
protocol.translatableRewriter().processText(event.user(), element);
|
||||
meta.setDataType(EntityDataTypes1_12.COMPONENT);
|
||||
data.setDataType(EntityDataTypes1_12.COMPONENT);
|
||||
} else if (typeId == 5) {
|
||||
// Rewrite optional chat to string
|
||||
JsonElement element = meta.value();
|
||||
meta.setTypeAndValue(EntityDataTypes1_12.STRING, protocol.jsonToLegacy(event.user(), element));
|
||||
JsonElement element = data.value();
|
||||
data.setTypeAndValue(EntityDataTypes1_12.STRING, protocol.jsonToLegacy(event.user(), element));
|
||||
} else if (typeId == 6) {
|
||||
Item item = (Item) meta.getValue();
|
||||
meta.setTypeAndValue(EntityDataTypes1_12.ITEM, protocol.getItemRewriter().handleItemToClient(event.user(), item));
|
||||
Item item = (Item) data.getValue();
|
||||
data.setTypeAndValue(EntityDataTypes1_12.ITEM, protocol.getItemRewriter().handleItemToClient(event.user(), item));
|
||||
} else if (typeId == 15) {
|
||||
// Discontinue particles
|
||||
event.cancel();
|
||||
} else {
|
||||
meta.setDataType(EntityDataTypes1_12.byId(typeId > 5 ? typeId - 1 : typeId));
|
||||
data.setDataType(EntityDataTypes1_12.byId(typeId > 5 ? typeId - 1 : typeId));
|
||||
}
|
||||
});
|
||||
|
||||
// Handle zombie metadata
|
||||
// Handle zombie entity data
|
||||
filter().type(EntityTypes1_13.EntityType.ZOMBIE).removeIndex(15);
|
||||
|
||||
// Handle turtle metadata (Remove them all for now)
|
||||
// Handle turtle entity data (Remove them all for now)
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(13); // Home pos
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(14); // Has egg
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(15); // Laying egg
|
||||
@@ -302,7 +302,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(17); // Going home
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(18); // Traveling
|
||||
|
||||
// Remove additional fish meta
|
||||
// Remove additional fish data
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISH).cancel(12);
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISH).cancel(13);
|
||||
|
||||
@@ -316,21 +316,21 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_13.EntityType.TRIDENT).cancel(7);
|
||||
|
||||
// Handle new wolf colors
|
||||
filter().type(EntityTypes1_13.EntityType.WOLF).index(17).handler((event, meta) -> {
|
||||
meta.setValue(15 - (int) meta.getValue());
|
||||
filter().type(EntityTypes1_13.EntityType.WOLF).index(17).handler((event, data) -> {
|
||||
data.setValue(15 - (int) data.getValue());
|
||||
});
|
||||
|
||||
// Rewrite AreaEffectCloud
|
||||
filter().type(EntityTypes1_13.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
filter().type(EntityTypes1_13.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, data) -> {
|
||||
Particle particle = (Particle) data.getValue();
|
||||
|
||||
ParticleIdMappings1_12_2.ParticleData data = ParticleIdMappings1_12_2.getMapping(particle.id());
|
||||
ParticleIdMappings1_12_2.ParticleData particleData = ParticleIdMappings1_12_2.getMapping(particle.id());
|
||||
|
||||
int firstArg = 0;
|
||||
int secondArg = 0;
|
||||
int[] particleArgs = data.rewriteMeta(protocol, particle.getArguments());
|
||||
int[] particleArgs = particleData.rewriteMeta(protocol, particle.getArguments());
|
||||
if (particleArgs != null && particleArgs.length != 0) {
|
||||
if (data.getHandler().isBlockHandler() && particleArgs[0] == 0) {
|
||||
if (particleData.getHandler().isBlockHandler() && particleArgs[0] == 0) {
|
||||
// Air doesn't have a break particle for sub 1.13 clients -> glass pane
|
||||
particleArgs[0] = 102;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
secondArg = particleArgs.length == 2 ? particleArgs[1] : 0;
|
||||
}
|
||||
|
||||
event.createExtraData(new EntityData(9, EntityDataTypes1_12.VAR_INT, data.getHistoryId()));
|
||||
event.createExtraData(new EntityData(9, EntityDataTypes1_12.VAR_INT, particleData.getHistoryId()));
|
||||
event.createExtraData(new EntityData(10, EntityDataTypes1_12.VAR_INT, firstArg));
|
||||
event.createExtraData(new EntityData(11, EntityDataTypes1_12.VAR_INT, secondArg));
|
||||
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@ public class EntityPacketRewriter1_14_1 extends LegacyEntityRewriter<Clientbound
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_14.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_14.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||
@@ -79,13 +79,13 @@ public class EntityPacketRewriter1_14_1 extends LegacyEntityRewriter<Clientbound
|
||||
// Register Type ID
|
||||
tracker(wrapper.user()).addEntity(entityId, EntityTypes1_14.getTypeFromId(type));
|
||||
|
||||
List<EntityData> metadata = wrapper.get(Types1_14.ENTITY_DATA_LIST, 0);
|
||||
handleEntityData(entityId, metadata, wrapper.user());
|
||||
List<EntityData> entityDataList = wrapper.get(Types1_14.ENTITY_DATA_LIST, 0);
|
||||
handleEntityData(entityId, entityDataList, wrapper.user());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Metadata
|
||||
// Entity data
|
||||
registerSetEntityData(ClientboundPackets1_14.SET_ENTITY_DATA, Types1_14.ENTITY_DATA_LIST);
|
||||
}
|
||||
|
||||
|
||||
+8
-3
@@ -20,6 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.storage.ChunkLightStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
@@ -48,6 +49,8 @@ import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viaversion.libs.gson.JsonParseException;
|
||||
import com.viaversion.viaversion.libs.mcstructs.text.utils.TextUtils;
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.v1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
@@ -239,9 +242,9 @@ public class BlockItemPacketRewriter1_14 extends BackwardsItemRewriter<Clientbou
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
List<EntityData> metadataList = new ArrayList<>();
|
||||
metadataList.add(new EntityData(16, Types1_13_2.ENTITY_DATA_TYPES.varIntType, armorType));
|
||||
wrapper.write(Types1_13.ENTITY_DATA_LIST, metadataList);
|
||||
List<EntityData> entityDataList = new ArrayList<>();
|
||||
entityDataList.add(new EntityData(16, Types1_13_2.ENTITY_DATA_TYPES.varIntType, armorType));
|
||||
wrapper.write(Types1_13.ENTITY_DATA_LIST, entityDataList);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -477,6 +480,8 @@ public class BlockItemPacketRewriter1_14 extends BackwardsItemRewriter<Clientbou
|
||||
each.remove();
|
||||
continue;
|
||||
}
|
||||
TextUtils.setTranslator(component, s -> Protocol1_12_2To1_13.MAPPINGS.getMojangTranslation().
|
||||
getOrDefault(s, TranslatableRewriter.getTranslatableMappings("1.14").get(s)));
|
||||
loreEntry.setValue(component.asLegacyFormatString());
|
||||
}
|
||||
} catch (final JsonParseException e) {
|
||||
|
||||
+32
-32
@@ -193,7 +193,7 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
map(Types1_14.ENTITY_DATA_LIST, Types1_13_2.ENTITY_DATA_LIST); // 12 - Metadata
|
||||
map(Types1_14.ENTITY_DATA_LIST, Types1_13_2.ENTITY_DATA_LIST); // 12 - Entity data
|
||||
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Types.VAR_INT, 1);
|
||||
@@ -214,7 +214,7 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
}
|
||||
});
|
||||
|
||||
// Handle entity type & metadata
|
||||
// Handle entity type & data
|
||||
handler(getMobSpawnRewriter1_11(Types1_13_2.ENTITY_DATA_LIST));
|
||||
}
|
||||
});
|
||||
@@ -266,9 +266,9 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
map(Types1_14.ENTITY_DATA_LIST, Types1_13_2.ENTITY_DATA_LIST); // 7 - Metadata
|
||||
map(Types1_14.ENTITY_DATA_LIST, Types1_13_2.ENTITY_DATA_LIST); // 7 - Entity data
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_13_2.ENTITY_DATA_LIST, EntityTypes1_14.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_13_2.ENTITY_DATA_LIST, EntityTypes1_14.PLAYER));
|
||||
handler(wrapper -> positionHandler.cacheEntityPosition(wrapper, true, false));
|
||||
}
|
||||
});
|
||||
@@ -323,14 +323,14 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.dataType().typeId();
|
||||
filter().handler((event, data) -> {
|
||||
int typeId = data.dataType().typeId();
|
||||
if (typeId <= 15) {
|
||||
meta.setDataType(Types1_13_2.ENTITY_DATA_TYPES.byId(typeId));
|
||||
data.setDataType(Types1_13_2.ENTITY_DATA_TYPES.byId(typeId));
|
||||
}
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(Types1_13_2.ENTITY_DATA_TYPES.itemType, null, Types1_13_2.ENTITY_DATA_TYPES.optionalBlockStateType, null,
|
||||
registerEntityDataTypeHandler(Types1_13_2.ENTITY_DATA_TYPES.itemType, null, Types1_13_2.ENTITY_DATA_TYPES.optionalBlockStateType, null,
|
||||
Types1_13_2.ENTITY_DATA_TYPES.componentType, Types1_13_2.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
|
||||
filter().type(EntityTypes1_14.PILLAGER).cancel(15);
|
||||
@@ -353,15 +353,15 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
filter().type(EntityTypes1_14.ABSTRACT_RAIDER).removeIndex(14); // Celebrating
|
||||
|
||||
filter().type(EntityTypes1_14.AREA_EFFECT_CLOUD).index(10).handler((event, meta) -> {
|
||||
rewriteParticle(event.user(), (Particle) meta.getValue());
|
||||
filter().type(EntityTypes1_14.AREA_EFFECT_CLOUD).index(10).handler((event, data) -> {
|
||||
rewriteParticle(event.user(), (Particle) data.getValue());
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_14.FIREWORK_ROCKET).index(8).handler((event, meta) -> {
|
||||
meta.setDataType(Types1_13_2.ENTITY_DATA_TYPES.varIntType);
|
||||
Integer value = (Integer) meta.getValue();
|
||||
filter().type(EntityTypes1_14.FIREWORK_ROCKET).index(8).handler((event, data) -> {
|
||||
data.setDataType(Types1_13_2.ENTITY_DATA_TYPES.varIntType);
|
||||
Integer value = (Integer) data.getValue();
|
||||
if (value == null) {
|
||||
meta.setValue(0);
|
||||
data.setValue(0);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -369,10 +369,10 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
filter().type(EntityTypes1_14.VILLAGER).cancel(15); // Head shake timer
|
||||
|
||||
EntityDataHandler villagerDataHandler = (event, meta) -> {
|
||||
VillagerData villagerData = (VillagerData) meta.getValue();
|
||||
meta.setTypeAndValue(Types1_13_2.ENTITY_DATA_TYPES.varIntType, villagerDataToProfession(villagerData));
|
||||
if (meta.id() == 16) {
|
||||
EntityDataHandler villagerDataHandler = (event, data) -> {
|
||||
VillagerData villagerData = (VillagerData) data.getValue();
|
||||
data.setTypeAndValue(Types1_13_2.ENTITY_DATA_TYPES.varIntType, villagerDataToProfession(villagerData));
|
||||
if (data.id() == 16) {
|
||||
event.setIndex(15); // decreased by 2 again in one of the following handlers
|
||||
}
|
||||
};
|
||||
@@ -381,14 +381,14 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_14.VILLAGER).index(16).handler(villagerDataHandler);
|
||||
|
||||
// Holding arms up - from bitfield into own boolean
|
||||
filter().type(EntityTypes1_14.ABSTRACT_SKELETON).index(13).handler((event, meta) -> {
|
||||
byte value = (byte) meta.getValue();
|
||||
filter().type(EntityTypes1_14.ABSTRACT_SKELETON).index(13).handler((event, data) -> {
|
||||
byte value = (byte) data.getValue();
|
||||
if ((value & 4) != 0) {
|
||||
event.createExtraData(new EntityData(14, Types1_13_2.ENTITY_DATA_TYPES.booleanType, true));
|
||||
}
|
||||
});
|
||||
filter().type(EntityTypes1_14.ZOMBIE).index(13).handler((event, meta) -> {
|
||||
byte value = (byte) meta.getValue();
|
||||
filter().type(EntityTypes1_14.ZOMBIE).index(13).handler((event, data) -> {
|
||||
byte value = (byte) data.getValue();
|
||||
if ((value & 4) != 0) {
|
||||
event.createExtraData(new EntityData(16, Types1_13_2.ENTITY_DATA_TYPES.booleanType, true));
|
||||
}
|
||||
@@ -397,10 +397,10 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_14.ZOMBIE).addIndex(16);
|
||||
|
||||
// Remove bed location
|
||||
filter().type(EntityTypes1_14.LIVING_ENTITY).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.LIVING_ENTITY).handler((event, data) -> {
|
||||
int index = event.index();
|
||||
if (index == 12) {
|
||||
BlockPosition position = (BlockPosition) meta.getValue();
|
||||
BlockPosition position = (BlockPosition) data.getValue();
|
||||
if (position != null) {
|
||||
// Use bed
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.PLAYER_SLEEP, null, event.user());
|
||||
@@ -423,22 +423,22 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
// Pose
|
||||
filter().removeIndex(6);
|
||||
|
||||
filter().type(EntityTypes1_14.OCELOT).index(13).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.OCELOT).index(13).handler((event, data) -> {
|
||||
event.setIndex(15);
|
||||
meta.setTypeAndValue(Types1_13_2.ENTITY_DATA_TYPES.varIntType, 0);
|
||||
data.setTypeAndValue(Types1_13_2.ENTITY_DATA_TYPES.varIntType, 0);
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_14.CAT).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_14.CAT).handler((event, data) -> {
|
||||
if (event.index() == 15) {
|
||||
meta.setValue(1);
|
||||
data.setValue(1);
|
||||
} else if (event.index() == 13) {
|
||||
meta.setValue((byte) ((byte) meta.getValue() & 0x4));
|
||||
data.setValue((byte) ((byte) data.getValue() & 0x4));
|
||||
}
|
||||
});
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
if (meta.dataType().typeId() > 15) {
|
||||
throw new IllegalArgumentException("Unhandled metadata: " + meta);
|
||||
filter().handler((event, data) -> {
|
||||
if (data.dataType().typeId() > 15) {
|
||||
throw new IllegalArgumentException("Unhandled entity data: " + data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+14
-16
@@ -21,7 +21,6 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.storage.ImmediateRespawnStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
@@ -81,7 +80,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
|
||||
map(Types.SHORT); // 9 - Velocity X
|
||||
map(Types.SHORT); // 10 - Velocity Y
|
||||
map(Types.SHORT); // 11 - Velocity Z
|
||||
handler(wrapper -> wrapper.write(Types1_14.ENTITY_DATA_LIST, new ArrayList<>())); // Metadata is no longer sent in 1.15, so we have to send an empty one
|
||||
handler(wrapper -> wrapper.write(Types1_14.ENTITY_DATA_LIST, new ArrayList<>())); // Entity data is no longer sent in 1.15, so we have to send an empty one
|
||||
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Types.VAR_INT, 1);
|
||||
@@ -137,7 +136,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.BYTE); // 5 - Yaw
|
||||
map(Types.BYTE); // 6 - Pitch
|
||||
handler(wrapper -> wrapper.write(Types1_14.ENTITY_DATA_LIST, new ArrayList<>())); // Metadata is no longer sent in 1.15, so we have to send an empty one
|
||||
handler(wrapper -> wrapper.write(Types1_14.ENTITY_DATA_LIST, new ArrayList<>())); // Entity data is no longer sent in 1.15, so we have to send an empty one
|
||||
|
||||
handler(getTrackerHandler(EntityTypes1_15.PLAYER, Types.VAR_INT));
|
||||
}
|
||||
@@ -192,7 +191,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
registerMetaTypeHandler(Types1_14.ENTITY_DATA_TYPES.itemType, null, Types1_14.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_14.ENTITY_DATA_TYPES.particleType,
|
||||
registerEntityDataTypeHandler(Types1_14.ENTITY_DATA_TYPES.itemType, null, Types1_14.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_14.ENTITY_DATA_TYPES.particleType,
|
||||
Types1_14.ENTITY_DATA_TYPES.componentType, Types1_14.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
|
||||
filter().type(EntityTypes1_15.LIVING_ENTITY).removeIndex(12);
|
||||
@@ -200,29 +199,28 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
|
||||
filter().type(EntityTypes1_15.BEE).cancel(15);
|
||||
filter().type(EntityTypes1_15.BEE).cancel(16);
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_15.BEE, EntityTypes1_15.PUFFERFISH).jsonName().spawnMetadata(storage -> {
|
||||
storage.add(new EntityData(14, Types1_14.ENTITY_DATA_TYPES.booleanType, false));
|
||||
storage.add(new EntityData(15, Types1_14.ENTITY_DATA_TYPES.varIntType, 2));
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_15.ENDERMAN).cancel(16);
|
||||
filter().type(EntityTypes1_15.TRIDENT).cancel(10);
|
||||
|
||||
// Redundant health removed in 1.15
|
||||
filter().type(EntityTypes1_15.WOLF).addIndex(17);
|
||||
filter().type(EntityTypes1_15.WOLF).index(8).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_15.WOLF).index(8).handler((event, data) -> {
|
||||
event.createExtraData(new EntityData(17/*WOLF_HEALTH*/, Types1_14.ENTITY_DATA_TYPES.floatType, event.data().value()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_15.BEE, EntityTypes1_15.PUFFERFISH).jsonName().spawnEntityData(storage -> {
|
||||
storage.add(new EntityData(14, Types1_14.ENTITY_DATA_TYPES.booleanType, false));
|
||||
storage.add(new EntityData(15, Types1_14.ENTITY_DATA_TYPES.varIntType, 2));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_15.getTypeFromId(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int newEntityId(final int newId) {
|
||||
if (newId == 4) return EntityTypes1_14.PUFFERFISH.getId(); // Flying pufferfish!
|
||||
return newId >= 5 ? newId - 1 : newId;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -120,7 +120,7 @@ public class EntityPacketRewriter1_16_2 extends EntityRewriter<ClientboundPacket
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
registerMetaTypeHandler(Types1_16.ENTITY_DATA_TYPES.itemType, null, Types1_16.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
registerEntityDataTypeHandler(Types1_16.ENTITY_DATA_TYPES.itemType, null, Types1_16.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
Types1_16.ENTITY_DATA_TYPES.particleType, Types1_16.ENTITY_DATA_TYPES.componentType, Types1_16.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
|
||||
filter().type(EntityTypes1_16_2.ABSTRACT_PIGLIN).index(15).toIndex(16);
|
||||
|
||||
+2
@@ -22,6 +22,7 @@ import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.TranslatableRewriter1_16;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.BackwardsMappingData1_16;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.CommandRewriter1_16;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.PlayerAttributesStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WorldNameTracker;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.BlockItemPacketRewriter1_16;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.EntityPacketRewriter1_16;
|
||||
@@ -173,6 +174,7 @@ public class Protocol1_16To1_15_2 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
user.put(new PlayerSneakStorage());
|
||||
user.put(new WorldNameTracker());
|
||||
user.put(new PlayerAttributesStorage());
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_16.PLAYER));
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -21,6 +21,7 @@ import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viaversion.protocols.v1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.AttributeMappings1_16;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -35,11 +36,11 @@ public class BackwardsMappingData1_16 extends BackwardsMappingData {
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
super.loadExtras(data);
|
||||
for (Map.Entry<String, String> entry : AttributeMappings1_16.attributeIdentifierMappings().entrySet()) {
|
||||
attributeMappings.put(entry.getValue(), entry.getKey());
|
||||
attributeMappings.put(Key.stripMinecraftNamespace(entry.getValue()), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> attributeIdentifierMappings() {
|
||||
return attributeMappings;
|
||||
public String mappedAttributeIdentifier(final String identifier) {
|
||||
return attributeMappings.getOrDefault(identifier, identifier);
|
||||
}
|
||||
}
|
||||
+56
-33
@@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.PlayerAttributesStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WorldNameTracker;
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WolfDataMaskStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
@@ -41,6 +42,7 @@ import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15;
|
||||
import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1_16, Protocol1_16To1_15_2> {
|
||||
|
||||
@@ -132,7 +134,17 @@ public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1
|
||||
if (wrapper.read(Types.BOOLEAN)) {
|
||||
wrapper.set(Types.STRING, 0, "flat");
|
||||
}
|
||||
wrapper.read(Types.BOOLEAN); // Keep all playerdata
|
||||
|
||||
final PlayerAttributesStorage attributes = wrapper.user().get(PlayerAttributesStorage.class);
|
||||
final boolean keepPlayerAttributes = wrapper.read(Types.BOOLEAN);
|
||||
if (keepPlayerAttributes) {
|
||||
// Ensure packet order
|
||||
wrapper.send(Protocol1_16To1_15_2.class);
|
||||
wrapper.cancel();
|
||||
attributes.sendAttributes(wrapper.user(), tracker(wrapper.user()).clientEntityId());
|
||||
} else {
|
||||
attributes.clearAttributes();
|
||||
}
|
||||
|
||||
// Finally update the world name
|
||||
worldNameTracker.setWorldName(nextWorldName);
|
||||
@@ -171,6 +183,7 @@ public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1
|
||||
wrapper.set(Types.STRING, 0, "flat");
|
||||
}
|
||||
});
|
||||
handler(playerTrackerHandler());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -182,19 +195,29 @@ public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1
|
||||
registerSetEntityData(ClientboundPackets1_16.SET_ENTITY_DATA, Types1_16.ENTITY_DATA_LIST, Types1_14.ENTITY_DATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.UPDATE_ATTRIBUTES, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT);
|
||||
int size = wrapper.passthrough(Types.INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String attributeIdentifier = wrapper.read(Types.STRING);
|
||||
String oldKey = protocol.getMappingData().attributeIdentifierMappings().get(attributeIdentifier);
|
||||
wrapper.write(Types.STRING, oldKey != null ? oldKey : Key.stripMinecraftNamespace(attributeIdentifier));
|
||||
final PlayerAttributesStorage attributes = wrapper.user().get(PlayerAttributesStorage.class);
|
||||
|
||||
wrapper.passthrough(Types.DOUBLE);
|
||||
int modifierSize = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int j = 0; j < modifierSize; j++) {
|
||||
wrapper.passthrough(Types.UUID);
|
||||
wrapper.passthrough(Types.DOUBLE);
|
||||
wrapper.passthrough(Types.BYTE);
|
||||
final int entityId = wrapper.passthrough(Types.VAR_INT);
|
||||
|
||||
final int size = wrapper.passthrough(Types.INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final String identifier = Key.stripMinecraftNamespace(wrapper.read(Types.STRING));
|
||||
|
||||
final String mappedIdentifier = protocol.getMappingData().mappedAttributeIdentifier(identifier);
|
||||
wrapper.write(Types.STRING, mappedIdentifier);
|
||||
final double value = wrapper.passthrough(Types.DOUBLE);
|
||||
|
||||
final int count = wrapper.passthrough(Types.VAR_INT);
|
||||
final var modifiers = new PlayerAttributesStorage.AttributeModifier[count];
|
||||
for (int j = 0; j < count; j++) {
|
||||
final UUID uuid = wrapper.passthrough(Types.UUID);
|
||||
final double amount = wrapper.passthrough(Types.DOUBLE);
|
||||
final byte operation = wrapper.passthrough(Types.BYTE);
|
||||
|
||||
modifiers[j] = new PlayerAttributesStorage.AttributeModifier(uuid, amount, operation);
|
||||
}
|
||||
if (entityId == tracker(wrapper.user()).clientEntityId()) {
|
||||
attributes.addAttribute(mappedIdentifier, new PlayerAttributesStorage.Attribute(value, modifiers));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -230,18 +253,18 @@ public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
meta.setDataType(Types1_14.ENTITY_DATA_TYPES.byId(meta.dataType().typeId()));
|
||||
filter().handler((event, data) -> {
|
||||
data.setDataType(Types1_14.ENTITY_DATA_TYPES.byId(data.dataType().typeId()));
|
||||
|
||||
EntityDataType type = meta.dataType();
|
||||
EntityDataType type = data.dataType();
|
||||
if (type == Types1_14.ENTITY_DATA_TYPES.itemType) {
|
||||
meta.setValue(protocol.getItemRewriter().handleItemToClient(event.user(), (Item) meta.getValue()));
|
||||
data.setValue(protocol.getItemRewriter().handleItemToClient(event.user(), (Item) data.getValue()));
|
||||
} else if (type == Types1_14.ENTITY_DATA_TYPES.optionalBlockStateType) {
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId((int) meta.getValue()));
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId((int) data.getValue()));
|
||||
} else if (type == Types1_14.ENTITY_DATA_TYPES.particleType) {
|
||||
rewriteParticle(event.user(), (Particle) meta.getValue());
|
||||
rewriteParticle(event.user(), (Particle) data.getValue());
|
||||
} else if (type == Types1_14.ENTITY_DATA_TYPES.optionalComponentType) {
|
||||
JsonElement text = meta.value();
|
||||
JsonElement text = data.value();
|
||||
if (text != null) {
|
||||
protocol.getComponentRewriter().processText(event.user(), text);
|
||||
}
|
||||
@@ -255,9 +278,9 @@ public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1
|
||||
filter().type(EntityTypes1_16.PIGLIN).cancel(17);
|
||||
filter().type(EntityTypes1_16.PIGLIN).cancel(18);
|
||||
|
||||
filter().type(EntityTypes1_16.STRIDER).index(15).handler((event, meta) -> {
|
||||
boolean baby = meta.value();
|
||||
meta.setTypeAndValue(Types1_14.ENTITY_DATA_TYPES.varIntType, baby ? 1 : 3);
|
||||
filter().type(EntityTypes1_16.STRIDER).index(15).handler((event, data) -> {
|
||||
boolean baby = data.value();
|
||||
data.setTypeAndValue(Types1_14.ENTITY_DATA_TYPES.varIntType, baby ? 1 : 3);
|
||||
});
|
||||
filter().type(EntityTypes1_16.STRIDER).cancel(16);
|
||||
filter().type(EntityTypes1_16.STRIDER).cancel(17);
|
||||
@@ -266,29 +289,29 @@ public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1
|
||||
filter().type(EntityTypes1_16.FISHING_BOBBER).cancel(8);
|
||||
|
||||
filter().type(EntityTypes1_16.ABSTRACT_ARROW).cancel(8);
|
||||
filter().type(EntityTypes1_16.ABSTRACT_ARROW).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_16.ABSTRACT_ARROW).handler((event, data) -> {
|
||||
if (event.index() >= 8) {
|
||||
event.setIndex(event.index() + 1);
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_16.WOLF).index(16).handler((event, meta) -> {
|
||||
byte mask = meta.value();
|
||||
StoredEntityData data = tracker(event.user()).entityData(event.entityId());
|
||||
data.put(new WolfDataMaskStorage(mask));
|
||||
filter().type(EntityTypes1_16.WOLF).index(16).handler((event, data) -> {
|
||||
byte mask = data.value();
|
||||
StoredEntityData entityData = tracker(event.user()).entityData(event.entityId());
|
||||
entityData.put(new WolfDataMaskStorage(mask));
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_16.WOLF).index(20).handler((event, meta) -> {
|
||||
StoredEntityData data = tracker(event.user()).entityDataIfPresent(event.entityId());
|
||||
filter().type(EntityTypes1_16.WOLF).index(20).handler((event, data) -> {
|
||||
StoredEntityData entityData = tracker(event.user()).entityDataIfPresent(event.entityId());
|
||||
byte previousMask = 0;
|
||||
if (data != null) {
|
||||
WolfDataMaskStorage wolfData = data.get(WolfDataMaskStorage.class);
|
||||
if (entityData != null) {
|
||||
WolfDataMaskStorage wolfData = entityData.get(WolfDataMaskStorage.class);
|
||||
if (wolfData != null) {
|
||||
previousMask = wolfData.tameableMask();
|
||||
}
|
||||
}
|
||||
|
||||
int angerTime = meta.value();
|
||||
int angerTime = data.value();
|
||||
byte tameableMask = (byte) (angerTime > 0 ? previousMask | 2 : previousMask & -3);
|
||||
event.createExtraData(new EntityData(16, Types1_14.ENTITY_DATA_TYPES.byteType, tameableMask));
|
||||
event.cancel();
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class PlayerAttributesStorage implements StorableObject {
|
||||
|
||||
private final Map<String, Attribute> attributes = new HashMap<>();
|
||||
|
||||
public void sendAttributes(final UserConnection connection, final int entityId) {
|
||||
final PacketWrapper updateAttributes = PacketWrapper.create(ClientboundPackets1_15.UPDATE_ATTRIBUTES, connection);
|
||||
|
||||
updateAttributes.write(Types.VAR_INT, entityId);
|
||||
updateAttributes.write(Types.INT, attributes.size());
|
||||
for (final Map.Entry<String, Attribute> attributeEntry : attributes.entrySet()) {
|
||||
final Attribute attribute = attributeEntry.getValue();
|
||||
updateAttributes.write(Types.STRING, attributeEntry.getKey());
|
||||
updateAttributes.write(Types.DOUBLE, attribute.value());
|
||||
updateAttributes.write(Types.VAR_INT, attribute.modifiers().length);
|
||||
|
||||
for (final AttributeModifier modifier : attribute.modifiers()) {
|
||||
updateAttributes.write(Types.UUID, modifier.uuid());
|
||||
updateAttributes.write(Types.DOUBLE, modifier.amount());
|
||||
updateAttributes.write(Types.BYTE, modifier.operation());
|
||||
}
|
||||
}
|
||||
updateAttributes.send(Protocol1_16To1_15_2.class);
|
||||
}
|
||||
|
||||
public void clearAttributes() {
|
||||
attributes.clear();
|
||||
}
|
||||
|
||||
public void addAttribute(final String key, final Attribute attribute) {
|
||||
attributes.put(key, attribute);
|
||||
}
|
||||
|
||||
public record Attribute(double value, AttributeModifier[] modifiers) {
|
||||
}
|
||||
|
||||
public record AttributeModifier(UUID uuid, double amount, byte operation) {
|
||||
}
|
||||
}
|
||||
+6
@@ -102,6 +102,12 @@ public final class Protocol1_17_1To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
boolean signing = wrapper.read(Types.BOOLEAN);
|
||||
wrapper.passthrough(Types.VAR_INT); // Slot comes first
|
||||
|
||||
if (item == null) {
|
||||
wrapper.write(Types.VAR_INT, 0); // Pages length
|
||||
wrapper.write(Types.BOOLEAN, false); // Optional title
|
||||
return;
|
||||
}
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
ListTag<StringTag> pagesTag;
|
||||
StringTag titleTag = null;
|
||||
|
||||
+12
-4
@@ -202,10 +202,10 @@ public final class Protocol1_17To1_16_4 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
//TODO translatables
|
||||
mergePacket(ClientboundPackets1_17.SET_TITLE_TEXT, ClientboundPackets1_16_2.SET_TITLES, 0);
|
||||
mergePacket(ClientboundPackets1_17.SET_SUBTITLE_TEXT, ClientboundPackets1_16_2.SET_TITLES, 1);
|
||||
mergePacket(ClientboundPackets1_17.SET_ACTION_BAR_TEXT, ClientboundPackets1_16_2.SET_TITLES, 2);
|
||||
rewriteTitlePacket(ClientboundPackets1_17.SET_TITLE_TEXT, 0);
|
||||
rewriteTitlePacket(ClientboundPackets1_17.SET_SUBTITLE_TEXT, 1);
|
||||
rewriteTitlePacket(ClientboundPackets1_17.SET_ACTION_BAR_TEXT, 2);
|
||||
|
||||
mergePacket(ClientboundPackets1_17.SET_TITLES_ANIMATION, ClientboundPackets1_16_2.SET_TITLES, 3);
|
||||
registerClientbound(ClientboundPackets1_17.CLEAR_TITLES, ClientboundPackets1_16_2.SET_TITLES, wrapper -> {
|
||||
if (wrapper.read(Types.BOOLEAN)) {
|
||||
@@ -240,6 +240,14 @@ public final class Protocol1_17To1_16_4 extends BackwardsProtocol<ClientboundPac
|
||||
registerClientbound(newPacketType, oldPacketType, wrapper -> wrapper.write(Types.VAR_INT, type));
|
||||
}
|
||||
|
||||
private void rewriteTitlePacket(ClientboundPackets1_17 newPacketType, int type) {
|
||||
// Also handles translations in the title
|
||||
registerClientbound(newPacketType, ClientboundPackets1_16_2.SET_TITLES, wrapper -> {
|
||||
wrapper.write(Types.VAR_INT, type);
|
||||
translatableRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPacketRewriter1_17 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
|
||||
+38
-9
@@ -17,6 +17,10 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_17to1_16_4.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.LongArrayTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.MapColorRewriter;
|
||||
@@ -28,16 +32,14 @@ import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.LongArrayTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ClientboundPackets1_17;
|
||||
@@ -53,6 +55,8 @@ import java.util.List;
|
||||
|
||||
public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<ClientboundPackets1_17, ServerboundPackets1_16_2, Protocol1_17To1_16_4> {
|
||||
|
||||
private static final int BEDROCK_BLOCK_STATE = 33;
|
||||
|
||||
public BlockItemPacketRewriter1_17(Protocol1_17To1_16_4 protocol) {
|
||||
super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_SHORT_ARRAY);
|
||||
}
|
||||
@@ -295,7 +299,11 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
|
||||
|
||||
BlockChangeRecord[] records = wrapper.passthrough(Types.VAR_LONG_BLOCK_CHANGE_ARRAY);
|
||||
for (BlockChangeRecord record : records) {
|
||||
record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId()));
|
||||
if (ViaBackwards.getConfig().bedrockAtY0() && chunkY == 0 && record.getSectionY() == 0) {
|
||||
record.setBlockId(BEDROCK_BLOCK_STATE);
|
||||
} else {
|
||||
record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -313,7 +321,11 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.set(Types.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Types.VAR_INT, 0)));
|
||||
if (ViaBackwards.getConfig().bedrockAtY0() && y == 0) {
|
||||
wrapper.set(Types.VAR_INT, 0, BEDROCK_BLOCK_STATE);
|
||||
} else {
|
||||
wrapper.set(Types.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Types.VAR_INT, 0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -350,15 +362,32 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
|
||||
|
||||
blockRewriter.handleChunk(chunk);
|
||||
|
||||
if (ViaBackwards.getConfig().bedrockAtY0()) {
|
||||
final ChunkSection lowestSection = chunk.getSections()[0];
|
||||
if (lowestSection != null) {
|
||||
final DataPalette blocks = lowestSection.palette(PaletteType.BLOCKS);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
blocks.setIdAt(x, 0, z, BEDROCK_BLOCK_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chunk.getBlockEntities().removeIf(compound -> {
|
||||
NumberTag tag = compound.getNumberTag("y");
|
||||
return tag != null && (tag.asInt() < 0 || tag.asInt() > 255);
|
||||
if (tag == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int y = tag.asInt();
|
||||
return y < 0 || y > 255 || (ViaBackwards.getConfig().bedrockAtY0() && y == 0);
|
||||
});
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.BLOCK_ENTITY_DATA, wrapper -> {
|
||||
int y = wrapper.passthrough(Types.BLOCK_POSITION1_14).y();
|
||||
if (y < 0 || y > 255) {
|
||||
if (y < 0 || y > 255 || (ViaBackwards.getConfig().bedrockAtY0() && y == 0)) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
@@ -369,7 +398,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
|
||||
map(Types.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int y = wrapper.passthrough(Types.BLOCK_POSITION1_14).y();
|
||||
if (y < 0 || y > 255) {
|
||||
if (y < 0 || y > 255 || (ViaBackwards.getConfig().bedrockAtY0() && y == 0)) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
+18
-14
@@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||
@@ -36,7 +35,7 @@ import com.viaversion.viaversion.util.TagUtil;
|
||||
|
||||
public final class EntityPacketRewriter1_17 extends EntityRewriter<ClientboundPackets1_17, Protocol1_17To1_16_4> {
|
||||
|
||||
private boolean warned;
|
||||
private boolean warned = ViaBackwards.getConfig().bedrockAtY0() || ViaBackwards.getConfig().suppressEmulationWarnings();
|
||||
|
||||
public EntityPacketRewriter1_17(Protocol1_17To1_16_4 protocol) {
|
||||
super(protocol);
|
||||
@@ -133,20 +132,25 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter<ClientboundPa
|
||||
}
|
||||
});
|
||||
|
||||
// TODO translatables
|
||||
protocol.mergePacket(ClientboundPackets1_17.PLAYER_COMBAT_ENTER, ClientboundPackets1_16_2.PLAYER_COMBAT, 0);
|
||||
protocol.mergePacket(ClientboundPackets1_17.PLAYER_COMBAT_END, ClientboundPackets1_16_2.PLAYER_COMBAT, 1);
|
||||
protocol.mergePacket(ClientboundPackets1_17.PLAYER_COMBAT_KILL, ClientboundPackets1_16_2.PLAYER_COMBAT, 2);
|
||||
protocol.registerClientbound(ClientboundPackets1_17.PLAYER_COMBAT_KILL, ClientboundPackets1_16_2.PLAYER_COMBAT, wrapper -> {
|
||||
wrapper.write(Types.VAR_INT, 2);
|
||||
|
||||
wrapper.passthrough(Types.VAR_INT); // Duration/Player id
|
||||
wrapper.passthrough(Types.INT); // Killer id
|
||||
protocol.getComponentRewriter().processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
meta.setDataType(Types1_16.ENTITY_DATA_TYPES.byId(meta.dataType().typeId()));
|
||||
filter().handler((event, data) -> {
|
||||
data.setDataType(Types1_16.ENTITY_DATA_TYPES.byId(data.dataType().typeId()));
|
||||
|
||||
EntityDataType type = meta.dataType();
|
||||
EntityDataType type = data.dataType();
|
||||
if (type == Types1_16.ENTITY_DATA_TYPES.particleType) {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
Particle particle = (Particle) data.getValue();
|
||||
if (particle.id() == 16) { // Dust / Dust Transition
|
||||
// Remove transition target color values 4-6
|
||||
particle.getArguments().subList(4, 7).clear();
|
||||
@@ -160,17 +164,17 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter<ClientboundPa
|
||||
rewriteParticle(event.user(), particle);
|
||||
} else if (type == Types1_16.ENTITY_DATA_TYPES.poseType) {
|
||||
// Goat LONG_JUMP added at 6
|
||||
int pose = meta.value();
|
||||
int pose = data.value();
|
||||
if (pose == 6) {
|
||||
meta.setValue(1); // FALL_FLYING
|
||||
data.setValue(1); // FALL_FLYING
|
||||
} else if (pose > 6) {
|
||||
meta.setValue(pose - 1);
|
||||
data.setValue(pose - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Particles have already been handled
|
||||
registerMetaTypeHandler(Types1_16.ENTITY_DATA_TYPES.itemType, null, Types1_16.ENTITY_DATA_TYPES.optionalBlockStateType, null,
|
||||
registerEntityDataTypeHandler(Types1_16.ENTITY_DATA_TYPES.itemType, null, Types1_16.ENTITY_DATA_TYPES.optionalBlockStateType, null,
|
||||
Types1_16.ENTITY_DATA_TYPES.componentType, Types1_16.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
|
||||
filter().type(EntityTypes1_17.AXOLOTL).cancel(17);
|
||||
@@ -206,8 +210,8 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter<ClientboundPa
|
||||
NumberTag height = tag.getNumberTag("height");
|
||||
NumberTag logicalHeight = tag.getNumberTag("logical_height");
|
||||
if (minY.asInt() != 0 || height.asInt() > 256 || logicalHeight.asInt() > 256) {
|
||||
if (warn && !warned && !ViaBackwards.getConfig().suppressEmulationWarnings()) {
|
||||
protocol.getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256");
|
||||
if (warn && !warned) {
|
||||
protocol.getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256. You can enable the `bedrock-at-y-0` config option to replace the air with a bedrock layer.");
|
||||
warned = true;
|
||||
}
|
||||
|
||||
|
||||
+7
-9
@@ -24,7 +24,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||
@@ -32,7 +31,6 @@ import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPacke
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.util.TagUtil;
|
||||
|
||||
public final class EntityPacketRewriter1_18 extends EntityRewriter<ClientboundPackets1_18, Protocol1_18To1_17_1> {
|
||||
@@ -94,15 +92,15 @@ public final class EntityPacketRewriter1_18 extends EntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
meta.setDataType(Types1_17.ENTITY_DATA_TYPES.byId(meta.dataType().typeId()));
|
||||
filter().handler((event, data) -> {
|
||||
data.setDataType(Types1_17.ENTITY_DATA_TYPES.byId(data.dataType().typeId()));
|
||||
|
||||
EntityDataType type = meta.dataType();
|
||||
EntityDataType type = data.dataType();
|
||||
if (type == Types1_17.ENTITY_DATA_TYPES.particleType) {
|
||||
Particle particle = meta.value();
|
||||
Particle particle = data.value();
|
||||
if (particle.id() == 3) { // Block marker
|
||||
Particle.ParticleData<?> data = particle.getArguments().remove(0);
|
||||
int blockState = (int) data.getValue();
|
||||
Particle.ParticleData<?> value = particle.getArguments().remove(0);
|
||||
int blockState = (int) value.getValue();
|
||||
if (blockState == 7786) { // Light block
|
||||
particle.setId(3);
|
||||
} else {
|
||||
@@ -117,7 +115,7 @@ public final class EntityPacketRewriter1_18 extends EntityRewriter<ClientboundPa
|
||||
});
|
||||
|
||||
// Particles have already been handled
|
||||
registerMetaTypeHandler(Types1_17.ENTITY_DATA_TYPES.itemType, null, null, null,
|
||||
registerEntityDataTypeHandler(Types1_17.ENTITY_DATA_TYPES.itemType, null, null, null,
|
||||
Types1_17.ENTITY_DATA_TYPES.componentType, Types1_17.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
}
|
||||
|
||||
|
||||
+10
-28
@@ -21,7 +21,6 @@ import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3;
|
||||
@@ -73,7 +72,7 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
final String type = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING));
|
||||
wrapper.passthrough(Types.STRING); // Recipe Identifier
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
case "crafting_shapeless" -> {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
final int ingredients = wrapper.passthrough(Types.VAR_INT);
|
||||
@@ -84,9 +83,8 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
}
|
||||
}
|
||||
handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
case "crafting_shaped" -> {
|
||||
final int ingredients = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT);
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
@@ -97,12 +95,8 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
}
|
||||
}
|
||||
handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result
|
||||
break;
|
||||
}
|
||||
case "smelting":
|
||||
case "campfire_cooking":
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "smelting", "campfire_cooking", "blasting", "smoking" -> {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
final Item[] items = wrapper.passthrough(Types.ITEM1_13_2_ARRAY); // Ingredients
|
||||
@@ -112,25 +106,13 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result
|
||||
wrapper.passthrough(Types.FLOAT); // EXP
|
||||
wrapper.passthrough(Types.VAR_INT); // Cooking time
|
||||
break;
|
||||
case "crafting_special_armordye":
|
||||
case "crafting_special_bookcloning":
|
||||
case "crafting_special_mapcloning":
|
||||
case "crafting_special_mapextending":
|
||||
case "crafting_special_firework_rocket":
|
||||
case "crafting_special_firework_star":
|
||||
case "crafting_special_firework_star_fade":
|
||||
case "crafting_special_tippedarrow":
|
||||
case "crafting_special_bannerduplicate":
|
||||
case "crafting_special_shielddecoration":
|
||||
case "crafting_special_shulkerboxcoloring":
|
||||
case "crafting_special_suspiciousstew":
|
||||
case "crafting_special_repairitem":
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
break;
|
||||
default:
|
||||
recipeRewriter.handleRecipeType(wrapper, type);
|
||||
break;
|
||||
}
|
||||
case "crafting_special_armordye", "crafting_special_bookcloning", "crafting_special_mapcloning",
|
||||
"crafting_special_mapextending", "crafting_special_firework_rocket", "crafting_special_firework_star",
|
||||
"crafting_special_firework_star_fade", "crafting_special_tippedarrow", "crafting_special_bannerduplicate",
|
||||
"crafting_special_shielddecoration", "crafting_special_shulkerboxcoloring", "crafting_special_suspiciousstew",
|
||||
"crafting_special_repairitem" -> wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
default -> recipeRewriter.handleRecipeType(wrapper, type);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+9
-10
@@ -27,7 +27,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_3;
|
||||
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_3;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||
@@ -230,25 +229,25 @@ public final class EntityPacketRewriter1_19_3 extends EntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
public void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
final int id = meta.dataType().typeId();
|
||||
filter().handler((event, data) -> {
|
||||
final int id = data.dataType().typeId();
|
||||
if (id > 2) {
|
||||
meta.setDataType(Types1_19.ENTITY_DATA_TYPES.byId(id - 1)); // long added
|
||||
data.setDataType(Types1_19.ENTITY_DATA_TYPES.byId(id - 1)); // long added
|
||||
} else if (id != 2) {
|
||||
meta.setDataType(Types1_19.ENTITY_DATA_TYPES.byId(id));
|
||||
data.setDataType(Types1_19.ENTITY_DATA_TYPES.byId(id));
|
||||
}
|
||||
});
|
||||
registerMetaTypeHandler(Types1_19.ENTITY_DATA_TYPES.itemType, null, Types1_19.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_19.ENTITY_DATA_TYPES.particleType,
|
||||
registerEntityDataTypeHandler(Types1_19.ENTITY_DATA_TYPES.itemType, null, Types1_19.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_19.ENTITY_DATA_TYPES.particleType,
|
||||
Types1_19.ENTITY_DATA_TYPES.componentType, Types1_19.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
registerBlockStateHandler(EntityTypes1_19_3.ABSTRACT_MINECART, 11);
|
||||
|
||||
filter().dataType(Types1_19.ENTITY_DATA_TYPES.poseType).handler((event, meta) -> {
|
||||
filter().dataType(Types1_19.ENTITY_DATA_TYPES.poseType).handler((event, data) -> {
|
||||
// Sitting pose added
|
||||
final int pose = meta.value();
|
||||
final int pose = data.value();
|
||||
if (pose == 10) {
|
||||
meta.setValue(0); // Standing
|
||||
data.setValue(0); // Standing
|
||||
} else if (pose > 10) {
|
||||
meta.setValue(pose - 1);
|
||||
data.setValue(pose - 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+5
-12
@@ -78,21 +78,14 @@ public final class Protocol1_19_4To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
@Override
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) {
|
||||
switch (argumentType) {
|
||||
case "minecraft:heightmap":
|
||||
wrapper.write(Types.VAR_INT, 0);
|
||||
break;
|
||||
case "minecraft:time":
|
||||
wrapper.read(Types.INT); // Minimum
|
||||
break;
|
||||
case "minecraft:resource":
|
||||
case "minecraft:resource_or_tag":
|
||||
case "minecraft:heightmap" -> wrapper.write(Types.VAR_INT, 0);
|
||||
case "minecraft:time" -> wrapper.read(Types.INT); // Minimum
|
||||
case "minecraft:resource", "minecraft:resource_or_tag" -> {
|
||||
final String resource = wrapper.read(Types.STRING);
|
||||
// Replace damage types with... something
|
||||
wrapper.write(Types.STRING, resource.equals("minecraft:damage_type") ? "minecraft:mob_effect" : resource);
|
||||
break;
|
||||
default:
|
||||
super.handleArgument(wrapper, argumentType);
|
||||
break;
|
||||
}
|
||||
default -> super.handleArgument(wrapper, argumentType);
|
||||
}
|
||||
}
|
||||
}.registerDeclareCommands1_19(ClientboundPackets1_19_4.COMMANDS);
|
||||
|
||||
+30
-20
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_19_4to1_19_3.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_19_4to1_19_3.Protocol1_19_4To1_19_3;
|
||||
@@ -30,9 +33,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3;
|
||||
import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.NumberTag;
|
||||
import com.viaversion.viaversion.util.TagUtil;
|
||||
|
||||
public final class EntityPacketRewriter1_19_4 extends EntityRewriter<ClientboundPackets1_19_4, Protocol1_19_4To1_19_3> {
|
||||
@@ -127,43 +127,53 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter<Clientbound
|
||||
handler(worldDataTrackerHandlerByKey());
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.UPDATE_MOB_EFFECT, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Entity id
|
||||
wrapper.passthrough(Types.VAR_INT); // Effect id
|
||||
wrapper.passthrough(Types.BYTE); // Amplifier
|
||||
|
||||
// Handle inifinite duration. Use a value the client still accepts without bugging out the display while still being practically infinite
|
||||
final int duration = wrapper.read(Types.VAR_INT);
|
||||
wrapper.write(Types.VAR_INT, duration == -1 ? 999999 : duration);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
int id = meta.dataType().typeId();
|
||||
filter().handler((event, data) -> {
|
||||
int id = data.dataType().typeId();
|
||||
if (id >= 25) { // Sniffer state, Vector3f, Quaternion types
|
||||
return;
|
||||
} else if (id >= 15) { // Optional block state - just map down to block state
|
||||
id--;
|
||||
}
|
||||
|
||||
meta.setDataType(Types1_19_3.ENTITY_DATA_TYPES.byId(id));
|
||||
data.setDataType(Types1_19_3.ENTITY_DATA_TYPES.byId(id));
|
||||
});
|
||||
registerMetaTypeHandler(Types1_19_3.ENTITY_DATA_TYPES.itemType, null, Types1_19_3.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_19_3.ENTITY_DATA_TYPES.particleType,
|
||||
registerEntityDataTypeHandler(Types1_19_3.ENTITY_DATA_TYPES.itemType, null, Types1_19_3.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_19_3.ENTITY_DATA_TYPES.particleType,
|
||||
Types1_19_3.ENTITY_DATA_TYPES.componentType, Types1_19_3.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
registerBlockStateHandler(EntityTypes1_19_4.ABSTRACT_MINECART, 11);
|
||||
|
||||
filter().type(EntityTypes1_19_4.BOAT).index(11).handler((event, meta) -> {
|
||||
final int boatType = meta.value();
|
||||
filter().type(EntityTypes1_19_4.BOAT).index(11).handler((event, data) -> {
|
||||
final int boatType = data.value();
|
||||
if (boatType > 4) { // Cherry
|
||||
meta.setValue(boatType - 1);
|
||||
data.setValue(boatType - 1);
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_19_4.TEXT_DISPLAY).index(22).handler(((event, meta) -> {
|
||||
filter().type(EntityTypes1_19_4.TEXT_DISPLAY).index(22).handler(((event, data) -> {
|
||||
// Send as custom display name
|
||||
event.setIndex(2);
|
||||
meta.setDataType(Types1_19_3.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
data.setDataType(Types1_19_3.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
event.createExtraData(new EntityData(3, Types1_19_3.ENTITY_DATA_TYPES.booleanType, true)); // Show custom name
|
||||
|
||||
final JsonElement element = meta.value();
|
||||
final JsonElement element = data.value();
|
||||
protocol.getComponentRewriter().processText(event.user(), element);
|
||||
}));
|
||||
filter().type(EntityTypes1_19_4.DISPLAY).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_19_4.DISPLAY).handler((event, data) -> {
|
||||
// TODO Maybe spawn an extra entity to ride the armor stand for blocks and items
|
||||
// Remove a large heap of display metadata
|
||||
// Remove a large heap of display entity data
|
||||
if (event.index() > 7) {
|
||||
event.cancel();
|
||||
}
|
||||
@@ -183,16 +193,16 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter<Clientbound
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
|
||||
final EntityReplacement.MetaCreator displayMetaCreator = storage -> {
|
||||
final EntityReplacement.EntityDataCreator displayDataCreator = storage -> {
|
||||
storage.add(new EntityData(0, Types1_19_3.ENTITY_DATA_TYPES.byteType, (byte) 0x20)); // Invisible
|
||||
storage.add(new EntityData(5, Types1_19_3.ENTITY_DATA_TYPES.booleanType, true)); // No gravity
|
||||
storage.add(new EntityData(15, Types1_19_3.ENTITY_DATA_TYPES.byteType, (byte) (0x01 | 0x10))); // Small marker
|
||||
};
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.TEXT_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator);
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.ITEM_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator);
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.BLOCK_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator);
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.TEXT_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnEntityData(displayDataCreator);
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.ITEM_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnEntityData(displayDataCreator);
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.BLOCK_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnEntityData(displayDataCreator);
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.INTERACTION, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator); // Not much we can do about this one
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.INTERACTION, EntityTypes1_19_4.ARMOR_STAND).spawnEntityData(displayDataCreator); // Not much we can do about this one
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_19_4.SNIFFER, EntityTypes1_19_4.RAVAGER).jsonName();
|
||||
}
|
||||
|
||||
+18
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_19to1_18_2.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
@@ -29,6 +30,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class BackwardsMappingData1_19 extends BackwardsMappingData {
|
||||
|
||||
private final boolean sculkShriekerToCryingObsidian = ViaBackwards.getConfig().sculkShriekerToCryingObsidian();
|
||||
|
||||
private final Int2ObjectMap<CompoundTag> defaultChatTypes = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public BackwardsMappingData1_19() {
|
||||
@@ -39,6 +42,13 @@ public final class BackwardsMappingData1_19 extends BackwardsMappingData {
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
super.loadExtras(data);
|
||||
|
||||
if (sculkShriekerToCryingObsidian) {
|
||||
blockMappings.setNewId(850, 750);
|
||||
for (int i = 18900; i <= 18907; i++) {
|
||||
blockStateMappings.setNewId(i, 16082);
|
||||
}
|
||||
}
|
||||
|
||||
final ListTag<CompoundTag> chatTypes = BackwardsMappingDataLoader.INSTANCE.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class);
|
||||
for (final CompoundTag chatType : chatTypes) {
|
||||
final NumberTag idTag = chatType.getNumberTag("id");
|
||||
@@ -46,6 +56,14 @@ public final class BackwardsMappingData1_19 extends BackwardsMappingData {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewItemId(final int id) {
|
||||
if (sculkShriekerToCryingObsidian && id == 329) {
|
||||
return 1065;
|
||||
}
|
||||
return super.getNewItemId(id);
|
||||
}
|
||||
|
||||
public @Nullable CompoundTag chatType(final int id) {
|
||||
return defaultChatTypes.get(id);
|
||||
}
|
||||
|
||||
+12
@@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.v1_19to1_18_2.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.Protocol1_19To1_18_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.storage.LastDeathPosition;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
@@ -42,6 +43,8 @@ import com.viaversion.viaversion.util.MathUtil;
|
||||
|
||||
public final class BlockItemPacketRewriter1_19 extends BackwardsItemRewriter<ClientboundPackets1_19, ServerboundPackets1_17, Protocol1_19To1_18_2> {
|
||||
|
||||
private final EnchantmentRewriter enchantmentRewriter = new EnchantmentRewriter(this);
|
||||
|
||||
public BlockItemPacketRewriter1_19(final Protocol1_19To1_18_2 protocol) {
|
||||
super(protocol, Types.ITEM1_13_2, Types.ITEM1_13_2_ARRAY);
|
||||
}
|
||||
@@ -208,6 +211,11 @@ public final class BlockItemPacketRewriter1_19 extends BackwardsItemRewriter<Cli
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
enchantmentRewriter.registerEnchantment("minecraft:swift_sneak", "§7Swift Sneak");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToClient(final UserConnection connection, final Item item) {
|
||||
if (item == null) return null;
|
||||
@@ -232,6 +240,8 @@ public final class BlockItemPacketRewriter1_19 extends BackwardsItemRewriter<Cli
|
||||
lodestonePosTag.putInt("X", position.x());
|
||||
lodestonePosTag.putInt("Y", position.y());
|
||||
lodestonePosTag.putInt("Z", position.z());
|
||||
|
||||
enchantmentRewriter.handleToClient(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -252,6 +262,8 @@ public final class BlockItemPacketRewriter1_19 extends BackwardsItemRewriter<Cli
|
||||
item.setTag(null);
|
||||
}
|
||||
}
|
||||
|
||||
enchantmentRewriter.handleToServer(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -84,7 +84,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
|
||||
return;
|
||||
} else if (entityType == EntityTypes1_19.PAINTING) {
|
||||
wrapper.cancel();
|
||||
// The entity has been tracked, now we wait for the metadata packet
|
||||
// The entity has been tracked, now we wait for the entity data packet
|
||||
final int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||
final StoredEntityData entityData = tracker(wrapper.user()).entityData(entityId);
|
||||
final BlockPosition position = new BlockPosition(wrapper.get(Types.DOUBLE, 0).intValue(), wrapper.get(Types.DOUBLE, 1).intValue(), wrapper.get(Types.DOUBLE, 2).intValue());
|
||||
@@ -202,7 +202,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
|
||||
map(Types.BYTE); // Previous gamemode
|
||||
map(Types.BOOLEAN); // Debug
|
||||
map(Types.BOOLEAN); // Flat
|
||||
map(Types.BOOLEAN); // Keep player data
|
||||
map(Types.BOOLEAN); // Keep player attributes
|
||||
handler(wrapper -> {
|
||||
final GlobalBlockPosition lastDeathPosition = wrapper.read(Types.OPTIONAL_GLOBAL_POSITION);
|
||||
if (lastDeathPosition != null) {
|
||||
@@ -247,14 +247,14 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
if (meta.dataType().typeId() <= Types1_18.ENTITY_DATA_TYPES.poseType.typeId()) {
|
||||
meta.setDataType(Types1_18.ENTITY_DATA_TYPES.byId(meta.dataType().typeId()));
|
||||
filter().handler((event, data) -> {
|
||||
if (data.dataType().typeId() <= Types1_18.ENTITY_DATA_TYPES.poseType.typeId()) {
|
||||
data.setDataType(Types1_18.ENTITY_DATA_TYPES.byId(data.dataType().typeId()));
|
||||
}
|
||||
|
||||
final EntityDataType type = meta.dataType();
|
||||
final EntityDataType type = data.dataType();
|
||||
if (type == Types1_18.ENTITY_DATA_TYPES.particleType) {
|
||||
final Particle particle = (Particle) meta.getValue();
|
||||
final Particle particle = (Particle) data.getValue();
|
||||
final ParticleMappings particleMappings = protocol.getMappingData().getParticleMappings();
|
||||
if (particle.id() == particleMappings.id("sculk_charge")) {
|
||||
//TODO
|
||||
@@ -272,19 +272,19 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
|
||||
|
||||
rewriteParticle(event.user(), particle);
|
||||
} else if (type == Types1_18.ENTITY_DATA_TYPES.poseType) {
|
||||
final int pose = meta.value();
|
||||
final int pose = data.value();
|
||||
if (pose >= 8) {
|
||||
// Croaking, using_tongue, roaring, sniffing, emerging, digging -> standing -> standing
|
||||
meta.setValue(0);
|
||||
data.setValue(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(Types1_18.ENTITY_DATA_TYPES.itemType, null, Types1_18.ENTITY_DATA_TYPES.optionalBlockStateType, null,
|
||||
registerEntityDataTypeHandler(Types1_18.ENTITY_DATA_TYPES.itemType, null, Types1_18.ENTITY_DATA_TYPES.optionalBlockStateType, null,
|
||||
Types1_18.ENTITY_DATA_TYPES.componentType, Types1_18.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
registerBlockStateHandler(EntityTypes1_19.ABSTRACT_MINECART, 11);
|
||||
|
||||
filter().type(EntityTypes1_19.PAINTING).index(8).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_19.PAINTING).index(8).handler((event, data) -> {
|
||||
event.cancel();
|
||||
|
||||
final StoredEntityData entityData = tracker(event.user()).entityDataIfPresent(event.entityId());
|
||||
@@ -293,7 +293,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
|
||||
final PacketWrapper packet = PacketWrapper.create(ClientboundPackets1_18.ADD_PAINTING, event.user());
|
||||
packet.write(Types.VAR_INT, storedPainting.entityId());
|
||||
packet.write(Types.UUID, storedPainting.uuid());
|
||||
packet.write(Types.VAR_INT, meta.value());
|
||||
packet.write(Types.VAR_INT, data.value());
|
||||
packet.write(Types.BLOCK_POSITION1_14, storedPainting.position());
|
||||
packet.write(Types.BYTE, storedPainting.direction());
|
||||
try {
|
||||
@@ -305,7 +305,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_19.CAT).index(19).handler((event, meta) -> meta.setDataType(Types1_18.ENTITY_DATA_TYPES.varIntType));
|
||||
filter().type(EntityTypes1_19.CAT).index(19).handler((event, data) -> data.setDataType(Types1_18.ENTITY_DATA_TYPES.varIntType));
|
||||
|
||||
filter().type(EntityTypes1_19.FROG).cancel(16); // Age
|
||||
filter().type(EntityTypes1_19.FROG).cancel(17); // Variant
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
|
||||
public class AdvancementCriteriaProvider implements Provider {
|
||||
|
||||
public String[] getCriteria(final String advacementKey) {
|
||||
public String[] getCriteria(final String advancementKey) {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
+12
-172
@@ -54,7 +54,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_19_4, Protocol1_20_2To1_20> {
|
||||
|
||||
public BlockItemPacketRewriter1_20_2(final Protocol1_20_2To1_20 protocol) {
|
||||
super(protocol, Types.ITEM1_20_2, Types.ITEM1_20_2_ARRAY);
|
||||
super(protocol, Types.ITEM1_20_2, Types.ITEM1_20_2_ARRAY, Types.ITEM1_13_2, Types.ITEM1_13_2_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,6 +65,13 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_20_2.SECTION_BLOCKS_UPDATE);
|
||||
blockRewriter.registerLevelEvent(ClientboundPackets1_20_2.LEVEL_EVENT, 1010, 2001);
|
||||
|
||||
registerSetContent1_17_1(ClientboundPackets1_20_2.CONTAINER_SET_CONTENT);
|
||||
registerSetSlot1_17_1(ClientboundPackets1_20_2.CONTAINER_SET_SLOT);
|
||||
registerContainerClick1_17_1(ServerboundPackets1_19_4.CONTAINER_CLICK);
|
||||
registerMerchantOffers1_19(ClientboundPackets1_20_2.MERCHANT_OFFERS);
|
||||
registerSetCreativeModeSlot(ServerboundPackets1_19_4.SET_CREATIVE_MODE_SLOT);
|
||||
registerLevelParticles1_19(ClientboundPackets1_20_2.LEVEL_PARTICLES);
|
||||
|
||||
protocol.cancelClientbound(ClientboundPackets1_20_2.CHUNK_BATCH_START);
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.CHUNK_BATCH_FINISHED, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
@@ -145,32 +152,6 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
}
|
||||
});
|
||||
|
||||
// Replace the NBT type everywhere
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.CONTAINER_SET_CONTENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UNSIGNED_BYTE); // Window id
|
||||
map(Types.VAR_INT); // State id
|
||||
handler(wrapper -> {
|
||||
final Item[] items = wrapper.read(Types.ITEM1_20_2_ARRAY);
|
||||
for (final Item item : items) {
|
||||
handleItemToClient(wrapper.user(), item);
|
||||
}
|
||||
|
||||
wrapper.write(Types.ITEM1_13_2_ARRAY, items);
|
||||
wrapper.write(Types.ITEM1_13_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2))); // Carried item
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.CONTAINER_SET_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UNSIGNED_BYTE); // Window id
|
||||
map(Types.VAR_INT); // State id
|
||||
map(Types.SHORT); // Slot id
|
||||
handler(wrapper -> wrapper.write(Types.ITEM1_13_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2))));
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.UPDATE_ADVANCEMENTS, wrapper -> {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Reset/clear
|
||||
final int size = wrapper.passthrough(Types.VAR_INT);
|
||||
@@ -216,159 +197,18 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter<C
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_19_4.CONTAINER_CLICK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UNSIGNED_BYTE); // Window Id
|
||||
map(Types.VAR_INT); // State id
|
||||
map(Types.SHORT); // Slot
|
||||
map(Types.BYTE); // Button
|
||||
map(Types.VAR_INT); // Mode
|
||||
|
||||
handler(wrapper -> {
|
||||
// Affected items
|
||||
final int length = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int i = 0; i < length; i++) {
|
||||
wrapper.passthrough(Types.SHORT); // Slot
|
||||
wrapper.write(Types.ITEM1_20_2, handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_13_2)));
|
||||
}
|
||||
|
||||
// Carried item
|
||||
wrapper.write(Types.ITEM1_20_2, handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_13_2)));
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.MERCHANT_OFFERS, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Container id
|
||||
final int size = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Types.ITEM1_13_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2))); // Input
|
||||
wrapper.write(Types.ITEM1_13_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2))); // Output
|
||||
wrapper.write(Types.ITEM1_13_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2))); // Second Item
|
||||
|
||||
wrapper.passthrough(Types.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Types.INT); // Number of tools uses
|
||||
wrapper.passthrough(Types.INT); // Maximum number of trade uses
|
||||
wrapper.passthrough(Types.INT); // XP
|
||||
wrapper.passthrough(Types.INT); // Special price
|
||||
wrapper.passthrough(Types.FLOAT); // Price multiplier
|
||||
wrapper.passthrough(Types.INT); // Demand
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_19_4.SET_CREATIVE_MODE_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.SHORT); // 0 - Slot
|
||||
handler(wrapper -> wrapper.write(Types.ITEM1_20_2, handleItemToServer(wrapper.user(), wrapper.read(Types.ITEM1_13_2)))); // 1 - Clicked Item
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_20_2.LEVEL_PARTICLES, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // 0 - Particle ID
|
||||
map(Types.BOOLEAN); // 1 - Long Distance
|
||||
map(Types.DOUBLE); // 2 - X
|
||||
map(Types.DOUBLE); // 3 - Y
|
||||
map(Types.DOUBLE); // 4 - Z
|
||||
map(Types.FLOAT); // 5 - Offset X
|
||||
map(Types.FLOAT); // 6 - Offset Y
|
||||
map(Types.FLOAT); // 7 - Offset Z
|
||||
map(Types.FLOAT); // 8 - Particle Data
|
||||
map(Types.INT); // 9 - Particle Count
|
||||
handler(wrapper -> {
|
||||
final int id = wrapper.get(Types.VAR_INT, 0);
|
||||
final ParticleMappings mappings = Protocol1_20_2To1_20.MAPPINGS.getParticleMappings();
|
||||
if (mappings.isBlockParticle(id)) {
|
||||
final int data = wrapper.read(Types.VAR_INT);
|
||||
wrapper.write(Types.VAR_INT, protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (mappings.isItemParticle(id)) {
|
||||
wrapper.write(Types.ITEM1_13_2, handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_20_2)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new RecipeRewriter1_20_2<>(protocol) {
|
||||
@Override
|
||||
public void handleCraftingShapeless(final PacketWrapper wrapper) {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.passthrough(Types.VAR_INT); // Crafting book category
|
||||
handleIngredients(wrapper);
|
||||
|
||||
final Item result = wrapper.read(itemType());
|
||||
rewrite(wrapper.user(), result);
|
||||
wrapper.write(Types.ITEM1_13_2, result);
|
||||
protected Type<Item> mappedItemType() {
|
||||
return BlockItemPacketRewriter1_20_2.this.mappedItemType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSmelting(final PacketWrapper wrapper) {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.passthrough(Types.VAR_INT); // Crafting book category
|
||||
handleIngredient(wrapper);
|
||||
|
||||
final Item result = wrapper.read(itemType());
|
||||
rewrite(wrapper.user(), result);
|
||||
wrapper.write(Types.ITEM1_13_2, result);
|
||||
|
||||
wrapper.passthrough(Types.FLOAT); // EXP
|
||||
wrapper.passthrough(Types.VAR_INT); // Cooking time
|
||||
protected Type<Item[]> mappedItemArrayType() {
|
||||
return BlockItemPacketRewriter1_20_2.this.mappedItemArrayType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) {
|
||||
final int ingredients = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT);
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.passthrough(Types.VAR_INT); // Crafting book category
|
||||
for (int i = 0; i < ingredients; i++) {
|
||||
handleIngredient(wrapper);
|
||||
}
|
||||
|
||||
final Item result = wrapper.read(itemType());
|
||||
rewrite(wrapper.user(), result);
|
||||
wrapper.write(Types.ITEM1_13_2, result);
|
||||
|
||||
wrapper.passthrough(Types.BOOLEAN); // Show notification
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleStonecutting(final PacketWrapper wrapper) {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
handleIngredient(wrapper);
|
||||
|
||||
final Item result = wrapper.read(itemType());
|
||||
rewrite(wrapper.user(), result);
|
||||
wrapper.write(Types.ITEM1_13_2, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSmithing(final PacketWrapper wrapper) {
|
||||
handleIngredient(wrapper); // Base
|
||||
handleIngredient(wrapper); // Addition
|
||||
|
||||
final Item result = wrapper.read(itemType());
|
||||
rewrite(wrapper.user(), result);
|
||||
wrapper.write(Types.ITEM1_13_2, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSmithingTransform(final PacketWrapper wrapper) {
|
||||
handleIngredient(wrapper); // Template
|
||||
handleIngredient(wrapper); // Base
|
||||
handleIngredient(wrapper); // Additions
|
||||
|
||||
final Item result = wrapper.read(itemType());
|
||||
rewrite(wrapper.user(), result);
|
||||
wrapper.write(Types.ITEM1_13_2, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleIngredient(final PacketWrapper wrapper) {
|
||||
final Item[] items = wrapper.read(itemArrayType());
|
||||
wrapper.write(Types.ITEM1_13_2_ARRAY, items);
|
||||
for (final Item item : items) {
|
||||
rewrite(wrapper.user(), item);
|
||||
}
|
||||
}
|
||||
}.register(ClientboundPackets1_20_2.UPDATE_RECIPES);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -198,8 +198,8 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> meta.setDataType(Types1_20.ENTITY_DATA_TYPES.byId(meta.dataType().typeId())));
|
||||
registerMetaTypeHandler(Types1_20.ENTITY_DATA_TYPES.itemType, Types1_20.ENTITY_DATA_TYPES.blockStateType, Types1_20.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_20.ENTITY_DATA_TYPES.particleType, null, null);
|
||||
filter().handler((event, data) -> data.setDataType(Types1_20.ENTITY_DATA_TYPES.byId(data.dataType().typeId())));
|
||||
registerEntityDataTypeHandler(Types1_20.ENTITY_DATA_TYPES.itemType, Types1_20.ENTITY_DATA_TYPES.blockStateType, Types1_20.ENTITY_DATA_TYPES.optionalBlockStateType, Types1_20.ENTITY_DATA_TYPES.particleType, null, null);
|
||||
registerBlockStateHandler(EntityTypes1_19_4.ABSTRACT_MINECART, 11);
|
||||
|
||||
filter().type(EntityTypes1_19_4.DISPLAY).removeIndex(10);
|
||||
|
||||
+9
-10
@@ -27,7 +27,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_3;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
|
||||
@@ -44,9 +43,9 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerSpawnTracker(ClientboundPackets1_20_3.ADD_ENTITY);
|
||||
registerSetEntityData(ClientboundPackets1_20_3.SET_ENTITY_DATA, Types1_20_3.ENTITY_DATA_LIST, Types1_20_2.ENTITY_DATA_LIST);
|
||||
registerRemoveEntities(ClientboundPackets1_20_3.REMOVE_ENTITIES);
|
||||
registerTrackerWithData1_19(ClientboundPackets1_20_3.ADD_ENTITY, EntityTypes1_20_3.FALLING_BLOCK);
|
||||
|
||||
protocol.registerClientbound(ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -97,16 +96,16 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter<Clientbound
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
final EntityDataType type = meta.dataType();
|
||||
filter().handler((event, data) -> {
|
||||
final EntityDataType type = data.dataType();
|
||||
if (type == Types1_20_3.ENTITY_DATA_TYPES.componentType) {
|
||||
meta.setTypeAndValue(Types1_20_2.ENTITY_DATA_TYPES.componentType, ComponentUtil.tagToJson(meta.value()));
|
||||
data.setTypeAndValue(Types1_20_2.ENTITY_DATA_TYPES.componentType, ComponentUtil.tagToJson(data.value()));
|
||||
return;
|
||||
} else if (type == Types1_20_3.ENTITY_DATA_TYPES.optionalComponentType) {
|
||||
meta.setTypeAndValue(Types1_20_2.ENTITY_DATA_TYPES.optionalComponentType, ComponentUtil.tagToJson(meta.value()));
|
||||
data.setTypeAndValue(Types1_20_2.ENTITY_DATA_TYPES.optionalComponentType, ComponentUtil.tagToJson(data.value()));
|
||||
return;
|
||||
} else if (type == Types1_20_3.ENTITY_DATA_TYPES.particleType) {
|
||||
final Particle particle = (Particle) meta.getValue();
|
||||
final Particle particle = (Particle) data.getValue();
|
||||
final ParticleMappings particleMappings = protocol.getMappingData().getParticleMappings();
|
||||
if (particle.id() == particleMappings.id("vibration")) {
|
||||
// Change the type of the position source type argument
|
||||
@@ -118,16 +117,16 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter<Clientbound
|
||||
}
|
||||
}
|
||||
} else if (type == Types1_20_3.ENTITY_DATA_TYPES.poseType) {
|
||||
final int pose = meta.value();
|
||||
final int pose = data.value();
|
||||
if (pose >= 15) {
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
meta.setDataType(Types1_20_2.ENTITY_DATA_TYPES.byId(type.typeId()));
|
||||
data.setDataType(Types1_20_2.ENTITY_DATA_TYPES.byId(type.typeId()));
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(
|
||||
registerEntityDataTypeHandler(
|
||||
Types1_20_2.ENTITY_DATA_TYPES.itemType,
|
||||
Types1_20_2.ENTITY_DATA_TYPES.blockStateType,
|
||||
Types1_20_2.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
|
||||
+2
@@ -29,6 +29,7 @@ import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.RegistryData
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.SecureChatStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
@@ -77,6 +78,7 @@ public final class Protocol1_20_5To1_20_3 extends BackwardsProtocol<ClientboundP
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
tagRewriter.addEmptyTag(RegistryType.ITEM, "minecraft:axolotl_tempt_items");
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_20_5.UPDATE_TAGS);
|
||||
registerClientbound(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS, wrapper -> {
|
||||
// Send off registry data first, needed for tags
|
||||
|
||||
+17
@@ -186,6 +186,23 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_20_5.MAP_ITEM_DATA, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Map id
|
||||
wrapper.passthrough(Types.BYTE); // Scale
|
||||
wrapper.passthrough(Types.BOOLEAN); // Locked
|
||||
if (wrapper.passthrough(Types.BOOLEAN)) {
|
||||
final int icons = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int i = 0; i < icons; i++) {
|
||||
final int decorationType = wrapper.read(Types.VAR_INT);
|
||||
wrapper.write(Types.VAR_INT, decorationType == 34 ? 32 : decorationType); // Trial champer to jungle temple
|
||||
wrapper.passthrough(Types.BYTE); // X
|
||||
wrapper.passthrough(Types.BYTE); // Y
|
||||
wrapper.passthrough(Types.BYTE); // Rotation
|
||||
wrapper.passthrough(Types.OPTIONAL_TAG); // Display name
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final RecipeRewriter1_20_3<ClientboundPacket1_20_5> recipeRewriter = new RecipeRewriter1_20_3<>(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_20_5.UPDATE_RECIPES, wrapper -> {
|
||||
final int size = wrapper.passthrough(Types.VAR_INT);
|
||||
|
||||
+27
-30
@@ -30,7 +30,6 @@ import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.RegistryData
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.SecureChatStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.DimensionData;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
@@ -72,15 +71,16 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_20_5.SET_EQUIPMENT, wrapper -> {
|
||||
final int entityId = wrapper.passthrough(Types.VAR_INT); // Entity id
|
||||
final EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
byte slot;
|
||||
do {
|
||||
slot = wrapper.read(Types.BYTE);
|
||||
final Item item = protocol.getItemRewriter().handleItemToClient(wrapper.user(), wrapper.read(Types1_20_5.ITEM));
|
||||
|
||||
if (slot == 6) {
|
||||
final EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_20_5To1_20_3.class);
|
||||
slot = 4; // Map body slot index to chest slot index for horses
|
||||
final EntityType type = tracker.entityType(entityId);
|
||||
if (type != null && type.isOrHasParent(EntityTypes1_20_5.ABSTRACT_HORSE)) {
|
||||
slot = 4; // Map body slot index to chest slot index for horses
|
||||
}
|
||||
if (type != null && type.isOrHasParent(EntityTypes1_20_5.LLAMA)) {
|
||||
// Cancel equipment and set correct entity data instead
|
||||
wrapper.cancel();
|
||||
@@ -372,34 +372,43 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
color = item.identifier() - 445;
|
||||
}
|
||||
}
|
||||
final List<EntityData> metadataList = new ArrayList<>();
|
||||
metadataList.add(new EntityData(20, Types1_20_3.ENTITY_DATA_TYPES.varIntType, color));
|
||||
setEntityData.write(Types1_20_3.ENTITY_DATA_LIST, metadataList);
|
||||
final List<EntityData> entityDataList = new ArrayList<>();
|
||||
entityDataList.add(new EntityData(20, Types1_20_3.ENTITY_DATA_TYPES.varIntType, color));
|
||||
setEntityData.write(Types1_20_3.ENTITY_DATA_LIST, entityDataList);
|
||||
setEntityData.send(Protocol1_20_5To1_20_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapDataType(typeId -> {
|
||||
filter().handler((event, data) -> {
|
||||
final int typeId = data.dataType().typeId();
|
||||
if (typeId == Types1_20_5.ENTITY_DATA_TYPES.particlesType.typeId()) {
|
||||
// Handled with living entity
|
||||
return Types1_20_5.ENTITY_DATA_TYPES.particlesType;
|
||||
final Particle[] particles = data.value();
|
||||
int color = 0;
|
||||
for (final Particle particle : particles) {
|
||||
if (particle.id() == protocol.getMappingData().getParticleMappings().id("entity_effect")) {
|
||||
// Remove color argument, use one of them for the ambient particle color
|
||||
color = particle.<Integer>removeArgument(0).getValue();
|
||||
}
|
||||
}
|
||||
data.setTypeAndValue(Types1_20_3.ENTITY_DATA_TYPES.varIntType, removeAlpha(color));
|
||||
return;
|
||||
}
|
||||
|
||||
int id = typeId;
|
||||
if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType.typeId()) {
|
||||
if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.armadilloState.typeId()) {
|
||||
id--;
|
||||
}
|
||||
if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.armadilloState.typeId()) {
|
||||
if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType.typeId()) {
|
||||
id--;
|
||||
}
|
||||
if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.particlesType.typeId()) {
|
||||
id--;
|
||||
}
|
||||
return Types1_20_3.ENTITY_DATA_TYPES.byId(id);
|
||||
data.setDataType(Types1_20_3.ENTITY_DATA_TYPES.byId(id));
|
||||
});
|
||||
|
||||
registerMetaTypeHandler1_20_3(
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
Types1_20_3.ENTITY_DATA_TYPES.itemType,
|
||||
Types1_20_3.ENTITY_DATA_TYPES.blockStateType,
|
||||
Types1_20_3.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
@@ -410,23 +419,11 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
);
|
||||
registerBlockStateHandler(EntityTypes1_20_5.ABSTRACT_MINECART, 11);
|
||||
|
||||
filter().type(EntityTypes1_20_5.LIVING_ENTITY).index(10).handler((event, meta) -> {
|
||||
final Particle[] particles = meta.value();
|
||||
int color = 0;
|
||||
for (final Particle particle : particles) {
|
||||
if (particle.id() == protocol.getMappingData().getParticleMappings().id("entity_effect")) {
|
||||
// Remove color argument, use one of them for the ambient particle color
|
||||
color = particle.<Integer>removeArgument(0).getValue();
|
||||
}
|
||||
}
|
||||
meta.setTypeAndValue(Types1_20_3.ENTITY_DATA_TYPES.varIntType, removeAlpha(color));
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_20_5.AREA_EFFECT_CLOUD).addIndex(9); // Color
|
||||
filter().type(EntityTypes1_20_5.AREA_EFFECT_CLOUD).index(11).handler((event, meta) -> {
|
||||
final Particle particle = meta.value();
|
||||
filter().type(EntityTypes1_20_5.AREA_EFFECT_CLOUD).index(11).handler((event, data) -> {
|
||||
final Particle particle = data.value();
|
||||
if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) {
|
||||
// Move color to its own metadata
|
||||
// Move color to its own entity data
|
||||
final int color = particle.<Integer>removeArgument(0).getValue();
|
||||
event.createExtraData(new EntityData(9, Types1_20_3.ENTITY_DATA_TYPES.varIntType, removeAlpha(color)));
|
||||
}
|
||||
@@ -452,4 +449,4 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
public EntityType typeFromId(final int type) {
|
||||
return EntityTypes1_20_5.getTypeFromId(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-7
@@ -34,7 +34,7 @@ import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ServerboundPac
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import java.util.Arrays;
|
||||
import com.viaversion.viaversion.util.ArrayUtil;
|
||||
|
||||
public final class Protocol1_20To1_19_4 extends BackwardsProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_4, ServerboundPackets1_19_4, ServerboundPackets1_19_4> {
|
||||
|
||||
@@ -62,7 +62,6 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_19_4.AWARD_STATS);
|
||||
|
||||
//TODO open window
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SET_ACTION_BAR_TEXT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SET_TITLE_TEXT);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SET_SUBTITLE_TEXT);
|
||||
@@ -75,10 +74,7 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_4.UPDATE_ENABLED_FEATURES, wrapper -> {
|
||||
String[] enabledFeatures = wrapper.read(Types.STRING_ARRAY);
|
||||
final int length = enabledFeatures.length;
|
||||
enabledFeatures = Arrays.copyOf(enabledFeatures, length + 1);
|
||||
enabledFeatures[length] = "minecraft:update_1_20";
|
||||
wrapper.write(Types.STRING_ARRAY, enabledFeatures);
|
||||
wrapper.write(Types.STRING_ARRAY, ArrayUtil.add(enabledFeatures, "minecraft:update_1_20"));
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_4.PLAYER_COMBAT_END, wrapper -> {
|
||||
@@ -86,7 +82,7 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol<ClientboundPac
|
||||
wrapper.write(Types.INT, -1); // Killer ID - unused (who knows for how long?)
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_19_4.PLAYER_COMBAT_KILL, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Duration
|
||||
wrapper.passthrough(Types.VAR_INT); // Player ID
|
||||
wrapper.write(Types.INT, -1); // Killer ID - unused (who knows for how long?)
|
||||
translatableRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT));
|
||||
});
|
||||
|
||||
+7
-2
@@ -26,7 +26,6 @@ import com.viaversion.viaversion.api.minecraft.BlockPosition;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
@@ -86,7 +85,13 @@ public final class BlockItemPacketRewriter1_20 extends BackwardsItemRewriter<Cli
|
||||
}
|
||||
});
|
||||
|
||||
registerOpenScreen(ClientboundPackets1_19_4.OPEN_SCREEN);
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.OPEN_SCREEN, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Container id
|
||||
|
||||
handleMenuType(wrapper);
|
||||
protocol.getComponentRewriter().passthroughAndProcess(wrapper);
|
||||
});
|
||||
|
||||
registerCooldown(ClientboundPackets1_19_4.COOLDOWN);
|
||||
registerSetContent1_17_1(ClientboundPackets1_19_4.CONTAINER_SET_CONTENT);
|
||||
registerSetSlot1_17_1(ClientboundPackets1_19_4.CONTAINER_SET_SLOT);
|
||||
|
||||
+6
-8
@@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20;
|
||||
@@ -33,7 +32,6 @@ import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPac
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -124,13 +122,13 @@ public final class EntityPacketRewriter1_20 extends EntityRewriter<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> meta.setDataType(Types1_19_4.ENTITY_DATA_TYPES.byId(meta.dataType().typeId())));
|
||||
registerMetaTypeHandler(Types1_19_4.ENTITY_DATA_TYPES.itemType, Types1_19_4.ENTITY_DATA_TYPES.blockStateType, Types1_19_4.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
filter().handler((event, data) -> data.setDataType(Types1_19_4.ENTITY_DATA_TYPES.byId(data.dataType().typeId())));
|
||||
registerEntityDataTypeHandler(Types1_19_4.ENTITY_DATA_TYPES.itemType, Types1_19_4.ENTITY_DATA_TYPES.blockStateType, Types1_19_4.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
Types1_19_4.ENTITY_DATA_TYPES.particleType, Types1_19_4.ENTITY_DATA_TYPES.componentType, Types1_19_4.ENTITY_DATA_TYPES.optionalComponentType);
|
||||
registerBlockStateHandler(EntityTypes1_19_4.ABSTRACT_MINECART, 11);
|
||||
|
||||
// Rotate item display by 180 degrees around the Y axis
|
||||
filter().type(EntityTypes1_19_4.ITEM_DISPLAY).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_19_4.ITEM_DISPLAY).handler((event, data) -> {
|
||||
if (event.trackedEntity().hasSentEntityData() || event.hasExtraData()) {
|
||||
return;
|
||||
}
|
||||
@@ -139,9 +137,9 @@ public final class EntityPacketRewriter1_20 extends EntityRewriter<ClientboundPa
|
||||
event.createExtraData(new EntityData(12, Types1_19_4.ENTITY_DATA_TYPES.quaternionType, Y_FLIPPED_ROTATION));
|
||||
}
|
||||
});
|
||||
filter().type(EntityTypes1_19_4.ITEM_DISPLAY).index(12).handler((event, meta) -> {
|
||||
final Quaternion quaternion = meta.value();
|
||||
meta.setValue(rotateY180(quaternion));
|
||||
filter().type(EntityTypes1_19_4.ITEM_DISPLAY).index(12).handler((event, data) -> {
|
||||
final Quaternion quaternion = data.value();
|
||||
data.setValue(rotateY180(quaternion));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -25,6 +25,7 @@ import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.BlockItemPack
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.ComponentRewriter1_21;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.EntityPacketRewriter1_21;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.EnchantmentsPaintingsStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.PlayerRotationStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||
@@ -45,6 +46,7 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.util.ArrayUtil;
|
||||
|
||||
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
||||
|
||||
@@ -174,12 +176,18 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol<ClientboundPac
|
||||
wrapper.set(Types.VAR_INT, 1, newSize);
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundConfigurationPackets1_21.UPDATE_ENABLED_FEATURES, wrapper -> {
|
||||
final String[] enabledFeatures = wrapper.read(Types.STRING_ARRAY);
|
||||
wrapper.write(Types.STRING_ARRAY, ArrayUtil.add(enabledFeatures, "minecraft:update_1_21"));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final UserConnection user) {
|
||||
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_20_5.PLAYER));
|
||||
user.put(new EnchantmentsPaintingsStorage());
|
||||
user.put(new PlayerRotationStorage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+59
-12
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.ByteTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
@@ -26,6 +27,7 @@ import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.StructuredEnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.EnchantmentsPaintingsStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.PlayerRotationStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||
@@ -37,6 +39,8 @@ import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.mcstructs.text.components.StringComponent;
|
||||
import com.viaversion.viaversion.libs.mcstructs.text.components.TranslationComponent;
|
||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.Enchantments1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
||||
@@ -45,10 +49,12 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
|
||||
import com.viaversion.viaversion.util.SerializerVersion;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.downgradeItemData;
|
||||
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.resetRarityValues;
|
||||
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.updateItemData;
|
||||
|
||||
public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21, ServerboundPacket1_20_5, Protocol1_21To1_20_5> {
|
||||
@@ -76,10 +82,21 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
||||
registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK);
|
||||
registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS, Types1_21.ITEM_COST, Types1_20_5.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST);
|
||||
registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT);
|
||||
registerContainerSetData(ClientboundPackets1_21.CONTAINER_SET_DATA);
|
||||
registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
|
||||
registerExplosion(ClientboundPackets1_21.EXPLODE, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21.CONTAINER_SET_DATA, wrapper -> {
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // Container id
|
||||
final short property = wrapper.passthrough(Types.SHORT);
|
||||
if (property >= 4 && property <= 6) { // Enchantment hints
|
||||
final short enchantmentId = wrapper.read(Types.SHORT);
|
||||
final EnchantmentsPaintingsStorage storage = wrapper.user().get(EnchantmentsPaintingsStorage.class);
|
||||
final String key = storage.enchantments().idToKey(enchantmentId);
|
||||
final int mappedId = key != null ? Enchantments1_20_5.keyToId(key) : -1;
|
||||
wrapper.write(Types.SHORT, (short) mappedId);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21.HORSE_SCREEN_OPEN, wrapper -> {
|
||||
wrapper.passthrough(Types.UNSIGNED_BYTE); // Container id
|
||||
|
||||
@@ -111,8 +128,10 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
||||
protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM, wrapper -> {
|
||||
wrapper.passthrough(Types.VAR_INT); // Hand
|
||||
wrapper.passthrough(Types.VAR_INT); // Sequence
|
||||
wrapper.write(Types.FLOAT, 0f); // Y rotation
|
||||
wrapper.write(Types.FLOAT, 0f); // X rotation
|
||||
|
||||
final PlayerRotationStorage rotation = wrapper.user().get(PlayerRotationStorage.class);
|
||||
wrapper.write(Types.FLOAT, rotation.yaw());
|
||||
wrapper.write(Types.FLOAT, rotation.pitch());
|
||||
});
|
||||
|
||||
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_21.UPDATE_RECIPES);
|
||||
@@ -139,17 +158,32 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
||||
return new StringTag("Unknown enchantment");
|
||||
}
|
||||
|
||||
final CompoundTag fullDescription = new CompoundTag();
|
||||
fullDescription.putString("translate", "%s " + EnchantmentRewriter.getRomanNumber(level));
|
||||
fullDescription.put("with", new ListTag<>(Arrays.asList(description)));
|
||||
return fullDescription;
|
||||
final var component = SerializerVersion.V1_20_5.toComponent(description);
|
||||
component.getSiblings().add(new StringComponent(" "));
|
||||
component.getSiblings().add(new TranslationComponent(EnchantmentRewriter.ENCHANTMENT_LEVEL_TRANSLATION.formatted(level)));
|
||||
|
||||
return SerializerVersion.V1_20_5.toTag(component);
|
||||
};
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false);
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true);
|
||||
|
||||
final int identifier = item.identifier();
|
||||
|
||||
// Order is important
|
||||
super.handleItemToClient(connection, item);
|
||||
downgradeItemData(item);
|
||||
|
||||
final StructuredDataContainer dataContainer = item.dataContainer();
|
||||
if (dataContainer.contains(StructuredDataKey.RARITY)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
// Change rarity of trident and piglin banner pattern
|
||||
final boolean trident = identifier == 1188;
|
||||
if (trident || identifier == 1200) {
|
||||
dataContainer.set(StructuredDataKey.RARITY, trident ? 3 : 1); // Epic or Uncommon
|
||||
saveTag(createCustomTag(item), new ByteTag(true), "rarity");
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -173,6 +207,7 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
||||
// Order is important
|
||||
super.handleItemToServer(connection, item);
|
||||
updateItemData(item);
|
||||
resetRarityValues(item, nbtTagName("rarity"));
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -183,7 +218,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
||||
}
|
||||
|
||||
final Enchantments enchantments = enchantmentsData.value();
|
||||
for (final Int2IntMap.Entry entry : new ArrayList<>(enchantments.enchantments().int2IntEntrySet())) {
|
||||
final List<PendingIdChange> updatedIds = new ArrayList<>();
|
||||
for (final Int2IntMap.Entry entry : enchantments.enchantments().int2IntEntrySet()) {
|
||||
final int id = entry.getIntKey();
|
||||
final String enchantmentKey = Enchantments1_20_5.idToKey(id);
|
||||
if (enchantmentKey == null) {
|
||||
@@ -192,9 +228,20 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
||||
|
||||
final int mappedId = storage.enchantments().keyToId(enchantmentKey);
|
||||
if (id != mappedId) {
|
||||
enchantments.enchantments().remove(id);
|
||||
enchantments.enchantments().put(mappedId, entry.getIntValue());
|
||||
final int level = entry.getIntValue();
|
||||
updatedIds.add(new PendingIdChange(id, mappedId, level));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove first, then add updated entries
|
||||
for (final PendingIdChange change : updatedIds) {
|
||||
enchantments.remove(change.id);
|
||||
}
|
||||
for (final PendingIdChange change : updatedIds) {
|
||||
enchantments.add(change.mappedId, change.level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record PendingIdChange(int id, int mappedId, int level) {
|
||||
}
|
||||
}
|
||||
+33
-11
@@ -37,19 +37,41 @@ public final class ComponentRewriter1_21 extends TranslatableRewriter<Clientboun
|
||||
super(protocol, ReadType.NBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleShowItem(final UserConnection connection, final CompoundTag componentsTag) {
|
||||
final CompoundTag attributeModifiers = TagUtil.getNamespacedCompoundTag(componentsTag, "attribute_modifiers");
|
||||
if (attributeModifiers != null) {
|
||||
final ListTag<CompoundTag> modifiers = attributeModifiers.getListTag("modifiers", CompoundTag.class);
|
||||
for (final CompoundTag modifier : modifiers) {
|
||||
final String id = modifier.getString("id");
|
||||
final UUID uuid = Protocol1_20_5To1_21.mapAttributeId(id);
|
||||
final String name = AttributeModifierMappings1_21.idToName(id);
|
||||
modifier.put("uuid", new IntArrayTag(UUIDUtil.toIntArray(uuid)));
|
||||
modifier.putString("name", name != null ? name : id);
|
||||
private void convertAttributeModifiersComponent(final CompoundTag tag) {
|
||||
final CompoundTag attributeModifiers = TagUtil.getNamespacedCompoundTag(tag, "attribute_modifiers");
|
||||
if (attributeModifiers == null) {
|
||||
return;
|
||||
}
|
||||
final ListTag<CompoundTag> modifiers = attributeModifiers.getListTag("modifiers", CompoundTag.class);
|
||||
for (final CompoundTag modifier : modifiers) {
|
||||
final String id = modifier.getString("id");
|
||||
final UUID uuid = Protocol1_20_5To1_21.mapAttributeId(id);
|
||||
final String name = AttributeModifierMappings1_21.idToName(id);
|
||||
modifier.put("uuid", new IntArrayTag(UUIDUtil.toIntArray(uuid)));
|
||||
modifier.putString("name", name != null ? name : id);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleContainerComponent(final CompoundTag tag) {
|
||||
final ListTag<CompoundTag> container = TagUtil.getNamespacedCompoundTagList(tag, "container");
|
||||
if (container == null) {
|
||||
return;
|
||||
}
|
||||
for (final CompoundTag entryTag : container) {
|
||||
final CompoundTag itemTag = entryTag.getCompoundTag("item");
|
||||
|
||||
final CompoundTag componentsTag = itemTag.getCompoundTag("components");
|
||||
if (componentsTag != null) {
|
||||
convertAttributeModifiersComponent(componentsTag);
|
||||
handleContainerComponent(componentsTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleShowItem(final UserConnection connection, final CompoundTag componentsTag) {
|
||||
convertAttributeModifiersComponent(componentsTag);
|
||||
handleContainerComponent(componentsTag);
|
||||
|
||||
TagUtil.removeNamespaced(componentsTag, "jukebox_playable");
|
||||
}
|
||||
|
||||
+21
-1
@@ -22,6 +22,7 @@ import com.viaversion.nbt.tag.Tag;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.EnchantmentsPaintingsStorage;
|
||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.PlayerRotationStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
@@ -29,10 +30,12 @@ import com.viaversion.viaversion.api.minecraft.WolfVariant;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.Paintings1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
||||
@@ -123,6 +126,23 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
|
||||
final String world = wrapper.passthrough(Types.STRING);
|
||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world); // Tracks world height and name for chunk data and entity (un)tracking
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_POS_ROT, wrapper -> {
|
||||
wrapper.passthrough(Types.DOUBLE); // X
|
||||
wrapper.passthrough(Types.DOUBLE); // Y
|
||||
wrapper.passthrough(Types.DOUBLE); // Z
|
||||
|
||||
storePlayerRotation(wrapper);
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_ROT, this::storePlayerRotation);
|
||||
}
|
||||
|
||||
private void storePlayerRotation(final PacketWrapper wrapper) {
|
||||
final float yaw = wrapper.passthrough(Types.FLOAT);
|
||||
final float pitch = wrapper.passthrough(Types.FLOAT);
|
||||
|
||||
wrapper.user().get(PlayerRotationStorage.class).setRotation(yaw, pitch);
|
||||
}
|
||||
|
||||
private int[] paintingMappingsForEntries(final RegistryEntry[] entries) {
|
||||
@@ -176,7 +196,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
|
||||
data.setDataType(Types1_20_5.ENTITY_DATA_TYPES.byId(type.typeId()));
|
||||
}
|
||||
});
|
||||
registerMetaTypeHandler1_20_3(
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
Types1_20_5.ENTITY_DATA_TYPES.itemType,
|
||||
Types1_20_5.ENTITY_DATA_TYPES.blockStateType,
|
||||
Types1_20_5.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public final class PlayerRotationStorage implements StorableObject {
|
||||
|
||||
private float yaw, pitch;
|
||||
|
||||
public void setRotation(final float yaw, final float pitch) {
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public float yaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public float pitch() {
|
||||
return pitch;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,15 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.utils;
|
||||
|
||||
import com.viaversion.viaversion.libs.mcstructs.text.ATextComponent;
|
||||
import com.viaversion.viaversion.libs.mcstructs.text.Style;
|
||||
import com.viaversion.viaversion.libs.mcstructs.text.components.TranslationComponent;
|
||||
import com.viaversion.viaversion.libs.mcstructs.text.serializer.LegacyStringDeserializer;
|
||||
import com.viaversion.viaversion.util.SerializerVersion;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class ChatUtil {
|
||||
@@ -30,6 +36,23 @@ public final class ChatUtil {
|
||||
return removeUnusedColor(legacy, defaultColor, false);
|
||||
}
|
||||
|
||||
public static String legacyToJsonString(String legacy, String translation, boolean itemData) {
|
||||
return legacyToJsonString(legacy, text -> {
|
||||
text.append(" ");
|
||||
text.append(new TranslationComponent(translation));
|
||||
}, itemData);
|
||||
}
|
||||
|
||||
public static String legacyToJsonString(String legacy, Consumer<ATextComponent> consumer, boolean itemData) {
|
||||
final ATextComponent component = LegacyStringDeserializer.parse(legacy, true);
|
||||
consumer.accept(component);
|
||||
|
||||
if (itemData) {
|
||||
component.setParentStyle((new Style()).setItalic(false));
|
||||
}
|
||||
return SerializerVersion.V1_12.toString(component);
|
||||
}
|
||||
|
||||
private static class ChatFormattingState {
|
||||
private final Set<Character> formatting;
|
||||
private final char defaultColor;
|
||||
|
||||
@@ -21,5 +21,12 @@ fix-formatted-inventory-titles: true
|
||||
# This only takes effect for ids in the short range. Useful for anticheat compatibility.
|
||||
handle-pings-as-inv-acknowledgements: false
|
||||
#
|
||||
# Adds bedrock blocks at y=0 for sub 1.17 clients. This may allow for weird interactions due to sending fake blocks.
|
||||
bedrock-at-y-0: false
|
||||
#
|
||||
# Shows sculk shriekers as crying obsidian for 1.18.2 clients on 1.19+ servers. This fixes collision and block breaking issues.
|
||||
# If disabled, the client will see them as end portal frames.
|
||||
sculk-shriekers-to-crying-obsidian: true
|
||||
#
|
||||
# Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+).
|
||||
suppress-emulation-warnings: false
|
||||
Binary file not shown.
@@ -11,41 +11,30 @@
|
||||
"attribute.name.player.submerged_mining_speed": "Submerged Mining Speed",
|
||||
"attribute.name.player.sweeping_damage_ratio": "Sweeping Damage Ratio",
|
||||
"gamerule.entitiesWithPassengersCanUsePortals": "Entities with passengers can use portals",
|
||||
"gamerule.entitiesWithPassengersCanUsePortals.description": "Allow entities with passengers to teleport through nether portals, end portals and end gateways.",
|
||||
"gamerule.entitiesWithPassengersCanUsePortals.description": "Allow entities with passengers to teleport through Nether Portals, End Portals, and End Gateways.",
|
||||
"gui.abuseReport.attestation": "By submitting this report, you confirm that the information you have provided is accurate and complete to the best of your knowledge.",
|
||||
"gui.abuseReport.send.not_attested": "Please read the text above and tick the checkbox to be able to send the report",
|
||||
"gui.fileDropFailure.detail": "Rejected %d files",
|
||||
"gui.fileDropFailure.title": "Failed to add files",
|
||||
"gui.open_report_dir": "Open Report Directory",
|
||||
"gui.report_to_server": "Report To Server",
|
||||
"item.minecraft.music_disc_creator": "Music Disc",
|
||||
"item.minecraft.music_disc_creator_music_box": "Music Disc",
|
||||
"item.minecraft.music_disc_creator_music_box.desc": "Lena Raine - Creator (Music Box)",
|
||||
"item.minecraft.music_disc_creator.desc": "Lena Raine - Creator",
|
||||
"item.minecraft.music_disc_precipice": "Music Disc",
|
||||
"item.minecraft.music_disc_precipice.desc": "Aaron Cherof - Precipice",
|
||||
"item.modifiers.any": "When equipped:",
|
||||
"item.modifiers.armor": "When worn:",
|
||||
"item.modifiers.hand": "When held:",
|
||||
"jukebox_song.minecraft.5": "Samuel �berg - 5",
|
||||
"jukebox_song.minecraft.11": "C418 - 11",
|
||||
"jukebox_song.minecraft.13": "C418 - 13",
|
||||
"jukebox_song.minecraft.blocks": "C418 - blocks",
|
||||
"jukebox_song.minecraft.cat": "C418 - cat",
|
||||
"jukebox_song.minecraft.chirp": "C418 - chirp",
|
||||
"jukebox_song.minecraft.creator": "Lena Raine - Creator",
|
||||
"jukebox_song.minecraft.creator_music_box": "Lena Raine - Creator (Music Box)",
|
||||
"jukebox_song.minecraft.far": "C418 - far",
|
||||
"jukebox_song.minecraft.mall": "C418 - mall",
|
||||
"jukebox_song.minecraft.mellohi": "C418 - mellohi",
|
||||
"jukebox_song.minecraft.otherside": "Lena Raine - otherside",
|
||||
"jukebox_song.minecraft.pigstep": "Lena Raine - Pigstep",
|
||||
"jukebox_song.minecraft.precipice": "Aaron Cherof - Precipice",
|
||||
"jukebox_song.minecraft.relic": "Aaron Cherof - Relic",
|
||||
"jukebox_song.minecraft.stal": "C418 - stal",
|
||||
"jukebox_song.minecraft.strad": "C418 - strad",
|
||||
"jukebox_song.minecraft.wait": "C418 - wait",
|
||||
"jukebox_song.minecraft.ward": "C418 - ward",
|
||||
"known_server_link.announcements": "Announcements",
|
||||
"known_server_link.community": "Community",
|
||||
"known_server_link.community_guidelines": "Community Guidelines",
|
||||
"known_server_link.feedback": "Feedback",
|
||||
"known_server_link.forums": "Forums",
|
||||
"known_server_link.news": "News",
|
||||
"known_server_link.report_bug": "Report Server Bug",
|
||||
"mco.compatibility.incompatible.popup.title": "Incompatible version",
|
||||
"known_server_link.support": "Support",
|
||||
"known_server_link.website": "Website",
|
||||
"mco.compatibility.incompatible.releaseType.popup.message": "The world you are trying to join is incompatible with the version you are on.",
|
||||
"mco.compatibility.incompatible.series.popup.message": "This world was last played in version %s; you are on version %s.\n\nThese series are not compatible with each other. A new world is needed to play on this version.",
|
||||
"mco.compatibility.upgrade.friend.description": "This world was last played in version %s; you are on version %s.\n\nA backup of the world will be saved under \"World Backups\".\n\nThe owner of the Realm can restore the world if needed.",
|
||||
@@ -57,53 +46,38 @@
|
||||
"menu.server_links": "Server Links...",
|
||||
"menu.server_links.title": "Server Links",
|
||||
"options.realmsNotifications.tooltip": "Fetches Realms news and invites in the title screen and displays their respective icon on the Realms button.",
|
||||
"painting.minecraft.backyard.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.backyard.title": "Backyard",
|
||||
"painting.minecraft.baroque.author": "Sarah Boeving",
|
||||
"painting.minecraft.baroque.title": "Baroque",
|
||||
"painting.minecraft.bouquet.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.bouquet.title": "Bouquet",
|
||||
"painting.minecraft.cavebird.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.cavebird.title": "Cavebird",
|
||||
"painting.minecraft.changing.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.changing.title": "Changing",
|
||||
"painting.minecraft.cotan.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.cotan.title": "Cot�n",
|
||||
"painting.minecraft.endboss.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.endboss.title": "Endboss",
|
||||
"painting.minecraft.fern.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.fern.title": "Fern",
|
||||
"painting.minecraft.finding.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.finding.title": "Finding",
|
||||
"painting.minecraft.humble.author": "Sarah Boeving",
|
||||
"painting.minecraft.humble.title": "Humble",
|
||||
"painting.minecraft.lowmist.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.lowmist.title": "Lowmist",
|
||||
"painting.minecraft.meditative.author": "Sarah Boeving",
|
||||
"painting.minecraft.meditative.title": "Meditative",
|
||||
"painting.minecraft.orb.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.orb.title": "Orb",
|
||||
"painting.minecraft.owlemons.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.owlemons.title": "Owlemons",
|
||||
"painting.minecraft.passage.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.passage.title": "Passage",
|
||||
"painting.minecraft.pond.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.pond.title": "Pond",
|
||||
"painting.minecraft.prairie_ride.author": "Sarah Boeving",
|
||||
"painting.minecraft.prairie_ride.title": "Prairie Ride",
|
||||
"painting.minecraft.sunflowers.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.sunflowers.title": "Sunflowers",
|
||||
"painting.minecraft.tides.author": "Kristoffer Zetterstrand",
|
||||
"painting.minecraft.tides.title": "Tides",
|
||||
"painting.minecraft.unpacked.author": "Sarah Boeving",
|
||||
"painting.minecraft.unpacked.title": "Unpacked",
|
||||
"subtitles.block.trial_spawner.ambient_ominous": "Ominous crackling",
|
||||
"subtitles.block.trial_spawner.ominous_activate": "Omen engulfs Trial Spawner",
|
||||
"subtitles.block.vault.reject_rewarded_player": "Vault rejects already rewarded player"
|
||||
"subtitles.block.vault.reject_rewarded_player": "Vault rejects player"
|
||||
},
|
||||
"1.20.5": {
|
||||
"advancements.adventure.blowback.description": "Kill a Breeze with a deflected Breeze-shot Wind Charge",
|
||||
"advancements.adventure.blowback.title": "Blowback",
|
||||
"advancements.adventure.brush_armadillo.description": "Get Armadillo Scutes from an Armadillo using a Brush",
|
||||
"advancements.adventure.brush_armadillo.title": "Isn't It Scute?",
|
||||
"advancements.adventure.crafters_crafting_crafters.description": "Be near a Crafter when it crafts a Crafter",
|
||||
"advancements.adventure.crafters_crafting_crafters.title": "Crafters Crafting Crafters",
|
||||
"advancements.adventure.lighten_up.description": "Scrape a Copper Bulb with an Axe to make it brighter",
|
||||
@@ -112,18 +86,28 @@
|
||||
"advancements.adventure.minecraft_trials_edition.title": "Minecraft: Trial(s) Edition",
|
||||
"advancements.adventure.overoverkill.description": "Deal 50 hearts of damage in a single hit using the Mace",
|
||||
"advancements.adventure.overoverkill.title": "Over-Overkill",
|
||||
"advancements.adventure.revaulting.description": "Unlock an Ominous Vault with an Ominous Trial Key",
|
||||
"advancements.adventure.revaulting.title": "Revaulting",
|
||||
"advancements.adventure.under_lock_and_key.description": "Unlock a Vault with a Trial Key",
|
||||
"advancements.adventure.under_lock_and_key.title": "Under Lock and Key",
|
||||
"advancements.adventure.who_needs_rockets.description": "Use a Wind Charge to launch yourself upward 8 blocks",
|
||||
"advancements.adventure.who_needs_rockets.title": "Who Needs Rockets?",
|
||||
"advancements.husbandry.remove_wolf_armor.description": "Remove Wolf Armor from a Wolf using Shears",
|
||||
"advancements.husbandry.remove_wolf_armor.title": "Shear Brilliance",
|
||||
"advancements.husbandry.repair_wolf_armor.description": "Repair a damaged Wolf Armor using Armadillo Scutes",
|
||||
"advancements.husbandry.repair_wolf_armor.title": "Good as New",
|
||||
"advancements.husbandry.whole_pack.description": "Tame one of each Wolf variant",
|
||||
"advancements.husbandry.whole_pack.title": "The Whole Pack",
|
||||
"argument.message.too_long": "Chat message was too long (%s > maximum %s characters)",
|
||||
"argument.resource_or_id.failed_to_parse": "Failed to parse structure: %s",
|
||||
"argument.resource_or_id.invalid": "Invalid id or tag",
|
||||
"arguments.item.component.expected": "Expected item component",
|
||||
"arguments.item.component.malformed": "Malformed '%s' component: '%s'",
|
||||
"arguments.item.component.repeated": "Item component '%s' was repeated, but only one value can be specified",
|
||||
"arguments.item.component.unknown": "Unknown item component '%s'",
|
||||
"arguments.item.malformed": "Malformed item: '%s'",
|
||||
"arguments.item.predicate.malformed": "Malformed '%s' predicate: '%s'",
|
||||
"arguments.item.predicate.unknown": "Unknown item predicate '%s''",
|
||||
"arguments.item.predicate.unknown": "Unknown item predicate '%s'",
|
||||
"attribute.name.generic.block_interaction_range": "Block Interaction Range",
|
||||
"attribute.name.generic.entity_interaction_range": "Entity Interaction Range",
|
||||
"attribute.name.generic.fall_damage_multiplier": "Fall Damage Multiplier",
|
||||
@@ -135,6 +119,38 @@
|
||||
"attribute.name.player.block_break_speed": "Block Break Speed",
|
||||
"attribute.name.player.block_interaction_range": "Block Interaction Range",
|
||||
"attribute.name.player.entity_interaction_range": "Entity Interaction Range",
|
||||
"block.minecraft.banner.flow.black": "Black Flow",
|
||||
"block.minecraft.banner.flow.blue": "Blue Flow",
|
||||
"block.minecraft.banner.flow.brown": "Brown Flow",
|
||||
"block.minecraft.banner.flow.cyan": "Cyan Flow",
|
||||
"block.minecraft.banner.flow.gray": "Gray Flow",
|
||||
"block.minecraft.banner.flow.green": "Green Flow",
|
||||
"block.minecraft.banner.flow.light_blue": "Light Blue Flow",
|
||||
"block.minecraft.banner.flow.light_gray": "Light Gray Flow",
|
||||
"block.minecraft.banner.flow.lime": "Lime Flow",
|
||||
"block.minecraft.banner.flow.magenta": "Magenta Flow",
|
||||
"block.minecraft.banner.flow.orange": "Orange Flow",
|
||||
"block.minecraft.banner.flow.pink": "Pink Flow",
|
||||
"block.minecraft.banner.flow.purple": "Purple Flow",
|
||||
"block.minecraft.banner.flow.red": "Red Flow",
|
||||
"block.minecraft.banner.flow.white": "White Flow",
|
||||
"block.minecraft.banner.flow.yellow": "Yellow Flow",
|
||||
"block.minecraft.banner.guster.black": "Black Guster",
|
||||
"block.minecraft.banner.guster.blue": "Blue Guster",
|
||||
"block.minecraft.banner.guster.brown": "Brown Guster",
|
||||
"block.minecraft.banner.guster.cyan": "Cyan Guster",
|
||||
"block.minecraft.banner.guster.gray": "Gray Guster",
|
||||
"block.minecraft.banner.guster.green": "Green Guster",
|
||||
"block.minecraft.banner.guster.light_blue": "Light Blue Guster",
|
||||
"block.minecraft.banner.guster.light_gray": "Light Gray Guster",
|
||||
"block.minecraft.banner.guster.lime": "Lime Guster",
|
||||
"block.minecraft.banner.guster.magenta": "Magenta Guster",
|
||||
"block.minecraft.banner.guster.orange": "Orange Guster",
|
||||
"block.minecraft.banner.guster.pink": "Pink Guster",
|
||||
"block.minecraft.banner.guster.purple": "Purple Guster",
|
||||
"block.minecraft.banner.guster.red": "Red Guster",
|
||||
"block.minecraft.banner.guster.white": "White Guster",
|
||||
"block.minecraft.banner.guster.yellow": "Yellow Guster",
|
||||
"block.minecraft.heavy_core": "Heavy Core",
|
||||
"block.minecraft.vault": "Vault",
|
||||
"chat.disabled.invalid_command_signature": "Command had unexpected or missing command argument signatures.",
|
||||
@@ -152,6 +168,7 @@
|
||||
"commands.transfer.success.single": "Transferring %s to %s:%s",
|
||||
"connect.failed.transfer": "Connection failed while transferring to the server",
|
||||
"connect.transferring": "Transferring to new server...",
|
||||
"disconnect.packetError": "Network Protocol Error",
|
||||
"disconnect.transfer": "Transferred to another server",
|
||||
"effect.minecraft.infested": "Infested",
|
||||
"effect.minecraft.oozing": "Oozing",
|
||||
@@ -161,28 +178,21 @@
|
||||
"effect.minecraft.wind_charged": "Wind Charged",
|
||||
"enchantment.minecraft.breach": "Breach",
|
||||
"enchantment.minecraft.density": "Density",
|
||||
"enchantment.minecraft.sweeping_edge": "Sweeping Edge",
|
||||
"enchantment.minecraft.wind_burst": "Wind Burst",
|
||||
"entity.minecraft.armadillo": "Armadillo",
|
||||
"entity.minecraft.bogged": "Bogged",
|
||||
"entity.minecraft.breeze_wind_charge": "Wind Charge",
|
||||
"entity.minecraft.ominous_item_spawner": "Ominous Item Spawner",
|
||||
"filled_map.trial_chambers": "Trial Chambers Map",
|
||||
"gamerule.spawnChunkRadius": "Spawn chunk radius",
|
||||
"gamerule.spawnChunkRadius.description": "Amount of chunks that stay loaded around the overworld spawn position.",
|
||||
"gamerule.spawnRadius.description": "Controls the size of the area around the spawn point that players can spawn in.",
|
||||
"item.canUse.unknown": "Unknown",
|
||||
"item.components": "%s component(s)",
|
||||
"item.minecraft.armadillo_scute": "Armadillo Scute",
|
||||
"item.minecraft.armadillo_spawn_egg": "Armadillo Spawn Egg",
|
||||
"item.minecraft.bogged_spawn_egg": "Bogged Spawn Egg",
|
||||
"item.minecraft.bolt_armor_trim_smithing_template": "Smithing Template",
|
||||
"item.minecraft.breeze_rod": "Breeze Rod",
|
||||
"item.minecraft.flow_armor_trim_smithing_template": "Smithing Template",
|
||||
"item.minecraft.flow_banner_pattern": "Banner Pattern",
|
||||
"item.minecraft.flow_banner_pattern.desc": "Flow",
|
||||
"item.minecraft.flow_pottery_sherd": "Flow Pottery Sherd",
|
||||
"item.minecraft.guster_banner_pattern": "Banner Pattern",
|
||||
"item.minecraft.guster_banner_pattern.desc": "Guster",
|
||||
"item.minecraft.guster_pottery_sherd": "Guster Pottery Sherd",
|
||||
"item.minecraft.lingering_potion.effect.infested": "Lingering Potion of Infestation",
|
||||
@@ -206,19 +216,16 @@
|
||||
"item.minecraft.tipped_arrow.effect.weaving": "Arrow of Weaving",
|
||||
"item.minecraft.tipped_arrow.effect.wind_charged": "Arrow of Wind Charging",
|
||||
"item.minecraft.turtle_scute": "Turtle Scute",
|
||||
"item.minecraft.wind_charge": "Wind Charge",
|
||||
"item.minecraft.wolf_armor": "Wolf Armor",
|
||||
"item.modifiers.body": "When equipped:",
|
||||
"mco.backup.narration": "Backup from %s",
|
||||
"mco.client.outdated.stable.version": "Your client version (%s) is not compatible with Realms.\n\nPlease use the most recent version of Minecraft.",
|
||||
"mco.client.unsupported.snapshot.version": "Your client version (%s) is not compatible with Realms.\n\nRealms is not available for this snapshot version.",
|
||||
"mco.invited.player.narration": "Invited player %s",
|
||||
"mco.upload.entry.commands": "%1$s, %2$s",
|
||||
"multiplayer.disconnect.transfers_disabled": "Server does not accept transfers",
|
||||
"optimizeWorld.stage.finished.chunks": "Finishing up upgrading chunks...",
|
||||
"optimizeWorld.stage.finished.entities": "Finishing up upgrading entities...",
|
||||
"optimizeWorld.stage.finished.poi": "Finishing up upgrading points of interest...",
|
||||
"optimizeWorld.stage.upgrading.chunks": "Upgrading all chunks...",
|
||||
"optimizeWorld.stage.upgrading.entities": "Upgrading all entities...",
|
||||
"optimizeWorld.stage.upgrading.poi": "Upgrading all points of interest...",
|
||||
"options.accessibility.menu_background_blurriness": "Menu Background Blur",
|
||||
@@ -228,6 +235,7 @@
|
||||
"options.japaneseGlyphVariants": "Japanese Glyph Variants",
|
||||
"options.japaneseGlyphVariants.tooltip": "Uses Japanese variants of CJK characters in the default font",
|
||||
"options.telemetry.disabled": "Telemetry is disabled.",
|
||||
"particle.invalidOptions": "Can't parse particle options: %s",
|
||||
"selectWorld.allowCommands.new": "Allow Commands",
|
||||
"selectWorld.commands": "Commands",
|
||||
"selectWorld.warning.lowDiskSpace.description": "There is not much space left on your device.\nRunning out of disk space while in game can lead to your world being damaged.",
|
||||
@@ -266,12 +274,9 @@
|
||||
"subtitles.entity.breeze.charge": "Breeze charges",
|
||||
"subtitles.entity.breeze.deflect": "Breeze deflects",
|
||||
"subtitles.entity.breeze.whirl": "Breeze whirls",
|
||||
"subtitles.entity.breeze.wind_burst": "Wind Charge bursts",
|
||||
"subtitles.entity.donkey.jump": "Donkey jumps",
|
||||
"subtitles.entity.mule.jump": "Mule jumps",
|
||||
"subtitles.entity.parrot.imitate.bogged": "Parrot rattles",
|
||||
"subtitles.entity.wind_charge.throw": "Wind Charge flies",
|
||||
"subtitles.entity.wind_charge.wind_burst": "Wind Charge bursts",
|
||||
"subtitles.event.mob_effect.bad_omen": "Omen takes hold",
|
||||
"subtitles.event.mob_effect.raid_omen": "Raid looms nearby",
|
||||
"subtitles.event.mob_effect.trial_omen": "Ominous trial looms nearby",
|
||||
@@ -4107,6 +4112,9 @@
|
||||
"realms.missing.snapshot.error.text": "Realms is currently not supported in snapshots"
|
||||
},
|
||||
"1.12": {
|
||||
"potion.potency.3": "enchantment.level.4",
|
||||
"potion.potency.4": "enchantment.level.5",
|
||||
"potion.potency.5": "enchantment.level.6",
|
||||
"gui.recipebook.moreRecipes": "Right Click for more",
|
||||
"gui.recipebook.toggleRecipes.all": "Showing all",
|
||||
"gui.recipebook.toggleRecipes.craftable": "Showing craftable",
|
||||
|
||||
@@ -28,9 +28,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.0",
|
||||
"viafabric": ">=0.4.10"
|
||||
},
|
||||
"recommends": {
|
||||
"viarewind": "*"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu:api": true,
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
projectVersion=5.0.0
|
||||
projectVersion=5.0.2
|
||||
|
||||
# Smile emoji
|
||||
mcVersions=1.21,1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10
|
||||
mcVersionRange=1.10-1.21
|
||||
waterfallVersion=1.20
|
||||
velocityVersion=3.3
|
||||
@@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
# ViaVersion
|
||||
viaver = "5.0.0"
|
||||
viaver = "5.0.2-SNAPSHOT"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -84,7 +86,8 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
Vendored
+2
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
|
||||
@@ -4,7 +4,6 @@ rootProject.name = "viabackwards-parent"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("https://repo.viaversion.com")
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
mavenCentral()
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerTrackerWithData1_19(ClientboundPackets1_20_5.ADD_ENTITY, EntityTypes1_20_5.FALLING_BLOCK);
|
||||
registerSetEntityData(ClientboundPackets1_20_5.SET_ENTITY_DATA, /*Types1_OLD.METADATA_LIST, */Types1_20_5.ENTITY_DATA_LIST); // Specify old and new metadata list if changed
|
||||
registerSetEntityData(ClientboundPackets1_20_5.SET_ENTITY_DATA, /*Types1_OLD.ENTITY_DATA_LIST, */Types1_20_5.ENTITY_DATA_LIST); // Specify old and new entity data list if changed
|
||||
registerRemoveEntities(ClientboundPackets1_20_5.REMOVE_ENTITIES);
|
||||
|
||||
// TODO Item and sound id changes in registries, probably others as well
|
||||
@@ -90,7 +90,7 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
||||
data.setDataType(Types1_20_5.ENTITY_DATA_TYPES.byId(id));
|
||||
});*/
|
||||
|
||||
registerMetaTypeHandler1_20_3(
|
||||
registerEntityDataTypeHandler1_20_3(
|
||||
Types1_20_5.ENTITY_DATA_TYPES.itemType,
|
||||
Types1_20_5.ENTITY_DATA_TYPES.blockStateType,
|
||||
Types1_20_5.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
@@ -101,7 +101,7 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
||||
);
|
||||
registerBlockStateHandler(EntityTypes1_20_5.ABSTRACT_MINECART, 11);
|
||||
|
||||
// Remove metadata of new entity type
|
||||
// Remove entity data of new entity type
|
||||
// filter().type(EntityTypes1_20_5.SNIFFER).removeIndex(newIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
autoAddDependsOn.set(false)
|
||||
detectLoaders.set(false)
|
||||
dependencies {
|
||||
optional.project("viaversion")
|
||||
required.project("viaversion")
|
||||
optional.project("viafabric")
|
||||
optional.project("viafabricplus")
|
||||
optional.project("viarewind")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,9 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
hangar("ViaVersion") {
|
||||
required = true
|
||||
}
|
||||
hangar("ViaRewind") {
|
||||
required = false
|
||||
}
|
||||
}
|
||||
}
|
||||
velocity {
|
||||
@@ -84,6 +87,9 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
hangar("ViaVersion") {
|
||||
required = true
|
||||
}
|
||||
hangar("ViaRewind") {
|
||||
required = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user