Compare commits

..
19 Commits
Author SHA1 Message Date
Myles e3c1b9bf64 1.0.4 Release 2017-02-03 16:27:18 +00:00
Myles a52552dcb4 Save boss bars to BungeeCord which are made by Withers / Enderdragons 2017-02-03 16:24:14 +00:00
Myles e8039e158f Fix horse spawn eggs 2017-02-01 15:58:53 +00:00
Myles c37ef71f72 Fix spawn eggs for 1.11+ #598 2017-01-30 18:02:12 +00:00
Myles 0388f340cc Don’t support older versions if protocol support is installed, fixes #615 2017-01-30 17:15:47 +00:00
Myles 5e437d26d9 Fix typo 2017-01-12 22:10:05 +00:00
Myles c10c3547b9 Move dumps to gists #608 2017-01-03 15:53:20 +00:00
Myles 528a8e5587 Update OpenNBT 2016-12-24 17:27:59 +00:00
Myles ea4487e33f Back to dev 2016-12-20 21:46:19 +00:00
Myles c2578bd212 Bump to 1.0.3 2016-12-20 21:06:23 +00:00
Myles a1347dd669 Move 1.11.1 support to new class, fixes any other support issues (or just upgrade bungee etc) 2016-12-20 20:54:28 +00:00
Myles 3228ba65ae Fix #587 2016-12-20 20:13:19 +00:00
Myles 08b2d5b7e8 Fix #604 2016-12-20 20:11:21 +00:00
Myles 2b89dbce0e Back to snapshot 2016-12-20 16:14:13 +00:00
Myles f256309487 Bump version to 1.0.2 2016-12-20 16:07:37 +00:00
Myles 462abb1ef9 Update to snapshot 1.11.1 2016-12-15 15:39:38 +00:00
Myles a35408d14f New config option for disabling piston animation for 1.11 clients #570 2016-12-15 15:32:54 +00:00
Myles 81d4deaea7 Fix block metadata #580 2016-11-28 23:47:49 +00:00
Myles 9103f89aff 1.0.2-SNAPSHOT 2016-11-16 19:58:59 +00:00
35 changed files with 376 additions and 49 deletions

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.1</version>
<version>1.0.4</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
}
}
@@ -37,16 +37,19 @@ public class DeathListener extends ViaBukkitListener {
Via.getPlatform().runSync(new Runnable() {
@Override
public void run() {
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
try {
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
wrapper.write(Type.INT, p.getEntityId()); // Entity ID
Protocol1_9TO1_8.FIX_JSON.write(wrapper, msg); // Message
// If online
if(getUserConnection(p) != null) {
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
try {
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
wrapper.write(Type.INT, p.getEntityId()); // Entity ID
Protocol1_9TO1_8.FIX_JSON.write(wrapper, msg); // Message
wrapper.send(Protocol1_9TO1_8.class);
} catch (Exception e) {
e.printStackTrace();
wrapper.send(Protocol1_9TO1_8.class);
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
@@ -52,6 +52,11 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.1</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -37,7 +37,7 @@
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion-common</artifactId>
<version>1.0.1</version>
<version>1.0.4</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());
@@ -29,16 +29,20 @@ public class MainHandPatch implements Listener {
@EventHandler
public void onServerConnect(ServerConnectEvent event) {
// Ignore if it doesn't exist (Like BungeeCord 1.8)
if (setMainHand == null)
if (setMainHand == null || getSettings == null)
return;
UserConnection user = Via.getManager().getConnection(event.getPlayer().getUniqueId());
if(user == null) return;
if (user == null) return;
try {
if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
Object settings = getSettings.invoke(event.getPlayer());
setMainHand.invoke(settings, user.get(EntityTracker.class).getMainHand());
if (settings != null) {
if (user.has(EntityTracker.class)) {
setMainHand.invoke(settings, user.get(EntityTracker.class).getMainHand());
}
}
}
} catch (Exception e) {
e.printStackTrace();
@@ -86,6 +86,11 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
@@ -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();
}
}
}
}
+1 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.1</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,7 +13,6 @@
<artifactId>viaversion-common</artifactId>
<dependencies>
<!-- Snake YAML -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
@@ -53,6 +53,13 @@ public interface ViaVersionConfig {
*/
boolean isHologramPatch();
/**
* Get if the 1.11 piston animation patch is enabled
*
* @return true if the piston patch is enabled.
*/
boolean isPistonAnimationPatch();
/**
* Get if boss bars are fixed for 1.9 &amp; 1.10 clients
*
@@ -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();
}
@@ -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();
}
@@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
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_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;
@@ -37,7 +38,8 @@ 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(), Collections.singletonList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_10.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());
}
@@ -28,6 +28,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_9_3;
public static final ProtocolVersion v1_10;
public static final ProtocolVersion v1_11;
public static final ProtocolVersion v1_11_1;
public static final ProtocolVersion unknown;
private final int id;
@@ -52,6 +53,7 @@ public class ProtocolVersion {
register(v1_9_3 = new ProtocolVersion(110, "1.9.3/4"));
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(unknown = new ProtocolVersion(-1, "UNKNOWN"));
}
@@ -8,7 +8,9 @@ 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();
}
@@ -138,6 +138,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;
@@ -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);
}
}
@@ -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) {
@@ -0,0 +1,16 @@
package us.myles.ViaVersion.protocols.protocol1_11_1to1_11;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
public class Protocol1_11_1To1_11 extends Protocol {
@Override
protected void registerPackets() {
// Only had metadata changes, see wiki.vg for full info.
}
@Override
public void init(UserConnection userConnection) {
}
}
@@ -1,16 +1,100 @@
package us.myles.ViaVersion.protocols.protocol1_11to1_10;
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 {
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(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());
if (oldToNewNames.containsKey(id.getValue())) {
id.setValue(oldToNewNames.get(id.getValue()));
}
}
}
}
@@ -20,11 +104,9 @@ public class ItemRewriter {
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);
if (oldToNewNames.inverse().containsKey(id.getValue())) {
id.setValue(oldToNewNames.inverse().get(id.getValue()));
}
}
}
}
@@ -219,6 +219,30 @@ public class Protocol1_11To1_10 extends Protocol {
}
});
// Block action packet
registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action ID
map(Type.UNSIGNED_BYTE); // 2 - Action Param
map(Type.VAR_INT); // 3 - Block Type
// Cheap hack to ensure it's always right block
handler(new PacketHandler() {
@Override
public void handle(final PacketWrapper actionWrapper) throws Exception {
if (Via.getConfig().isPistonAnimationPatch()) {
int id = actionWrapper.get(Type.VAR_INT, 0);
if (id == 33 || id == 29) {
actionWrapper.cancel();
}
}
}
});
}
});
/*
INCOMING PACKETS
*/
@@ -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);
@@ -72,7 +72,7 @@ public class MetadataRewriter {
id = (Short) value;
}
if (id != -1 && data != -1) {
int combined = id << 4 | data;
int combined = id | (data & 0xF);
data = -1;
id = -1;
entry.setValue(combined);
@@ -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) {
}
}
@@ -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());
}
}
@@ -203,6 +207,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 +224,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
View File
@@ -79,6 +79,9 @@ tracking-max-kick-msg: "You are sending too many packets, :("
hologram-patch: false
# This is the offset, should work as default when enabled.
hologram-y: -0.96
# Should we disable piston animation for 1.11/1.11.1 clients?
# In some cases when firing lots of pistons it crashes them.
piston-animation-patch: false
#
#----------------------------------------------------------#
# 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS #
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.1</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name>
+4 -3
View File
@@ -6,7 +6,7 @@
<groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId>
<version>1.0.1</version>
<version>1.0.4</version>
<packaging>pom</packaging>
<name>viaversion-parent</name>
@@ -65,6 +65,7 @@
<version>1.16.6</version>
<scope>provided</scope>
</dependency>
<!-- Javassist (Bytecode Library) -->
<dependency>
<groupId>org.javassist</groupId>
@@ -74,11 +75,11 @@
<optional>true</optional>
</dependency>
<!-- NBT Edit Library -->
<!-- OpenNBT Library -->
<dependency>
<groupId>org.spacehq</groupId>
<artifactId>opennbt</artifactId>
<version>1.0</version>
<version>1.1</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.1</version>
<version>1.0.4</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.1</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -199,4 +199,9 @@ public class SpongePlugin implements ViaPlatform {
return platformSpecific;
}
@Override
public boolean isOldClientsAllowed() {
return true;
}
}
@@ -59,6 +59,11 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);