mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-14 10:55:20 +01:00
Fix NPE for unknown beds & keep original NBT data
This commit is contained in:
parent
ea2f603cf7
commit
dbc92572fd
@ -52,8 +52,15 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
|||||||
|
|
||||||
if (i.getTag() == null)
|
if (i.getTag() == null)
|
||||||
i.setTag(new CompoundTag(""));
|
i.setTag(new CompoundTag(""));
|
||||||
|
|
||||||
|
// Backup data for toServer
|
||||||
i.getTag().put(createViaNBT(original));
|
i.getTag().put(createViaNBT(original));
|
||||||
|
|
||||||
|
// Keep original data
|
||||||
|
if (original.getTag() != null)
|
||||||
|
for (Tag ai : original.getTag())
|
||||||
|
i.getTag().put(ai);
|
||||||
|
|
||||||
// Handle colors
|
// Handle colors
|
||||||
if (i.getTag().contains("display")) {
|
if (i.getTag().contains("display")) {
|
||||||
CompoundTag tag = i.getTag().get("display");
|
CompoundTag tag = i.getTag().get("display");
|
||||||
@ -76,6 +83,8 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
|||||||
data.getItemHandler().handle(i);
|
data.getItemHandler().handle(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println(i);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +155,10 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
|||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
int block = section.getBlock(x, y, z);
|
int block = section.getBlock(x, y, z);
|
||||||
int btype = block >> 4;
|
int btype = block >> 4;
|
||||||
|
int meta = block & 15;
|
||||||
|
|
||||||
if (containsBlock(btype)) {
|
if (containsBlock(btype)) {
|
||||||
Block b = handleBlock(btype, block & 15); // Type / data
|
Block b = handleBlock(btype, meta); // Type / data
|
||||||
section.setBlock(x, y, z, b.getId(), b.getData());
|
section.setBlock(x, y, z, b.getId(), b.getData());
|
||||||
}
|
}
|
||||||
// Entity Tags
|
// Entity Tags
|
||||||
|
@ -45,6 +45,6 @@ public class BlockColors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String get(Integer key) {
|
public static String get(Integer key) {
|
||||||
return colors.get(key);
|
return colors.getOrDefault(key, "Unknown color");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user