3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

remove deprecated methods and constructor on item and position, inline some uses of position

Dieser Commit ist enthalten in:
creeper123123321 2019-11-24 17:55:46 -03:00
Ursprung 9308fc7712
Commit 1e8d04a07d
27 geänderte Dateien mit 84 neuen und 145 gelöschten Zeilen

Datei anzeigen

@ -22,7 +22,7 @@ public class BlockListener extends ViaBukkitListener {
Block b = e.getBlockPlaced(); Block b = e.getBlockPlaced();
getUserConnection(e.getPlayer()) getUserConnection(e.getPlayer())
.get(EntityTracker1_9.class) .get(EntityTracker1_9.class)
.addBlockInteraction(new Position((long) b.getX(), (long) b.getY(), (long) b.getZ())); .addBlockInteraction(new Position(b.getX(), (short) b.getY(), b.getZ()));
} }
} }
} }

Datei anzeigen

@ -34,7 +34,7 @@ public class HandItemCache extends BukkitRunnable {
} }
public static Item convert(ItemStack itemInHand) { public static Item convert(ItemStack itemInHand) {
if (itemInHand == null) return new Item((short) 0, (byte) 0, (short) 0, null); if (itemInHand == null) return new Item(0, (byte) 0, (short) 0, null);
return new Item((short) itemInHand.getTypeId(), (byte) itemInHand.getAmount(), itemInHand.getDurability(), null); return new Item(itemInHand.getTypeId(), (byte) itemInHand.getAmount(), itemInHand.getDurability(), null);
} }
} }

Datei anzeigen

@ -16,16 +16,16 @@ public class BukkitBlockConnectionProvider extends BlockConnectionProvider {
private Chunk lastChunk; private Chunk lastChunk;
@Override @Override
public int getWorldBlockData(UserConnection user, Position position) { public int getWorldBlockData(UserConnection user, int bx, int by, int bz) {
UUID uuid = user.get(ProtocolInfo.class).getUuid(); UUID uuid = user.get(ProtocolInfo.class).getUuid();
Player player = Bukkit.getPlayer(uuid); Player player = Bukkit.getPlayer(uuid);
if (player != null) { if (player != null) {
World world = player.getWorld(); World world = player.getWorld();
int x = position.getPosX() >> 4; int x = bx >> 4;
int z = position.getPosZ() >> 4; int z = bx >> 4;
if (world.isChunkLoaded(x, z)) { if (world.isChunkLoaded(x, z)) {
Chunk c = getChunk(world, x, z); Chunk c = getChunk(world, x, z);
Block b = c.getBlock(position.getPosX(), position.getPosY(), position.getPosZ()); Block b = c.getBlock(bx, by, bz);
return b.getTypeId() << 4 | b.getData(); return b.getTypeId() << 4 | b.getData();
} }
} }

Datei anzeigen

@ -10,59 +10,22 @@ import lombok.ToString;
@ToString @ToString
@EqualsAndHashCode @EqualsAndHashCode
public class Position { public class Position {
private int posX; private int x;
private short posY; private short y;
private int posZ; private int z;
@Deprecated
public Position(Long x, Long y, Long z) {
this.posX = x.intValue();
this.posY = y.shortValue();
this.posZ = z.intValue();
}
public Position(Position toCopy) { public Position(Position toCopy) {
this(toCopy.getPosX(), toCopy.getPosY(), toCopy.getPosZ()); this(toCopy.getX(), toCopy.getY(), toCopy.getZ());
}
@Deprecated
public void setX(Long x) {
this.posX = x.intValue();
}
@Deprecated
public void setY(Long y) {
this.posY = y.shortValue();
}
@Deprecated
public void setZ(Long z) {
this.posZ = z.intValue();
}
@Deprecated
public Long getX() {
return (long) this.posX;
}
@Deprecated
public Long getY() {
return (long) this.posY;
}
@Deprecated
public Long getZ() {
return (long) this.posZ;
} }
public Position getRelative(BlockFace face) { public Position getRelative(BlockFace face) {
return new Position(posX + face.getModX(), (short) (posY + face.getModY()), posZ + face.getModZ()); return new Position(x + face.getModX(), (short) (y + face.getModY()), z + face.getModZ());
} }
public Position shift(BlockFace face) { public Position shift(BlockFace face) {
this.posX += face.getModX(); this.x += face.getModX();
this.posY += face.getModY(); this.y += face.getModY();
this.posZ += face.getModZ(); this.z += face.getModZ();
return this; return this;
} }
} }

Datei anzeigen

@ -17,24 +17,6 @@ public class Item {
private short data; private short data;
private CompoundTag tag; private CompoundTag tag;
@Deprecated
public short getId() {
return (short) identifier;
}
@Deprecated
public void setId(short id) {
identifier = id;
}
@Deprecated
public Item(short id, byte amount, short data, CompoundTag tag) {
this.identifier = id;
this.amount = amount;
this.data = data;
this.tag = tag;
}
public Item(Item toCopy) { public Item(Item toCopy) {
this(toCopy.getIdentifier(), toCopy.getAmount(), toCopy.getData(), toCopy.getTag()); this(toCopy.getIdentifier(), toCopy.getAmount(), toCopy.getData(), toCopy.getTag());
} }

Datei anzeigen

@ -22,8 +22,8 @@ public class Position1_14Type extends Type<Position> {
@Override @Override
public void write(ByteBuf buffer, Position object) { public void write(ByteBuf buffer, Position object) {
buffer.writeLong((((long) object.getPosX() & 0x3ffffff) << 38) buffer.writeLong((((long) object.getX() & 0x3ffffff) << 38)
| (object.getPosY() & 0xfff) | (object.getY() & 0xfff)
| ((object.getPosZ() & 0x3ffffff) << 12)); | ((object.getZ() & 0x3ffffff) << 12));
} }
} }

Datei anzeigen

@ -22,8 +22,8 @@ public class PositionType extends Type<Position> {
@Override @Override
public void write(ByteBuf buffer, Position object) { public void write(ByteBuf buffer, Position object) {
buffer.writeLong((((long) object.getPosX() & 0x3ffffff) << 38) buffer.writeLong((((long) object.getX() & 0x3ffffff) << 38)
| ((object.getPosY() & 0xfff) << 26) | ((object.getY() & 0xfff) << 26)
| (object.getPosZ() & 0x3ffffff)); | (object.getZ() & 0x3ffffff));
} }
} }

Datei anzeigen

@ -47,9 +47,9 @@ public class Protocol1_13To1_12_2 extends Protocol {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
Position position = wrapper.read(Type.POSITION); Position position = wrapper.read(Type.POSITION);
wrapper.write(Type.INT, position.getPosX()); wrapper.write(Type.INT, position.getX());
wrapper.write(Type.INT, (int) position.getPosY()); wrapper.write(Type.INT, (int) position.getY());
wrapper.write(Type.INT, position.getPosZ()); wrapper.write(Type.INT, position.getZ());
} }
}; };

Datei anzeigen

@ -31,7 +31,7 @@ public class ConnectionData {
BlockConnectionProvider connectionProvider = Via.getManager().getProviders().get(BlockConnectionProvider.class); BlockConnectionProvider connectionProvider = Via.getManager().getProviders().get(BlockConnectionProvider.class);
for (BlockFace face : BlockFace.values()) { for (BlockFace face : BlockFace.values()) {
Position pos = position.getRelative(face); Position pos = position.getRelative(face);
int blockState = connectionProvider.getBlockdata(user, pos); int blockState = connectionProvider.getBlockData(user, pos.getX(), pos.getY(), pos.getZ());
ConnectionHandler handler = connectionHandlerMap.get(blockState); ConnectionHandler handler = connectionHandlerMap.get(blockState);
if (handler == null) continue; if (handler == null) continue;
@ -124,24 +124,24 @@ public class ConnectionData {
} }
public static void updateBlock(UserConnection user, Position pos, List<BlockChangeRecord> records) { public static void updateBlock(UserConnection user, Position pos, List<BlockChangeRecord> records) {
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos); int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockData(user, pos.getX(), pos.getY(), pos.getZ());
ConnectionHandler handler = getConnectionHandler(blockState); ConnectionHandler handler = getConnectionHandler(blockState);
if (handler == null) return; if (handler == null) return;
int newBlockState = handler.connect(user, pos, blockState); int newBlockState = handler.connect(user, pos, blockState);
records.add(new BlockChangeRecord((short) (((pos.getPosX() & 0xF) << 4) | (pos.getPosZ() & 0xF)), pos.getPosY(), newBlockState)); records.add(new BlockChangeRecord((short) (((pos.getX() & 0xF) << 4) | (pos.getZ() & 0xF)), pos.getY(), newBlockState));
} }
public static BlockConnectionProvider getProvider() { public static BlockConnectionProvider getProvider() {
return Via.getManager().getProviders().get(BlockConnectionProvider.class); return Via.getManager().getProviders().get(BlockConnectionProvider.class);
} }
public static void updateBlockStorage(UserConnection userConnection, Position position, int blockState) { public static void updateBlockStorage(UserConnection userConnection, int x, int y, int z, int blockState) {
if (!needStoreBlocks()) return; if (!needStoreBlocks()) return;
if (ConnectionData.isWelcome(blockState)) { if (ConnectionData.isWelcome(blockState)) {
ConnectionData.getProvider().storeBlock(userConnection, position, blockState); ConnectionData.getProvider().storeBlock(userConnection, x, y, z, blockState);
} else { } else {
ConnectionData.getProvider().removeBlock(userConnection, position); ConnectionData.getProvider().removeBlock(userConnection, x, y, z);
} }
} }

Datei anzeigen

@ -9,7 +9,7 @@ public abstract class ConnectionHandler {
public abstract int connect(UserConnection user, Position position, int blockState); public abstract int connect(UserConnection user, Position position, int blockState);
public int getBlockData(UserConnection user, Position position) { public int getBlockData(UserConnection user, Position position) {
return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, position); return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockData(user, position.getX(), position.getY(), position.getZ());
} }
public boolean canConnect(int id) { public boolean canConnect(int id) {

Datei anzeigen

@ -6,28 +6,23 @@ import us.myles.ViaVersion.api.platform.providers.Provider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
public class BlockConnectionProvider implements Provider { public class BlockConnectionProvider implements Provider {
public int getBlockData(UserConnection connection, int x, int y, int z) {
public int getBlockdata(UserConnection connection, Position position) { int oldId = getWorldBlockData(connection, x, y, z);
int oldId = getWorldBlockData(connection, position);
return MappingData.blockMappings.getNewId(oldId); return MappingData.blockMappings.getNewId(oldId);
} }
public int getWorldBlockData(UserConnection connection, Position position) { public int getWorldBlockData(UserConnection connection, int x, int y, int z) {
return -1; return -1;
} }
public void storeBlock(UserConnection connection, Position position, int blockState) { public void storeBlock(UserConnection connection, int x, int y, int z, int blockState) {
} }
public void removeBlock(UserConnection connection, Position position) { public void removeBlock(UserConnection connection, int x, int y, int z) {
} }
public void storeBlock(UserConnection connection, long x, long y, long z, int blockState) {
storeBlock(connection, new Position(x, y, z), blockState);
}
public void clearStorage(UserConnection connection) { public void clearStorage(UserConnection connection) {
} }

Datei anzeigen

@ -1,24 +1,23 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers; package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockConnectionStorage; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockConnectionStorage;
public class PacketBlockConnectionProvider extends BlockConnectionProvider { public class PacketBlockConnectionProvider extends BlockConnectionProvider {
@Override @Override
public void storeBlock(UserConnection connection, Position position, int blockState) { public void storeBlock(UserConnection connection, int x, int y, int z, int blockState) {
connection.get(BlockConnectionStorage.class).store(position, blockState); connection.get(BlockConnectionStorage.class).store(x, y, z, blockState);
} }
@Override @Override
public void removeBlock(UserConnection connection, Position position) { public void removeBlock(UserConnection connection, int x, int y, int z) {
connection.get(BlockConnectionStorage.class).remove(position); connection.get(BlockConnectionStorage.class).remove(x, y, z);
} }
@Override @Override
public int getBlockdata(UserConnection connection, Position position) { public int getBlockData(UserConnection connection, int x, int y, int z) {
return connection.get(BlockConnectionStorage.class).get(position); return connection.get(BlockConnectionStorage.class).get(x, y, z);
} }
@Override @Override

Datei anzeigen

@ -127,9 +127,9 @@ public class ParticleRewriter {
public Particle handler(Particle particle, Integer[] data) { public Particle handler(Particle particle, Integer[] data) {
Item item; Item item;
if (data.length == 1) if (data.length == 1)
item = new Item(data[0].shortValue(), (byte) 1, (short) 0, null); item = new Item(data[0], (byte) 1, (short) 0, null);
else if (data.length == 2) else if (data.length == 2)
item = new Item(data[0].shortValue(), (byte) 1, data[1].shortValue(), null); item = new Item(data[0], (byte) 1, data[1].shortValue(), null);
else else
return particle; return particle;

Datei anzeigen

@ -177,7 +177,7 @@ public class WorldPackets {
UserConnection userConnection = wrapper.user(); UserConnection userConnection = wrapper.user();
if (Via.getConfig().isServersideBlockConnections()) { if (Via.getConfig().isServersideBlockConnections()) {
ConnectionData.updateBlockStorage(userConnection, position, newId); ConnectionData.updateBlockStorage(userConnection, position.getX(), position.getY(), position.getZ(), newId);
newId = ConnectionData.connect(userConnection, position, newId); newId = ConnectionData.connect(userConnection, position, newId);
} }
wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId)); wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId));
@ -216,7 +216,7 @@ public class WorldPackets {
(record.getHorizontal() & 15) + (chunkZ * 16)); (record.getHorizontal() & 15) + (chunkZ * 16));
if (Via.getConfig().isServersideBlockConnections()) { if (Via.getConfig().isServersideBlockConnections()) {
ConnectionData.updateBlockStorage(userConnection, position, newBlock); ConnectionData.updateBlockStorage(userConnection, position.getX(), position.getY(), position.getZ(), newBlock);
} }
record.setBlockId(checkStorage(wrapper.user(), position, newBlock)); record.setBlockId(checkStorage(wrapper.user(), position, newBlock));
} }
@ -226,9 +226,9 @@ public class WorldPackets {
int blockState = record.getBlockId(); int blockState = record.getBlockId();
Position position = new Position( Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16), (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
(long) record.getY(), record.getY(),
(long) (record.getHorizontal() & 15) + (chunkZ * 16)); (record.getHorizontal() & 15) + (chunkZ * 16));
ConnectionHandler handler = ConnectionData.getConnectionHandler(blockState); ConnectionHandler handler = ConnectionData.getConnectionHandler(blockState);
if (handler != null) { if (handler != null) {
@ -242,9 +242,9 @@ public class WorldPackets {
for (BlockChangeRecord record : records) { for (BlockChangeRecord record : records) {
Position position = new Position( Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16), (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
(long) record.getY(), record.getY(),
(long) (record.getHorizontal() & 15) + (chunkZ * 16)); (record.getHorizontal() & 15) + (chunkZ * 16));
ConnectionData.update(userConnection, position); ConnectionData.update(userConnection, position);
} }
} }
@ -393,7 +393,7 @@ public class WorldPackets {
int y = (int) tag.get("y").getValue(); int y = (int) tag.get("y").getValue();
int z = (int) tag.get("z").getValue(); int z = (int) tag.get("z").getValue();
Position position = new Position((long) x, (long) y, (long) z); Position position = new Position(x, (short) y, z);
// Store the replacement blocks for blockupdates // Store the replacement blocks for blockupdates
if (storage.contains(position)) if (storage.contains(position))
storage.get(position).setReplacement(newId); storage.get(position).setReplacement(newId);

Datei anzeigen

@ -18,7 +18,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
@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);
Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z"))); Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
if (!storage.contains(position)) { if (!storage.contains(position)) {
Via.getPlatform().getLogger().warning("Received an banner color update packet, but there is no banner! O_o " + tag); Via.getPlatform().getLogger().warning("Received an banner color update packet, but there is no banner! O_o " + tag);

Datei anzeigen

@ -13,7 +13,7 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
@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);
Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z"))); Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
if (!storage.contains(position)) { if (!storage.contains(position)) {
Via.getPlatform().getLogger().warning("Received an bed color update packet, but there is no bed! O_o " + tag); Via.getPlatform().getLogger().warning("Received an bed color update packet, but there is no bed! O_o " + tag);

Datei anzeigen

@ -15,7 +15,7 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
@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);
Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z"))); Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
if (!storage.contains(position)) { if (!storage.contains(position)) {
Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag); Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag);

Datei anzeigen

@ -37,35 +37,35 @@ public class BlockConnectionStorage extends StoredObject {
super(user); super(user);
} }
public void store(Position position, int blockState) { public void store(int x, int y, int z, int blockState) {
Short mapping = reverseBlockMappings.get((short) blockState); Short mapping = reverseBlockMappings.get((short) blockState);
if (mapping == null) return; if (mapping == null) return;
blockState = mapping; blockState = mapping;
long pair = getChunkSectionIndex(position); long pair = getChunkSectionIndex(x, y, z);
Pair<byte[], NibbleArray> map = getChunkSection(pair, (blockState & 0xF) != 0); Pair<byte[], NibbleArray> map = getChunkSection(pair, (blockState & 0xF) != 0);
int blockIndex = encodeBlockPos(position); int blockIndex = encodeBlockPos(x, y, z);
map.getKey()[blockIndex] = (byte) (blockState >> 4); map.getKey()[blockIndex] = (byte) (blockState >> 4);
NibbleArray nibbleArray = map.getValue(); NibbleArray nibbleArray = map.getValue();
if (nibbleArray != null) nibbleArray.set(blockIndex, blockState); if (nibbleArray != null) nibbleArray.set(blockIndex, blockState);
} }
public int get(Position position) { public int get(int x, int y, int z) {
long pair = getChunkSectionIndex(position); long pair = getChunkSectionIndex(x, y, z);
Pair<byte[], NibbleArray> map = blockStorage.get(pair); Pair<byte[], NibbleArray> map = blockStorage.get(pair);
if (map == null) return 0; if (map == null) return 0;
short blockPosition = encodeBlockPos(position); short blockPosition = encodeBlockPos(x, y, z);
NibbleArray nibbleArray = map.getValue(); NibbleArray nibbleArray = map.getValue();
return WorldPackets.toNewId( return WorldPackets.toNewId(
((map.getKey()[blockPosition] & 0xFF) << 4) ((map.getKey()[blockPosition] & 0xFF) << 4)
| (nibbleArray == null ? 0 : nibbleArray.get(blockPosition)) | (nibbleArray == null ? 0 : nibbleArray.get(blockPosition))
); );
} }
public void remove(Position position) { public void remove(int x, int y, int z) {
long pair = getChunkSectionIndex(position); long pair = getChunkSectionIndex(x, y, z);
Pair<byte[], NibbleArray> map = blockStorage.get(pair); Pair<byte[], NibbleArray> map = blockStorage.get(pair);
if (map == null) return; if (map == null) return;
int blockIndex = encodeBlockPos(position); int blockIndex = encodeBlockPos(x, y, z);
NibbleArray nibbleArray = map.getValue(); NibbleArray nibbleArray = map.getValue();
if (nibbleArray != null) { if (nibbleArray != null) {
nibbleArray.set(blockIndex, 0); nibbleArray.set(blockIndex, 0);
@ -112,7 +112,7 @@ public class BlockConnectionStorage extends StoredObject {
} }
private long getChunkSectionIndex(Position position) { private long getChunkSectionIndex(Position position) {
return getChunkSectionIndex(position.getPosX(), position.getPosY(), position.getPosZ()); return getChunkSectionIndex(position.getX(), position.getY(), position.getZ());
} }
private short encodeBlockPos(int x, int y, int z) { private short encodeBlockPos(int x, int y, int z) {
@ -120,7 +120,7 @@ public class BlockConnectionStorage extends StoredObject {
} }
private short encodeBlockPos(Position pos) { private short encodeBlockPos(Position pos) {
return encodeBlockPos(pos.getPosX(), pos.getPosY(), pos.getPosZ()); return encodeBlockPos(pos.getX(), pos.getY(), pos.getZ());
} }
private <T> Map<Long, T> createLongObjectMap() { private <T> Map<Long, T> createLongObjectMap() {

Datei anzeigen

@ -45,7 +45,7 @@ public class BlockEntity {
int y = (int) tag.get("y").getValue(); int y = (int) tag.get("y").getValue();
int z = (int) tag.get("z").getValue(); int z = (int) tag.get("z").getValue();
Position pos = new Position((long) x, (long) y, (long) z); Position pos = new Position(x, (short) y, z);
updateBlockEntity(pos, (short) newId, tag, connection); updateBlockEntity(pos, (short) newId, tag, connection);
} catch (Exception e) { } catch (Exception e) {

Datei anzeigen

@ -55,9 +55,9 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol {
//Create nbt //Create nbt
CompoundTag tag = new CompoundTag(""); CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("id", "Sign")); tag.put(new StringTag("id", "Sign"));
tag.put(new IntTag("x", position.getPosX())); tag.put(new IntTag("x", position.getX()));
tag.put(new IntTag("y", position.getPosY())); tag.put(new IntTag("y", position.getY()));
tag.put(new IntTag("z", position.getPosZ())); tag.put(new IntTag("z", position.getZ()));
for (int i = 0; i < lines.length; i++) for (int i = 0; i < lines.length; i++)
tag.put(new StringTag("Text" + (i + 1), lines[i])); tag.put(new StringTag("Text" + (i + 1), lines[i]));

Datei anzeigen

@ -103,7 +103,7 @@ public class SpawnPackets {
public void write(PacketWrapper wrapper) throws Exception { public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.VAR_INT, entityID); wrapper.write(Type.VAR_INT, entityID);
List<Metadata> meta = new ArrayList<>(); List<Metadata> meta = new ArrayList<>();
Item item = new Item((short) 373, (byte) 1, (short) data, null); // Potion Item item = new Item(373, (byte) 1, (short) data, null); // Potion
ItemRewriter.toClient(item); // Rewrite so that it gets the right nbt ItemRewriter.toClient(item); // Rewrite so that it gets the right nbt
// TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS // TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS
Metadata potion = new Metadata(5, MetaType1_9.Slot, item); Metadata potion = new Metadata(5, MetaType1_9.Slot, item);

Datei anzeigen

@ -303,7 +303,7 @@ public class WorldPackets {
if (hand == 0) { if (hand == 0) {
if (!tracker.isBlocking()) { if (!tracker.isBlocking()) {
tracker.setBlocking(true); tracker.setBlocking(true);
Item shield = new Item((short) 442, (byte) 1, (short) 0, null); Item shield = new Item(442, (byte) 1, (short) 0, null);
tracker.setSecondHand(shield); tracker.setSecondHand(shield);
} }
wrapper.cancel(); wrapper.cancel();
@ -363,9 +363,9 @@ public class WorldPackets {
if (face == 255) if (face == 255)
return; return;
Position p = wrapper.get(Type.POSITION, 0); Position p = wrapper.get(Type.POSITION, 0);
int x = p.getPosX(); int x = p.getX();
short y = p.getPosY(); short y = p.getY();
int z = p.getPosZ(); int z = p.getZ();
switch (face) { switch (face) {
case 0: case 0:
y--; y--;

Datei anzeigen

@ -6,6 +6,6 @@ import us.myles.ViaVersion.api.platform.providers.Provider;
public class HandItemProvider implements Provider { public class HandItemProvider implements Provider {
public Item getHandItem(final UserConnection info) { public Item getHandItem(final UserConnection info) {
return new Item((short) 0, (byte) 0, (short) 0, null); return new Item(0, (byte) 0, (short) 0, null);
} }
} }

Datei anzeigen

@ -44,8 +44,8 @@ public class CommandBlockStorage extends StoredObject {
} }
private Pair<Integer, Integer> getChunkCoords(Position position) { private Pair<Integer, Integer> getChunkCoords(Position position) {
int chunkX = Math.floorDiv(position.getPosX(), 16); int chunkX = Math.floorDiv(position.getX(), 16);
int chunkZ = Math.floorDiv(position.getPosZ(), 16); int chunkZ = Math.floorDiv(position.getZ(), 16);
return new Pair<>(chunkX, chunkZ); return new Pair<>(chunkX, chunkZ);
} }

Datei anzeigen

@ -153,7 +153,7 @@ public class EntityTracker1_9 extends EntityTracker {
if (entityId != getProvidedEntityId() && Via.getConfig().isShieldBlocking()) { if (entityId != getProvidedEntityId() && Via.getConfig().isShieldBlocking()) {
if ((data & 0x10) == 0x10) { if ((data & 0x10) == 0x10) {
if (validBlocking.contains(entityId)) { if (validBlocking.contains(entityId)) {
Item shield = new Item((short) 442, (byte) 1, (short) 0, null); Item shield = new Item(442, (byte) 1, (short) 0, null);
setSecondHand(entityId, shield); setSecondHand(entityId, shield);
} else { } else {
setSecondHand(entityId, null); setSecondHand(entityId, null);

Datei anzeigen

@ -23,7 +23,7 @@ public class BlockListener extends ViaSpongeListener {
Location loc = e.getTransactions().get(0).getFinal().getLocation().get(); Location loc = e.getTransactions().get(0).getFinal().getLocation().get();
getUserConnection(player.getUniqueId()) getUserConnection(player.getUniqueId())
.get(EntityTracker1_9.class) .get(EntityTracker1_9.class)
.addBlockInteraction(new Position((long) loc.getX(), (long) loc.getY(), (long) loc.getZ())); .addBlockInteraction(new Position(loc.getBlockX(), (short) loc.getBlockY(), loc.getBlockZ()));
} }
} }
} }

Datei anzeigen

@ -51,7 +51,7 @@ public class HandItemCache implements Runnable {
} }
public static Item convert(ItemStack itemInHand) { public static Item convert(ItemStack itemInHand) {
if (itemInHand == null) return new Item((short) 0, (byte) 0, (short) 0, null); if (itemInHand == null) return new Item(0, (byte) 0, (short) 0, null);
if (GET_DAMAGE == null) { if (GET_DAMAGE == null) {
try { try {
GET_DAMAGE = itemInHand.getClass().getDeclaredField("field_77991_e"); GET_DAMAGE = itemInHand.getClass().getDeclaredField("field_77991_e");
@ -87,7 +87,7 @@ public class HandItemCache implements Runnable {
e.printStackTrace(); e.printStackTrace();
} }
} }
return new Item((short) id, (byte) itemInHand.getQuantity(), (short) damage, null); return new Item(id, (byte) itemInHand.getQuantity(), (short) damage, null);
} }
} }