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

Merge pull request #820 from creeper123123321/dev

Fix setFlatBlock, update mappings and change some things on item rewriting
Dieser Commit ist enthalten in:
Mats 2018-04-04 20:22:40 +02:00 committet von GitHub
Commit c0c1a6bbcf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
5 geänderte Dateien mit 71 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -47,7 +47,13 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
@Override @Override
public void setFlatBlock(int x, int y, int z, int type) { public void setFlatBlock(int x, int y, int z, int type) {
throw new UnsupportedOperationException(); int index = palette.indexOf(type);
if (index == -1) {
index = palette.size();
palette.add(type);
}
blocks[index(x, y, z)] = index;
} }
public int getBlockId(int x, int y, int z) { public int getBlockId(int x, int y, int z) {

Datei anzeigen

@ -48,7 +48,13 @@ public class ChunkSection1_9to1_8 implements ChunkSection {
@Override @Override
public void setFlatBlock(int x, int y, int z, int type) { public void setFlatBlock(int x, int y, int z, int type) {
throw new UnsupportedOperationException(); int index = palette.indexOf(type);
if (index == -1) {
index = palette.size();
palette.add(type);
}
blocks[index(x, y, z)] = index;
} }
public int getBlockId(int x, int y, int z) { public int getBlockId(int x, int y, int z) {

Datei anzeigen

@ -198,14 +198,39 @@ public class InventoryPackets {
public static void toClient(Item item) { public static void toClient(Item item) {
if (item == null) return; if (item == null) return;
int rawId = (item.getId() << 4 | item.getData() & 0xF);
int originalId = (item.getId() << 16 | item.getData() & 0xFFFF); // create tag
// Save original id
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
if (tag == null) { if (tag == null) {
item.setTag(tag = new CompoundTag("tag")); item.setTag(tag = new CompoundTag("tag"));
} }
item.getTag().put(new IntTag(NBT_TAG_NAME, originalId));
// Save original id
int originalId = (item.getId() << 16 | item.getData() & 0xFFFF);
tag.put(new IntTag(NBT_TAG_NAME, originalId));
if (isDamageable(item.getId())) {
tag.put(new IntTag("Damage", item.getData()));
}
if (item.getId() == 358) { // map
tag.put(new IntTag("map", item.getData()));
}
if (item.getId() == 442) { // shield
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue()); // invert color id
}
}
}
// todo spawn egg
int rawId = (item.getId() << 4 | item.getData() & 0xF);
if (!MappingData.oldToNewItems.containsKey(rawId)) { if (!MappingData.oldToNewItems.containsKey(rawId)) {
if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) { if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) {
rawId = item.getId() << 4; rawId = item.getId() << 4;
@ -214,31 +239,19 @@ public class InventoryPackets {
rawId = 16; // Stone rawId = 16; // Stone
} }
} }
if (isDamageable(item.getId())) {
tag.put(new IntTag("Damage", item.getData()));
}
if (item.getId() == 358) { // map
tag.put(new IntTag("map", item.getData()));
}
if (item.getId() == 442) { // shield
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue());
}
}
}
// todo spawn egg
item.setId(MappingData.oldToNewItems.get(rawId).shortValue()); item.setId(MappingData.oldToNewItems.get(rawId).shortValue());
item.setData((short) 0); item.setData((short) 0);
} }
public static void toServer(Item item) { public static void toServer(Item item) {
if (item == null) return; if (item == null) return;
Integer rawId = null; Integer rawId = null;
boolean gotRawIdFromTag = false; boolean gotRawIdFromTag = false;
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
if (tag != null) { if (tag != null) {
// Check for valid tag // Check for valid tag
if (tag.contains(NBT_TAG_NAME)) { if (tag.contains(NBT_TAG_NAME)) {
@ -254,31 +267,40 @@ public class InventoryPackets {
for (Map.Entry<Integer, Integer> entry : MappingData.oldToNewItems.entrySet()) { for (Map.Entry<Integer, Integer> entry : MappingData.oldToNewItems.entrySet()) {
if (entry.getValue() == item.getId()) { if (entry.getValue() == item.getId()) {
int oldId = entry.getKey(); int oldId = entry.getKey();
rawId = oldId >> 4 << 16 | oldId & 0xF; rawId = (oldId >> 4) << 16 | oldId & 0xF;
break;
} }
} }
} }
if (rawId != null) { if (rawId != null) {
item.setId((short) (rawId >> 16)); item.setId((short) (rawId >> 16));
item.setData((short) (rawId & 0xFFFF)); item.setData((short) (rawId & 0xFFFF));
if (!gotRawIdFromTag) {
if (tag != null) {
if (isDamageable(item.getId())) { if (isDamageable(item.getId())) {
if (tag != null && tag.get("Damage") instanceof IntTag) { if (tag.get("Damage") instanceof IntTag) {
if (!gotRawIdFromTag)
item.setData((short) (int) tag.get("Damage").getValue()); item.setData((short) (int) tag.get("Damage").getValue());
tag.remove("Damage");
} }
} }
if (item.getId() == 358) { // map if (item.getId() == 358) { // map
if (tag != null && tag.get("map") instanceof IntTag) { if (tag.get("map") instanceof IntTag) {
if (!gotRawIdFromTag)
item.setData((short) (int) tag.get("map").getValue()); item.setData((short) (int) tag.get("map").getValue());
tag.remove("map");
} }
} }
}
if (item.getId() == 442) { // shield if (item.getId() == 442) { // shield
if (tag != null && tag.get("BlockEntityTag") instanceof CompoundTag) { if (tag.get("BlockEntityTag") instanceof CompoundTag) {
CompoundTag blockEntityTag = tag.get("BlockEntityTag"); CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) { if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base"); IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue()); base.setValue(15 - base.getValue()); // invert color id
}
} }
} }
} }

Datei anzeigen

@ -10,7 +10,6 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStora
public class SkullHandler implements BlockEntityProvider.BlockEntityHandler { public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
private final int SKULL_WALL_START = 5357; private final int SKULL_WALL_START = 5357;
private final int SKULL_END = 5476; private final int SKULL_END = 5476;
// remember to change blockstorage
@Override @Override
public int transform(UserConnection user, CompoundTag tag) { public int transform(UserConnection user, CompoundTag tag) {
BlockStorage storage = user.get(BlockStorage.class); BlockStorage storage = user.get(BlockStorage.class);

Datei anzeigen

@ -9170,6 +9170,7 @@
"763": "minecraft:music_disc_ward", "763": "minecraft:music_disc_ward",
"764": "minecraft:music_disc_11", "764": "minecraft:music_disc_11",
"765": "minecraft:music_disc_wait", "765": "minecraft:music_disc_wait",
"766": "minecraft:trident" "766": "minecraft:trident",
"767": "minecraft:phantom_membrane"
} }
} }