use of com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage in project Geyser by GeyserMC.
the class GeyserSpigot1_12WorldManager method getBlockNetworkId.
@Override
@SuppressWarnings("deprecation")
public int getBlockNetworkId(Player player, Block block, int x, int y, int z) {
// Get block entity storage
BlockStorage storage = Via.getManager().getConnectionManager().getConnectedClient(player.getUniqueId()).get(BlockStorage.class);
// Black magic that gets the old block state ID
int oldBlockId = (block.getType().getId() << 4) | (block.getData() & 0xF);
return getLegacyBlock(storage, oldBlockId, x, y, z);
}
use of com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage in project ViaVersion by ViaVersion.
the class BannerHandler method transform.
@Override
public int transform(UserConnection user, CompoundTag tag) {
BlockStorage storage = user.get(BlockStorage.class);
Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
if (!storage.contains(position)) {
Via.getPlatform().getLogger().warning("Received an banner color update packet, but there is no banner! O_o " + tag);
return -1;
}
int blockId = storage.get(position).getOriginal();
Tag base = tag.get("Base");
int color = 0;
if (base != null) {
color = ((NumberTag) tag.get("Base")).asInt();
}
// Standing banner
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
blockId += ((15 - color) * 16);
// Wall banner
} else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
blockId += ((15 - color) * 4);
} else {
Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
}
if (tag.get("Patterns") instanceof ListTag) {
for (Tag pattern : (ListTag) tag.get("Patterns")) {
if (pattern instanceof CompoundTag) {
Tag c = ((CompoundTag) pattern).get("Color");
if (c instanceof IntTag) {
// Invert color id
((IntTag) c).setValue(15 - (int) c.getValue());
}
}
}
}
Tag name = tag.get("CustomName");
if (name instanceof StringTag) {
((StringTag) name).setValue(ChatRewriter.legacyTextToJsonString(((StringTag) name).getValue()));
}
return blockId;
}
use of com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage in project ViaVersion by ViaVersion.
the class SkullHandler method transform.
@Override
public int transform(UserConnection user, CompoundTag tag) {
BlockStorage storage = user.get(BlockStorage.class);
Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
if (!storage.contains(position)) {
Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag);
return -1;
}
int id = storage.get(position).getOriginal();
if (id >= SKULL_WALL_START && id <= SKULL_END) {
Tag skullType = tag.get("SkullType");
if (skullType != null) {
id += ((NumberTag) tag.get("SkullType")).asInt() * 20;
}
if (tag.contains("Rot")) {
id += ((NumberTag) tag.get("Rot")).asInt();
}
} else {
Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);
return -1;
}
return id;
}
use of com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage in project DirtMultiversion by DirtPowered.
the class ProtocolBeta17to14 method onConnect.
@Override
public void onConnect(ServerSession session) {
ProtocolStorage storage = session.getStorage();
storage.set(BlockStorage.class, new BlockStorage(MinecraftVersion.B1_7_3));
storage.set(PlayerTabListCache.class, new PlayerTabListCache());
storage.set(KeepAliveTask.class, new KeepAliveTask(session));
storage.set(PlayerHealthTracker.class, new PlayerHealthTracker());
session.broadcastPacket(createTabEntryPacket(session.getUserData().getUsername(), true), getFrom());
}
use of com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage in project DirtMultiversion by DirtPowered.
the class RotationUtil method fixBlockRotation.
public static byte fixBlockRotation(ServerSession session, int startX, int startY, int startZ) {
BlockStorage blockStorage = session.getUserData().getProtocolStorage().get(BlockStorage.class);
byte blockData = 3;
if (blockStorage == null) {
return blockData;
}
int rot1 = blockStorage.getBlockAt(startX, startY, startZ - 1);
int rot2 = blockStorage.getBlockAt(startX, startY, startZ + 1);
int rot3 = blockStorage.getBlockAt(startX - 1, startY, startZ);
int rot4 = blockStorage.getBlockAt(startX + 1, startY, startZ);
int rot5;
if (rot3 == CHEST_BLOCK) {
rot5 = blockStorage.getBlockAt(startX - 1, startY, startZ - 1);
} else {
rot5 = blockStorage.getBlockAt(startX + 1, startY, startZ - 1);
}
int rot6;
if (rot3 == CHEST_BLOCK) {
rot6 = blockStorage.getBlockAt(startX - 1, startY, startZ + 1);
} else {
rot6 = blockStorage.getBlockAt(startX + 1, startY, startZ + 1);
}
if (rot1 != CHEST_BLOCK && rot2 != CHEST_BLOCK) {
if (rot3 != CHEST_BLOCK && rot4 != CHEST_BLOCK) {
if (SolidBlockList.isSolid(rot2) && !SolidBlockList.isSolid(rot1)) {
blockData = 2;
}
if (SolidBlockList.isSolid(rot3) && !SolidBlockList.isSolid(rot4)) {
blockData = 5;
}
if (SolidBlockList.isSolid(rot4) && !SolidBlockList.isSolid(rot3)) {
blockData = 4;
}
} else {
if (SolidBlockList.isSolid(rot2) || SolidBlockList.isSolid(rot6)) {
if (!SolidBlockList.isSolid(rot1) && !SolidBlockList.isSolid(rot5)) {
blockData = 2;
}
}
}
} else {
blockData = 5;
if (rot1 == CHEST_BLOCK) {
rot5 = blockStorage.getBlockAt(startX - 1, startY, startZ - 1);
} else {
rot5 = blockStorage.getBlockAt(startX - 1, startY, startZ + 1);
}
if (rot1 == CHEST_BLOCK) {
rot6 = blockStorage.getBlockAt(startX + 1, startY, startZ - 1);
} else {
rot6 = blockStorage.getBlockAt(startX + 1, startY, startZ + 1);
}
if (SolidBlockList.isSolid(rot4) || SolidBlockList.isSolid(rot6)) {
if (!SolidBlockList.isSolid(rot3) && !SolidBlockList.isSolid(rot5)) {
blockData = 4;
}
}
}
return blockData;
}
Aggregations