Handle skull block entities

This commit is contained in:
Matsv 2019-01-20 17:19:26 +01:00
parent fd4c9b5e6c
commit 520eb15ce9
5 changed files with 167 additions and 6 deletions

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2016 Matsv
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
public class SkullHandler implements BackwardsBlockEntityHandler {
private final int SKULL_START = 5447;
@Override
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
int pos = (blockId - SKULL_START) % 20;
byte type = (byte) Math.floor((blockId - SKULL_START) / 20);
// Set type
tag.put(new ByteTag("SkullType", type));
// Remove wall skulls
if (pos < 4) {
return tag;
}
// Add rotation for normal skulls
tag.put(new ByteTag("Rot", (byte) ((pos - 4) & 255)));
return tag;
}
}

View File

@ -73,6 +73,7 @@ public class BlockItemPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class); BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
switch (wrapper.get(Type.UNSIGNED_BYTE, 0)) { switch (wrapper.get(Type.UNSIGNED_BYTE, 0)) {
case 4:
case 6: case 6:
case 11: case 11:
wrapper.set(Type.NBT, 0, wrapper.set(Type.NBT, 0,

View File

@ -13,6 +13,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.BannerHandler; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.BannerHandler;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.BedHandler; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.BedHandler;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.SkullHandler;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@ -27,10 +28,10 @@ public class BackwardsBlockEntityProvider implements Provider {
private final Map<String, BackwardsBlockEntityProvider.BackwardsBlockEntityHandler> handlers = new ConcurrentHashMap<>(); private final Map<String, BackwardsBlockEntityProvider.BackwardsBlockEntityHandler> handlers = new ConcurrentHashMap<>();
public BackwardsBlockEntityProvider() { public BackwardsBlockEntityProvider() {
handlers.put("minecraft:flower_pot", new FlowerPotHandler()); handlers.put("minecraft:flower_pot", new FlowerPotHandler()); // TODO requires special treatment, manually send
handlers.put("minecraft:bed", new BedHandler()); handlers.put("minecraft:bed", new BedHandler());
handlers.put("minecraft:banner", new BannerHandler()); handlers.put("minecraft:banner", new BannerHandler());
// handlers.put("minecraft:skull", ); handlers.put("minecraft:skull", new SkullHandler());
// handlers.put("minecraft:mob_spawner", ); // handlers.put("minecraft:mob_spawner", );
} }

View File

@ -41,9 +41,9 @@ public class BackwardsBlockStorage extends StoredObject {
// whitelist.add(7110 + i); // whitelist.add(7110 + i);
// } // }
// Skeleton skulls // Skulls
// for (int i = 0; i < 5; i++) for (int i = 5447; i <= 5566; i++)
// whitelist.add(5447 + i); whitelist.add(i);
} }

View File

@ -5127,6 +5127,126 @@
"minecraft:black_wall_banner[facing=north]": "minecraft:white_wall_banner[facing=north]", "minecraft:black_wall_banner[facing=north]": "minecraft:white_wall_banner[facing=north]",
"minecraft:black_wall_banner[facing=south]": "minecraft:white_wall_banner[facing=south]", "minecraft:black_wall_banner[facing=south]": "minecraft:white_wall_banner[facing=south]",
"minecraft:black_wall_banner[facing=west]": "minecraft:white_wall_banner[facing=west]", "minecraft:black_wall_banner[facing=west]": "minecraft:white_wall_banner[facing=west]",
"minecraft:black_wall_banner[facing=east]": "minecraft:white_wall_banner[facing=east]" "minecraft:black_wall_banner[facing=east]": "minecraft:white_wall_banner[facing=east]",
"minecraft:skeleton_wall_skull[facing=north]": "id:2306",
"minecraft:skeleton_wall_skull[facing=south]": "id:2307",
"minecraft:skeleton_wall_skull[facing=west]": "id:2308",
"minecraft:skeleton_wall_skull[facing=east]": "id:2309",
"minecraft:skeleton_skull[rotation=0]": "id:2305",
"minecraft:skeleton_skull[rotation=1]": "id:2305",
"minecraft:skeleton_skull[rotation=2]": "id:2305",
"minecraft:skeleton_skull[rotation=3]": "id:2305",
"minecraft:skeleton_skull[rotation=4]": "id:2305",
"minecraft:skeleton_skull[rotation=5]": "id:2305",
"minecraft:skeleton_skull[rotation=6]": "id:2305",
"minecraft:skeleton_skull[rotation=7]": "id:2305",
"minecraft:skeleton_skull[rotation=8]": "id:2305",
"minecraft:skeleton_skull[rotation=9]": "id:2305",
"minecraft:skeleton_skull[rotation=10]": "id:2305",
"minecraft:skeleton_skull[rotation=11]": "id:2305",
"minecraft:skeleton_skull[rotation=12]": "id:2305",
"minecraft:skeleton_skull[rotation=13]": "id:2305",
"minecraft:skeleton_skull[rotation=14]": "id:2305",
"minecraft:skeleton_skull[rotation=15]": "id:2305",
"minecraft:wither_skeleton_wall_skull[facing=north]": "id:2306",
"minecraft:wither_skeleton_wall_skull[facing=south]": "id:2307",
"minecraft:wither_skeleton_wall_skull[facing=west]": "id:2308",
"minecraft:wither_skeleton_wall_skull[facing=east]": "id:2309",
"minecraft:wither_skeleton_skull[rotation=0]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=1]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=2]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=3]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=4]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=5]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=6]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=7]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=8]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=9]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=10]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=11]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=12]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=13]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=14]": "id:2305",
"minecraft:wither_skeleton_skull[rotation=15]": "id:2305",
"minecraft:zombie_wall_head[facing=north]": "id:2306",
"minecraft:zombie_wall_head[facing=south]": "id:2307",
"minecraft:zombie_wall_head[facing=west]": "id:2308",
"minecraft:zombie_wall_head[facing=east]": "id:2309",
"minecraft:zombie_head[rotation=0]": "id:2305",
"minecraft:zombie_head[rotation=1]": "id:2305",
"minecraft:zombie_head[rotation=2]": "id:2305",
"minecraft:zombie_head[rotation=3]": "id:2305",
"minecraft:zombie_head[rotation=4]": "id:2305",
"minecraft:zombie_head[rotation=5]": "id:2305",
"minecraft:zombie_head[rotation=6]": "id:2305",
"minecraft:zombie_head[rotation=7]": "id:2305",
"minecraft:zombie_head[rotation=8]": "id:2305",
"minecraft:zombie_head[rotation=9]": "id:2305",
"minecraft:zombie_head[rotation=10]": "id:2305",
"minecraft:zombie_head[rotation=11]": "id:2305",
"minecraft:zombie_head[rotation=12]": "id:2305",
"minecraft:zombie_head[rotation=13]": "id:2305",
"minecraft:zombie_head[rotation=14]": "id:2305",
"minecraft:zombie_head[rotation=15]": "id:2305",
"minecraft:player_wall_head[facing=north]": "id:2306",
"minecraft:player_wall_head[facing=south]": "id:2307",
"minecraft:player_wall_head[facing=west]": "id:2308",
"minecraft:player_wall_head[facing=east]": "id:2309",
"minecraft:player_head[rotation=0]": "id:2305",
"minecraft:player_head[rotation=1]": "id:2305",
"minecraft:player_head[rotation=2]": "id:2305",
"minecraft:player_head[rotation=3]": "id:2305",
"minecraft:player_head[rotation=4]": "id:2305",
"minecraft:player_head[rotation=5]": "id:2305",
"minecraft:player_head[rotation=6]": "id:2305",
"minecraft:player_head[rotation=7]": "id:2305",
"minecraft:player_head[rotation=8]": "id:2305",
"minecraft:player_head[rotation=9]": "id:2305",
"minecraft:player_head[rotation=10]": "id:2305",
"minecraft:player_head[rotation=11]": "id:2305",
"minecraft:player_head[rotation=12]": "id:2305",
"minecraft:player_head[rotation=13]": "id:2305",
"minecraft:player_head[rotation=14]": "id:2305",
"minecraft:player_head[rotation=15]": "id:2305",
"minecraft:creeper_wall_head[facing=north]": "id:2306",
"minecraft:creeper_wall_head[facing=south]": "id:2307",
"minecraft:creeper_wall_head[facing=west]": "id:2308",
"minecraft:creeper_wall_head[facing=east]": "id:2309",
"minecraft:creeper_head[rotation=0]": "id:2305",
"minecraft:creeper_head[rotation=1]": "id:2305",
"minecraft:creeper_head[rotation=2]": "id:2305",
"minecraft:creeper_head[rotation=3]": "id:2305",
"minecraft:creeper_head[rotation=4]": "id:2305",
"minecraft:creeper_head[rotation=5]": "id:2305",
"minecraft:creeper_head[rotation=6]": "id:2305",
"minecraft:creeper_head[rotation=7]": "id:2305",
"minecraft:creeper_head[rotation=8]": "id:2305",
"minecraft:creeper_head[rotation=9]": "id:2305",
"minecraft:creeper_head[rotation=10]": "id:2305",
"minecraft:creeper_head[rotation=11]": "id:2305",
"minecraft:creeper_head[rotation=12]": "id:2305",
"minecraft:creeper_head[rotation=13]": "id:2305",
"minecraft:creeper_head[rotation=14]": "id:2305",
"minecraft:creeper_head[rotation=15]": "id:2305",
"minecraft:dragon_wall_head[facing=north]": "id:2306",
"minecraft:dragon_wall_head[facing=south]": "id:2307",
"minecraft:dragon_wall_head[facing=west]": "id:2308",
"minecraft:dragon_wall_head[facing=east]": "id:2309",
"minecraft:dragon_head[rotation=0]": "id:2305",
"minecraft:dragon_head[rotation=1]": "id:2305",
"minecraft:dragon_head[rotation=2]": "id:2305",
"minecraft:dragon_head[rotation=3]": "id:2305",
"minecraft:dragon_head[rotation=4]": "id:2305",
"minecraft:dragon_head[rotation=5]": "id:2305",
"minecraft:dragon_head[rotation=6]": "id:2305",
"minecraft:dragon_head[rotation=7]": "id:2305",
"minecraft:dragon_head[rotation=8]": "id:2305",
"minecraft:dragon_head[rotation=9]": "id:2305",
"minecraft:dragon_head[rotation=10]": "id:2305",
"minecraft:dragon_head[rotation=11]": "id:2305",
"minecraft:dragon_head[rotation=12]": "id:2305",
"minecraft:dragon_head[rotation=13]": "id:2305",
"minecraft:dragon_head[rotation=14]": "id:2305",
"minecraft:dragon_head[rotation=15]": "id:2305"
} }
} }