Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 00:50:13 +01:00
Handle optional block state entity meta
Dieser Commit ist enthalten in:
Ursprung
8864b161f9
Commit
1a46346789
@ -162,7 +162,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
||||
}
|
||||
}
|
||||
});
|
||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, Types1_17.META_TYPES.particleType);
|
||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, null, Types1_17.META_TYPES.particleType);
|
||||
|
||||
// Ticks frozen added with id 7
|
||||
filter().filterFamily(Entity1_17Types.ENTITY).addIndex(7);
|
||||
|
@ -96,7 +96,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
|
||||
}
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null);
|
||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,7 +155,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
|
||||
final int id = meta.metaType().typeId();
|
||||
meta.setMetaType(Types1_19_3.META_TYPES.byId(id >= 2 ? id + 1 : id)); // long added
|
||||
});
|
||||
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);
|
||||
|
||||
filter().index(6).handler((event, meta) -> {
|
||||
// Sitting pose added
|
||||
|
@ -208,7 +208,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
|
||||
}
|
||||
meta.setMetaType(Types1_19_4.META_TYPES.byId(id));
|
||||
});
|
||||
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.particleType);
|
||||
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);
|
||||
|
||||
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||
final int blockState = meta.value();
|
||||
|
@ -355,7 +355,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> meta.setMetaType(Types1_19.META_TYPES.byId(meta.metaType().typeId())));
|
||||
|
||||
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);
|
||||
|
||||
filter().filterFamily(Entity1_19Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||
// Convert to new block id
|
||||
|
@ -235,17 +235,24 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
* Registers a metadata handler to rewrite, item, block, and particle ids stored in metadata.
|
||||
*
|
||||
* @param itemType item meta type if needed
|
||||
* @param blockType block meta type if needed
|
||||
* @param blockStateType block state meta type if needed
|
||||
* @param optionalBlockStateType optional block state meta type if needed
|
||||
* @param particleType particle meta type if needed
|
||||
*/
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockType, @Nullable MetaType particleType) {
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockStateType, @Nullable MetaType optionalBlockStateType, @Nullable MetaType particleType) {
|
||||
filter().handler((event, meta) -> {
|
||||
if (itemType != null && meta.metaType() == itemType) {
|
||||
final MetaType type = meta.metaType();
|
||||
if (type == itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(meta.value());
|
||||
} else if (blockType != null && meta.metaType() == blockType) {
|
||||
} else if (type == blockStateType) {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (particleType != null && meta.metaType() == particleType) {
|
||||
} else if (type == optionalBlockStateType) {
|
||||
int data = meta.value();
|
||||
if (data != 0) {
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
}
|
||||
} else if (type == particleType) {
|
||||
rewriteParticle(meta.value());
|
||||
}
|
||||
});
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren