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 |
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.1";
|
||||
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;
|
||||
+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;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -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;
|
||||
@@ -37,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;
|
||||
@@ -55,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);
|
||||
|
||||
+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);
|
||||
|
||||
+17
-17
@@ -141,39 +141,39 @@ public final class EntityPacketRewriter1_19_4 extends EntityRewriter<Clientbound
|
||||
|
||||
@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();
|
||||
}
|
||||
@@ -193,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,
|
||||
|
||||
+12
-12
@@ -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,9 +372,9 @@ 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);
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
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,
|
||||
@@ -420,10 +420,10 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
registerBlockStateHandler(EntityTypes1_20_5.ABSTRACT_MINECART, 11);
|
||||
|
||||
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)));
|
||||
}
|
||||
@@ -449,4 +449,4 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
public EntityType typeFromId(final int type) {
|
||||
return EntityTypes1_20_5.getTypeFromId(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -82,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));
|
||||
});
|
||||
|
||||
+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));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+38
-7
@@ -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;
|
||||
@@ -38,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;
|
||||
@@ -46,11 +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> {
|
||||
@@ -78,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
|
||||
|
||||
@@ -143,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;
|
||||
}
|
||||
|
||||
@@ -177,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;
|
||||
}
|
||||
|
||||
@@ -213,4 +244,4 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
+1
-1
@@ -196,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,
|
||||
|
||||
@@ -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
|
||||
@@ -4112,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.1
|
||||
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.1-SNAPSHOT"
|
||||
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 ##########################################################################
|
||||
|
||||
+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