Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-19 14:30:16 +01:00
Make handling of optional block metadata more explicit in <1.19.4 (#3782)
Dieser Commit ist enthalten in:
Ursprung
6f53c069ea
Commit
0c2c8400ae
@ -32,7 +32,7 @@ public class MetadataRewriter1_13_1To1_13 extends EntityRewriter<ClientboundPack
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
registerMetaTypeHandler(Types1_13.META_TYPES.itemType, Types1_13.META_TYPES.blockStateType, null, Types1_13.META_TYPES.particleType);
|
registerMetaTypeHandler(Types1_13.META_TYPES.itemType, Types1_13.META_TYPES.blockStateType, Types1_13.META_TYPES.particleType);
|
||||||
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
|
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
|
||||||
int data = meta.value();
|
int data = meta.value();
|
||||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||||
|
@ -41,10 +41,12 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<ClientboundPack
|
|||||||
filter().mapMetaType(typeId -> Types1_13.META_TYPES.byId(typeId > 4 ? typeId + 1 : typeId));
|
filter().mapMetaType(typeId -> Types1_13.META_TYPES.byId(typeId > 4 ? typeId + 1 : typeId));
|
||||||
filter().metaType(Types1_13.META_TYPES.itemType).handler(((event, meta) -> protocol.getItemRewriter().handleItemToClient(meta.value())));
|
filter().metaType(Types1_13.META_TYPES.itemType).handler(((event, meta) -> protocol.getItemRewriter().handleItemToClient(meta.value())));
|
||||||
filter().metaType(Types1_13.META_TYPES.blockStateType).handler(((event, meta) -> {
|
filter().metaType(Types1_13.META_TYPES.blockStateType).handler(((event, meta) -> {
|
||||||
int oldId = meta.value();
|
final int oldId = meta.value();
|
||||||
int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15));
|
if (oldId != 0) {
|
||||||
int newId = WorldPackets.toNewId(combined);
|
final int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15));
|
||||||
|
final int newId = WorldPackets.toNewId(combined);
|
||||||
meta.setValue(newId);
|
meta.setValue(newId);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Previously unused, now swimming
|
// Previously unused, now swimming
|
||||||
@ -66,9 +68,9 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<ClientboundPack
|
|||||||
filter().type(EntityTypes1_13.EntityType.ZOMBIE).addIndex(15); // Shaking
|
filter().type(EntityTypes1_13.EntityType.ZOMBIE).addIndex(15); // Shaking
|
||||||
|
|
||||||
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
|
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
|
||||||
int oldId = meta.value();
|
final int oldId = meta.value();
|
||||||
int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15));
|
final int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15));
|
||||||
int newId = WorldPackets.toNewId(combined);
|
final int newId = WorldPackets.toNewId(combined);
|
||||||
meta.setValue(newId);
|
meta.setValue(newId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
filter().mapMetaType(Types1_14.META_TYPES::byId);
|
filter().mapMetaType(Types1_14.META_TYPES::byId);
|
||||||
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType);
|
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, Types1_14.META_TYPES.particleType);
|
||||||
|
|
||||||
filter().type(EntityTypes1_14.ENTITY).addIndex(6);
|
filter().type(EntityTypes1_14.ENTITY).addIndex(6);
|
||||||
filter().type(EntityTypes1_14.LIVINGENTITY).addIndex(12);
|
filter().type(EntityTypes1_14.LIVINGENTITY).addIndex(12);
|
||||||
|
@ -33,7 +33,7 @@ public class MetadataRewriter1_15To1_14_4 extends EntityRewriter<ClientboundPack
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType);
|
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, Types1_14.META_TYPES.particleType);
|
||||||
filter().type(EntityTypes1_15.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
filter().type(EntityTypes1_15.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
||||||
int data = meta.value();
|
int data = meta.value();
|
||||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||||
|
@ -34,7 +34,7 @@ public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<ClientboundPa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType);
|
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, Types1_16.META_TYPES.particleType);
|
||||||
filter().type(EntityTypes1_16_2.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
filter().type(EntityTypes1_16_2.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
||||||
int data = meta.value();
|
int data = meta.value();
|
||||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||||
|
@ -37,7 +37,7 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<ClientboundPack
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
filter().mapMetaType(Types1_16.META_TYPES::byId);
|
filter().mapMetaType(Types1_16.META_TYPES::byId);
|
||||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType);
|
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, Types1_16.META_TYPES.particleType);
|
||||||
filter().type(EntityTypes1_16.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
filter().type(EntityTypes1_16.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
|
||||||
int data = meta.value();
|
int data = meta.value();
|
||||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||||
|
@ -159,7 +159,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
meta.setValue(pose + 1);
|
meta.setValue(pose + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, null, Types1_17.META_TYPES.particleType);
|
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, Types1_17.META_TYPES.particleType);
|
||||||
|
|
||||||
// Ticks frozen added with id 7
|
// Ticks frozen added with id 7
|
||||||
filter().type(EntityTypes1_17.ENTITY).addIndex(7);
|
filter().type(EntityTypes1_17.ENTITY).addIndex(7);
|
||||||
|
@ -94,7 +94,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null, null);
|
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,7 +152,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
filter().mapMetaType(typeId -> Types1_19_3.META_TYPES.byId(typeId >= 2 ? typeId + 1 : typeId)); // Long added
|
filter().mapMetaType(typeId -> Types1_19_3.META_TYPES.byId(typeId >= 2 ? typeId + 1 : typeId)); // Long added
|
||||||
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType);
|
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, Types1_19_3.META_TYPES.particleType);
|
||||||
|
|
||||||
filter().type(EntityTypes1_19_3.ENTITY).index(6).handler((event, meta) -> {
|
filter().type(EntityTypes1_19_3.ENTITY).index(6).handler((event, meta) -> {
|
||||||
// Sitting pose added
|
// Sitting pose added
|
||||||
|
@ -338,7 +338,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
rewriteParticle(particle);
|
rewriteParticle(particle);
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null, null);
|
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null);
|
||||||
|
|
||||||
filter().type(EntityTypes1_19.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
filter().type(EntityTypes1_19.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||||
// Convert to new block id
|
// Convert to new block id
|
||||||
|
@ -20,7 +20,6 @@ package com.viaversion.viaversion.rewriter;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
@ -202,6 +201,17 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
typeMappings = protocol.getMappingData().getEntityMappings();
|
typeMappings = protocol.getMappingData().getEntityMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a metadata handler to rewrite, item, block, and particle ids stored in metadata.
|
||||||
|
*
|
||||||
|
* @param itemType item meta type if needed
|
||||||
|
* @param blockStateType block state meta type if needed
|
||||||
|
* @param particleType particle meta type if needed
|
||||||
|
*/
|
||||||
|
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockStateType, @Nullable MetaType particleType) {
|
||||||
|
registerMetaTypeHandler(itemType, null, blockStateType, particleType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a metadata handler to rewrite, item, block, and particle ids stored in metadata.
|
* Registers a metadata handler to rewrite, item, block, and particle ids stored in metadata.
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren