Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
381ff1e5d3 | ||
|
|
079f8df6e0 | ||
|
|
56637f50bc | ||
|
|
914888dade | ||
|
|
8e20df57a9 | ||
|
|
7d5191fa2f | ||
|
|
08528a1745 | ||
|
|
a8e3d9ec95 | ||
|
|
e5dd9b61a4 | ||
|
|
6ee2d0574f | ||
|
|
91b5a8036c | ||
|
|
24ab0d8590 | ||
|
|
d8f55006ff | ||
|
|
0817d28b88 | ||
|
|
577c8b4eaf | ||
|
|
5b5f0dce24 | ||
|
|
a818b9a9d4 | ||
|
|
3160c076f0 | ||
|
|
6d0b28fac4 | ||
|
|
ce286cf322 | ||
|
|
7d001c61a8 | ||
|
|
a09e8b9f4d | ||
|
|
395d020411 | ||
|
|
ece4455130 | ||
|
|
cc64ffff98 | ||
|
|
dd332420e5 | ||
|
|
ce8ba6a5af | ||
|
|
21eb824395 | ||
|
|
246e5ca742 | ||
|
|
2bd03ad92c | ||
|
|
7971dc797b | ||
|
|
36c047bfa0 | ||
|
|
d7daab7e64 | ||
|
|
b925e91bbb | ||
|
|
3b1341f2b3 | ||
|
|
667ad0d059 | ||
|
|
da98722470 | ||
|
|
c92fcc9f9a | ||
|
|
8d66ce776c | ||
|
|
412202e105 | ||
|
|
35c9e4e268 | ||
|
|
81ea78e003 | ||
|
|
833698fe8a | ||
|
|
70964e9ba9 | ||
|
|
255a4d516e | ||
|
|
11d26c13b8 | ||
|
|
00b4396f86 | ||
|
|
1d5d0012e6 | ||
|
|
18c706ab8a | ||
|
|
6a65a35dee | ||
|
|
37aab2c759 | ||
|
|
18ad5da081 | ||
|
|
9f65e727c9 | ||
|
|
efa6e8ec31 | ||
|
|
a7df7715b1 | ||
|
|
a9831c842c | ||
|
|
439a5f90c1 | ||
|
|
a6491cf792 | ||
|
|
e1025afb54 | ||
|
|
a5dddf371d | ||
|
|
fe95bbf312 | ||
|
|
0bab4f62de | ||
|
|
981b5cf3bf | ||
|
|
89f47c6a6a | ||
|
|
9fd1687348 | ||
|
|
899eac0e7e | ||
|
|
efad8f41a1 | ||
|
|
ee81935a74 | ||
|
|
e3c4253c13 | ||
|
|
9d991cdd26 | ||
|
|
3fdbf5b062 | ||
|
|
40937acfa0 | ||
|
|
99e4ab22e3 | ||
|
|
8da0c4310c | ||
|
|
280da6b8e9 | ||
|
|
71ff8a773b | ||
|
|
e3c1b9bf64 | ||
|
|
a52552dcb4 | ||
|
|
e8039e158f | ||
|
|
c37ef71f72 | ||
|
|
0388f340cc | ||
|
|
5e437d26d9 | ||
|
|
c10c3547b9 | ||
|
|
528a8e5587 | ||
|
|
ea4487e33f |
No files matched your search
@@ -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.
|
||||
@@ -1,6 +1,7 @@
|
||||
# ViaVersion 1.0.0 - Spigot, Sponge, BungeeCord
|
||||
# ViaVersion 1.1.0 - Spigot, Sponge, BungeeCord
|
||||
[](https://travis-ci.org/MylesIsCool/ViaVersion)
|
||||
[](https://gitter.im/MylesIsCool/ViaVersion)
|
||||
[](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)
|
||||

|
||||
|
||||
On Bukkit you may also use ProtocolSupport, but ensure you have the right build for your server version.
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -253,4 +253,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
||||
|
||||
return platformSpecific;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOldClientsAllowed() {
|
||||
return !protocolSupport; // Use protocolsupport for older clients
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.3</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.3</version>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -155,6 +155,11 @@ public class BungeePlugin extends Plugin implements ViaPlatform, Listener {
|
||||
return platformSpecific;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOldClientsAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerDisconnectEvent e) {
|
||||
Via.getManager().removePortedClient(e.getPlayer().getUniqueId());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -9,11 +9,13 @@ import us.myles.ViaVersion.bungee.handlers.BungeeServerHandler;
|
||||
import us.myles.ViaVersion.bungee.listeners.ElytraPatch;
|
||||
import us.myles.ViaVersion.bungee.listeners.MainHandPatch;
|
||||
import us.myles.ViaVersion.bungee.listeners.UpdateListener;
|
||||
import us.myles.ViaVersion.bungee.providers.BungeeBossBarProvider;
|
||||
import us.myles.ViaVersion.bungee.providers.BungeeEntityIdProvider;
|
||||
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
|
||||
import us.myles.ViaVersion.bungee.providers.BungeeVersionProvider;
|
||||
import us.myles.ViaVersion.bungee.service.ProtocolDetectorService;
|
||||
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
|
||||
@@ -36,6 +38,8 @@ public class BungeeViaLoader implements ViaPlatformLoader {
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new BungeeVersionProvider());
|
||||
Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider());
|
||||
Via.getManager().getProviders().use(BossBarProvider.class, new BungeeBossBarProvider());
|
||||
|
||||
if (plugin.getConf().getBungeePingInterval() > 0) {
|
||||
plugin.getProxy().getScheduler().schedule(plugin, new ProtocolDetectorService(plugin), 0, plugin.getConf().getBungeePingInterval(), TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package us.myles.ViaVersion.bungee.providers;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.bungee.storage.BungeeStorage;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BungeeBossBarProvider extends BossBarProvider {
|
||||
@Override
|
||||
public void handleAdd(UserConnection user, UUID barUUID) {
|
||||
if (user.has(BungeeStorage.class)) {
|
||||
BungeeStorage storage = user.get(BungeeStorage.class);
|
||||
// Check if bossbars are supported by bungee, static maybe
|
||||
if (storage.getBossbar() != null) {
|
||||
storage.getBossbar().add(barUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRemove(UserConnection user, UUID barUUID) {
|
||||
if (user.has(BungeeStorage.class)) {
|
||||
BungeeStorage storage = user.get(BungeeStorage.class);
|
||||
if (storage.getBossbar() != null) {
|
||||
storage.getBossbar().remove(barUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,43 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BungeeStorage extends StoredObject {
|
||||
private static Field bossField;
|
||||
|
||||
static {
|
||||
try {
|
||||
Class<?> user = Class.forName("net.md_5.bungee.UserConnection");
|
||||
bossField = user.getDeclaredField("sentBossBars");
|
||||
bossField.setAccessible(true);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Not supported *shrug* probably modified
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Not supported, old version probably
|
||||
}
|
||||
}
|
||||
|
||||
private ProxiedPlayer player;
|
||||
private String currentServer;
|
||||
private Set<UUID> bossbar;
|
||||
|
||||
public BungeeStorage(UserConnection user, ProxiedPlayer player) {
|
||||
super(user);
|
||||
this.player = player;
|
||||
this.currentServer = "";
|
||||
|
||||
// Get bossbar list if it's supported
|
||||
if (bossField != null) {
|
||||
try {
|
||||
bossbar = (Set<UUID>) bossField.get(player);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -13,11 +13,10 @@
|
||||
<artifactId>viaversion-common</artifactId>
|
||||
<dependencies>
|
||||
<!-- Snake YAML -->
|
||||
|
||||
<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();
|
||||
|
||||
@@ -167,4 +167,11 @@ public abstract class BossBar<T> {
|
||||
* @return visibility changable with show() and hide()
|
||||
*/
|
||||
public abstract boolean isVisible();
|
||||
|
||||
/**
|
||||
* Get the UUID of this bossbar
|
||||
*
|
||||
* @return Unique Id for this bossbar
|
||||
*/
|
||||
public abstract UUID getId();
|
||||
}
|
||||
@@ -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
|
||||
|
||||
+34
@@ -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];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,4 +140,12 @@ public interface ViaPlatform<T> {
|
||||
* @return The json data
|
||||
*/
|
||||
JsonObject getDump();
|
||||
|
||||
/**
|
||||
* Get if older clients are allowed to be used using ViaVersion.
|
||||
* (Only 1.9 on 1.9.2 server is supported by ViaVersion alone)
|
||||
*
|
||||
* @return True if allowed
|
||||
*/
|
||||
boolean isOldClientsAllowed();
|
||||
}
|
||||
@@ -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,14 +1,16 @@
|
||||
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;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
public class NBTType extends Type<CompoundTag> {
|
||||
@@ -28,7 +30,7 @@ public class NBTType extends Type<CompoundTag> {
|
||||
buffer.readerIndex(readerIndex);
|
||||
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer);
|
||||
try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) {
|
||||
return (CompoundTag) NBTIO.readTag(dataInputStream);
|
||||
return (CompoundTag) NBTIO.readTag((DataInput) dataInputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +43,7 @@ public class NBTType extends Type<CompoundTag> {
|
||||
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer);
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream);
|
||||
|
||||
NBTIO.writeTag(dataOutputStream, object);
|
||||
NBTIO.writeTag((DataOutput) dataOutputStream, object);
|
||||
|
||||
dataOutputStream.close();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -138,6 +141,11 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
private void setVisible(boolean value) {
|
||||
if (visible != value) {
|
||||
visible = value;
|
||||
@@ -147,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();
|
||||
}
|
||||
@@ -206,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 {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.commands.defaultsubs;
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
@@ -10,6 +11,7 @@ import us.myles.ViaVersion.dump.DumpTemplate;
|
||||
import us.myles.ViaVersion.dump.VersionInfo;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.OutputStream;
|
||||
@@ -50,35 +52,66 @@ public class DumpSubCmd extends ViaSubCommand {
|
||||
Via.getPlatform().runAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
HttpURLConnection con = (HttpURLConnection) new URL("http://hastebin.com/documents").openConnection();
|
||||
|
||||
con.setRequestProperty("Content-Type", "text/plain");
|
||||
HttpURLConnection con;
|
||||
try {
|
||||
con = (HttpURLConnection) new URL("https://api.github.com/gists").openConnection();
|
||||
} catch (IOException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Gist", e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.addRequestProperty("User-Agent", "ViaVersion");
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
|
||||
OutputStream out = con.getOutputStream();
|
||||
out.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(Charset.forName("UTF-8")));
|
||||
String contents = GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template);
|
||||
// Create payload
|
||||
JsonObject payload = new JsonObject();
|
||||
payload.addProperty("description", "ViaVersion Dump");
|
||||
payload.addProperty("public", "false");
|
||||
// Create file contents
|
||||
JsonObject file = new JsonObject();
|
||||
file.addProperty("content", contents);
|
||||
// Create file list
|
||||
JsonObject files = new JsonObject();
|
||||
files.add("dump.json", file);
|
||||
payload.add("files", files);
|
||||
// Write to stream
|
||||
out.write(GsonUtil.getGson().toJson(payload).getBytes(Charset.forName("UTF-8")));
|
||||
out.close();
|
||||
|
||||
JsonObject output = GsonUtil.getGson().fromJson(new InputStreamReader(con.getInputStream()), JsonObject.class);
|
||||
String rawOutput = CharStreams.toString(new InputStreamReader(con.getInputStream()));
|
||||
con.getInputStream().close();
|
||||
JsonObject output = GsonUtil.getGson().fromJson(rawOutput, JsonObject.class);
|
||||
|
||||
if (!output.has("key"))
|
||||
throw new InvalidObjectException("Key is not given in Hastebin output");
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "We've made a dump with useful information, report your issue and provide this url: " + getUrl(output.get("key").getAsString()));
|
||||
if (!output.has("html_url"))
|
||||
throw new InvalidObjectException("URL is not given in Gist output");
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "We've made a dump with useful information, report your issue and provide this url: " + output.get("html_url").getAsString());
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Hastebin", e);
|
||||
try {
|
||||
if (con.getResponseCode() == 403) {
|
||||
// Ensure 403 is due to rate limit being hit
|
||||
if("0".equals(con.getHeaderField("X-RateLimit-Remaining"))) {
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "You may only create 60 dumps per hour, please try again later.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Gist", e);
|
||||
|
||||
} catch (IOException e1) {
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to capture further info", e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getUrl(String id) {
|
||||
return String.format("http://hastebin.com/%s.json", id);
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -72,7 +72,12 @@ public class BaseProtocol extends Protocol {
|
||||
ProtocolRegistry.SERVER_PROTOCOL = protocolVersion;
|
||||
|
||||
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
|
||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
|
||||
List<Pair<Integer, Protocol>> protocols = null;
|
||||
|
||||
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
|
||||
if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
|
||||
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
|
||||
}
|
||||
|
||||
if (protocols != null) {
|
||||
if (protocolVersion != 9999) {
|
||||
@@ -163,7 +168,13 @@ public class BaseProtocol extends Protocol {
|
||||
info.setProtocolVersion(protVer);
|
||||
// Choose the pipe
|
||||
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
|
||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
|
||||
List<Pair<Integer, Protocol>> protocols = null;
|
||||
|
||||
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
|
||||
if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
|
||||
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
|
||||
}
|
||||
|
||||
ProtocolPipeline pipeline = wrapper.user().get(ProtocolInfo.class).getPipeline();
|
||||
if (protocols != null) {
|
||||
for (Pair<Integer, Protocol> prot : protocols) {
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
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 us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
|
||||
public class EntityIdRewriter {
|
||||
private static BiMap<String, String> oldToNewNames = HashBiMap.create();
|
||||
|
||||
static {
|
||||
oldToNewNames.put("AreaEffectCloud", "minecraft:area_effect_cloud");
|
||||
oldToNewNames.put("ArmorStand", "minecraft:armor_stand");
|
||||
oldToNewNames.put("Arrow", "minecraft:arrow");
|
||||
oldToNewNames.put("Bat", "minecraft:bat");
|
||||
oldToNewNames.put("Blaze", "minecraft:blaze");
|
||||
oldToNewNames.put("Boat", "minecraft:boat");
|
||||
oldToNewNames.put("CaveSpider", "minecraft:cave_spider");
|
||||
oldToNewNames.put("Chicken", "minecraft:chicken");
|
||||
oldToNewNames.put("Cow", "minecraft:cow");
|
||||
oldToNewNames.put("Creeper", "minecraft:creeper");
|
||||
oldToNewNames.put("Donkey", "minecraft:donkey");
|
||||
oldToNewNames.put("DragonFireball", "minecraft:dragon_fireball");
|
||||
oldToNewNames.put("ElderGuardian", "minecraft:elder_guardian");
|
||||
oldToNewNames.put("EnderCrystal", "minecraft:ender_crystal");
|
||||
oldToNewNames.put("EnderDragon", "minecraft:ender_dragon");
|
||||
oldToNewNames.put("Enderman", "minecraft:enderman");
|
||||
oldToNewNames.put("Endermite", "minecraft:endermite");
|
||||
oldToNewNames.put("EntityHorse", "minecraft:horse");
|
||||
oldToNewNames.put("EyeOfEnderSignal", "minecraft:eye_of_ender_signal");
|
||||
oldToNewNames.put("FallingSand", "minecraft:falling_block");
|
||||
oldToNewNames.put("Fireball", "minecraft:fireball");
|
||||
oldToNewNames.put("FireworksRocketEntity", "minecraft:fireworks_rocket");
|
||||
oldToNewNames.put("Ghast", "minecraft:ghast");
|
||||
oldToNewNames.put("Giant", "minecraft:giant");
|
||||
oldToNewNames.put("Guardian", "minecraft:guardian");
|
||||
oldToNewNames.put("Husk", "minecraft:husk");
|
||||
oldToNewNames.put("Item", "minecraft:item");
|
||||
oldToNewNames.put("ItemFrame", "minecraft:item_frame");
|
||||
oldToNewNames.put("LavaSlime", "minecraft:magma_cube");
|
||||
oldToNewNames.put("LeashKnot", "minecraft:leash_knot");
|
||||
oldToNewNames.put("MinecartChest", "minecraft:chest_minecart");
|
||||
oldToNewNames.put("MinecartCommandBlock", "minecraft:commandblock_minecart");
|
||||
oldToNewNames.put("MinecartFurnace", "minecraft:furnace_minecart");
|
||||
oldToNewNames.put("MinecartHopper", "minecraft:hopper_minecart");
|
||||
oldToNewNames.put("MinecartRideable", "minecraft:minecart");
|
||||
oldToNewNames.put("MinecartSpawner", "minecraft:spawner_minecart");
|
||||
oldToNewNames.put("MinecartTNT", "minecraft:tnt_minecart");
|
||||
oldToNewNames.put("Mule", "minecraft:mule");
|
||||
oldToNewNames.put("MushroomCow", "minecraft:mooshroom");
|
||||
oldToNewNames.put("Ozelot", "minecraft:ocelot");
|
||||
oldToNewNames.put("Painting", "minecraft:painting");
|
||||
oldToNewNames.put("Pig", "minecraft:pig");
|
||||
oldToNewNames.put("PigZombie", "minecraft:zombie_pigman");
|
||||
oldToNewNames.put("PolarBear", "minecraft:polar_bear");
|
||||
oldToNewNames.put("PrimedTnt", "minecraft:tnt");
|
||||
oldToNewNames.put("Rabbit", "minecraft:rabbit");
|
||||
oldToNewNames.put("Sheep", "minecraft:sheep");
|
||||
oldToNewNames.put("Shulker", "minecraft:shulker");
|
||||
oldToNewNames.put("ShulkerBullet", "minecraft:shulker_bullet");
|
||||
oldToNewNames.put("Silverfish", "minecraft:silverfish");
|
||||
oldToNewNames.put("Skeleton", "minecraft:skeleton");
|
||||
oldToNewNames.put("SkeletonHorse", "minecraft:skeleton_horse");
|
||||
oldToNewNames.put("Slime", "minecraft:slime");
|
||||
oldToNewNames.put("SmallFireball", "minecraft:small_fireball");
|
||||
oldToNewNames.put("Snowball", "minecraft:snowball");
|
||||
oldToNewNames.put("SnowMan", "minecraft:snowman");
|
||||
oldToNewNames.put("SpectralArrow", "minecraft:spectral_arrow");
|
||||
oldToNewNames.put("Spider", "minecraft:spider");
|
||||
oldToNewNames.put("Squid", "minecraft:squid");
|
||||
oldToNewNames.put("Stray", "minecraft:stray");
|
||||
oldToNewNames.put("ThrownEgg", "minecraft:egg");
|
||||
oldToNewNames.put("ThrownEnderpearl", "minecraft:ender_pearl");
|
||||
oldToNewNames.put("ThrownExpBottle", "minecraft:xp_bottle");
|
||||
oldToNewNames.put("ThrownPotion", "minecraft:potion");
|
||||
oldToNewNames.put("Villager", "minecraft:villager");
|
||||
oldToNewNames.put("VillagerGolem", "minecraft:villager_golem");
|
||||
oldToNewNames.put("Witch", "minecraft:witch");
|
||||
oldToNewNames.put("WitherBoss", "minecraft:wither");
|
||||
oldToNewNames.put("WitherSkeleton", "minecraft:wither_skeleton");
|
||||
oldToNewNames.put("WitherSkull", "minecraft:wither_skull");
|
||||
oldToNewNames.put("Wolf", "minecraft:wolf");
|
||||
oldToNewNames.put("XPOrb", "minecraft:xp_orb");
|
||||
oldToNewNames.put("Zombie", "minecraft:zombie");
|
||||
oldToNewNames.put("ZombieHorse", "minecraft:zombie_horse");
|
||||
oldToNewNames.put("ZombieVillager", "minecraft:zombie_villager");
|
||||
}
|
||||
|
||||
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 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) {
|
||||
StringTag id = entityTag.get("id");
|
||||
if (oldToNewNames.inverse().containsKey(id.getValue())) {
|
||||
id.setValue(oldToNewNames.inverse().get(id.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasEntityTag(Item item) {
|
||||
if (item != null && item.getId() == 383) { // Monster Egg
|
||||
CompoundTag tag = item.getTag();
|
||||
if (tag != null && tag.contains("EntityTag") && tag.get("EntityTag") instanceof CompoundTag) {
|
||||
if (((CompoundTag) tag.get("EntityTag")).get("id") instanceof StringTag) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_11to1_10;
|
||||
|
||||
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 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");
|
||||
id.setValue("minecraft:" + id.getValue().toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void toServer(Item item) {
|
||||
if (hasEntityTag(item)) {
|
||||
CompoundTag entityTag = item.getTag().get("EntityTag");
|
||||
if (entityTag.get("id") instanceof StringTag) {
|
||||
StringTag id = entityTag.get("id");
|
||||
|
||||
String value = id.getValue().replaceAll("minecraft:", "");
|
||||
if (value.length() > 1)
|
||||
value = value.substring(0, 1).toUpperCase() + value.substring(1);
|
||||
id.setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasEntityTag(Item item) {
|
||||
if (item != null && item.getId() == 383) { // Monster Egg
|
||||
CompoundTag tag = item.getTag();
|
||||
if (tag != null && tag.contains("EntityTag") && tag.get("EntityTag") instanceof CompoundTag) {
|
||||
if (((CompoundTag) tag.get("EntityTag")).get("id") instanceof StringTag) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+92
@@ -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));
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+268
@@ -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));
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -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
-1
@@ -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
-1
@@ -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;
|
||||
|
||||
+5
-1
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-3
@@ -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
|
||||
|
||||
+6
-6
@@ -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]));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+5
-1
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -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
-1
@@ -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;
|
||||
|
||||
+4
-4
@@ -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
@@ -94,6 +94,7 @@ public class Protocol1_9TO1_8 extends Protocol {
|
||||
providers.register(BulkChunkTranslatorProvider.class, new BulkChunkTranslatorProvider());
|
||||
providers.register(CommandBlockProvider.class, new CommandBlockProvider());
|
||||
providers.register(EntityIdProvider.class, new EntityIdProvider());
|
||||
providers.register(BossBarProvider.class, new BossBarProvider());
|
||||
providers.require(MovementTransmitterProvider.class);
|
||||
if (Via.getConfig().isStimulatePlayerTick()) {
|
||||
Via.getPlatform().runRepeatingSync(new ViaIdleThread(), 1L);
|
||||
|
||||
+5
-8
@@ -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();
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
|
||||
+14
-12
@@ -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);
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.providers;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.platform.providers.Provider;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BossBarProvider implements Provider {
|
||||
public void handleAdd(UserConnection user, UUID barUUID) {
|
||||
|
||||
}
|
||||
|
||||
public void handleRemove(UserConnection user, UUID barUUID) {
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+11
@@ -24,6 +24,8 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chat.GameMode;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
|
||||
|
||||
import java.util.*;
|
||||
@@ -95,6 +97,8 @@ public class EntityTracker extends StoredObject {
|
||||
BossBar bar = bossBarMap.remove(entityID);
|
||||
if (bar != null) {
|
||||
bar.hide();
|
||||
// Send to provider
|
||||
Via.getManager().getProviders().get(BossBarProvider.class).handleRemove(getUser(), bar.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,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);
|
||||
@@ -203,6 +209,9 @@ public class EntityTracker extends StoredObject {
|
||||
bossBarMap.put(entityID, bar);
|
||||
bar.addPlayer(uuid);
|
||||
bar.show();
|
||||
|
||||
// Send to provider
|
||||
Via.getManager().getProviders().get(BossBarProvider.class).handleAdd(getUser(), bar.getId());
|
||||
} else {
|
||||
bar.setTitle(title);
|
||||
}
|
||||
@@ -217,6 +226,8 @@ public class EntityTracker extends StoredObject {
|
||||
bossBarMap.put(entityID, bar);
|
||||
bar.addPlayer(uuid);
|
||||
bar.show();
|
||||
// Send to provider
|
||||
Via.getManager().getProviders().get(BossBarProvider.class).handleAdd(getUser(), bar.getId());
|
||||
} else {
|
||||
bar.setHealth(health);
|
||||
}
|
||||
|
||||
+3
-5
@@ -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
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.3</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>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<version>1.0.3</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>
|
||||
@@ -65,6 +65,7 @@
|
||||
<version>1.16.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Javassist (Bytecode Library) -->
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
@@ -74,11 +75,12 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- NBT Edit Library -->
|
||||
<!-- 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.0</version>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -199,4 +199,9 @@ public class SpongePlugin implements ViaPlatform {
|
||||
|
||||
return platformSpecific;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOldClientsAllowed() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+18
-12
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user