us.myles.ViaVersion.api.minecraft.metadata.MetaType Java Examples
The following examples show how to use
us.myles.ViaVersion.api.minecraft.metadata.MetaType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModernMetaType.java From ViaVersion with MIT License | 5 votes |
@Override public Metadata read(final ByteBuf buffer) throws Exception { final short index = buffer.readUnsignedByte(); if (index == 0xff) return null; // End of metadata final MetaType type = this.getType(buffer.readByte()); return new Metadata(index, type, type.getType().read(buffer)); }
Example #2
Source File: ModernMetaType.java From ViaVersion with MIT License | 5 votes |
@Override public void write(final ByteBuf buffer, final Metadata object) throws Exception { if (object == null) { buffer.writeByte(0xff); } else { buffer.writeByte(object.getId()); final MetaType type = object.getMetaType(); buffer.writeByte(type.getTypeID()); type.getType().write(buffer, object.getValue()); } }
Example #3
Source File: Metadata1_14Type.java From ViaVersion with MIT License | 4 votes |
@Override protected MetaType getType(final int index) { return MetaType1_14.byId(index); }
Example #4
Source File: Metadata1_9Type.java From ViaVersion with MIT License | 4 votes |
@Override protected MetaType getType(final int index) { return MetaType1_9.byId(index); }
Example #5
Source File: Metadata1_13Type.java From ViaVersion with MIT License | 4 votes |
@Override protected MetaType getType(final int index) { return MetaType1_13.byId(index); }
Example #6
Source File: Metadata1_12Type.java From ViaVersion with MIT License | 4 votes |
@Override protected MetaType getType(final int index) { return MetaType1_12.byId(index); }
Example #7
Source File: Metadata1_13_2Type.java From ViaVersion with MIT License | 4 votes |
@Override protected MetaType getType(final int index) { return MetaType1_13_2.byId(index); }
Example #8
Source File: EntityPackets1_16.java From ViaBackwards with MIT License | 4 votes |
@Override protected void registerRewrites() { registerMetaHandler().handle(e -> { Metadata meta = e.getData(); MetaType type = meta.getMetaType(); if (type == MetaType1_14.Slot) { meta.setValue(protocol.getBlockItemPackets().handleItemToClient((Item) meta.getValue())); } else if (type == MetaType1_14.BlockID) { meta.setValue(Protocol1_15_2To1_16.getNewBlockStateId((int) meta.getValue())); } else if (type == MetaType1_14.PARTICLE) { Particle particle = (Particle) meta.getValue(); particle.setId(ParticleMapping.getOldId(particle.getId())); } else if (type == MetaType1_14.OptChat) { JsonElement text = meta.getCastedValue(); if (text != null) { protocol.getTranslatableRewriter().processText(text); } } return meta; }); mapEntityDirect(Entity1_16Types.EntityType.ZOMBIFIED_PIGLIN, Entity1_15Types.EntityType.ZOMBIE_PIGMAN); mapTypes(Entity1_16Types.EntityType.values(), Entity1_15Types.EntityType.class); mapEntity(Entity1_16Types.EntityType.HOGLIN, Entity1_16Types.EntityType.COW).jsonName("Hoglin"); mapEntity(Entity1_16Types.EntityType.ZOGLIN, Entity1_16Types.EntityType.COW).jsonName("Zoglin"); mapEntity(Entity1_16Types.EntityType.PIGLIN, Entity1_16Types.EntityType.ZOMBIFIED_PIGLIN).jsonName("Piglin"); mapEntity(Entity1_16Types.EntityType.STRIDER, Entity1_16Types.EntityType.MAGMA_CUBE).jsonName("Strider"); registerMetaHandler().filter(Entity1_16Types.EntityType.ZOGLIN, 16).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.HOGLIN, 15).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.PIGLIN, 16).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.PIGLIN, 17).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.PIGLIN, 18).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.STRIDER, 15).handle(meta -> { boolean baby = meta.getData().getCastedValue(); meta.getData().setValue(baby ? 1 : 3); meta.getData().setMetaType(MetaType1_14.VarInt); return meta.getData(); }); registerMetaHandler().filter(Entity1_16Types.EntityType.STRIDER, 16).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.STRIDER, 17).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.STRIDER, 18).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.FISHING_BOBBER, 8).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.ABSTRACT_ARROW, true, 8).removed(); registerMetaHandler().filter(Entity1_16Types.EntityType.ABSTRACT_ARROW, true).handle(meta -> { if (meta.getIndex() >= 8) { meta.getData().setId(meta.getIndex() + 1); } return meta.getData(); }); }
Example #9
Source File: LegacyEntityRewriter.java From ViaBackwards with MIT License | 4 votes |
protected LegacyEntityRewriter(T protocol, MetaType displayType) { super(protocol, displayType, 2); }
Example #10
Source File: EntityRewriterBase.java From ViaBackwards with MIT License | 4 votes |
EntityRewriterBase(T protocol, MetaType displayNameMetaType, int displayNameIndex) { super(protocol); this.displayNameMetaType = displayNameMetaType; this.displayNameIndex = displayNameIndex; }
Example #11
Source File: EntityRewriter.java From ViaBackwards with MIT License | 4 votes |
protected EntityRewriter(T protocol, MetaType displayType) { super(protocol, displayType, 2); }
Example #12
Source File: ModernMetaType.java From ViaVersion with MIT License | votes |
protected abstract MetaType getType(final int index);