use of com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.WolfDataMaskStorage in project ViaBackwards by ViaVersion.
the class EntityPackets1_16 method registerRewrites.
@Override
protected void registerRewrites() {
filter().handler((event, meta) -> {
meta.setMetaType(Types1_14.META_TYPES.byId(meta.metaType().typeId()));
MetaType type = meta.metaType();
if (type == Types1_14.META_TYPES.itemType) {
meta.setValue(protocol.getItemRewriter().handleItemToClient((Item) meta.getValue()));
} else if (type == Types1_14.META_TYPES.blockStateType) {
meta.setValue(protocol.getMappingData().getNewBlockStateId((int) meta.getValue()));
} else if (type == Types1_14.META_TYPES.particleType) {
rewriteParticle((Particle) meta.getValue());
} else if (type == Types1_14.META_TYPES.optionalComponentType) {
JsonElement text = meta.value();
if (text != null) {
protocol.getTranslatableRewriter().processText(text);
}
}
});
mapEntityType(Entity1_16Types.ZOMBIFIED_PIGLIN, Entity1_15Types.ZOMBIE_PIGMAN);
mapTypes(Entity1_16Types.values(), Entity1_15Types.class);
mapEntityTypeWithData(Entity1_16Types.HOGLIN, Entity1_16Types.COW).jsonName();
mapEntityTypeWithData(Entity1_16Types.ZOGLIN, Entity1_16Types.COW).jsonName();
mapEntityTypeWithData(Entity1_16Types.PIGLIN, Entity1_16Types.ZOMBIFIED_PIGLIN).jsonName();
mapEntityTypeWithData(Entity1_16Types.STRIDER, Entity1_16Types.MAGMA_CUBE).jsonName();
filter().type(Entity1_16Types.ZOGLIN).cancel(16);
filter().type(Entity1_16Types.HOGLIN).cancel(15);
filter().type(Entity1_16Types.PIGLIN).cancel(16);
filter().type(Entity1_16Types.PIGLIN).cancel(17);
filter().type(Entity1_16Types.PIGLIN).cancel(18);
filter().type(Entity1_16Types.STRIDER).index(15).handler((event, meta) -> {
boolean baby = meta.value();
meta.setTypeAndValue(Types1_14.META_TYPES.varIntType, baby ? 1 : 3);
});
filter().type(Entity1_16Types.STRIDER).cancel(16);
filter().type(Entity1_16Types.STRIDER).cancel(17);
filter().type(Entity1_16Types.STRIDER).cancel(18);
filter().type(Entity1_16Types.FISHING_BOBBER).cancel(8);
filter().filterFamily(Entity1_16Types.ABSTRACT_ARROW).cancel(8);
filter().filterFamily(Entity1_16Types.ABSTRACT_ARROW).handler((event, meta) -> {
if (event.index() >= 8) {
event.setIndex(event.index() + 1);
}
});
filter().type(Entity1_16Types.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(Entity1_16Types.WOLF).index(20).handler((event, meta) -> {
StoredEntityData data = tracker(event.user()).entityDataIfPresent(event.entityId());
byte previousMask = 0;
if (data != null) {
WolfDataMaskStorage wolfData = data.get(WolfDataMaskStorage.class);
if (wolfData != null) {
previousMask = wolfData.tameableMask();
}
}
int angerTime = meta.value();
byte tameableMask = (byte) (angerTime > 0 ? previousMask | 2 : previousMask & -3);
event.createExtraMeta(new Metadata(16, Types1_14.META_TYPES.byteType, tameableMask));
event.cancel();
});
}
Aggregations