mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-22 16:57:40 +01:00
Handle optional block state entity meta
This commit is contained in:
parent
65c8024ba7
commit
da35067e1d
@ -177,18 +177,24 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
|||||||
|
|
||||||
public void registerMetaTypeHandler(
|
public void registerMetaTypeHandler(
|
||||||
@Nullable MetaType itemType,
|
@Nullable MetaType itemType,
|
||||||
@Nullable MetaType blockType,
|
@Nullable MetaType blockStateType,
|
||||||
|
@Nullable MetaType optionalBlockStateType,
|
||||||
@Nullable MetaType particleType,
|
@Nullable MetaType particleType,
|
||||||
@Nullable MetaType optionalComponentType,
|
@Nullable MetaType componentType,
|
||||||
@Nullable MetaType componentType
|
@Nullable MetaType optionalComponentType
|
||||||
) {
|
) {
|
||||||
filter().handler((event, meta) -> {
|
filter().handler((event, meta) -> {
|
||||||
MetaType type = meta.metaType();
|
MetaType type = meta.metaType();
|
||||||
if (type == itemType) {
|
if (type == itemType) {
|
||||||
protocol.getItemRewriter().handleItemToClient(meta.value());
|
protocol.getItemRewriter().handleItemToClient(meta.value());
|
||||||
} else if (type == blockType) {
|
} else if (type == blockStateType) {
|
||||||
int data = meta.value();
|
int data = meta.value();
|
||||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||||
|
} else if (type == optionalBlockStateType) {
|
||||||
|
int data = meta.value();
|
||||||
|
if (data != 0) {
|
||||||
|
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||||
|
}
|
||||||
} else if (type == particleType) {
|
} else if (type == particleType) {
|
||||||
rewriteParticle(meta.value());
|
rewriteParticle(meta.value());
|
||||||
} else if (type == optionalComponentType || type == componentType) {
|
} else if (type == optionalComponentType || type == componentType) {
|
||||||
|
@ -348,8 +348,8 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaTypeHandler(Types1_13_2.META_TYPES.itemType, Types1_13_2.META_TYPES.blockStateType, null,
|
registerMetaTypeHandler(Types1_13_2.META_TYPES.itemType, Types1_13_2.META_TYPES.blockStateType, null, null,
|
||||||
Types1_13_2.META_TYPES.optionalComponentType, Types1_13_2.META_TYPES.componentType);
|
Types1_13_2.META_TYPES.componentType, Types1_13_2.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
filter().type(Entity1_14Types.PILLAGER).cancel(15);
|
filter().type(Entity1_14Types.PILLAGER).cancel(15);
|
||||||
|
|
||||||
|
@ -192,8 +192,8 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, Types1_14.META_TYPES.particleType,
|
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType,
|
||||||
Types1_14.META_TYPES.optionalComponentType, Types1_14.META_TYPES.componentType);
|
Types1_14.META_TYPES.componentType, Types1_14.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
filter().filterFamily(Entity1_15Types.LIVINGENTITY).removeIndex(12);
|
filter().filterFamily(Entity1_15Types.LIVINGENTITY).removeIndex(12);
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType,
|
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null,
|
||||||
Types1_16.META_TYPES.particleType, Types1_16.META_TYPES.optionalComponentType, Types1_16.META_TYPES.componentType);
|
Types1_16.META_TYPES.particleType, Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
mapTypes(Entity1_16_2Types.values(), Entity1_16Types.class);
|
mapTypes(Entity1_16_2Types.values(), Entity1_16Types.class);
|
||||||
mapEntityTypeWithData(Entity1_16_2Types.PIGLIN_BRUTE, Entity1_16_2Types.PIGLIN).jsonName();
|
mapEntityTypeWithData(Entity1_16_2Types.PIGLIN_BRUTE, Entity1_16_2Types.PIGLIN).jsonName();
|
||||||
|
@ -180,8 +180,8 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Particles have already been handled
|
// Particles have already been handled
|
||||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null,
|
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, null,
|
||||||
Types1_16.META_TYPES.optionalComponentType, Types1_16.META_TYPES.componentType);
|
Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
mapTypes(Entity1_17Types.values(), Entity1_16_2Types.class);
|
mapTypes(Entity1_17Types.values(), Entity1_16_2Types.class);
|
||||||
filter().type(Entity1_17Types.AXOLOTL).cancel(17);
|
filter().type(Entity1_17Types.AXOLOTL).cancel(17);
|
||||||
|
@ -117,8 +117,8 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Particles have already been handled
|
// Particles have already been handled
|
||||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null,
|
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, null,
|
||||||
Types1_17.META_TYPES.optionalComponentType, Types1_17.META_TYPES.componentType);
|
Types1_17.META_TYPES.componentType, Types1_17.META_TYPES.optionalComponentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -269,8 +269,8 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, Types1_18.META_TYPES.blockStateType, null,
|
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, Types1_18.META_TYPES.blockStateType, null, null,
|
||||||
Types1_18.META_TYPES.optionalComponentType, Types1_18.META_TYPES.componentType);
|
Types1_18.META_TYPES.componentType, Types1_18.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
filter().filterFamily(Entity1_19Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
filter().filterFamily(Entity1_19Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||||
final int data = (int) meta.getValue();
|
final int data = (int) meta.getValue();
|
||||||
|
@ -230,8 +230,8 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
|||||||
meta.setMetaType(Types1_19.META_TYPES.byId(id));
|
meta.setMetaType(Types1_19.META_TYPES.byId(id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, Types1_19.META_TYPES.particleType,
|
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null, Types1_19.META_TYPES.particleType,
|
||||||
Types1_19.META_TYPES.optionalComponentType, Types1_19.META_TYPES.componentType);
|
Types1_19.META_TYPES.componentType, Types1_19.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
filter().index(6).handler((event, meta) -> {
|
filter().index(6).handler((event, meta) -> {
|
||||||
// Sitting pose added
|
// Sitting pose added
|
||||||
|
@ -143,8 +143,8 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
|||||||
|
|
||||||
meta.setMetaType(Types1_19_3.META_TYPES.byId(id));
|
meta.setMetaType(Types1_19_3.META_TYPES.byId(id));
|
||||||
});
|
});
|
||||||
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, Types1_19_3.META_TYPES.particleType,
|
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType,
|
||||||
Types1_19_3.META_TYPES.optionalComponentType, Types1_19_3.META_TYPES.componentType);
|
Types1_19_3.META_TYPES.componentType, Types1_19_3.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||||
final int blockState = meta.value();
|
final int blockState = meta.value();
|
||||||
|
@ -90,8 +90,8 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
filter().handler((event, meta) -> meta.setMetaType(Types1_19_4.META_TYPES.byId(meta.metaType().typeId())));
|
filter().handler((event, meta) -> meta.setMetaType(Types1_19_4.META_TYPES.byId(meta.metaType().typeId())));
|
||||||
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType,
|
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.optionalBlockStateType,
|
||||||
Types1_19_4.META_TYPES.particleType, Types1_19_4.META_TYPES.optionalComponentType, Types1_19_4.META_TYPES.componentType);
|
Types1_19_4.META_TYPES.particleType, Types1_19_4.META_TYPES.componentType, Types1_19_4.META_TYPES.optionalComponentType);
|
||||||
|
|
||||||
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||||
final int blockState = meta.value();
|
final int blockState = meta.value();
|
||||||
|
Loading…
Reference in New Issue
Block a user