3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-19 18:40:04 +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,6 +16,7 @@ import java.util.List;
public class MetadataRewriter { public class MetadataRewriter {
public static void handleMetadata(int entityId, Entity1_13Types.EntityType type, List<Metadata> metadatas, UserConnection connection) { public static void handleMetadata(int entityId, Entity1_13Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
for (Metadata metadata : new ArrayList<>(metadatas)) { for (Metadata metadata : new ArrayList<>(metadatas)) {
try {
// Handle new MetaTypes // Handle new MetaTypes
if (metadata.getMetaType().getTypeID() > 4) if (metadata.getMetaType().getTypeID() > 4)
metadata.setMetaType(MetaType1_13.byId(metadata.getMetaType().getTypeID() + 1)); metadata.setMetaType(MetaType1_13.byId(metadata.getMetaType().getTypeID() + 1));
@ -30,11 +31,6 @@ public class MetadataRewriter {
} }
} }
// 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) // 1.13 changed item to flat item (no data)
if (metadata.getMetaType() == MetaType1_13.Slot) { if (metadata.getMetaType() == MetaType1_13.Slot) {
metadata.setMetaType(MetaType1_13.Slot); metadata.setMetaType(MetaType1_13.Slot);
@ -45,9 +41,18 @@ public class MetadataRewriter {
metadata.setValue(WorldPackets.toNewId((int) metadata.getValue())); 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 // Handle other changes
try { if (type.is(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD)) {
if (type != null && type.is(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD)) {
if (metadata.getId() == 9 || 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

Datei anzeigen

@ -139,7 +139,7 @@ public class WorldPackets {
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
Chunk1_13Type type1_13 = new Chunk1_13Type(clientWorld); Chunk1_13Type type1_13 = new Chunk1_13Type(clientWorld);
Chunk chunk = wrapper.read(type); Chunk chunk = wrapper.read(type);
wrapper.write(type1_13,chunk); wrapper.write(type1_13, chunk);
for (int i = 0; i < chunk.getSections().length; i++) { for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i]; ChunkSection section = chunk.getSections()[i];
@ -172,16 +172,16 @@ public class WorldPackets {
for (CompoundTag tag : chunk.getBlockEntities()) { for (CompoundTag tag : chunk.getBlockEntities()) {
int newId = provider.transform(wrapper.user(), null, tag, false); int newId = provider.transform(wrapper.user(), null, tag, false);
if (newId != -1) { 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 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); Position position = new Position((long) x, (long) y, (long) z);
// Store the replacement blocks for blockupdates // Store the replacement blocks for blockupdates
if (storage.contains(position)) if (storage.contains(position))
storage.get(position).setReplacement(newId); 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); super(user);
} }
public static void main(String[] args) {
new BlockStorage(null);
}
public void store(Position position, int block) { public void store(Position position, int block) {
store(position, block, -1); store(position, block, -1);
} }
@ -80,4 +76,10 @@ public class BlockStorage extends StoredObject {
private int original; private int original;
private int replacement; private int replacement;
} }
public static void main(String[] args) {
System.out.println(17 & 0xF);
System.out.println(0xF);
}
} }