use of com.viaversion.viaversion.api.minecraft.metadata.MetaType in project ViaBackwards by ViaVersion.
the class EntityPackets1_17 method registerRewrites.
@Override
protected void registerRewrites() {
filter().handler((event, meta) -> {
meta.setMetaType(Types1_16.META_TYPES.byId(meta.metaType().typeId()));
MetaType type = meta.metaType();
if (type == Types1_16.META_TYPES.particleType) {
Particle particle = (Particle) meta.getValue();
if (particle.getId() == 16) {
// Dust / Dust Transition
// Remove transition target color values 4-6
particle.getArguments().subList(4, 7).clear();
} else if (particle.getId() == 37) {
// Vibration Signal
// No nice mapping possible without tracking entity positions and doing particle tasks
particle.setId(0);
particle.getArguments().clear();
return;
}
rewriteParticle(particle);
} else if (type == Types1_16.META_TYPES.poseType) {
// Goat LONG_JUMP added at 6
int pose = meta.value();
if (pose == 6) {
// FALL_FLYING
meta.setValue(1);
} else if (pose > 6) {
meta.setValue(pose - 1);
}
}
});
// Particles have already been handled
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.optionalComponentType);
mapTypes(Entity1_17Types.values(), Entity1_16_2Types.class);
filter().type(Entity1_17Types.AXOLOTL).cancel(17);
filter().type(Entity1_17Types.AXOLOTL).cancel(18);
filter().type(Entity1_17Types.AXOLOTL).cancel(19);
filter().type(Entity1_17Types.GLOW_SQUID).cancel(16);
filter().type(Entity1_17Types.GOAT).cancel(17);
mapEntityTypeWithData(Entity1_17Types.AXOLOTL, Entity1_17Types.TROPICAL_FISH).jsonName();
mapEntityTypeWithData(Entity1_17Types.GOAT, Entity1_17Types.SHEEP).jsonName();
mapEntityTypeWithData(Entity1_17Types.GLOW_SQUID, Entity1_17Types.SQUID).jsonName();
mapEntityTypeWithData(Entity1_17Types.GLOW_ITEM_FRAME, Entity1_17Types.ITEM_FRAME);
// TODO Handle attachment pos?
filter().type(Entity1_17Types.SHULKER).addIndex(17);
// Ticks frozen
filter().removeIndex(7);
}
use of com.viaversion.viaversion.api.minecraft.metadata.MetaType in project ViaBackwards by ViaVersion.
the class EntityPackets1_18 method registerRewrites.
@Override
protected void registerRewrites() {
filter().handler((event, meta) -> {
meta.setMetaType(Types1_17.META_TYPES.byId(meta.metaType().typeId()));
MetaType type = meta.metaType();
if (type == Types1_17.META_TYPES.particleType) {
Particle particle = (Particle) meta.getValue();
if (particle.getId() == 3) {
// Block marker
Particle.ParticleData data = particle.getArguments().remove(0);
int blockState = (int) data.getValue();
if (blockState == 7786) {
// Light block
particle.setId(3);
} else {
// Else assume barrier block
particle.setId(2);
}
return;
}
rewriteParticle(particle);
}
});
// Particles have already been handled
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, Types1_17.META_TYPES.optionalComponentType);
}
use of com.viaversion.viaversion.api.minecraft.metadata.MetaType 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();
});
}
use of com.viaversion.viaversion.api.minecraft.metadata.MetaType in project ViaVersion by ViaVersion.
the class OldMetaType method read.
@Override
public Metadata read(final ByteBuf buffer) throws Exception {
final byte index = buffer.readByte();
// End of metadata
if (index == END)
return null;
final MetaType type = this.getType((index & 224) >> 5);
return new Metadata(index & 31, type, type.type().read(buffer));
}
Aggregations