Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Send valid biomes again + remap new ones (#136)
* Remap biomes * Fix base shulker box remappings, remove unnecessary int/short casting
Dieser Commit ist enthalten in:
Ursprung
3ecf898d0a
Commit
781ef86af6
@ -43,9 +43,9 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
||||
protected Item handleItemToClient(Item i) {
|
||||
if (i == null)
|
||||
return null;
|
||||
if (!replacementData.containsKey((int) i.getId()))
|
||||
if (!replacementData.containsKey(i.getIdentifier()))
|
||||
return i;
|
||||
BlockItemSettings data = replacementData.get((int) i.getId());
|
||||
BlockItemSettings data = replacementData.get(i.getIdentifier());
|
||||
|
||||
Item original = ItemUtil.copyItem(i);
|
||||
if (data.hasRepItem()) {
|
||||
|
@ -255,7 +255,6 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
Chunk1_13Type type = new Chunk1_13Type(clientWorld);
|
||||
Chunk chunk = wrapper.read(type);
|
||||
|
||||
|
||||
// Handle Block Entities before block rewrite
|
||||
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
@ -324,10 +323,35 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
|
||||
|
||||
// Rewrite biome id 255 to plains
|
||||
if (chunk.isBiomeData()) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
chunk.getBiomeData()[i] = 1; // Plains
|
||||
int biome = chunk.getBiomeData()[i];
|
||||
int newId = -1;
|
||||
switch (biome) {
|
||||
case 40: // end biomes
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
newId = 9;
|
||||
break;
|
||||
case 47: // deep ocean biomes
|
||||
case 48:
|
||||
case 49:
|
||||
newId = 24;
|
||||
break;
|
||||
case 50: // deep frozen... let's just pick the frozen variant
|
||||
newId = 10;
|
||||
break;
|
||||
case 44: // the other new ocean biomes
|
||||
case 45:
|
||||
case 46:
|
||||
newId = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (newId != -1) {
|
||||
chunk.getBiomeData()[i] = newId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,7 +641,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
|
||||
if (rawId == null) {
|
||||
Integer oldId = MappingData.oldToNewItems.inverse().get((int) item.getId());
|
||||
Integer oldId = MappingData.oldToNewItems.inverse().get(item.getIdentifier());
|
||||
if (oldId != null) {
|
||||
// Handle spawn eggs
|
||||
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
|
||||
@ -633,22 +657,24 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
} else {
|
||||
rawId = (oldId >> 4) << 16 | oldId & 0xF;
|
||||
}
|
||||
} else if (item.getIdentifier() == 362) { // base/colorless shulker box
|
||||
rawId = 0xe50000; // purple shulker box
|
||||
}
|
||||
}
|
||||
|
||||
if (rawId == null) {
|
||||
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.12 item for " + item.getId());
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.12 item for " + item.getIdentifier());
|
||||
}
|
||||
rawId = 0x10000; // Stone
|
||||
}
|
||||
|
||||
item.setId((short) (rawId >> 16));
|
||||
item.setIdentifier(rawId >> 16);
|
||||
item.setData((short) (rawId & 0xFFFF));
|
||||
|
||||
// NBT changes
|
||||
if (tag != null) {
|
||||
if (isDamageable(item.getId())) {
|
||||
if (isDamageable(item.getIdentifier())) {
|
||||
if (tag.get("Damage") instanceof IntTag) {
|
||||
if (!gotRawIdFromTag)
|
||||
item.setData((short) (int) tag.get("Damage").getValue());
|
||||
@ -656,7 +682,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getId() == 358) { // map
|
||||
if (item.getIdentifier() == 358) { // map
|
||||
if (tag.get("map") instanceof IntTag) {
|
||||
if (!gotRawIdFromTag)
|
||||
item.setData((short) (int) tag.get("map").getValue());
|
||||
@ -664,7 +690,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getId() == 442 || item.getId() == 425) { // shield / banner
|
||||
if (item.getIdentifier() == 442 || item.getIdentifier() == 425) { // shield / banner
|
||||
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
|
||||
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
|
||||
if (blockEntityTag.get("Base") instanceof IntTag) {
|
||||
@ -837,16 +863,16 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
CompoundTag tag = item.getTag();
|
||||
|
||||
// Save original id
|
||||
int originalId = (item.getId() << 16 | item.getData() & 0xFFFF);
|
||||
int originalId = (item.getIdentifier() << 16 | item.getData() & 0xFFFF);
|
||||
|
||||
int rawId = (item.getId() << 4 | item.getData() & 0xF);
|
||||
int rawId = (item.getIdentifier() << 4 | item.getData() & 0xF);
|
||||
|
||||
// NBT Additions
|
||||
if (isDamageable(item.getId())) {
|
||||
if (isDamageable(item.getIdentifier())) {
|
||||
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
|
||||
tag.put(new IntTag("Damage", item.getData()));
|
||||
}
|
||||
if (item.getId() == 358) { // map
|
||||
if (item.getIdentifier() == 358) { // map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
|
||||
tag.put(new IntTag("map", item.getData()));
|
||||
}
|
||||
@ -854,7 +880,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
// NBT Changes
|
||||
if (tag != null) {
|
||||
// Invert shield color id
|
||||
if (item.getId() == 442 || item.getId() == 425) {
|
||||
if (item.getIdentifier() == 442 || item.getIdentifier() == 425) {
|
||||
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
|
||||
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
|
||||
if (blockEntityTag.get("Base") instanceof IntTag) {
|
||||
@ -910,7 +936,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
|
||||
// Handle SpawnEggs
|
||||
if (item.getId() == 383) {
|
||||
if (item.getIdentifier() == 383) {
|
||||
if (tag.get("EntityTag") instanceof CompoundTag) {
|
||||
CompoundTag entityTag = tag.get("EntityTag");
|
||||
if (entityTag.get("id") instanceof StringTag) {
|
||||
@ -937,24 +963,32 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
}
|
||||
|
||||
int newId = -1;
|
||||
if (!MappingData.oldToNewItems.containsKey(rawId)) {
|
||||
if (!isDamageable(item.getId()) && item.getId() != 358) { // Map
|
||||
if (!isDamageable(item.getIdentifier()) && item.getIdentifier() != 358) { // Map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
|
||||
tag.put(new IntTag(NBT_TAG_NAME, originalId)); // Data will be lost, saving original id
|
||||
}
|
||||
if (item.getId() == 31 && item.getData() == 0) { // Shrub was removed
|
||||
|
||||
if (item.getIdentifier() == 229) { // purple shulker box
|
||||
newId = 362; // directly set the new id -> base/colorless shulker box
|
||||
} else if (item.getIdentifier() == 31 && item.getData() == 0) { // Shrub was removed
|
||||
rawId = 32 << 4; // Dead Bush
|
||||
} else if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
|
||||
rawId &= ~0xF; // Remove data
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getId());
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getIdentifier());
|
||||
}
|
||||
rawId = 16; // Stone
|
||||
}
|
||||
}
|
||||
|
||||
item.setId(MappingData.oldToNewItems.get(rawId).shortValue());
|
||||
if (newId == -1) {
|
||||
newId = MappingData.oldToNewItems.get(rawId);
|
||||
}
|
||||
|
||||
item.setIdentifier(newId);
|
||||
item.setData((short) 0);
|
||||
item = super.handleItemToServer(item);
|
||||
return item;
|
||||
|
@ -155,7 +155,7 @@ public class InventoryPackets1_13_1 {
|
||||
|
||||
public static void toClient(Item item) {
|
||||
if (item == null) return;
|
||||
item.setId((short) getOldItemId(item.getId()));
|
||||
item.setIdentifier(getOldItemId(item.getIdentifier()));
|
||||
}
|
||||
|
||||
//1.13.1 Item Id
|
||||
@ -168,7 +168,7 @@ public class InventoryPackets1_13_1 {
|
||||
|
||||
public static void toServer(Item item) {
|
||||
if (item == null) return;
|
||||
item.setId((short) getNewItemId(item.getId()));
|
||||
item.setIdentifier(getNewItemId(item.getIdentifier()));
|
||||
}
|
||||
|
||||
//1.13 Item Id
|
||||
|
@ -4393,12 +4393,12 @@
|
||||
"minecraft:purpur_slab[type=bottom,waterlogged=true]": "minecraft:purpur_slab[type=bottom,waterlogged=false]",
|
||||
"minecraft:purpur_slab[type=double,waterlogged=true]": "minecraft:purpur_slab[type=double,waterlogged=false]",
|
||||
"minecraft:chorus_plant": "minecraft:chorus_plant[down=false,east=false,north=false,south=false,up=false,west=false]",
|
||||
"minecraft:shulker_box[facing=north]": "minecraft:magenta_shulker_box[facing=north]",
|
||||
"minecraft:shulker_box[facing=east]": "minecraft:magenta_shulker_box[facing=east]",
|
||||
"minecraft:shulker_box[facing=south]": "minecraft:magenta_shulker_box[facing=south]",
|
||||
"minecraft:shulker_box[facing=west]": "minecraft:magenta_shulker_box[facing=west]",
|
||||
"minecraft:shulker_box[facing=up]": "minecraft:magenta_shulker_box[facing=up]",
|
||||
"minecraft:shulker_box[facing=down]": "minecraft:magenta_shulker_box[facing=down]",
|
||||
"minecraft:shulker_box[facing=north]": "minecraft:purple_shulker_box[facing=north]",
|
||||
"minecraft:shulker_box[facing=east]": "minecraft:purple_shulker_box[facing=east]",
|
||||
"minecraft:shulker_box[facing=south]": "minecraft:purple_shulker_box[facing=south]",
|
||||
"minecraft:shulker_box[facing=west]": "minecraft:purple_shulker_box[facing=west]",
|
||||
"minecraft:shulker_box[facing=up]": "minecraft:purple_shulker_box[facing=up]",
|
||||
"minecraft:shulker_box[facing=down]": "minecraft:purple_shulker_box[facing=down]",
|
||||
"minecraft:vine[east=true,north=true,south=true,up=true,west=true]": "minecraft:vine[east=true,north=true,south=true,up=false,west=true]",
|
||||
"minecraft:vine[east=true,north=true,south=true,up=true,west=false]": "minecraft:vine[east=true,north=true,south=true,up=false,west=false]",
|
||||
"minecraft:vine[east=true,north=true,south=false,up=true,west=true]": "minecraft:vine[east=true,north=true,south=false,up=false,west=true]",
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren