Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-16 04:50:10 +01:00
Rename missing metadata references to entity data (#811)
Dieser Commit ist enthalten in:
Ursprung
16f1bdff02
Commit
33d8485852
@ -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 {
|
||||
|
@ -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;
|
@ -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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ 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.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());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -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()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -242,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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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,51 +423,49 @@ 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int villagerDataToProfession(VillagerData data) {
|
||||
switch (data.profession()) {
|
||||
case 1: // Armorer
|
||||
case 10: // Mason
|
||||
case 13: // Toolsmith
|
||||
case 14: // Weaponsmith
|
||||
return 3; // Blacksmith
|
||||
case 2: // Butcher
|
||||
case 8: // Leatherworker
|
||||
return 4; // Butcher
|
||||
case 3: // Cartographer
|
||||
case 9: // Librarian
|
||||
return 1; // Librarian
|
||||
case 4: // Cleric
|
||||
return 2; // Priest
|
||||
case 5: // Farmer
|
||||
case 6: // Fisherman
|
||||
case 7: // Fletcher
|
||||
case 12: // Shepherd
|
||||
return 0; // Farmer
|
||||
case 0: // None
|
||||
case 11: // Nitwit
|
||||
default:
|
||||
return 5; // Nitwit
|
||||
}
|
||||
return switch (data.profession()) { // Armorer
|
||||
// Mason
|
||||
// Toolsmith
|
||||
case 1, 10, 13, 14 -> // Weaponsmith
|
||||
3; // Blacksmith
|
||||
// Butcher
|
||||
case 2, 8 -> // Leatherworker
|
||||
4; // Butcher
|
||||
// Cartographer
|
||||
case 3, 9 -> // Librarian
|
||||
1; // Librarian
|
||||
case 4 -> // Cleric
|
||||
2; // Priest
|
||||
// Farmer
|
||||
// Fisherman
|
||||
// Fletcher
|
||||
case 5, 6, 7, 12 -> // Shepherd
|
||||
0; // Farmer
|
||||
// None
|
||||
// Nitwit
|
||||
default -> 5; // Nitwit
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,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);
|
||||
@ -136,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));
|
||||
}
|
||||
@ -191,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);
|
||||
@ -204,7 +204,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
|
||||
|
||||
// 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()));
|
||||
});
|
||||
}
|
||||
@ -213,7 +213,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_15.BEE, EntityTypes1_15.PUFFERFISH).jsonName().spawnMetadata(storage -> {
|
||||
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));
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -230,18 +230,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 +255,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 +266,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();
|
||||
|
@ -145,12 +145,12 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter<ClientboundPa
|
||||
|
||||
@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();
|
||||
@ -164,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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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());
|
||||
@ -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
|
||||
|
@ -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);
|
||||
|
@ -96,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
|
||||
@ -117,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,
|
||||
|
@ -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)));
|
||||
}
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren