3
0
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:
Myles 2017-12-24 12:20:09 +00:00
Ursprung cc4ae6eb80
Commit ede4fa5a5d
4 geänderte Dateien mit 320 neuen und 288 gelöschten Zeilen

Datei anzeigen

@ -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.minecraft.metadata.types.MetaType1_13;
import us.myles.ViaVersion.api.type.Type; 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.InventoryPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -21,15 +22,20 @@ public class MetadataRewriter {
metadata.setMetaType(MetaType1_13.Slot); metadata.setMetaType(MetaType1_13.Slot);
InventoryPackets.toClient((Item) metadata.getValue()); 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 // Handle other changes
try { try {
if (type.is(Entity1_12Types.EntityType.AREA_EFFECT_CLOUD)) { if (type != null && type.is(Entity1_12Types.EntityType.AREA_EFFECT_CLOUD)) {
if (metadata.getId() == 10 || metadata.getId() == 11) { if (metadata.getId() == 9 || metadata.getId() == 10 || metadata.getId() == 11) {
// TODO: AreaEffectCloud has lost 2 integers and gained "ef" // TODO: AreaEffectCloud has lost 2 integers and gained "ef"
// Will be implemented when more info is known // Will be implemented when more info is known
metadatas.remove(metadata); // Remove metadatas.remove(metadata); // Remove
} }
} }
// TODO: Boat has changed
} catch (Exception e) { } catch (Exception e) {
metadatas.remove(metadata); metadatas.remove(metadata);
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {

Datei anzeigen

@ -1,282 +1,308 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2; package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.EntityTracker;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.TabCompleteTracker; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.TabCompleteTracker;
// Development of 1.13 support! // Development of 1.13 support!
public class ProtocolSnapshotTo1_12_2 extends Protocol { public class ProtocolSnapshotTo1_12_2 extends Protocol {
static { static {
MappingData.init(); MappingData.init();
} }
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Register grouped packet changes // Register grouped packet changes
EntityPackets.register(this); EntityPackets.register(this);
WorldPackets.register(this); WorldPackets.register(this);
InventoryPackets.register(this); InventoryPackets.register(this);
// Outgoing packets // Outgoing packets
// Statistics // Statistics
registerOutgoing(State.PLAY, 0x7, 0x7, new PacketRemapper() { registerOutgoing(State.PLAY, 0x7, 0x7, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
// TODO: This packet has changed // TODO: This packet has changed
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel(); wrapper.cancel();
} }
}); });
} }
}); });
registerOutgoing(State.PLAY, 0xF, 0xE); registerOutgoing(State.PLAY, 0xF, 0xE);
// Tab-Complete // Tab-Complete
registerOutgoing(State.PLAY, 0xE, 0x10, new PacketRemapper() { registerOutgoing(State.PLAY, 0xE, 0x10, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(new ValueCreator() {
@Override @Override
public void write(PacketWrapper wrapper) throws Exception { public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.VAR_INT, wrapper.user().get(TabCompleteTracker.class).getTransactionId()); wrapper.write(Type.VAR_INT, wrapper.user().get(TabCompleteTracker.class).getTransactionId());
String input = wrapper.user().get(TabCompleteTracker.class).getInput(); String input = wrapper.user().get(TabCompleteTracker.class).getInput();
// Start & End // Start & End
int index; int index;
int length; int length;
// If no input or new word (then it's the start) // If no input or new word (then it's the start)
if (input.endsWith(" ") || input.length() == 0) { if (input.endsWith(" ") || input.length() == 0) {
index = input.length(); index = input.length();
length = 0; length = 0;
} else { } else {
// Otherwise find the last space (+1 as we include it) // Otherwise find the last space (+1 as we include it)
int lastSpace = input.lastIndexOf(" ") + 1; int lastSpace = input.lastIndexOf(" ") + 1;
index = lastSpace; index = lastSpace;
length = input.length() - lastSpace; length = input.length() - lastSpace;
} }
// Write index + length // Write index + length
wrapper.write(Type.VAR_INT, index); wrapper.write(Type.VAR_INT, index);
wrapper.write(Type.VAR_INT, length); wrapper.write(Type.VAR_INT, length);
int count = wrapper.passthrough(Type.VAR_INT); int count = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
String suggestion = wrapper.read(Type.STRING); String suggestion = wrapper.read(Type.STRING);
// If we're at the start then handle removing slash // If we're at the start then handle removing slash
if (suggestion.startsWith("/") && index == 0) { if (suggestion.startsWith("/") && index == 0) {
suggestion = suggestion.substring(1); suggestion = suggestion.substring(1);
} }
wrapper.write(Type.STRING, suggestion); wrapper.write(Type.STRING, suggestion);
} }
} }
}); });
} }
}); });
// New packet 0x11, declare commands // New packet 0x11, declare commands
registerOutgoing(State.PLAY, 0x11, 0x12); registerOutgoing(State.PLAY, 0x11, 0x12);
registerOutgoing(State.PLAY, 0x12, 0x13); registerOutgoing(State.PLAY, 0x12, 0x13);
registerOutgoing(State.PLAY, 0x13, 0x14); registerOutgoing(State.PLAY, 0x13, 0x14);
registerOutgoing(State.PLAY, 0x15, 0x16); registerOutgoing(State.PLAY, 0x15, 0x16);
registerOutgoing(State.PLAY, 0x17, 0x18); registerOutgoing(State.PLAY, 0x17, 0x18);
registerOutgoing(State.PLAY, 0x1A, 0x1B); registerOutgoing(State.PLAY, 0x1A, 0x1B);
registerOutgoing(State.PLAY, 0x1B, 0x1C); registerOutgoing(State.PLAY, 0x1B, 0x1C);
registerOutgoing(State.PLAY, 0x1C, 0x1D); registerOutgoing(State.PLAY, 0x1C, 0x1D);
registerOutgoing(State.PLAY, 0x1D, 0x1E); registerOutgoing(State.PLAY, 0x1D, 0x1E);
registerOutgoing(State.PLAY, 0x1E, 0x1F); registerOutgoing(State.PLAY, 0x1E, 0x1F);
registerOutgoing(State.PLAY, 0x1F, 0x20); registerOutgoing(State.PLAY, 0x1F, 0x20);
registerOutgoing(State.PLAY, 0x21, 0x22); registerOutgoing(State.PLAY, 0x21, 0x22);
// Join (save dimension id) // Join (save dimension id)
registerOutgoing(State.PLAY, 0x23, 0x24, new PacketRemapper() { registerOutgoing(State.PLAY, 0x23, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID
map(Type.UNSIGNED_BYTE); // 1 - Gamemode map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension map(Type.INT); // 2 - Dimension
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 1); int dimensionId = wrapper.get(Type.INT, 1);
clientChunks.setEnvironment(dimensionId); clientChunks.setEnvironment(dimensionId);
// Send fake declare commands // Send fake declare commands
wrapper.create(0x11, new ValueCreator() { wrapper.create(0x11, new ValueCreator() {
@Override @Override
public void write(PacketWrapper wrapper) { public void write(PacketWrapper wrapper) {
wrapper.write(Type.VAR_INT, 2); // Size wrapper.write(Type.VAR_INT, 2); // Size
// Write root node // Write root node
wrapper.write(Type.VAR_INT, 0); // Mark as command wrapper.write(Type.VAR_INT, 0); // Mark as command
wrapper.write(Type.VAR_INT, 1); // 1 child wrapper.write(Type.VAR_INT, 1); // 1 child
wrapper.write(Type.VAR_INT, 1); // Child is at 1 wrapper.write(Type.VAR_INT, 1); // Child is at 1
// Write arg node // Write arg node
wrapper.write(Type.VAR_INT, 0x02 | 0x04 | 0x10); // Mark as command wrapper.write(Type.VAR_INT, 0x02 | 0x04 | 0x10); // Mark as command
wrapper.write(Type.VAR_INT, 0); // No children wrapper.write(Type.VAR_INT, 0); // No children
// Extra data // Extra data
wrapper.write(Type.STRING, "args"); // Arg name wrapper.write(Type.STRING, "args"); // Arg name
wrapper.write(Type.STRING, "brigadier:string"); wrapper.write(Type.STRING, "brigadier:string");
wrapper.write(Type.VAR_INT, 2); // Greedy wrapper.write(Type.VAR_INT, 2); // Greedy
wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server
wrapper.write(Type.VAR_INT, 0); // Root node index wrapper.write(Type.VAR_INT, 0); // Root node index
} }
}).send(ProtocolSnapshotTo1_12_2.class); }).send(ProtocolSnapshotTo1_12_2.class);
} }
}); });
} }
}); });
registerOutgoing(State.PLAY, 0x24, 0x25); registerOutgoing(State.PLAY, 0x24, 0x25);
registerOutgoing(State.PLAY, 0x25, 0x26); registerOutgoing(State.PLAY, 0x25, 0x26);
registerOutgoing(State.PLAY, 0x26, 0x27); registerOutgoing(State.PLAY, 0x26, 0x27);
registerOutgoing(State.PLAY, 0x27, 0x28); registerOutgoing(State.PLAY, 0x27, 0x28);
registerOutgoing(State.PLAY, 0x28, 0x29); registerOutgoing(State.PLAY, 0x28, 0x29);
registerOutgoing(State.PLAY, 0x29, 0x2A); registerOutgoing(State.PLAY, 0x29, 0x2A);
registerOutgoing(State.PLAY, 0x2A, 0x2B); registerOutgoing(State.PLAY, 0x2A, 0x2B);
registerOutgoing(State.PLAY, 0x2B, 0x2C); registerOutgoing(State.PLAY, 0x2B, 0x2C);
registerOutgoing(State.PLAY, 0x2C, 0x2D); registerOutgoing(State.PLAY, 0x2C, 0x2D);
registerOutgoing(State.PLAY, 0x2D, 0x2E); registerOutgoing(State.PLAY, 0x2D, 0x2E);
registerOutgoing(State.PLAY, 0x2E, 0x2F); registerOutgoing(State.PLAY, 0x2E, 0x2F);
registerOutgoing(State.PLAY, 0x2F, 0x30); registerOutgoing(State.PLAY, 0x2F, 0x30);
registerOutgoing(State.PLAY, 0x30, 0x31); registerOutgoing(State.PLAY, 0x30, 0x31);
registerOutgoing(State.PLAY, 0x31, 0x32); // Recipe
registerOutgoing(State.PLAY, 0x31, 0x32, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x33, 0x34); @Override
registerOutgoing(State.PLAY, 0x34, 0x35); public void registerMap() {
handler(new PacketHandler() {
// Respawn (save dimension id) @Override
registerOutgoing(State.PLAY, 0x35, 0x36, new PacketRemapper() { public void handle(PacketWrapper wrapper) throws Exception {
@Override // TODO: This has changed >.>
public void registerMap() { wrapper.cancel();
map(Type.INT); // 0 - Dimension ID }
handler(new PacketHandler() { });
@Override }
public void handle(PacketWrapper wrapper) throws Exception { });
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 0); registerOutgoing(State.PLAY, 0x33, 0x34);
clientWorld.setEnvironment(dimensionId); registerOutgoing(State.PLAY, 0x34, 0x35);
}
}); // Respawn (save dimension id)
} registerOutgoing(State.PLAY, 0x35, 0x36, new PacketRemapper() {
}); @Override
public void registerMap() {
registerOutgoing(State.PLAY, 0x36, 0x37); map(Type.INT); // 0 - Dimension ID
registerOutgoing(State.PLAY, 0x37, 0x38); handler(new PacketHandler() {
registerOutgoing(State.PLAY, 0x38, 0x39); @Override
registerOutgoing(State.PLAY, 0x39, 0x3A); public void handle(PacketWrapper wrapper) throws Exception {
registerOutgoing(State.PLAY, 0x3A, 0x3B); ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
registerOutgoing(State.PLAY, 0x3B, 0x3C); int dimensionId = wrapper.get(Type.INT, 0);
clientWorld.setEnvironment(dimensionId);
registerOutgoing(State.PLAY, 0x3D, 0x3E); }
registerOutgoing(State.PLAY, 0x3E, 0x3F); });
}
registerOutgoing(State.PLAY, 0x40, 0x41); });
registerOutgoing(State.PLAY, 0x41, 0x42);
// Scoreboard Objective registerOutgoing(State.PLAY, 0x36, 0x37);
registerOutgoing(State.PLAY, 0x42, 0x43, new PacketRemapper() { registerOutgoing(State.PLAY, 0x37, 0x38);
@Override registerOutgoing(State.PLAY, 0x38, 0x39);
public void registerMap() { registerOutgoing(State.PLAY, 0x39, 0x3A);
map(Type.STRING); registerOutgoing(State.PLAY, 0x3A, 0x3B);
map(Type.BYTE); registerOutgoing(State.PLAY, 0x3B, 0x3C);
handler(new PacketHandler() {
@Override registerOutgoing(State.PLAY, 0x3D, 0x3E);
public void handle(PacketWrapper wrapper) throws Exception { registerOutgoing(State.PLAY, 0x3E, 0x3F);
if (wrapper.get(Type.BYTE, 0) == 0 || wrapper.get(Type.BYTE, 0) == 1) {
wrapper.passthrough(Type.STRING); registerOutgoing(State.PLAY, 0x40, 0x41);
String type = wrapper.read(Type.STRING); registerOutgoing(State.PLAY, 0x41, 0x42);
// integer or hearts // Scoreboard Objective
wrapper.write(Type.VAR_INT, type.equals("integer") ? 0 : 1); registerOutgoing(State.PLAY, 0x42, 0x43, new PacketRemapper() {
} @Override
} public void registerMap() {
}); map(Type.STRING);
} map(Type.BYTE);
}); handler(new PacketHandler() {
@Override
registerOutgoing(State.PLAY, 0x43, 0x44); public void handle(PacketWrapper wrapper) throws Exception {
registerOutgoing(State.PLAY, 0x44, 0x45); if (wrapper.get(Type.BYTE, 0) == 0 || wrapper.get(Type.BYTE, 0) == 1) {
registerOutgoing(State.PLAY, 0x45, 0x46); wrapper.passthrough(Type.STRING);
registerOutgoing(State.PLAY, 0x46, 0x47); String type = wrapper.read(Type.STRING);
registerOutgoing(State.PLAY, 0x47, 0x48); // integer or hearts
registerOutgoing(State.PLAY, 0x48, 0x49); wrapper.write(Type.VAR_INT, type.equals("integer") ? 0 : 1);
// New packet 0x4A - Stop sound (TODO: Migrate from Plugin Messages) }
registerOutgoing(State.PLAY, 0x49, 0x4B); }
registerOutgoing(State.PLAY, 0x4A, 0x4C); });
registerOutgoing(State.PLAY, 0x4B, 0x4D); }
registerOutgoing(State.PLAY, 0x4C, 0x4E); });
registerOutgoing(State.PLAY, 0x4D, 0x4F);
registerOutgoing(State.PLAY, 0x4E, 0x50); registerOutgoing(State.PLAY, 0x43, 0x44);
registerOutgoing(State.PLAY, 0x4F, 0x51); registerOutgoing(State.PLAY, 0x44, 0x45);
// New packet 0x52 - Declare Recipes registerOutgoing(State.PLAY, 0x45, 0x46);
// New packet 0x53 - Tags registerOutgoing(State.PLAY, 0x46, 0x47);
registerOutgoing(State.PLAY, 0x47, 0x48);
// Incoming packets registerOutgoing(State.PLAY, 0x48, 0x49);
registerIncoming(State.PLAY, 0x2, 0x1); // New packet 0x4A - Stop sound (TODO: Migrate from Plugin Messages)
registerIncoming(State.PLAY, 0x3, 0x2); registerOutgoing(State.PLAY, 0x49, 0x4B);
registerIncoming(State.PLAY, 0x4, 0x3); registerOutgoing(State.PLAY, 0x4A, 0x4C);
registerOutgoing(State.PLAY, 0x4B, 0x4D);
// Tab-Complete registerOutgoing(State.PLAY, 0x4C, 0x4E);
registerIncoming(State.PLAY, 0x1, 0x4, new PacketRemapper() { registerOutgoing(State.PLAY, 0x4D, 0x4F);
@Override registerOutgoing(State.PLAY, 0x4E, 0x50);
public void registerMap() { registerOutgoing(State.PLAY, 0x4F, 0x51);
handler(new PacketHandler() { // New packet 0x52 - Declare Recipes
@Override // New packet 0x53 - Tags
public void handle(PacketWrapper wrapper) throws Exception {
int tid = wrapper.read(Type.VAR_INT); // Incoming packets
// Save transaction id registerIncoming(State.PLAY, 0x2, 0x1);
wrapper.user().get(TabCompleteTracker.class).setTransactionId(tid); registerIncoming(State.PLAY, 0x3, 0x2);
} registerIncoming(State.PLAY, 0x4, 0x3);
});
// Prepend / // Tab-Complete
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) { registerIncoming(State.PLAY, 0x1, 0x4, new PacketRemapper() {
@Override @Override
public String transform(PacketWrapper wrapper, String inputValue) { public void registerMap() {
wrapper.user().get(TabCompleteTracker.class).setInput(inputValue); handler(new PacketHandler() {
return "/" + inputValue; @Override
} public void handle(PacketWrapper wrapper) throws Exception {
}); int tid = wrapper.read(Type.VAR_INT);
// Fake the end of the packet // Save transaction id
create(new ValueCreator() { wrapper.user().get(TabCompleteTracker.class).setTransactionId(tid);
@Override }
public void write(PacketWrapper wrapper) { });
wrapper.write(Type.BOOLEAN, false); // Prepend /
wrapper.write(Type.OPTIONAL_POSITION, null); map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
} @Override
}); public String transform(PacketWrapper wrapper, String inputValue) {
} wrapper.user().get(TabCompleteTracker.class).setInput(inputValue);
}); return "/" + inputValue;
}
registerIncoming(State.PLAY, 0x12, 0x12); });
} // Fake the end of the packet
create(new ValueCreator() {
@Override @Override
public void init(UserConnection userConnection) { public void write(PacketWrapper wrapper) {
userConnection.put(new EntityTracker(userConnection)); wrapper.write(Type.BOOLEAN, false);
userConnection.put(new TabCompleteTracker(userConnection)); wrapper.write(Type.OPTIONAL_POSITION, null);
if (!userConnection.has(ClientWorld.class)) }
userConnection.put(new ClientWorld(userConnection)); });
} }
} });
// 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
public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker(userConnection));
userConnection.put(new TabCompleteTracker(userConnection));
if (!userConnection.has(ClientWorld.class))
userConnection.put(new ClientWorld(userConnection));
}
}

Datei anzeigen

@ -102,10 +102,8 @@ public class EntityPackets {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
Optional<Entity1_12Types.EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId); 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());
} }
}); });
} }

Datei anzeigen

@ -30,6 +30,7 @@ public class WorldPackets {
}); });
} }
}); });
// Block Change // Block Change
protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() {
@Override @Override
@ -44,6 +45,7 @@ public class WorldPackets {
}); });
} }
}); });
// Multi Block Change // Multi Block Change
protocol.registerOutgoing(State.PLAY, 0x10, 0xF, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x10, 0xF, new PacketRemapper() {
@Override @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)) { if (MappingData.oldToNewBlocks.containsKey(oldId)) {
return MappingData.oldToNewBlocks.get(oldId); return MappingData.oldToNewBlocks.get(oldId);
} else { } else {