Compare commits

...
76 Commits
Author SHA1 Message Date
Myles 381ff1e5d3 1.12 update 2017-06-07 12:58:51 +01:00
Matsv 079f8df6e0 Merge branches 'dev' and 'master' of https://github.com/MylesIsCool/ViaVersion into dev 2017-06-01 21:47:37 +02:00
Myles 56637f50bc Merge pull request #676 from RaynLegends/master
Improved the shield handling (1.9->1.8)
2017-06-01 19:11:31 +01:00
Matsv 914888dade Refactor Snapshot to 1.12 as preparation for tomorrows release 2017-06-01 18:49:07 +02:00
RaynLegends 8e20df57a9 Improved the shield handling (1.9->1.8) 2017-06-01 18:23:16 +02:00
Matsv 7d5191fa2f Implement 1.12 MetaTypes 2017-06-01 16:00:35 +02:00
Matsv 08528a1745 Addd get/setBlock to the interface of ChunkSection 2017-06-01 15:44:41 +02:00
Matsv a8e3d9ec95 Update to 1.12-pre7 2017-05-31 14:05:18 +02:00
Matsv e5dd9b61a4 Remove wrong EntityType 2017-05-31 00:26:28 +02:00
Matsv 6ee2d0574f Bump version from 1.0.5 -to 1.1.0 since this won't be just a bugfix update. 2017-05-29 20:23:54 +02:00
Myles 91b5a8036c 1.12-pre6 2017-05-29 13:59:02 +01:00
Myles 24ab0d8590 Merge branch 'master' into dev 2017-05-27 20:41:19 +01:00
Myles d8f55006ff Ensure connection isn’t null (reloads etc), fixes #674 2017-05-27 20:41:00 +01:00
Matsv 0817d28b88 Merge branches 'dev' and 'master' of https://github.com/MylesIsCool/ViaVersion into dev 2017-05-27 16:39:43 +02:00
Matsv 577c8b4eaf Add a getBlock method in ChunkSection1_9_3_4.java 2017-05-27 16:39:07 +02:00
Matsv 5b5f0dce24 Manually hide Entity BossBars on (from 1.8.x) server switch. Fixes #666 2017-05-25 18:14:56 +02:00
Myles a818b9a9d4 Add discord server 2017-05-22 15:50:22 +01:00
Myles 3160c076f0 Add discord server 2017-05-22 15:49:42 +01:00
Myles 6d0b28fac4 Merge branch 'master' into dev 2017-05-22 13:38:37 +01:00
Myles ce286cf322 Remove unnecessary synchronising 2017-05-22 13:38:22 +01:00
Myles 7d001c61a8 Fix packet id typo causing random dc’s #669 2017-05-22 13:17:24 +01:00
Myles a09e8b9f4d Fix comment with 1.12-pre5 2017-05-19 22:35:24 +01:00
Myles 395d020411 Update to 1.12-pre5 2017-05-19 22:32:21 +01:00
Myles ece4455130 Fix chunk sending #667 2017-05-18 22:58:27 +01:00
Matsv cc64ffff98 Update to 1.12-pre4 2017-05-18 15:03:27 +02:00
Matsv dd332420e5 Fix invisible beds for 1.12-pre3 2017-05-17 21:52:36 +02:00
Myles ce8ba6a5af Merge branch 'master' into dev 2017-05-17 19:44:00 +01:00
Myles 21eb824395 Better support for nbt arrays rereading in chunks 2017-05-17 19:43:48 +01:00
Myles 246e5ca742 Merge branch 'master' into dev 2017-05-17 18:16:07 +01:00
Myles 2bd03ad92c Fix chunks on 1.11 encoder 2017-05-17 18:15:52 +01:00
Myles 7971dc797b Handle packet 2017-05-17 18:14:47 +01:00
Myles 36c047bfa0 Merge branch 'dev' of https://github.com/MylesIsCool/ViaVersion into dev 2017-05-17 17:09:27 +01:00
Myles d7daab7e64 1.12-pre3 2017-05-17 16:26:12 +01:00
Matsv b925e91bbb Merge branch 'upmaster' into dev 2017-05-14 17:13:04 +02:00
Matsv 3b1341f2b3 Cleanup code 2017-05-14 16:15:21 +02:00
Matsv 667ad0d059 Rewrite Spawner entity ID, fix #643 2017-05-14 16:02:04 +02:00
Matsv da98722470 Merge branches 'dev' and 'master' of https://github.com/MylesIsCool/ViaVersion into dev 2017-05-14 14:50:44 +02:00
Matsv c92fcc9f9a Add NullCheck for #657 fixes #663 2017-05-14 14:50:00 +02:00
Matsv 8d66ce776c Add NullCheck for #657 fixes #663 2017-05-14 14:47:00 +02:00
Matsv 412202e105 Merge branch 'dev' of https://github.com/MylesIsCool/ViaVersion into dev 2017-05-14 14:39:02 +02:00
Matsv 35c9e4e268 Merge branch 'master' of https://github.com/MylesIsCool/ViaVersion into dev 2017-05-14 14:38:45 +02:00
Matsv 81ea78e003 Update dependencies fix #662 2017-05-14 14:34:51 +02:00
Myles 833698fe8a Update to 1.12-pre2 2017-05-11 18:05:20 +01:00
Myles 70964e9ba9 Merge branch 'master' into dev 2017-05-11 18:02:50 +01:00
Myles 255a4d516e Merge pull request #657 from KernelFreeze/master
Fixing item count on 1.11, where size <= 0. (#553)
2017-05-10 20:52:22 +01:00
Matsv 11d26c13b8 1.12-pre1 2017-05-10 18:03:15 +02:00
Matsv 00b4396f86 Merge branch 'master' of https://github.com/MylesIsCool/ViaVersion into dev 2017-05-10 18:00:18 +02:00
KernelFreeze 1d5d0012e6 Item count on 1.11. 2017-05-09 23:32:32 -05:00
KernelFreeze 18c706ab8a Fixing item count on 1.11, where size <= 0. Fixes #553 2017-05-09 23:19:23 -05:00
Myles 6a65a35dee 17w18b 2017-05-04 18:51:38 +01:00
Myles 37aab2c759 ViaVersion for 17w18a 2017-05-03 15:00:37 +01:00
Myles 18ad5da081 17w17b 2017-04-27 15:02:17 +01:00
Myles 9f65e727c9 17w17a 2017-04-26 15:34:24 +01:00
xBytez efa6e8ec31 Fix README.md typo that prevents the table from showing. (#654)
* Fix README.md typo that prevents the table from showing.

* Remove extra unneeded bracket from README.md
2017-04-26 13:33:10 +01:00
Myles a7df7715b1 Update to 17w16b 2017-04-21 21:26:30 +01:00
Myles a9831c842c 1.8.8 -> 1.9.4, fix hand item being sent in different tick 2017-04-20 22:03:09 +01:00
Myles 439a5f90c1 Merge branch 'dev' of https://github.com/MylesIsCool/ViaVersion into dev 2017-04-20 16:31:57 +01:00
Myles a6491cf792 17w16a support 2017-04-20 16:31:11 +01:00
Myles e1025afb54 1716a support 2017-04-20 16:23:09 +01:00
AlfieC a5dddf371d Fix critical bug (#636) 2017-04-12 18:20:27 +01:00
DoNotSpamPls fe95bbf312 1.0.4 -> 1.0.5 (#649) 2017-04-12 18:20:18 +01:00
Myles 0bab4f62de Update to 17w15a, (some sound stuff may of changed) 2017-04-12 11:55:32 +01:00
Myles 981b5cf3bf Add sound shifting for snapshot 2017-04-05 20:24:19 +01:00
Matsv 89f47c6a6a Merge branch 'master' of https://github.com/MylesIsCool/ViaVersion into dev 2017-04-05 21:09:47 +02:00
Matsv 9fd1687348 Use PacketWrapper for BossBar's instead of raw 2017-04-05 21:08:27 +02:00
Myles 899eac0e7e Fix ProtocolSupport not working on new versions #629 (+1 ProtocolSupport having nice code) 2017-04-05 20:05:08 +01:00
Myles efad8f41a1 13w14a 2017-04-05 18:09:36 +01:00
Myles ee81935a74 Update to 17w13b
Note: I had an issue with some packet not working, if you have steps to replicate please make an issue.
2017-04-01 21:55:51 +01:00
Myles e3c4253c13 Merge branch 'master' into dev 2017-04-01 00:07:32 +01:00
Myles 9d991cdd26 Merge branch 'master' of https://github.com/MylesIsCool/ViaVersion 2017-02-17 14:15:45 +00:00
Myles 3fdbf5b062 Revert previous Server protocol check, add a call to ProtocolRegistry to force class load. 2017-02-17 14:15:27 +00:00
Phineas 40937acfa0 Update to 2017 (#632) 2017-02-15 18:31:22 +00:00
Myles 99e4ab22e3 Only inject channels when server protocol is known #631 2017-02-13 17:22:52 +00:00
Myles 8da0c4310c Update to 17w06a 2017-02-08 14:10:18 +00:00
Myles 280da6b8e9 Update README 2017-02-03 16:33:34 +00:00
Myles 71ff8a773b Back to dev 2017-02-03 16:32:56 +00:00
50 changed files with 643 additions and 174 deletions

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@ License:
MIT License
Copyright (c) 2016
Copyright (c) 2017
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -21,4 +21,4 @@ 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.
SOFTWARE.
+3 -2
View File
@@ -1,6 +1,7 @@
# ViaVersion 1.0.0 - Spigot, Sponge, BungeeCord
# ViaVersion 1.1.0 - Spigot, Sponge, BungeeCord
[![Build Status](https://travis-ci.org/MylesIsCool/ViaVersion.svg?branch=master)](https://travis-ci.org/MylesIsCool/ViaVersion)
[![Gitter](https://badges.gitter.im/MylesIsCool/ViaVersion.svg)](https://gitter.im/MylesIsCool/ViaVersion)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)
IRC: [#viaversion](http://irc.spi.gt/iris/?channels=viaversion) on irc.spi.gt for Support.
@@ -8,7 +9,7 @@ IRC: [#viaversion](http://irc.spi.gt/iris/?channels=viaversion) on irc.spi.gt fo
Supported Versions:
[![Table] (http://i.imgur.com/SVVhFQ4.png)](http://i.imgur.com/SVVhFQ4.png)
![Table (http://i.imgur.com/jbrm2Ep.png)](http://i.imgur.com/jbrm2Ep.png)
On Bukkit you may also use ProtocolSupport, but ensure you have the right build for your server version.
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.4</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -33,8 +33,16 @@ public class ClassGenerator {
addSpigotCompatibility(pool, BukkitDecodeHandler.class, decodeSuper);
addSpigotCompatibility(pool, BukkitEncodeHandler.class, encodeSuper);
} else {
Class decodeSuper = Class.forName(getPSPackage().equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketDecoder" : getPSPackage() + ".wrapped.WrappedDecoder");
Class encodeSuper = Class.forName(getPSPackage().equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketEncoder" : getPSPackage() + ".wrapped.WrappedEncoder");
// ProtocolSupport compatibility
Class encodeSuper;
Class decodeSuper;
if (isMultiplatformPS()) {
return;
} else {
String psPackage = getOldPSPackage();
decodeSuper = Class.forName(psPackage.equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketDecoder" : psPackage + ".wrapped.WrappedDecoder");
encodeSuper = Class.forName(psPackage.equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketEncoder" : psPackage + ".wrapped.WrappedEncoder");
}
// Generate the classes
addPSCompatibility(pool, BukkitDecodeHandler.class, decodeSuper);
addPSCompatibility(pool, BukkitEncodeHandler.class, encodeSuper);
@@ -110,7 +118,7 @@ public class ClassGenerator {
}
private static Class addPSCompatibility(ClassPool pool, Class input, Class superclass) {
boolean newPS = getPSPackage().equals("unknown");
boolean newPS = getOldPSPackage().equals("unknown");
String newName = "us.myles.ViaVersion.classgenerator.generated." + input.getSimpleName();
try {
@@ -121,8 +129,8 @@ public class ClassGenerator {
if (!newPS) {
// Override setRealEncoder / setRealDecoder
pool.importPackage(getPSPackage());
pool.importPackage(getPSPackage() + ".wrapped");
pool.importPackage(getOldPSPackage());
pool.importPackage(getOldPSPackage() + ".wrapped");
if (superclass.getName().endsWith("Decoder")) {
// Decoder
generated.addMethod(CtMethod.make("public void setRealDecoder(IPacketDecoder dec) {\n" +
@@ -158,7 +166,7 @@ public class ClassGenerator {
return null;
}
public static String getPSPackage() {
public static String getOldPSPackage() {
if (psPackage == null) {
try {
Class.forName("protocolsupport.protocol.core.IPacketDecoder");
@@ -174,4 +182,14 @@ public class ClassGenerator {
}
return psPackage;
}
public static boolean isMultiplatformPS() {
try {
Class.forName("protocolsupport.zplatform.impl.spigot.network.pipeline.SpigotPacketEncoder");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}
@@ -37,14 +37,12 @@ public class BukkitViaInjector implements ViaInjector {
// Inject the list
List wrapper = new ListWrapper((List) value) {
@Override
public synchronized void handleAdd(Object o) {
synchronized (this) {
if (o instanceof ChannelFuture) {
try {
injectChannelFuture((ChannelFuture) o);
} catch (Exception e) {
e.printStackTrace();
}
public void handleAdd(Object o) {
if (o instanceof ChannelFuture) {
try {
injectChannelFuture((ChannelFuture) o);
} catch (Exception e) {
e.printStackTrace();
}
}
}
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.4</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -37,7 +37,7 @@
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion-common</artifactId>
<version>1.0.4</version>
<version>1.1.0</version>
</dependency>
</dependencies>
</project>
@@ -8,6 +8,7 @@ import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.event.EventPriority;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
@@ -15,6 +16,7 @@ import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.bungee.service.ProtocolDetectorService;
import us.myles.ViaVersion.bungee.storage.BungeeStorage;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@@ -79,6 +81,15 @@ public class BungeeServerHandler implements Listener {
public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception {
if (user == null) return;
// Manually hide ViaVersion-created BossBars if the childserver was version 1.8.x (#666)
if (user.has(EntityTracker.class)) {
EntityTracker tracker = user.get(EntityTracker.class);
if (tracker.getBossBarMap() != null)
for (BossBar bar : tracker.getBossBarMap().values())
bar.hide();
}
// Handle server/version change
if (user.has(BungeeStorage.class)) {
BungeeStorage storage = user.get(BungeeStorage.class);
ProxiedPlayer player = storage.getPlayer();
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.4</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -16,7 +16,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.18-SNAPSHOT</version>
<version>1.18</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -46,6 +46,8 @@ public class ViaManager {
// Check for updates
if (platform.getConf().isCheckForUpdates())
UpdateUtil.sendUpdateMessage();
// Force class load
ProtocolRegistry.getSupportedVersions();
// Inject
try {
injector.inject();
@@ -43,7 +43,6 @@ public class Entity1_11Types {
PRIMED_TNT(20, ENTITY),
FALLING_BLOCK(21, ENTITY),
FIREWORK(22, ENTITY),
TIPPED_ARROW(23, ARROW),
SPECTRAL_ARROW(24, ARROW),
SHULKER_BULLET(25, ENTITY),
DRAGON_FIREBALL(26, FIREBALL),
@@ -194,7 +193,7 @@ public class Entity1_11Types {
MINECART(10, EntityType.MINECART_ABSTRACT),
TNT_PRIMED(50, EntityType.PRIMED_TNT),
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
TIPPED_ARROW(60, EntityType.TIPPED_ARROW),
TIPPED_ARROW(60, EntityType.ARROW),
SNOWBALL(61, EntityType.SNOWBALL),
EGG(62, EntityType.EGG),
FIREBALL(63, EntityType.FIREBALL),
@@ -1,6 +1,6 @@
package us.myles.ViaVersion.api.minecraft.chunks;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import java.util.List;
@@ -3,6 +3,10 @@ package us.myles.ViaVersion.api.minecraft.chunks;
import io.netty.buffer.ByteBuf;
public interface ChunkSection {
int getBlock(int x, int y, int z);
void setBlock(int x, int y, int z, int type, int data);
int getBlockId(int x, int y, int z);
void writeBlocks(ByteBuf output) throws Exception;
@@ -1,7 +1,7 @@
package us.myles.ViaVersion.api.minecraft.item;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.*;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
@Getter
@Setter
@@ -0,0 +1,34 @@
package us.myles.ViaVersion.api.minecraft.metadata.types;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.type.Type;
@RequiredArgsConstructor
@Getter
public enum MetaType1_12 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),
Float(2, Type.FLOAT),
String(3, Type.STRING),
Chat(4, Type.STRING),
Slot(5, Type.ITEM),
Boolean(6, Type.BOOLEAN),
Vector3F(7, Type.ROTATION),
Position(8, Type.POSITION),
OptPosition(9, Type.OPTIONAL_POSITION),
Direction(10, Type.VAR_INT),
OptUUID(11, Type.OPTIONAL_UUID),
BlockID(12, Type.VAR_INT),
NBTTag(13, Type.NBT),
Discontinued(99, null);
private final int typeID;
private final Type type;
public static MetaType1_12 byId(int id) {
return values()[id];
}
}
@@ -8,6 +8,7 @@ import us.myles.ViaVersion.protocols.base.BaseProtocol;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2TO1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3TO1_9_1_2;
@@ -38,9 +39,11 @@ public class ProtocolRegistry {
registerProtocol(new Protocol1_9_1_2TO1_9_3_4(), Arrays.asList(ProtocolVersion.v1_9_1.getId(), ProtocolVersion.v1_9_2.getId()), ProtocolVersion.v1_9_3.getId());
registerProtocol(new Protocol1_10To1_9_3_4(), Collections.singletonList(ProtocolVersion.v1_10.getId()), ProtocolVersion.v1_9_3.getId());
registerProtocol(new Protocol1_11To1_10(), Arrays.asList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_10.getId());
registerProtocol(new Protocol1_11_1To1_11(), Arrays.asList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_11.getId());
registerProtocol(new Protocol1_11To1_10(), Collections.singletonList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_10.getId());
registerProtocol(new Protocol1_11_1To1_11(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_11.getId());
// Snapshot
registerProtocol(new Protocol1_12To1_11_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_11_1.getId());
}
/**
@@ -29,6 +29,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_10;
public static final ProtocolVersion v1_11;
public static final ProtocolVersion v1_11_1;
public static final ProtocolVersion v1_12;
public static final ProtocolVersion unknown;
private final int id;
@@ -54,6 +55,7 @@ public class ProtocolVersion {
register(v1_10 = new ProtocolVersion(210, "1.10"));
register(v1_11 = new ProtocolVersion(315, "1.11"));
register(v1_11_1 = new ProtocolVersion(316, "1.11.1"));
register(v1_12 = new ProtocolVersion(335, "1.12"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
}
@@ -1,8 +1,8 @@
package us.myles.ViaVersion.api.type;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.Getter;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.minecraft.EulerAngle;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.Vector;
@@ -1,11 +1,11 @@
package us.myles.ViaVersion.api.type.types.minecraft;
import com.github.steveice10.opennbt.NBTIO;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import org.spacehq.opennbt.NBTIO;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.type.Type;
import java.io.DataInput;
@@ -1,16 +1,16 @@
package us.myles.ViaVersion.boss;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossFlag;
import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
@@ -80,8 +80,10 @@ public abstract class CommonBoss<T> extends BossBar<T> {
public BossBar addPlayer(UUID player) {
if (!players.contains(player)) {
players.add(player);
if (visible)
sendPacket(player, getPacket(CommonBoss.UpdateAction.ADD));
if (visible) {
UserConnection user = Via.getManager().getConnection(player);
sendPacket(player, getPacket(CommonBoss.UpdateAction.ADD, user));
}
}
return this;
}
@@ -90,7 +92,8 @@ public abstract class CommonBoss<T> extends BossBar<T> {
public BossBar removePlayer(UUID uuid) {
if (players.contains(uuid)) {
players.remove(uuid);
sendPacket(uuid, getPacket(UpdateAction.REMOVE));
UserConnection user = Via.getManager().getConnection(uuid);
sendPacket(uuid, getPacket(UpdateAction.REMOVE, user));
}
return this;
}
@@ -152,52 +155,55 @@ public abstract class CommonBoss<T> extends BossBar<T> {
private void sendPacket(UpdateAction action) {
for (UUID uuid : new ArrayList<>(players)) {
ByteBuf buf = getPacket(action);
sendPacket(uuid, buf);
UserConnection connection = Via.getManager().getConnection(uuid);
PacketWrapper wrapper = getPacket(action, connection);
sendPacket(uuid, wrapper);
}
}
private void sendPacket(UUID uuid, ByteBuf buf) {
private void sendPacket(UUID uuid, PacketWrapper wrapper) {
if (!Via.getAPI().isPorted(uuid) || !(Via.getAPI().getPlayerVersion(uuid) >= ProtocolVersion.v1_9.getId())) {
players.remove(uuid);
buf.release();
return;
}
Via.getAPI().sendRawPacket(uuid, buf);
try {
wrapper.send(Protocol1_9TO1_8.class);
} catch (Exception e) {
e.printStackTrace();
}
}
private ByteBuf getPacket(UpdateAction action) {
private PacketWrapper getPacket(UpdateAction action, UserConnection connection) {
try {
ByteBuf buf = Unpooled.buffer();
Type.VAR_INT.write(buf, 0x0C); // Boss bar packet
Type.UUID.write(buf, uuid);
Type.VAR_INT.write(buf, action.getId());
PacketWrapper wrapper = new PacketWrapper(0x0C, null, connection); // TODO don't use fixed packet ids for future support
wrapper.write(Type.UUID, uuid);
wrapper.write(Type.VAR_INT, action.getId());
switch (action) {
case ADD:
Type.STRING.write(buf, fixJson(title));
buf.writeFloat(health);
Type.VAR_INT.write(buf, color.getId());
Type.VAR_INT.write(buf, style.getId());
buf.writeByte(flagToBytes());
Protocol1_9TO1_8.FIX_JSON.write(wrapper, title);
wrapper.write(Type.FLOAT, health);
wrapper.write(Type.VAR_INT, color.getId());
wrapper.write(Type.VAR_INT, style.getId());
wrapper.write(Type.BYTE, (byte) flagToBytes());
break;
case REMOVE:
break;
case UPDATE_HEALTH:
buf.writeFloat(health);
wrapper.write(Type.FLOAT, health);
break;
case UPDATE_TITLE:
Type.STRING.write(buf, fixJson(title));
Protocol1_9TO1_8.FIX_JSON.write(wrapper, title);
break;
case UPDATE_STYLE:
Type.VAR_INT.write(buf, color.getId());
Type.VAR_INT.write(buf, style.getId());
wrapper.write(Type.VAR_INT, color.getId());
wrapper.write(Type.VAR_INT, style.getId());
break;
case UPDATE_FLAGS:
buf.writeByte(flagToBytes());
wrapper.write(Type.BYTE, (byte) flagToBytes());
break;
}
return buf;
return wrapper;
} catch (Exception e) {
e.printStackTrace();
}
@@ -211,10 +217,6 @@ public abstract class CommonBoss<T> extends BossBar<T> {
return bitmask;
}
private String fixJson(String text) {
return Protocol1_9TO1_8.fixJson(text);
}
@RequiredArgsConstructor
@Getter
private enum UpdateAction {
@@ -36,7 +36,7 @@ public class PPSSubCmd extends ViaSubCommand {
if (!playerVersions.containsKey(playerVersion))
playerVersions.put(playerVersion, new HashSet<String>());
UserConnection uc = Via.getManager().getConnection(p.getUUID());
if (uc.getPacketsPerSecond() > -1) {
if (uc != null && uc.getPacketsPerSecond() > -1) {
playerVersions.get(playerVersion).add(p.getName() + " (" + uc.getPacketsPerSecond() + " PPS)");
totalPackets += uc.getPacketsPerSecond();
if (uc.getPacketsPerSecond() > max) {
@@ -1,12 +1,12 @@
package us.myles.ViaVersion.protocols.protocol1_11to1_10;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.minecraft.item.Item;
public class ItemRewriter {
public class EntityIdRewriter {
private static BiMap<String, String> oldToNewNames = HashBiMap.create();
static {
@@ -87,19 +87,32 @@ public class ItemRewriter {
oldToNewNames.put("ZombieVillager", "minecraft:zombie_villager");
}
public static void toClient(Item item) {
if (hasEntityTag(item)) {
CompoundTag entityTag = item.getTag().get("EntityTag");
if (entityTag.get("id") instanceof StringTag) {
StringTag id = entityTag.get("id");
if (oldToNewNames.containsKey(id.getValue())) {
id.setValue(oldToNewNames.get(id.getValue()));
}
public static void toClient(CompoundTag tag) {
if (tag.get("id") instanceof StringTag) {
StringTag id = tag.get("id");
if (oldToNewNames.containsKey(id.getValue())) {
id.setValue(oldToNewNames.get(id.getValue()));
}
}
}
public static void toServer(Item item) {
public static void toClientSpawner(CompoundTag tag) {
if (tag != null && tag.contains("SpawnData")) {
CompoundTag spawnData = tag.get("SpawnData");
if (spawnData != null && spawnData.contains("id"))
toClient(spawnData);
}
}
public static void toClientItem(Item item) {
if (hasEntityTag(item)) {
CompoundTag entityTag = item.getTag().get("EntityTag");
toClient(entityTag);
}
if (item != null && item.getAmount() <= 0) item.setAmount((byte) 1);
}
public static void toServerItem(Item item) {
if (hasEntityTag(item)) {
CompoundTag entityTag = item.getTag().get("EntityTag");
if (entityTag.get("id") instanceof StringTag) {
@@ -1,10 +1,13 @@
package us.myles.ViaVersion.protocols.protocol1_11to1_10;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.google.common.base.Optional;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.Entity1_11Types;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
@@ -15,6 +18,8 @@ import us.myles.ViaVersion.api.type.types.version.Types1_9;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.storage.EntityTracker;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_11To1_10 extends Protocol {
private static final ValueTransformer<Float, Short> toOldByte = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
@@ -243,6 +248,91 @@ public class Protocol1_11To1_10 extends Protocol {
}
});
// Update Block Entity
registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action
map(Type.NBT); // 2 - NBT data
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1) {
CompoundTag tag = wrapper.get(Type.NBT, 0);
EntityIdRewriter.toClientSpawner(tag);
}
}
});
}
});
// Chunk Data
registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
Chunk chunk = wrapper.passthrough(type);
// Clear any other bytes (This is a workaround for a issue with 1.9.2 encoder adding nbt list)
wrapper.clearInputBuffer();
if (chunk.getBlockEntities() == null) return;
for (CompoundTag tag : chunk.getBlockEntities()) {
if (tag.contains("id") &&
((StringTag) tag.get("id")).getValue().equals("MobSpawner")) {
EntityIdRewriter.toClientSpawner(tag);
}
}
}
});
}
});
// Join (save dimension id)
registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 1);
clientChunks.setEnvironment(dimensionId);
}
});
}
});
// Respawn (save dimension id)
registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Dimension ID
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 0);
clientWorld.setEnvironment(dimensionId);
}
});
}
});
/*
INCOMING PACKETS
*/
@@ -314,5 +404,7 @@ public class Protocol1_11To1_10 extends Protocol {
@Override
public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker(userConnection));
if (!userConnection.has(ClientWorld.class))
userConnection.put(new ClientWorld(userConnection));
}
}
@@ -6,7 +6,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.ItemRewriter;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
public class InventoryPackets {
@@ -27,7 +27,7 @@ public class InventoryPackets {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Item stack = wrapper.get(Type.ITEM, 0);
ItemRewriter.toClient(stack);
EntityIdRewriter.toClientItem(stack);
}
});
}
@@ -45,7 +45,7 @@ public class InventoryPackets {
public void handle(PacketWrapper wrapper) throws Exception {
Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0);
for (Item stack : stacks)
ItemRewriter.toClient(stack);
EntityIdRewriter.toClientItem(stack);
}
});
}
@@ -63,7 +63,7 @@ public class InventoryPackets {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Item stack = wrapper.get(Type.ITEM, 0);
ItemRewriter.toClient(stack);
EntityIdRewriter.toClientItem(stack);
}
});
}
@@ -83,12 +83,12 @@ public class InventoryPackets {
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
ItemRewriter.toClient(wrapper.passthrough(Type.ITEM)); // Input Item
ItemRewriter.toClient(wrapper.passthrough(Type.ITEM)); // Output Item
EntityIdRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Input Item
EntityIdRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Output Item
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem)
ItemRewriter.toClient(wrapper.passthrough(Type.ITEM)); // Second Item
EntityIdRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Second Item
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
wrapper.passthrough(Type.INT); // Number of tools uses
@@ -119,7 +119,7 @@ public class InventoryPackets {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Item item = wrapper.get(Type.ITEM, 0);
ItemRewriter.toServer(item);
EntityIdRewriter.toServerItem(item);
}
});
}
@@ -137,7 +137,7 @@ public class InventoryPackets {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Item item = wrapper.get(Type.ITEM, 0);
ItemRewriter.toServer(item);
EntityIdRewriter.toServerItem(item);
}
});
}
@@ -0,0 +1,268 @@
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_12To1_11_1 extends Protocol {
@Override
protected void registerPackets() {
// Outgoing
// Chunk Data
registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
Chunk chunk = wrapper.passthrough(type);
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
if (section == null)
continue;
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
int block = section.getBlockId(x, y, z);
// Is this a bed?
if (block == 26) {
// NBT -> { color:14, x:132, y:64, z:222, id:"minecraft:bed" } (Debug output)
CompoundTag tag = new CompoundTag("");
tag.put(new IntTag("color", 14)); // Set color to red (Default in previous versions)
tag.put(new IntTag("x", x + (chunk.getX() << 4)));
tag.put(new IntTag("y", y + (i << 4)));
tag.put(new IntTag("z", z + (chunk.getZ() << 4)));
tag.put(new StringTag("id", "minecraft:bed"));
// Add a fake block entity
chunk.getBlockEntities().add(tag);
}
}
}
}
}
}
});
}
});
// Join Packet
registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 1);
clientChunks.setEnvironment(dimensionId);
}
});
}
});
// 0x28 moved to 0x25
registerOutgoing(State.PLAY, 0x28, 0x25);
registerOutgoing(State.PLAY, 0x25, 0x26);
registerOutgoing(State.PLAY, 0x26, 0x27);
registerOutgoing(State.PLAY, 0x27, 0x28);
// New packet at 0x30
registerOutgoing(State.PLAY, 0x30, 0x31);
registerOutgoing(State.PLAY, 0x31, 0x32);
registerOutgoing(State.PLAY, 0x32, 0x33);
// Respawn Packet
registerOutgoing(State.PLAY, 0x33, 0x34, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Dimension ID
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 0);
clientWorld.setEnvironment(dimensionId);
}
});
}
});
registerOutgoing(State.PLAY, 0x34, 0x35);
// New packet at 0x36
registerOutgoing(State.PLAY, 0x35, 0x37);
registerOutgoing(State.PLAY, 0x36, 0x38);
registerOutgoing(State.PLAY, 0x37, 0x39);
registerOutgoing(State.PLAY, 0x38, 0x3a);
registerOutgoing(State.PLAY, 0x39, 0x3b);
registerOutgoing(State.PLAY, 0x3a, 0x3c);
registerOutgoing(State.PLAY, 0x3b, 0x3d);
registerOutgoing(State.PLAY, 0x3c, 0x3e);
registerOutgoing(State.PLAY, 0x3d, 0x3f);
registerOutgoing(State.PLAY, 0x3e, 0x40);
registerOutgoing(State.PLAY, 0x3f, 0x41);
registerOutgoing(State.PLAY, 0x40, 0x42);
registerOutgoing(State.PLAY, 0x41, 0x43);
registerOutgoing(State.PLAY, 0x42, 0x44);
registerOutgoing(State.PLAY, 0x43, 0x45);
registerOutgoing(State.PLAY, 0x44, 0x46);
registerOutgoing(State.PLAY, 0x45, 0x47);
// Sound effect, should work fine, might need checking for parrots?
registerOutgoing(State.PLAY, 0x46, 0x48, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Sound name
map(Type.VAR_INT); // 1 - Sound Category
map(Type.INT); // 2 - x
map(Type.INT); // 3 - y
map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume
map(Type.FLOAT); // 6 - Pitch
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.VAR_INT, 0);
id = getNewSoundId(id);
if (id == -1) // Removed
wrapper.cancel();
wrapper.set(Type.VAR_INT, 0, id);
}
});
}
});
registerOutgoing(State.PLAY, 0x47, 0x49);
registerOutgoing(State.PLAY, 0x48, 0x4a);
registerOutgoing(State.PLAY, 0x49, 0x4b);
// New packet at 0x4c
registerOutgoing(State.PLAY, 0x4a, 0x4d);
registerOutgoing(State.PLAY, 0x4b, 0x4e);
// Incoming
// New packet at 0x01
registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
}
});
}
});
registerIncoming(State.PLAY, 0x01, 0x02);
registerIncoming(State.PLAY, 0x02, 0x03);
registerIncoming(State.PLAY, 0x03, 0x04);
registerIncoming(State.PLAY, 0x04, 0x05);
registerIncoming(State.PLAY, 0x05, 0x06);
registerIncoming(State.PLAY, 0x06, 0x07);
registerIncoming(State.PLAY, 0x07, 0x08);
registerIncoming(State.PLAY, 0x08, 0x09);
registerIncoming(State.PLAY, 0x09, 0x0a);
registerIncoming(State.PLAY, 0x0a, 0x0b);
registerIncoming(State.PLAY, 0x0b, 0x0c);
// Mojang swapped 0x0F to 0x0D
registerIncoming(State.PLAY, 0x0f, 0x0d);
registerIncoming(State.PLAY, 0x0c, 0x0e);
// Mojang swapped 0x0F to 0x0D
registerIncoming(State.PLAY, 0x0d, 0x0f);
registerIncoming(State.PLAY, 0x0e, 0x10);
registerIncoming(State.PLAY, 0x10, 0x11);
registerIncoming(State.PLAY, 0x11, 0x12);
registerIncoming(State.PLAY, 0x12, 0x13);
registerIncoming(State.PLAY, 0x13, 0x14);
registerIncoming(State.PLAY, 0x14, 0x15);
registerIncoming(State.PLAY, 0x15, 0x16);
// New packet at 0x17
registerIncoming(State.PLAY, 0x17, 0x17, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
}
});
}
});
registerIncoming(State.PLAY, 0x16, 0x18);
// New packet 0x19
registerIncoming(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
}
});
}
});
registerIncoming(State.PLAY, 0x17, 0x1a);
registerIncoming(State.PLAY, 0x18, 0x1b);
registerIncoming(State.PLAY, 0x19, 0x1c);
registerIncoming(State.PLAY, 0x1a, 0x1d);
registerIncoming(State.PLAY, 0x1b, 0x1e);
registerIncoming(State.PLAY, 0x1c, 0x1f);
registerIncoming(State.PLAY, 0x1d, 0x20);
}
private int getNewSoundId(int id) { //TODO Make it better, suggestions are welcome. It's ugly and hardcoded now.
int newId = id;
if (id >= 26) // End Portal Sounds
newId += 2;
if (id >= 70) // New Block Notes
newId += 4;
if (id >= 74) // New Block Note 2
newId += 1;
if (id >= 143) // Boat Sounds
newId += 3;
if (id >= 185) // Endereye death
newId += 1;
if (id >= 263) // Illagers
newId += 7;
if (id >= 301) // Parrots
newId += 33;
if (id >= 317) // Player Sounds
newId += 2;
if (id >= 491) // UI toast sound
newId += 3;
return newId;
}
@Override
public void init(UserConnection userConnection) {
if (!userConnection.has(ClientWorld.class))
userConnection.put(new ClientWorld(userConnection));
}
}
@@ -1,6 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
@@ -13,6 +13,7 @@ import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type;
public class Protocol1_9_1_2TO1_9_3_4 extends Protocol {
@@ -53,6 +54,7 @@ public class Protocol1_9_1_2TO1_9_3_4 extends Protocol {
}
});
// Chunk Packet
registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
@Override
public void registerMap() {
@@ -61,9 +63,11 @@ public class Protocol1_9_1_2TO1_9_3_4 extends Protocol {
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
Chunk chunk = wrapper.passthrough(type);
Chunk1_9_3_4Type newType = new Chunk1_9_3_4Type(clientWorld);
Chunk1_9_1_2Type oldType = new Chunk1_9_1_2Type(clientWorld); // Get the old type to not write Block Entities
Chunk chunk = wrapper.read(newType);
wrapper.write(oldType, chunk);
BlockEntity.handle(chunk.getBlockEntities(), wrapper.user());
}
});
@@ -1,7 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.Getter;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
@@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import java.util.List;
@@ -48,8 +48,12 @@ public class ChunkSection1_9_3_4 implements ChunkSection {
}
public int getBlockId(int x, int y, int z) {
return getBlock(x, y, z) >> 4;
}
public int getBlock(int x, int y, int z) {
int index = blocks[index(x, y, z)];
return palette.get(index) >> 4;
return palette.get(index);
}
/**
@@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.minecraft.Environment;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
@@ -13,6 +13,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.ChunkSection1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
@@ -58,7 +59,7 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
input.readBytes(biomeData);
}
List<CompoundTag> nbtData = Arrays.asList(Type.NBT_ARRAY.read(input));
List<CompoundTag> nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input)));
return new Chunk1_9_3_4(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
}
@@ -92,7 +93,8 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
output.writeBytes(chunk.getBiomeData());
}
// Don't write block entities
// Write Block Entities
Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0]));
}
@Override
@@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.IntTag;
import org.spacehq.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
@@ -17,7 +17,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks.FakeTileEntit
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type;
import java.util.ArrayList;
import java.util.List;
public class Protocol1_9_3TO1_9_1_2 extends Protocol {
@@ -80,7 +79,7 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
Chunk1_9_1_2Type type = new Chunk1_9_1_2Type(clientWorld);
Chunk chunk = wrapper.passthrough(type);
List<CompoundTag> tags = new ArrayList<>();
List<CompoundTag> tags = chunk.getBlockEntities();
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
if (section == null)
@@ -98,7 +97,8 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
}
}
wrapper.write(Type.NBT_ARRAY, tags.toArray(new CompoundTag[0]));
// Send (for clients on this version)
wrapper.write(Type.NBT_ARRAY, chunk.getBlockEntities().toArray(new CompoundTag[0]));
}
});
}
@@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import java.util.List;
@@ -16,7 +16,7 @@ public class Chunk1_9_1_2 implements Chunk {
private int bitmask;
private final ChunkSection1_9_1_2[] sections;
private byte[] biomeData;
List<CompoundTag> blockEntities;
private List<CompoundTag> blockEntities;
public boolean isBiomeData() {
return biomeData != null;
@@ -48,8 +48,12 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
}
public int getBlockId(int x, int y, int z) {
return getBlock(x, y, z) >> 4;
}
public int getBlock(int x, int y, int z) {
int index = blocks[index(x, y, z)];
return palette.get(index) >> 4;
return palette.get(index);
}
/**
@@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.IntTag;
import org.spacehq.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import java.util.Arrays;
import java.util.List;
@@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.Environment;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
@@ -1,9 +1,9 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.ListTag;
import org.spacehq.opennbt.tag.builtin.StringTag;
import org.spacehq.opennbt.tag.builtin.Tag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.minecraft.item.Item;
import java.util.Collections;
@@ -1,12 +1,12 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
@RequiredArgsConstructor
@@ -19,6 +19,7 @@ public class Chunk1_9to1_8 implements Chunk {
private final int primaryBitmask;
private final ChunkSection1_9to1_8[] sections;
private final byte[] biomeData;
private final List<CompoundTag> blockEntities;
private boolean unloadPacket = false;
/**
@@ -28,7 +29,8 @@ public class Chunk1_9to1_8 implements Chunk {
* @param z coord
*/
public Chunk1_9to1_8(int x, int z) {
this(x, z, true, 0, new ChunkSection1_9to1_8[16], null);
this(x, z, true, 0, new ChunkSection1_9to1_8[16], null,
new ArrayList<CompoundTag>());
this.unloadPacket = true;
}
@@ -50,9 +52,4 @@ public class Chunk1_9to1_8 implements Chunk {
public int getBitmask() {
return primaryBitmask;
}
@Override
public List<CompoundTag> getBlockEntities() {
return Collections.emptyList();
}
}
@@ -47,8 +47,12 @@ public class ChunkSection1_9to1_8 implements ChunkSection {
}
public int getBlockId(int x, int y, int z) {
return getBlock(x, y, z) >> 4;
}
public int getBlock(int x, int y, int z) {
int index = blocks[index(x, y, z)];
return palette.get(index) >> 4;
return palette.get(index);
}
/**
@@ -303,7 +303,7 @@ public class SpawnPackets {
packet.write(Type.VAR_INT, 0);
packet.write(Type.ITEM, new Item(item, (byte) 1, (short) 0, null));
try {
packet.send(Protocol1_9TO1_8.class);
packet.send(Protocol1_9TO1_8.class, true, true);
} catch (Exception e) {
e.printStackTrace();
}
@@ -1,10 +1,10 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.google.common.base.Optional;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.Position;
@@ -306,18 +306,20 @@ public class WorldPackets {
Item item = Protocol1_9TO1_8.getHandItem(wrapper.user());
// Blocking patch
if (Via.getConfig().isShieldBlocking()) {
if (item != null) {
if (Protocol1_9TO1_8.isSword(item.getId())) {
if (hand == 0) {
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if (!tracker.isBlocking()) {
tracker.setBlocking(true);
Item shield = new Item((short) 442, (byte) 1, (short) 0, null);
tracker.setSecondHand(shield);
}
wrapper.cancel();
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if (item != null && Protocol1_9TO1_8.isSword(item.getId())) {
if (hand == 0) {
if (!tracker.isBlocking()) {
tracker.setBlocking(true);
Item shield = new Item((short) 442, (byte) 1, (short) 0, null);
tracker.setSecondHand(shield);
}
wrapper.cancel();
}
} else {
tracker.setSecondHand(null);
tracker.setBlocking(false);
}
}
wrapper.write(Type.ITEM, item);
@@ -1,7 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.providers;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.common.base.Optional;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
@@ -1,10 +1,10 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.common.base.Optional;
import lombok.Getter;
import lombok.Setter;
import org.spacehq.opennbt.tag.builtin.ByteTag;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
@@ -162,6 +162,8 @@ public class EntityTracker extends StoredObject {
if (validBlocking.contains(entityID)) {
Item shield = new Item((short) 442, (byte) 1, (short) 0, null);
setSecondHand(entityID, shield);
} else {
setSecondHand(entityID, null);
}
} else {
setSecondHand(entityID, null);
@@ -1,5 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import us.myles.ViaVersion.api.Via;
@@ -16,6 +17,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.logging.Level;
@@ -137,7 +139,7 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
}
// Return chunks
return new Chunk1_9to1_8(chunkX, chunkZ, groundUp, bitmask, sections, biomeData);
return new Chunk1_9to1_8(chunkX, chunkZ, groundUp, bitmask, sections, biomeData, new ArrayList<CompoundTag>());
}
@Override
@@ -172,9 +174,5 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
if (chunk.hasBiomeData()) {
output.writeBytes(chunk.getBiomeData());
}
}
}
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.4</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name>
@@ -46,7 +46,7 @@
<minimizeJar>false</minimizeJar>
<relocations>
<relocation>
<pattern>org.spacehq.opennbt</pattern>
<pattern>com.github.steveice10.opennbt</pattern>
<shadedPattern>us.myles.viaversion.libs.opennbt</shadedPattern>
</relocation>
<relocation>
+10 -9
View File
@@ -6,7 +6,7 @@
<groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId>
<version>1.0.4</version>
<version>1.1.0</version>
<packaging>pom</packaging>
<name>viaversion-parent</name>
@@ -44,17 +44,17 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository>
<!-- SpaceHQ Repo-->
<repository>
<id>spacehq-repo</id>
<url>https://repo.spacehq.org/content/repositories/releases/</url>
</repository>
<!-- Bungee repo -->
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<!-- ViaVersion repo -->
<repository>
<id>viaversion-repo</id>
<url>https://repo.viaversion.com</url>
</repository>
</repositories>
<dependencies>
@@ -76,10 +76,11 @@
</dependency>
<!-- OpenNBT Library -->
<!--Version 1.0 is conflicting with Maven Central (2012)-->
<dependency>
<groupId>org.spacehq</groupId>
<groupId>com.github.steveice10</groupId>
<artifactId>opennbt</artifactId>
<version>1.1</version>
<version>1.1-SNAPSHOT</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.4</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.4</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -7,6 +7,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import java.lang.reflect.Method;
@@ -31,18 +32,23 @@ public class SpongeChannelInitializer extends ChannelInitializer<SocketChannel>
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
UserConnection info = new UserConnection(socketChannel);
// init protocol
new ProtocolPipeline(info);
// Add originals
this.method.invoke(this.original, socketChannel);
// Add our transformers
MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder"));
ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder"));
SpongePacketHandler chunkHandler = new SpongePacketHandler(info);
// Ensure ViaVersion is loaded
if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
UserConnection info = new UserConnection(socketChannel);
// init protocol
new ProtocolPipeline(info);
// Add originals
this.method.invoke(this.original, socketChannel);
// Add our transformers
MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder"));
ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder"));
SpongePacketHandler chunkHandler = new SpongePacketHandler(info);
socketChannel.pipeline().replace("encoder", "encoder", encoder);
socketChannel.pipeline().replace("decoder", "decoder", decoder);
socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler);
socketChannel.pipeline().replace("encoder", "encoder", encoder);
socketChannel.pipeline().replace("decoder", "decoder", decoder);
socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler);
} else {
this.method.invoke(this.original, socketChannel);
}
}
}
@@ -36,14 +36,12 @@ public class SpongeViaInjector implements ViaInjector {
// Inject the list
List wrapper = new ListWrapper((List) value) {
@Override
public synchronized void handleAdd(Object o) {
synchronized (this) {
if (o instanceof ChannelFuture) {
try {
injectChannelFuture((ChannelFuture) o);
} catch (Exception e) {
e.printStackTrace();
}
public void handleAdd(Object o) {
if (o instanceof ChannelFuture) {
try {
injectChannelFuture((ChannelFuture) o);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -42,7 +42,7 @@ public class SpongeViaLoader implements ViaPlatformLoader {
new BlockListener(plugin).register();
if (plugin.getConf().isItemCache()) {
Via.getPlatform().runRepeatingSync(new HandItemCache(), 2L); // Updates player's items :)
Via.getPlatform().runRepeatingSync(new HandItemCache(), 2L); // Updates players items :)
HandItemCache.CACHE = true;
}