3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-17 01:23:43 +02:00

Correct x, z for BlockStorage

Dieser Commit ist enthalten in:
Matsv 2018-03-20 10:14:47 +01:00
Ursprung a6af99fdbc
Commit 4f3074eca8
3 geänderte Dateien mit 46 neuen und 39 gelöschten Zeilen

Datei anzeigen

@ -16,38 +16,43 @@ import java.util.List;
public class MetadataRewriter {
public static void handleMetadata(int entityId, Entity1_13Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
for (Metadata metadata : new ArrayList<>(metadatas)) {
// Handle new MetaTypes
if (metadata.getMetaType().getTypeID() > 4)
metadata.setMetaType(MetaType1_13.byId(metadata.getMetaType().getTypeID() + 1));
// Handle String -> Chat DisplayName
if (metadata.getId() == 2) {
metadata.setMetaType(MetaType1_13.OptChat);
if (metadata.getValue() != null && !((String) metadata.getValue()).isEmpty()) {
metadata.setValue(Protocol1_9TO1_8.fixJson((String) metadata.getValue()));
} else {
metadata.setValue(null);
}
}
// Handle new colors
if (type.is(Entity1_13Types.EntityType.WOLF) && metadata.getId() == 17) {
metadata.setValue(15 - (int) metadata.getValue());
}
// 1.13 changed item to flat item (no data)
if (metadata.getMetaType() == MetaType1_13.Slot) {
metadata.setMetaType(MetaType1_13.Slot);
InventoryPackets.toClient((Item) metadata.getValue());
}
if (metadata.getMetaType() == MetaType1_13.BlockID) {
// Convert to new block id
metadata.setValue(WorldPackets.toNewId((int) metadata.getValue()));
}
// Handle other changes
try {
if (type != null && type.is(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD)) {
// Handle new MetaTypes
if (metadata.getMetaType().getTypeID() > 4)
metadata.setMetaType(MetaType1_13.byId(metadata.getMetaType().getTypeID() + 1));
// Handle String -> Chat DisplayName
if (metadata.getId() == 2) {
metadata.setMetaType(MetaType1_13.OptChat);
if (metadata.getValue() != null && !((String) metadata.getValue()).isEmpty()) {
metadata.setValue(Protocol1_9TO1_8.fixJson((String) metadata.getValue()));
} else {
metadata.setValue(null);
}
}
// 1.13 changed item to flat item (no data)
if (metadata.getMetaType() == MetaType1_13.Slot) {
metadata.setMetaType(MetaType1_13.Slot);
InventoryPackets.toClient((Item) metadata.getValue());
}
if (metadata.getMetaType() == MetaType1_13.BlockID) {
// Convert to new block id
metadata.setValue(WorldPackets.toNewId((int) metadata.getValue()));
}
// Skip type related changes when the type is null
if (type == null)
continue;
// Handle new colors
if (type.is(Entity1_13Types.EntityType.WOLF) && metadata.getId() == 17) {
metadata.setValue(15 - (int) metadata.getValue());
}
// Handle other changes
if (type.is(Entity1_13Types.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

Datei anzeigen

@ -139,7 +139,7 @@ public class WorldPackets {
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
Chunk1_13Type type1_13 = new Chunk1_13Type(clientWorld);
Chunk chunk = wrapper.read(type);
wrapper.write(type1_13,chunk);
wrapper.write(type1_13, chunk);
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
@ -172,16 +172,16 @@ public class WorldPackets {
for (CompoundTag tag : chunk.getBlockEntities()) {
int newId = provider.transform(wrapper.user(), null, tag, false);
if (newId != -1) {
int x = (int) tag.get("x").getValue() & 0xF;
int x = (int) tag.get("x").getValue();
int y = (int) tag.get("y").getValue();
int z = (int) tag.get("z").getValue() & 0xF;
int z = (int) tag.get("z").getValue();
Position position = new Position((long) x, (long) y, (long) z);
// Store the replacement blocks for blockupdates
if (storage.contains(position))
storage.get(position).setReplacement(newId);
chunk.getSections()[y >> 4].setFlatBlock(x, y, z, newId);
chunk.getSections()[y >> 4].setFlatBlock(x & 0xF, y, z & 0xF, newId);
}
}
}

Datei anzeigen

@ -43,10 +43,6 @@ public class BlockStorage extends StoredObject {
super(user);
}
public static void main(String[] args) {
new BlockStorage(null);
}
public void store(Position position, int block) {
store(position, block, -1);
}
@ -80,4 +76,10 @@ public class BlockStorage extends StoredObject {
private int original;
private int replacement;
}
public static void main(String[] args) {
System.out.println(17 & 0xF);
System.out.println(0xF);
}
}