Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Rewrite BlockId, cancel changed packets, rewrite metadata even if type not found
Dieser Commit ist enthalten in:
Ursprung
cc4ae6eb80
Commit
ede4fa5a5d
@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -21,15 +22,20 @@ public class MetadataRewriter {
|
||||
metadata.setMetaType(MetaType1_13.Slot);
|
||||
InventoryPackets.toClient((Item) metadata.getValue());
|
||||
}
|
||||
if (metadata.getMetaType().getTypeID() == MetaType1_13.BlockID.getTypeID()) {
|
||||
// Convert to new block id
|
||||
metadata.setValue(WorldPackets.toNewId((int) metadata.getValue()));
|
||||
}
|
||||
// Handle other changes
|
||||
try {
|
||||
if (type.is(Entity1_12Types.EntityType.AREA_EFFECT_CLOUD)) {
|
||||
if (metadata.getId() == 10 || metadata.getId() == 11) {
|
||||
if (type != null && type.is(Entity1_12Types.EntityType.AREA_EFFECT_CLOUD)) {
|
||||
if (metadata.getId() == 9 || metadata.getId() == 10 || metadata.getId() == 11) {
|
||||
// TODO: AreaEffectCloud has lost 2 integers and gained "ef"
|
||||
// Will be implemented when more info is known
|
||||
metadatas.remove(metadata); // Remove
|
||||
}
|
||||
}
|
||||
// TODO: Boat has changed
|
||||
} catch (Exception e) {
|
||||
metadatas.remove(metadata);
|
||||
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
|
||||
|
@ -163,7 +163,19 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
registerOutgoing(State.PLAY, 0x2E, 0x2F);
|
||||
registerOutgoing(State.PLAY, 0x2F, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x31);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x32);
|
||||
// Recipe
|
||||
registerOutgoing(State.PLAY, 0x31, 0x32, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// TODO: This has changed >.>
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(State.PLAY, 0x33, 0x34);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x35);
|
||||
@ -269,7 +281,21 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(State.PLAY, 0x12, 0x12);
|
||||
// Craft recipe request
|
||||
registerIncoming(State.PLAY, 0x12, 0x12, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// TODO: This has changed >.>
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Sound effect
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,10 +102,8 @@ public class EntityPackets {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
Optional<Entity1_12Types.EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId);
|
||||
if (!type.isPresent())
|
||||
return;
|
||||
|
||||
MetadataRewriter.handleMetadata(entityId, type.get(), wrapper.get(Types1_12.METADATA_LIST, 0), wrapper.user());
|
||||
MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_12.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public class WorldPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change
|
||||
protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() {
|
||||
@Override
|
||||
@ -44,6 +45,7 @@ public class WorldPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change
|
||||
protocol.registerOutgoing(State.PLAY, 0x10, 0xF, new PacketRemapper() {
|
||||
@Override
|
||||
@ -107,7 +109,7 @@ public class WorldPackets {
|
||||
});
|
||||
}
|
||||
|
||||
private static int toNewId(int oldId) {
|
||||
public static int toNewId(int oldId) {
|
||||
if (MappingData.oldToNewBlocks.containsKey(oldId)) {
|
||||
return MappingData.oldToNewBlocks.get(oldId);
|
||||
} else {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren