3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Move everything into the right package.

Clean up a lot of code.
Remove PacketUtil (evil laugh)
Add Pipeline Util
Organise listeners, and add protocol pipe checks
Dieser Commit ist enthalten in:
Myles 2016-03-18 21:18:48 +00:00
Ursprung 69e8ddcbf6
Commit 8a35c0235e
98 geänderte Dateien mit 1268 neuen und 1437 gelöschten Zeilen

Datei anzeigen

@ -2,11 +2,11 @@ package us.myles.ViaVersion;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection;
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.storage.MovementTracker;
import us.myles.ViaVersion.util.ReflectionUtil; import us.myles.ViaVersion.util.ReflectionUtil;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.MovementTracker;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -19,15 +19,15 @@ public class ViaIdleThread extends BukkitRunnable {
this.portedPlayers = portedPlayers; this.portedPlayers = portedPlayers;
try { try {
this.idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying"); this.idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying");
} catch(ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new RuntimeException("Couldn't find player idle packet, help!", e); throw new RuntimeException("Couldn't find player idle packet, help!", e);
} }
} }
@Override @Override
public void run() { public void run() {
for(UserConnection info : portedPlayers.values()) { for (UserConnection info : portedPlayers.values()) {
if(info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) { if (info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket(); long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
if (nextIdleUpdate <= System.currentTimeMillis()) { if (nextIdleUpdate <= System.currentTimeMillis()) {
try { try {

Datei anzeigen

@ -17,19 +17,19 @@ import us.myles.ViaVersion.api.ViaVersionAPI;
import us.myles.ViaVersion.api.boss.BossBar; import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor; import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle; import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.armor.ArmorListener; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.boss.ViaBossBar; import us.myles.ViaVersion.boss.ViaBossBar;
import us.myles.ViaVersion.commands.ViaVersionCommand; import us.myles.ViaVersion.commands.ViaVersionCommand;
import us.myles.ViaVersion.handlers.ViaVersionInitializer; import us.myles.ViaVersion.handlers.ViaVersionInitializer;
import us.myles.ViaVersion.listeners.CommandBlockListener; import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.ArmorListener;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.CommandBlockListener;
import us.myles.ViaVersion.update.UpdateListener; import us.myles.ViaVersion.update.UpdateListener;
import us.myles.ViaVersion.update.UpdateUtil; import us.myles.ViaVersion.update.UpdateUtil;
import us.myles.ViaVersion.util.Configuration; import us.myles.ViaVersion.util.Configuration;
import us.myles.ViaVersion.util.ListWrapper; import us.myles.ViaVersion.util.ListWrapper;
import us.myles.ViaVersion.util.ReflectionUtil; import us.myles.ViaVersion.util.ReflectionUtil;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo;
import java.io.File; import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -244,7 +244,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
@Override @Override
public int getPlayerVersion(@NonNull Player player) { public int getPlayerVersion(@NonNull Player player) {
if (!isPorted(player)) if (!isPorted(player))
return 47; return ProtocolRegistry.SERVER_PROTOCOL;
return portedPlayers.get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion(); return portedPlayers.get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion();
} }
@ -258,6 +258,14 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
return getDescription().getVersion(); return getDescription().getVersion();
} }
public UserConnection getConnection(UUID playerUUID){
return portedPlayers.get(playerUUID);
}
public UserConnection getConnection(Player player){
return portedPlayers.get(player.getUniqueId());
}
public void sendRawPacket(Player player, ByteBuf packet) throws IllegalArgumentException { public void sendRawPacket(Player player, ByteBuf packet) throws IllegalArgumentException {
sendRawPacket(player.getUniqueId(), packet); sendRawPacket(player.getUniqueId(), packet);
} }
@ -292,8 +300,8 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
return getConfig().getBoolean("prevent-collision", true); return getConfig().getBoolean("prevent-collision", true);
} }
public boolean isNewEffectIndicator(){ public boolean isNewEffectIndicator() {
return getConfig().getBoolean("use-new-effect-indicator",true); return getConfig().getBoolean("use-new-effect-indicator", true);
} }
public boolean isSuppressMetadataErrors() { public boolean isSuppressMetadataErrors() {
@ -322,8 +330,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
public boolean isAutoTeam() { public boolean isAutoTeam() {
// Collision has to be enabled first // Collision has to be enabled first
if (!isPreventCollision()) return false; return isPreventCollision() && getConfig().getBoolean("auto-team", true);
return getConfig().getBoolean("auto-team", true);
} }
public void addPortedClient(UserConnection info) { public void addPortedClient(UserConnection info) {

Datei anzeigen

@ -1,15 +1,14 @@
package us.myles.ViaVersion2.api; package us.myles.ViaVersion.api;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import us.myles.ViaVersion2.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion2.api.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
import us.myles.ViaVersion2.api.util.Pair;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -60,7 +59,7 @@ public class PacketWrapper {
} }
public <T> T read(Type<T> type) throws Exception { public <T> T read(Type<T> type) throws Exception {
if(type == Type.NOTHING) return null; if (type == Type.NOTHING) return null;
if (readableObjects.isEmpty()) { if (readableObjects.isEmpty()) {
Preconditions.checkNotNull(inputBuffer, "This packet does not have an input buffer."); Preconditions.checkNotNull(inputBuffer, "This packet does not have an input buffer.");
// We could in the future log input read values, but honestly for things like bulk maps, mem waste D: // We could in the future log input read values, but honestly for things like bulk maps, mem waste D:

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.util; package us.myles.ViaVersion.api;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
@ -13,7 +13,7 @@ public class Pair<X, Y> {
private X key; private X key;
private Y value; private Y value;
public Pair(X key, Y value){ public Pair(X key, Y value) {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }

Datei anzeigen

@ -19,6 +19,7 @@ public interface ViaVersionAPI {
/** /**
* Get protocol number from a player * Get protocol number from a player
*
* @param player Bukkit player object * @param player Bukkit player object
* @return Protocol ID, For example (47=1.8-1.8.8, 107=1.9, 108=1.9.1) * @return Protocol ID, For example (47=1.8-1.8.8, 107=1.9, 108=1.9.1)
*/ */

Datei anzeigen

@ -6,13 +6,6 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
public interface BossBar { public interface BossBar {
/**
* Change the title
*
* @param title Title can be in either JSON or just text
*/
void setTitle(String title);
/** /**
* Get the current title * Get the current title
* *
@ -21,11 +14,11 @@ public interface BossBar {
String getTitle(); String getTitle();
/** /**
* Change the health * Change the title
* *
* @param health this float has to be between 0F - 1F * @param title Title can be in either JSON or just text
*/ */
void setHealth(float health); void setTitle(String title);
/** /**
* Get the health * Get the health
@ -35,11 +28,11 @@ public interface BossBar {
float getHealth(); float getHealth();
/** /**
* Yay colors! * Change the health
* *
* @param color Whatever color you want! * @param health this float has to be between 0F - 1F
*/ */
void setColor(BossColor color); void setHealth(float health);
/** /**
* Get the bossbar color * Get the bossbar color
@ -49,11 +42,11 @@ public interface BossBar {
BossColor getColor(); BossColor getColor();
/** /**
* Change the bosbar style * Yay colors!
* *
* @param style BossStyle * @param color Whatever color you want!
*/ */
void setStyle(BossStyle style); void setColor(BossColor color);
/** /**
* Get the bosbar style * Get the bosbar style
@ -62,6 +55,13 @@ public interface BossBar {
*/ */
BossStyle getStyle(); BossStyle getStyle();
/**
* Change the bosbar style
*
* @param style BossStyle
*/
void setStyle(BossStyle style);
/** /**
* Show the bossbar to a player. * Show the bossbar to a player.
* *

Datei anzeigen

@ -1,8 +1,9 @@
package us.myles.ViaVersion2.api.data; package us.myles.ViaVersion.api.data;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@Getter(AccessLevel.PROTECTED) @Getter(AccessLevel.PROTECTED)
@AllArgsConstructor @AllArgsConstructor
public class StoredObject { public class StoredObject {

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.data; package us.myles.ViaVersion.api.data;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
@ -10,13 +10,13 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class UserConnection { public class UserConnection {
@Getter
private final SocketChannel channel;
List<StoredObject> storedObjects = new ArrayList<>(); List<StoredObject> storedObjects = new ArrayList<>();
@Getter @Getter
@Setter @Setter
private boolean active = true; private boolean active = true;
@Getter @Getter
private final SocketChannel channel;
@Getter
@Setter @Setter
private Object lastPacket; private Object lastPacket;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.util; package us.myles.ViaVersion.api.minecraft;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.chunks; package us.myles.ViaVersion.api.minecraft.chunks;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

Datei anzeigen

@ -1,10 +1,9 @@
package us.myles.ViaVersion.chunks; package us.myles.ViaVersion.api.minecraft.chunks;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import org.bukkit.Material; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.util.PacketUtil;
import java.util.List; import java.util.List;
@ -20,7 +19,6 @@ public class ChunkSection {
/** /**
* Length of the block data array. * Length of the block data array.
*/ */
// public static final int BLOCK_LENGTH = 16 * 16 * 16 * 2; // size * size * size * 2 (char bit count)
private final List<Integer> palette = Lists.newArrayList(); private final List<Integer> palette = Lists.newArrayList();
private final int[] blocks; private final int[] blocks;
@ -40,7 +38,7 @@ public class ChunkSection {
public void setBlock(int idx, int type, int data) { public void setBlock(int idx, int type, int data) {
int hash = type << 4 | (data & 0xF); int hash = type << 4 | (data & 0xF);
int index = palette.indexOf(hash); int index = palette.indexOf(hash);
if(index == -1) { if (index == -1) {
index = palette.size(); index = palette.size();
palette.add(hash); palette.add(hash);
} }
@ -53,7 +51,7 @@ public class ChunkSection {
} }
public void setSkyLight(byte[] data) { public void setSkyLight(byte[] data) {
if(data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH); if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
this.skyLight = new NibbleArray(data); this.skyLight = new NibbleArray(data);
} }
@ -61,37 +59,39 @@ public class ChunkSection {
return z << 8 | y << 4 | x; return z << 8 | y << 4 | x;
} }
public void writeBlocks(ByteBuf output) { public void writeBlocks(ByteBuf output) throws Exception {
// Write bits per block // Write bits per block
int bitsPerBlock = 4; int bitsPerBlock = 4;
while(palette.size() > 1 << bitsPerBlock) { while (palette.size() > 1 << bitsPerBlock) {
bitsPerBlock += 1; bitsPerBlock += 1;
} }
long maxEntryValue = (1L << bitsPerBlock) - 1; long maxEntryValue = (1L << bitsPerBlock) - 1;
output.writeByte(bitsPerBlock); output.writeByte(bitsPerBlock);
// Write pallet (or not) // Write pallet (or not)
PacketUtil.writeVarInt(palette.size(), output); Type.VAR_INT.write(output, palette.size());
for(int mappedId : palette) { for (int mappedId : palette) {
PacketUtil.writeVarInt(mappedId, output); Type.VAR_INT.write(output, mappedId);
} }
int length = (int) Math.ceil(SIZE * bitsPerBlock / 64.0); int length = (int) Math.ceil(SIZE * bitsPerBlock / 64.0);
PacketUtil.writeVarInt(length, output); Type.VAR_INT.write(output, length);
long[] data = new long[length]; long[] data = new long[length];
for(int index = 0; index < blocks.length; index++) { for (int index = 0; index < blocks.length; index++) {
int value = blocks[index]; int value = blocks[index];
int bitIndex = index * bitsPerBlock; int bitIndex = index * bitsPerBlock;
int startIndex = bitIndex / 64; int startIndex = bitIndex / 64;
int endIndex = ((index + 1) * bitsPerBlock - 1) / 64; int endIndex = ((index + 1) * bitsPerBlock - 1) / 64;
int startBitSubIndex = bitIndex % 64; int startBitSubIndex = bitIndex % 64;
data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex; data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex;
if(startIndex != endIndex) { if (startIndex != endIndex) {
int endBitSubIndex = 64 - startBitSubIndex; int endBitSubIndex = 64 - startBitSubIndex;
data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex; data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex;
} }
} }
PacketUtil.writeLongs(data, output); for (long l : data) {
Type.LONG.write(output, l);
}
} }
public void writeBlockLight(ByteBuf output) { public void writeBlockLight(ByteBuf output) {
@ -111,7 +111,7 @@ public class ChunkSection {
* *
* @return Amount of bytes sent by this section * @return Amount of bytes sent by this section
*/ */
public int getExpectedSize() { public int getExpectedSize() throws Exception {
int bitsPerBlock = palette.size() > 255 ? 16 : 8; int bitsPerBlock = palette.size() > 255 ? 16 : 8;
int bytes = 1; // bits per block int bytes = 1; // bits per block
bytes += paletteBytes(); // palette bytes += paletteBytes(); // palette
@ -122,19 +122,19 @@ public class ChunkSection {
return bytes; return bytes;
} }
private int paletteBytes() { private int paletteBytes() throws Exception {
// Count bytes used by pallet // Count bytes used by pallet
int bytes = countBytes(palette.size()); int bytes = countBytes(palette.size());
for(int mappedId : palette) { for (int mappedId : palette) {
bytes += countBytes(mappedId); bytes += countBytes(mappedId);
} }
return bytes; return bytes;
} }
private int countBytes(int value) { private int countBytes(int value) throws Exception {
// Count amount of bytes that would be sent if the value were sent as a VarInt // Count amount of bytes that would be sent if the value were sent as a VarInt
ByteBuf buf = Unpooled.buffer(); ByteBuf buf = Unpooled.buffer();
PacketUtil.writeVarInt(value, buf); Type.VAR_INT.write(buf, value);
buf.readerIndex(0); buf.readerIndex(0);
int bitCount = buf.readableBytes(); int bitCount = buf.readableBytes();
buf.release(); buf.release();

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.chunks; package us.myles.ViaVersion.api.minecraft.chunks;
import java.util.Arrays; import java.util.Arrays;
@ -6,7 +6,7 @@ public class NibbleArray {
private final byte[] handle; private final byte[] handle;
public NibbleArray(int length) { public NibbleArray(int length) {
if(length == 0 || length % 2 != 0) { if (length == 0 || length % 2 != 0) {
throw new IllegalArgumentException("Length of nibble array must be a positive number dividable by 2!"); throw new IllegalArgumentException("Length of nibble array must be a positive number dividable by 2!");
} }
@ -14,7 +14,7 @@ public class NibbleArray {
} }
public NibbleArray(byte[] handle) { public NibbleArray(byte[] handle) {
if(handle.length == 0 || handle.length % 2 != 0) { if (handle.length == 0 || handle.length % 2 != 0) {
throw new IllegalArgumentException("Length of nibble array must be a positive number dividable by 2!"); throw new IllegalArgumentException("Length of nibble array must be a positive number dividable by 2!");
} }
@ -27,7 +27,7 @@ public class NibbleArray {
public byte get(int index) { public byte get(int index) {
byte value = handle[index / 2]; byte value = handle[index / 2];
if(index % 2 == 0) { if (index % 2 == 0) {
return (byte) (value & 0xF); return (byte) (value & 0xF);
} else { } else {
return (byte) ((value >> 4) & 0xF); return (byte) ((value >> 4) & 0xF);
@ -40,7 +40,7 @@ public class NibbleArray {
public void set(int index, int value) { public void set(int index, int value) {
index /= 2; index /= 2;
if(index % 2 == 0) { if (index % 2 == 0) {
handle[index] = (byte) (handle[index] & 0xF0 | value & 0xF); handle[index] = (byte) (handle[index] & 0xF0 | value & 0xF);
} else { } else {
handle[index] = (byte) (handle[index] & 0xF | (value & 0xF) << 4); handle[index] = (byte) (handle[index] & 0xF | (value & 0xF) << 4);
@ -60,15 +60,15 @@ public class NibbleArray {
Arrays.fill(handle, (byte) ((value << 4) | value)); Arrays.fill(handle, (byte) ((value << 4) | value));
} }
public byte[] getHandle() {
return handle;
}
public void setHandle(byte[] handle) { public void setHandle(byte[] handle) {
if(handle.length != this.handle.length) { if (handle.length != this.handle.length) {
throw new IllegalArgumentException("Length of handle must equal to size of nibble array!"); throw new IllegalArgumentException("Length of handle must equal to size of nibble array!");
} }
System.arraycopy(handle, 0, this.handle, 0, handle.length); System.arraycopy(handle, 0, this.handle, 0, handle.length);
} }
public byte[] getHandle() {
return handle;
}
} }

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.item; package us.myles.ViaVersion.api.minecraft.item;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@ -18,7 +18,7 @@ public class Item {
private CompoundTag tag; private CompoundTag tag;
public static Item getItem(ItemStack stack) { public static Item getItem(ItemStack stack) {
if(stack == null) return null; if (stack == null) return null;
return new Item((short) stack.getTypeId(), (byte) stack.getAmount(), stack.getDurability(), null); return new Item((short) stack.getTypeId(), (byte) stack.getAmount(), stack.getDurability(), null);
} }
} }

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion2.api.metadata; package us.myles.ViaVersion.api.minecraft.metadata;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter

Datei anzeigen

@ -1,14 +1,14 @@
package us.myles.ViaVersion2.api.protocol; package us.myles.ViaVersion.api.protocol;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import us.myles.ViaVersion.CancelException; import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.util.Pair;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

Datei anzeigen

@ -1,11 +1,11 @@
package us.myles.ViaVersion2.api.protocol; package us.myles.ViaVersion.api.protocol;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.BaseProtocol;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion2.api.PacketWrapper;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.base.BaseProtocol;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

Datei anzeigen

@ -1,21 +1,20 @@
package us.myles.ViaVersion2.api.protocol; package us.myles.ViaVersion.api.protocol;
import us.myles.ViaVersion2.api.protocol1_9_1to1_9.Protocol1_9_1TO1_9; import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.util.Pair; import us.myles.ViaVersion.api.Pair;
import java.util.*; import java.util.*;
public class ProtocolRegistry { public class ProtocolRegistry {
public static int SERVER_PROTOCOL = -1;
// Input Version -> Output Version & Protocol (Allows fast lookup) // Input Version -> Output Version & Protocol (Allows fast lookup)
private static Map<Integer, Map<Integer, Protocol>> registryMap = new HashMap<>(); private static Map<Integer, Map<Integer, Protocol>> registryMap = new HashMap<>();
public static int SERVER_PROTOCOL = -1;
static { static {
// Register built in protocols // Register built in protocols
registerProtocol(new Protocol1_9TO1_8(), Arrays.asList(ProtocolVersion.V1_9), ProtocolVersion.V1_8); registerProtocol(new Protocol1_9TO1_8(), Collections.singletonList(ProtocolVersion.V1_9), ProtocolVersion.V1_8);
registerProtocol(new Protocol1_9_1TO1_9(), Arrays.asList(ProtocolVersion.V1_9_1_PRE2), ProtocolVersion.V1_9); registerProtocol(new Protocol1_9_1TO1_9(), Collections.singletonList(ProtocolVersion.V1_9_1_PRE2), ProtocolVersion.V1_9);
} }
public static void registerProtocol(Protocol protocol, List<Integer> supported, Integer output) { public static void registerProtocol(Protocol protocol, List<Integer> supported, Integer output) {

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.protocol; package us.myles.ViaVersion.api.protocol;
public class ProtocolVersion { public class ProtocolVersion {
/* Defined protocol constants */ /* Defined protocol constants */

Datei anzeigen

@ -1,6 +1,6 @@
package us.myles.ViaVersion2.api.remapper; package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
public abstract class PacketHandler implements ValueWriter { public abstract class PacketHandler implements ValueWriter {
public abstract void handle(PacketWrapper wrapper) throws Exception; public abstract void handle(PacketWrapper wrapper) throws Exception;

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.remapper; package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.util.Pair; import us.myles.ViaVersion.api.Pair;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -41,7 +41,7 @@ public abstract class PacketRemapper {
public abstract void registerMap(); public abstract void registerMap();
public void remap(PacketWrapper packetWrapper) throws Exception{ public void remap(PacketWrapper packetWrapper) throws Exception {
// Read all the current values // Read all the current values
for (Pair<ValueReader, ValueWriter> valueRemapper : valueRemappers) { for (Pair<ValueReader, ValueWriter> valueRemapper : valueRemappers) {
Object object = valueRemapper.getKey().read(packetWrapper); Object object = valueRemapper.getKey().read(packetWrapper);

Datei anzeigen

@ -1,7 +1,7 @@
package us.myles.ViaVersion2.api.remapper; package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
public class TypeRemapper<T> implements ValueReader<T>, ValueWriter<T> { public class TypeRemapper<T> implements ValueReader<T>, ValueWriter<T> {
private final Type<T> type; private final Type<T> type;

Datei anzeigen

@ -1,6 +1,6 @@
package us.myles.ViaVersion2.api.remapper; package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
public abstract class ValueCreator implements ValueWriter { public abstract class ValueCreator implements ValueWriter {
public abstract void write(PacketWrapper wrapper) throws Exception; public abstract void write(PacketWrapper wrapper) throws Exception;

Datei anzeigen

@ -0,0 +1,7 @@
package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion.api.PacketWrapper;
public interface ValueReader<T> {
T read(PacketWrapper wrapper) throws Exception;
}

Datei anzeigen

@ -1,7 +1,7 @@
package us.myles.ViaVersion2.api.remapper; package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> { public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> {
private final Type<T2> outputType; private final Type<T2> outputType;

Datei anzeigen

@ -0,0 +1,7 @@
package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion.api.PacketWrapper;
public interface ValueWriter<T> {
void write(PacketWrapper writer, T inputValue) throws Exception;
}

Datei anzeigen

@ -0,0 +1,7 @@
package us.myles.ViaVersion.api.type;
import io.netty.buffer.ByteBuf;
public interface ByteBufReader<T> {
T read(ByteBuf buffer) throws Exception;
}

Datei anzeigen

@ -0,0 +1,7 @@
package us.myles.ViaVersion.api.type;
import io.netty.buffer.ByteBuf;
public interface ByteBufWriter<T> {
void write(ByteBuf buffer, T object) throws Exception;
}

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.type; package us.myles.ViaVersion.api.type;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -10,17 +10,17 @@ public abstract class PartialType<T, X> extends Type<T> {
this.param = param; this.param = param;
} }
public abstract T read(ByteBuf buffer, X param); public abstract T read(ByteBuf buffer, X param) throws Exception;
public abstract void write(ByteBuf buffer, X param, T object); public abstract void write(ByteBuf buffer, X param, T object) throws Exception;
@Override @Override
public T read(ByteBuf buffer) { public T read(ByteBuf buffer) throws Exception {
return read(buffer, this.param); return read(buffer, this.param);
} }
@Override @Override
public void write(ByteBuf buffer, T object) { public void write(ByteBuf buffer, T object) throws Exception {
write(buffer, this.param, object); write(buffer, this.param, object);
} }
} }

Datei anzeigen

@ -1,14 +1,14 @@
package us.myles.ViaVersion2.api.type; package us.myles.ViaVersion.api.type;
import lombok.Getter; import lombok.Getter;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion2.api.type.types.*; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion2.api.type.types.minecraft.*; import us.myles.ViaVersion.api.type.types.*;
import us.myles.ViaVersion2.api.util.Position; import us.myles.ViaVersion.api.type.types.minecraft.*;
import java.util.UUID; import java.util.UUID;

Datei anzeigen

@ -0,0 +1,5 @@
package us.myles.ViaVersion.api.type;
public interface TypeConverter<T> {
T from(Object o);
}

Datei anzeigen

@ -1,7 +1,7 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import java.lang.reflect.Array; import java.lang.reflect.Array;
@ -13,25 +13,6 @@ public class ArrayType<T> extends Type<T[]> {
this.elementType = type; this.elementType = type;
} }
@Override
public T[] read(ByteBuf buffer) throws Exception{
int amount = Type.VAR_INT.read(buffer);
T[] array = (T[]) Array.newInstance(elementType.getOutputClass(), amount);
for (int i = 0; i < amount; i++) {
array[i] = elementType.read(buffer);
}
return array;
}
@Override
public void write(ByteBuf buffer, T[] object) throws Exception{
Type.VAR_INT.write(buffer, object.length);
for (T o : object) {
elementType.write(buffer, o);
}
}
/* Taken from http://stackoverflow.com/questions/4901128/obtaining-the-array-class-of-a-component-type */ /* Taken from http://stackoverflow.com/questions/4901128/obtaining-the-array-class-of-a-component-type */
public static Class<?> getArrayClass(Class<?> componentType) { public static Class<?> getArrayClass(Class<?> componentType) {
ClassLoader classLoader = componentType.getClassLoader(); ClassLoader classLoader = componentType.getClassLoader();
@ -65,4 +46,23 @@ public class ArrayType<T> extends Type<T[]> {
return null; // oh return null; // oh
} }
} }
@Override
public T[] read(ByteBuf buffer) throws Exception {
int amount = Type.VAR_INT.read(buffer);
T[] array = (T[]) Array.newInstance(elementType.getOutputClass(), amount);
for (int i = 0; i < amount; i++) {
array[i] = elementType.read(buffer);
}
return array;
}
@Override
public void write(ByteBuf buffer, T[] object) throws Exception {
Type.VAR_INT.write(buffer, object.length);
for (T o : object) {
elementType.write(buffer, o);
}
}
} }

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class BooleanType extends Type<Boolean> implements TypeConverter<Boolean>{ public class BooleanType extends Type<Boolean> implements TypeConverter<Boolean> {
public BooleanType() { public BooleanType() {
super(Boolean.class); super(Boolean.class);
} }

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class ByteType extends Type<Byte> implements TypeConverter<Byte> { public class ByteType extends Type<Byte> implements TypeConverter<Byte> {
public ByteType() { public ByteType() {
@ -25,8 +25,8 @@ public class ByteType extends Type<Byte> implements TypeConverter<Byte> {
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).byteValue(); return ((Number) o).byteValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? (byte) 1 : 0; return (Boolean) o ? (byte) 1 : 0;
} }
return (Byte) o; return (Byte) o;
} }

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class DoubleType extends Type<Double> implements TypeConverter<Double>{ public class DoubleType extends Type<Double> implements TypeConverter<Double> {
public DoubleType() { public DoubleType() {
super(Double.class); super(Double.class);
} }
@ -24,8 +24,8 @@ public class DoubleType extends Type<Double> implements TypeConverter<Double>{
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).doubleValue(); return ((Number) o).doubleValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? 1D : 0D; return (Boolean) o ? (byte) 1D : 0D;
} }
return (Double) o; return (Double) o;
} }

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class FloatType extends Type<Float> implements TypeConverter<Float>{ public class FloatType extends Type<Float> implements TypeConverter<Float> {
public FloatType() { public FloatType() {
super(Float.class); super(Float.class);
} }
@ -25,8 +25,8 @@ public class FloatType extends Type<Float> implements TypeConverter<Float>{
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).floatValue(); return ((Number) o).floatValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? 1F : 0; return ((Boolean) o) ? 1F : 0;
} }
return (Float) o; return (Float) o;
} }

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class IntType extends Type<Integer> implements TypeConverter<Integer>{ public class IntType extends Type<Integer> implements TypeConverter<Integer> {
public IntType() { public IntType() {
super(Integer.class); super(Integer.class);
} }
@ -24,8 +24,8 @@ public class IntType extends Type<Integer> implements TypeConverter<Integer>{
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).intValue(); return ((Number) o).intValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? 1 : 0; return ((Boolean) o) ? 1 : 0;
} }
return (Integer) o; return (Integer) o;
} }

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class LongType extends Type<Long> implements TypeConverter<Long> { public class LongType extends Type<Long> implements TypeConverter<Long> {
public LongType() { public LongType() {
@ -25,8 +25,8 @@ public class LongType extends Type<Long> implements TypeConverter<Long> {
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).longValue(); return ((Number) o).longValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? 1L : 0; return ((Boolean) o) ? 1L : 0;
} }
return (Long) o; return (Long) o;
} }

Datei anzeigen

@ -1,7 +1,7 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
public class RemainingBytesType extends Type<byte[]> { public class RemainingBytesType extends Type<byte[]> {
public RemainingBytesType() { public RemainingBytesType() {

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class ShortType extends Type<Short> implements TypeConverter<Short> { public class ShortType extends Type<Short> implements TypeConverter<Short> {
public ShortType() { public ShortType() {
@ -24,8 +24,8 @@ public class ShortType extends Type<Short> implements TypeConverter<Short> {
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).shortValue(); return ((Number) o).shortValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? (short) 1 : 0; return ((Boolean) o) ? (short) 1 : 0;
} }
return (short) o; return (short) o;
} }

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
public class StringType extends Type<String> { public class StringType extends Type<String> {
public StringType() { public StringType() {

Datei anzeigen

@ -1,7 +1,7 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import java.util.UUID; import java.util.UUID;

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class UnsignedByteType extends Type<Short> implements TypeConverter<Short> { public class UnsignedByteType extends Type<Short> implements TypeConverter<Short> {
public UnsignedByteType() { public UnsignedByteType() {
@ -24,8 +24,8 @@ public class UnsignedByteType extends Type<Short> implements TypeConverter<Short
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).shortValue(); return ((Number) o).shortValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? (short) 1 : 0; return ((Boolean) o) ? (short) 1 : 0;
} }
return (short) o; return (short) o;
} }

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class UnsignedShortType extends Type<Integer> implements TypeConverter<Integer> { public class UnsignedShortType extends Type<Integer> implements TypeConverter<Integer> {
public UnsignedShortType() { public UnsignedShortType() {
@ -24,8 +24,8 @@ public class UnsignedShortType extends Type<Integer> implements TypeConverter<In
if (o instanceof Number) { if (o instanceof Number) {
return ((Number) o).intValue(); return ((Number) o).intValue();
} }
if(o instanceof Boolean){ if (o instanceof Boolean) {
return ((Boolean)o) == true ? 1 : 0; return ((Boolean) o) ? 1 : 0;
} }
return (Integer) o; return (Integer) o;
} }

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class VarIntType extends Type<Integer> implements TypeConverter<Integer> { public class VarIntType extends Type<Integer> implements TypeConverter<Integer> {
@ -58,7 +58,7 @@ public class VarIntType extends Type<Integer> implements TypeConverter<Integer>
return ((Number) o).intValue(); return ((Number) o).intValue();
} }
if (o instanceof Boolean) { if (o instanceof Boolean) {
return ((Boolean) o) == true ? 1 : 0; return ((Boolean) o) ? 1 : 0;
} }
return (Integer) o; return (Integer) o;
} }

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion2.api.type.types; package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class VoidType extends Type<Void> implements TypeConverter<Void>{ public class VoidType extends Type<Void> implements TypeConverter<Void> {
public VoidType() { public VoidType() {
super(Void.class); super(Void.class);
} }

Datei anzeigen

@ -1,9 +1,8 @@
package us.myles.ViaVersion2.api.type.types.minecraft; package us.myles.ViaVersion.api.type.types.minecraft;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.Type;
public class EulerAngleType extends Type<EulerAngle> { public class EulerAngleType extends Type<EulerAngle> {
public EulerAngleType() { public EulerAngleType() {

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types.minecraft; package us.myles.ViaVersion.api.type.types.minecraft;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
public class ItemArrayType extends Type<Item[]> { public class ItemArrayType extends Type<Item[]> {

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types.minecraft; package us.myles.ViaVersion.api.type.types.minecraft;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
public class ItemType extends Type<Item> { public class ItemType extends Type<Item> {
public ItemType() { public ItemType() {

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.type.types.minecraft; package us.myles.ViaVersion.api.type.types.minecraft;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -6,7 +6,7 @@ import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.ByteBufOutputStream;
import org.spacehq.opennbt.NBTIO; import org.spacehq.opennbt.NBTIO;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -27,11 +27,8 @@ public class NBTType extends Type<CompoundTag> {
} else { } else {
buffer.readerIndex(readerIndex); buffer.readerIndex(readerIndex);
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer); ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer);
DataInputStream dataInputStream = new DataInputStream(bytebufStream); try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) {
try {
return (CompoundTag) NBTIO.readTag(dataInputStream); return (CompoundTag) NBTIO.readTag(dataInputStream);
} finally {
dataInputStream.close();
} }
} }
} }

Datei anzeigen

@ -1,7 +1,7 @@
package us.myles.ViaVersion2.api.type.types.minecraft; package us.myles.ViaVersion.api.type.types.minecraft;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import java.util.UUID; import java.util.UUID;
@ -13,16 +13,15 @@ public class OptUUIDType extends Type<UUID> {
@Override @Override
public UUID read(ByteBuf buffer) { public UUID read(ByteBuf buffer) {
boolean present = buffer.readBoolean(); boolean present = buffer.readBoolean();
if(!present) return null; if (!present) return null;
return new UUID(buffer.readLong(), buffer.readLong()); return new UUID(buffer.readLong(), buffer.readLong());
} }
@Override @Override
public void write(ByteBuf buffer, UUID object) { public void write(ByteBuf buffer, UUID object) {
if(object == null){ if (object == null) {
buffer.writeBoolean(false); buffer.writeBoolean(false);
return; } else {
}else{
buffer.writeBoolean(true); buffer.writeBoolean(true);
buffer.writeLong(object.getMostSignificantBits()); buffer.writeLong(object.getMostSignificantBits());
buffer.writeLong(object.getLeastSignificantBits()); buffer.writeLong(object.getLeastSignificantBits());

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types.minecraft; package us.myles.ViaVersion.api.type.types.minecraft;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion2.api.util.Position; import us.myles.ViaVersion.api.type.Type;
public class PositionType extends Type<Position> { public class PositionType extends Type<Position> {
public PositionType() { public PositionType() {

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.type.types.minecraft; package us.myles.ViaVersion.api.type.types.minecraft;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
public class VectorType extends Type<Vector> { public class VectorType extends Type<Vector> {
public VectorType() { public VectorType() {

Datei anzeigen

@ -11,9 +11,9 @@ import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor; import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossFlag; import us.myles.ViaVersion.api.boss.BossFlag;
import us.myles.ViaVersion.api.boss.BossStyle; import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.PacketType; import us.myles.ViaVersion.packets.PacketType;
import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.*; import java.util.*;
@ -152,36 +152,41 @@ public class ViaBossBar implements BossBar {
} }
private ByteBuf getPacket(UpdateAction action) { private ByteBuf getPacket(UpdateAction action) {
ByteBuf buf = Unpooled.buffer(); try {
PacketUtil.writeVarInt(PacketType.PLAY_BOSS_BAR.getNewPacketID(), buf); ByteBuf buf = Unpooled.buffer();
PacketUtil.writeUUID(uuid, buf); Type.VAR_INT.write(buf, 0x0C); // Boss bar packet
PacketUtil.writeVarInt(action.getId(), buf); Type.UUID.write(buf, uuid);
switch (action) { Type.VAR_INT.write(buf, action.getId());
case ADD: switch (action) {
PacketUtil.writeString(fixJson(title), buf); case ADD:
buf.writeFloat(health); Type.STRING.write(buf, fixJson(title));
PacketUtil.writeVarInt(color.getId(), buf); buf.writeFloat(health);
PacketUtil.writeVarInt(style.getId(), buf); Type.VAR_INT.write(buf, color.getId());
buf.writeByte(flagToBytes()); Type.VAR_INT.write(buf, style.getId());
break; buf.writeByte(flagToBytes());
case REMOVE: break;
break; case REMOVE:
case UPDATE_HEALTH: break;
buf.writeFloat(health); case UPDATE_HEALTH:
break; buf.writeFloat(health);
case UPDATE_TITLE: break;
PacketUtil.writeString(fixJson(title), buf); case UPDATE_TITLE:
break; Type.STRING.write(buf, fixJson(title));
case UPDATE_STYLE: break;
PacketUtil.writeVarInt(color.getId(), buf); case UPDATE_STYLE:
PacketUtil.writeVarInt(style.getId(), buf); Type.VAR_INT.write(buf, color.getId());
break; Type.VAR_INT.write(buf, style.getId());
case UPDATE_FLAGS: break;
buf.writeByte(flagToBytes()); case UPDATE_FLAGS:
break; buf.writeByte(flagToBytes());
} break;
}
return buf; return buf;
} catch (Exception e) {
e.printStackTrace();
}
return null;
} }
private int flagToBytes() { private int flagToBytes() {

Datei anzeigen

@ -12,9 +12,6 @@ import us.myles.ViaVersion.api.ViaVersion;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* Created by fillefilip8 on 2016-03-03.
*/
@RequiredArgsConstructor @RequiredArgsConstructor
public class ViaVersionCommand implements CommandExecutor { public class ViaVersionCommand implements CommandExecutor {
@ -62,7 +59,7 @@ public class ViaVersionCommand implements CommandExecutor {
return false; return false;
} }
public void sendHelp(CommandSender sender){ public void sendHelp(CommandSender sender) {
sender.sendMessage(color("&aViaVersion &c" + ViaVersion.getInstance().getVersion())); sender.sendMessage(color("&aViaVersion &c" + ViaVersion.getInstance().getVersion()));
sender.sendMessage(color("&6Commands:")); sender.sendMessage(color("&6Commands:"));
sender.sendMessage(color("&2/viaversion list &7- &6Shows lists of all 1.9 clients and 1.8 clients.")); sender.sendMessage(color("&2/viaversion list &7- &6Shows lists of all 1.9 clients and 1.8 clients."));

Datei anzeigen

@ -3,8 +3,8 @@ package us.myles.ViaVersion.handlers;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder; import io.netty.handler.codec.MessageToMessageEncoder;
import us.myles.ViaVersion2.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.ClientChunks; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import java.util.List; import java.util.List;
@ -23,7 +23,7 @@ public class ViaChunkHandler extends MessageToMessageEncoder {
if (!(o instanceof ByteBuf)) { if (!(o instanceof ByteBuf)) {
info.setLastPacket(o); info.setLastPacket(o);
/* This transformer is more for fixing issues which we find hard at packet level :) */ /* This transformer is more for fixing issues which we find hard at packet level :) */
if(o.getClass().getName().endsWith("PacketPlayOutMapChunkBulk") && info.isActive()) { if (o.getClass().getName().endsWith("PacketPlayOutMapChunkBulk") && info.isActive()) {
list.addAll(info.get(ClientChunks.class).transformMapChunkBulk(o)); list.addAll(info.get(ClientChunks.class).transformMapChunkBulk(o));
return; return;
} }

Datei anzeigen

@ -4,11 +4,12 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
import us.myles.ViaVersion.CancelException; import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.util.PipelineUtil;
import us.myles.ViaVersion2.api.PacketWrapper;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
@ -28,7 +29,7 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
// use transformers // use transformers
if (bytebuf.readableBytes() > 0) { if (bytebuf.readableBytes() > 0) {
if (info.isActive()) { if (info.isActive()) {
int id = PacketUtil.readVarInt(bytebuf); int id = Type.VAR_INT.read(bytebuf);
// Transform // Transform
try { try {
@ -47,7 +48,7 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
} }
// call minecraft decoder // call minecraft decoder
try { try {
list.addAll(PacketUtil.callDecode(this.minecraftDecoder, ctx, bytebuf)); list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, bytebuf));
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof Exception) { if (e.getCause() instanceof Exception) {
throw (Exception) e.getCause(); throw (Exception) e.getCause();
@ -58,7 +59,7 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (PacketUtil.containsCause(cause, CancelException.class)) return; if (PipelineUtil.containsCause(cause, CancelException.class)) return;
super.exceptionCaught(ctx, cause); super.exceptionCaught(ctx, cause);
} }
} }

Datei anzeigen

@ -4,11 +4,12 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.CancelException; import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.util.PipelineUtil;
import us.myles.ViaVersion2.api.PacketWrapper;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -28,7 +29,7 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
if (!(o instanceof ByteBuf)) { if (!(o instanceof ByteBuf)) {
// call minecraft encoder // call minecraft encoder
try { try {
PacketUtil.callEncode(this.minecraftEncoder, ctx, o, bytebuf); PipelineUtil.callEncode(this.minecraftEncoder, ctx, o, bytebuf);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof Exception) { if (e.getCause() instanceof Exception) {
throw (Exception) e.getCause(); throw (Exception) e.getCause();
@ -39,7 +40,7 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
throw new CancelException(); throw new CancelException();
} }
if (info.isActive()) { if (info.isActive()) {
int id = PacketUtil.readVarInt(bytebuf); int id = Type.VAR_INT.read(bytebuf);
// Transform // Transform
ByteBuf oldPacket = bytebuf.copy(); ByteBuf oldPacket = bytebuf.copy();
bytebuf.clear(); bytebuf.clear();
@ -59,7 +60,7 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (PacketUtil.containsCause(cause, CancelException.class)) return; if (PipelineUtil.containsCause(cause, CancelException.class)) return;
super.exceptionCaught(ctx, cause); super.exceptionCaught(ctx, cause);
} }
} }

Datei anzeigen

@ -5,8 +5,8 @@ import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion2.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.ProtocolPipeline; import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import java.lang.reflect.Method; import java.lang.reflect.Method;

Datei anzeigen

@ -2,9 +2,7 @@ package us.myles.ViaVersion.packets;
import java.util.HashMap; import java.util.HashMap;
import com.google.common.collect.HashBasedTable; @Deprecated
import com.google.common.collect.Table;
public enum PacketType { public enum PacketType {
/* Handshake serverbound */ /* Handshake serverbound */
HANDSHAKE(State.HANDSHAKE, Direction.INCOMING, 0x00), // Mapped HANDSHAKE(State.HANDSHAKE, Direction.INCOMING, 0x00), // Mapped
@ -138,9 +136,19 @@ public enum PacketType {
PLAY_ENTITY_PROPERTIES(State.PLAY, Direction.OUTGOING, 0x20, 0x4B), // Mapped PLAY_ENTITY_PROPERTIES(State.PLAY, Direction.OUTGOING, 0x20, 0x4B), // Mapped
PLAY_ENTITY_EFFECT(State.PLAY, Direction.OUTGOING, 0x1D, 0x4C), // Mapped PLAY_ENTITY_EFFECT(State.PLAY, Direction.OUTGOING, 0x1D, 0x4C), // Mapped
PLAY_MAP_CHUNK_BULK(State.PLAY, Direction.OUTGOING, 0x26, -1), // TODO? PLAY_MAP_CHUNK_BULK(State.PLAY, Direction.OUTGOING, 0x26, -1),
PLAY_SET_COMPRESSION(State.PLAY, Direction.OUTGOING, 0x46, -1), // TODO? PLAY_SET_COMPRESSION(State.PLAY, Direction.OUTGOING, 0x46, -1),
PLAY_UPDATE_ENTITY_NBT(State.PLAY, Direction.OUTGOING, 0x49, -1),; // TODO? PLAY_UPDATE_ENTITY_NBT(State.PLAY, Direction.OUTGOING, 0x49, -1);
private static HashMap<Short, PacketType> oldids = new HashMap<>();
private static HashMap<Short, PacketType> newids = new HashMap<>();
static {
for (PacketType pt : PacketType.values()) {
oldids.put(toShort((short) pt.getPacketID(), (short) pt.getDirection().ordinal(), (short) pt.getState().ordinal()), pt);
newids.put(toShort((short) pt.getNewPacketID(), (short) pt.getDirection().ordinal(), (short) pt.getState().ordinal()), pt);
}
}
private State state; private State state;
private Direction direction; private Direction direction;
@ -161,6 +169,26 @@ public enum PacketType {
this.newPacketID = newPacketID; this.newPacketID = newPacketID;
} }
public static PacketType findNewPacket(State state, Direction direction, int id) {
return newids.get(toShort((short) id, (short) direction.ordinal(), (short) state.ordinal()));
}
public static PacketType findOldPacket(State state, Direction direction, int id) {
return oldids.get(toShort((short) id, (short) direction.ordinal(), (short) state.ordinal()));
}
public static PacketType getIncomingPacket(State state, int id) {
return findNewPacket(state, Direction.INCOMING, id);
}
public static PacketType getOutgoingPacket(State state, int id) {
return findOldPacket(state, Direction.OUTGOING, id);
}
private static short toShort(short id, short direction, short state) {
return (short) ((id & 0x00FF) | (direction << 8) & 0x0F00 | (state << 12) & 0xF000);
}
public State getState() { public State getState() {
return state; return state;
} }
@ -177,33 +205,4 @@ public enum PacketType {
return newPacketID; return newPacketID;
} }
public static PacketType findNewPacket(State state, Direction direction, int id) {
return newids.get(toShort((short) id, (short)direction.ordinal(), (short) state.ordinal()));
}
public static PacketType findOldPacket(State state, Direction direction, int id) {
return oldids.get(toShort((short) id, (short)direction.ordinal(), (short) state.ordinal()));
}
public static PacketType getIncomingPacket(State state, int id) {
return findNewPacket(state, Direction.INCOMING, id);
}
public static PacketType getOutgoingPacket(State state, int id) {
return findOldPacket(state, Direction.OUTGOING, id);
}
private static short toShort(short id, short direction, short state) {
return (short) ((id & 0x00FF) | (direction<<8) & 0x0F00 | (state << 12) & 0xF000);
}
private static HashMap<Short, PacketType> oldids = new HashMap<Short, PacketType>();
private static HashMap<Short, PacketType> newids = new HashMap<Short, PacketType>();
static {
for(PacketType pt : PacketType.values()) {
oldids.put(toShort((short) pt.getPacketID(), (short)pt.getDirection().ordinal(), (short)pt.getState().ordinal()), pt);
newids.put(toShort((short) pt.getNewPacketID(), (short)pt.getDirection().ordinal(), (short)pt.getState().ordinal()), pt);
}
}
} }

Datei anzeigen

@ -1,20 +1,20 @@
package us.myles.ViaVersion2.api.protocol.base; package us.myles.ViaVersion.protocols.base;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException; import org.json.simple.parser.ParseException;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
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.packets.State;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.Protocol;
import us.myles.ViaVersion2.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion2.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion2.api.remapper.PacketHandler;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.type.Type;
import us.myles.ViaVersion2.api.util.Pair;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;

Datei anzeigen

@ -1,17 +1,17 @@
package us.myles.ViaVersion2.api.protocol.base; package us.myles.ViaVersion.protocols.base;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion2.api.data.StoredObject;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.ProtocolPipeline;
import java.util.UUID; import java.util.UUID;
@Getter @Getter
@Setter @Setter
public class ProtocolInfo extends StoredObject{ public class ProtocolInfo extends StoredObject {
private State state = State.HANDSHAKE; private State state = State.HANDSHAKE;
private int protocolVersion = -1; private int protocolVersion = -1;
private String username; private String username;

Datei anzeigen

@ -1,12 +1,12 @@
package us.myles.ViaVersion2.api.protocol1_9_1to1_9; package us.myles.ViaVersion.protocols.protocol1_9_1to1_9;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion2.api.data.UserConnection;
import us.myles.ViaVersion2.api.protocol.Protocol;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.type.Type;
public class Protocol1_9_1TO1_9 extends Protocol{ public class Protocol1_9_1TO1_9 extends Protocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Currently supports 1.9.1 PRE 2 // Currently supports 1.9.1 PRE 2

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.armor; package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -36,8 +36,8 @@ public enum ArmorType {
private final Material type; private final Material type;
public static ArmorType findByType(Material type) { public static ArmorType findByType(Material type) {
for(ArmorType a : ArmorType.values()) for (ArmorType a : ArmorType.values())
if(a.getType() == type) if (a.getType() == type)
return a; return a;
return ArmorType.NONE; return ArmorType.NONE;
} }
@ -52,15 +52,15 @@ public enum ArmorType {
} }
public static ArmorType findById(int id) { public static ArmorType findById(int id) {
for(ArmorType a : ArmorType.values()) for (ArmorType a : ArmorType.values())
if(a.getId() == id) if (a.getId() == id)
return a; return a;
return ArmorType.NONE; return ArmorType.NONE;
} }
public static boolean isArmor(Material material){ public static boolean isArmor(Material material) {
for(ArmorType a : ArmorType.values()) for (ArmorType a : ArmorType.values())
if(a.getType() == material) if (a.getType() == material)
return true; return true;
return false; return false;
} }

Datei anzeigen

@ -1,11 +1,11 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8; package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import org.bukkit.Material; import org.bukkit.Material;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.ListTag; import org.spacehq.opennbt.tag.builtin.ListTag;
import org.spacehq.opennbt.tag.builtin.StringTag; import org.spacehq.opennbt.tag.builtin.StringTag;
import org.spacehq.opennbt.tag.builtin.Tag; import org.spacehq.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8; package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.MovementTracker; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion2.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.remapper.PacketRemapper; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
public class PlayerMovementMapper extends PacketRemapper { public class PlayerMovementMapper extends PacketRemapper {
@Override @Override

Datei anzeigen

@ -1,27 +1,25 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8; package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.json.simple.JSONObject; import us.myles.ViaVersion.api.PacketWrapper;
import org.json.simple.parser.JSONParser;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion2.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion2.api.metadata.Metadata; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion2.api.protocol.Protocol; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion2.api.protocol1_9to1_8.packets.*; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.ClientChunks; import us.myles.ViaVersion.protocols.protocol1_9to1_8.packets.*;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.InventoryTracker; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.MovementTracker; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.InventoryTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.types.MetadataListType; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.types.MetadataType; import us.myles.ViaVersion.protocols.protocol1_9to1_8.types.MetadataListType;
import us.myles.ViaVersion2.api.remapper.ValueTransformer; import us.myles.ViaVersion.protocols.protocol1_9to1_8.types.MetadataType;
import us.myles.ViaVersion2.api.type.Type;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -29,11 +27,9 @@ import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class Protocol1_9TO1_8 extends Protocol { public class Protocol1_9TO1_8 extends Protocol {
private static Gson gson = new GsonBuilder().create();
public static Type<List<Metadata>> METADATA_LIST = new MetadataListType(); public static Type<List<Metadata>> METADATA_LIST = new MetadataListType();
public static Type<Metadata> METADATA = new MetadataType(); public static Type<Metadata> METADATA = new MetadataType();
private static Gson gson = new GsonBuilder().create();
public static ValueTransformer<String, String> FIX_JSON = new ValueTransformer<String, String>(Type.STRING) { public static ValueTransformer<String, String> FIX_JSON = new ValueTransformer<String, String>(Type.STRING) {
@Override @Override
public String transform(PacketWrapper wrapper, String line) { public String transform(PacketWrapper wrapper, String line) {
@ -41,27 +37,6 @@ public class Protocol1_9TO1_8 extends Protocol {
} }
}; };
@Override
protected void registerPackets() {
SpawnPackets.register(this);
InventoryPackets.register(this);
EntityPackets.register(this);
PlayerPackets.register(this);
WorldPackets.register(this);
}
@Override
public void init(UserConnection userConnection) {
// Entity tracker
userConnection.put(new EntityTracker(userConnection));
// Chunk tracker
userConnection.put(new ClientChunks(userConnection));
// Movement tracker
userConnection.put(new MovementTracker(userConnection));
// Inventory tracker
userConnection.put(new InventoryTracker(userConnection));
}
public static String fixJson(String line) { public static String fixJson(String line) {
if (line == null || line.equalsIgnoreCase("null")) { if (line == null || line.equalsIgnoreCase("null")) {
line = "{\"text\":\"\"}"; line = "{\"text\":\"\"}";
@ -103,4 +78,25 @@ public class Protocol1_9TO1_8 extends Protocol {
return null; return null;
} }
} }
@Override
protected void registerPackets() {
SpawnPackets.register(this);
InventoryPackets.register(this);
EntityPackets.register(this);
PlayerPackets.register(this);
WorldPackets.register(this);
}
@Override
public void init(UserConnection userConnection) {
// Entity tracker
userConnection.put(new EntityTracker(userConnection));
// Chunk tracker
userConnection.put(new ClientChunks(userConnection));
// Movement tracker
userConnection.put(new MovementTracker(userConnection));
// Inventory tracker
userConnection.put(new InventoryTracker(userConnection));
}
} }

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.armor; package us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@ -18,12 +18,15 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.CraftingInventory;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.packets.PacketType; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ArmorType;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.UUID; import java.util.UUID;
import static us.myles.ViaVersion.util.PacketUtil.*;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ArmorListener implements Listener { public class ArmorListener implements Listener {
@ -31,20 +34,27 @@ public class ArmorListener implements Listener {
private final ViaVersionPlugin plugin; private final ViaVersionPlugin plugin;
public static void sendArmorUpdate(Player player) { public static void sendArmorUpdate(Player player) {
// Ensure that the player is on our pipe
UserConnection userConnection = ((ViaVersionPlugin)ViaVersion.getInstance()).getConnection(player);
if(userConnection == null) return;
if(!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
int armor = ArmorType.calculateArmorPoints(player.getInventory().getArmorContents()); int armor = ArmorType.calculateArmorPoints(player.getInventory().getArmorContents());
try {
ByteBuf buf = Unpooled.buffer();
Type.VAR_INT.write(buf, 0x4B); // Entity Properties
Type.VAR_INT.write(buf, player.getEntityId());
buf.writeInt(1); // only 1 property
Type.STRING.write(buf, "generic.armor");
buf.writeDouble(0); //default 0 armor
Type.VAR_INT.write(buf, 1); // 1 modifier
Type.UUID.write(buf, ARMOR_ATTRIBUTE); // armor modifier uuid
buf.writeDouble((double) armor); // the modifier value
buf.writeByte(0); // the modifier operation, 0 is add number
ByteBuf buf = Unpooled.buffer(); ViaVersion.getInstance().sendRawPacket(player, buf);
writeVarInt(PacketType.PLAY_ENTITY_PROPERTIES.getNewPacketID(), buf); } catch (Exception ignored) {
writeVarInt(player.getEntityId(), buf); }
buf.writeInt(1); // only 1 property
writeString("generic.armor", buf);
buf.writeDouble(0); //default 0 armor
writeVarInt(1, buf); // 1 modifier
writeUUID(ARMOR_ATTRIBUTE, buf); // armor modifier uuid
buf.writeDouble((double) armor); // the modifier value
buf.writeByte(0); // the modifier operation, 0 is add number
ViaVersion.getInstance().sendRawPacket(player, buf);
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.listeners; package us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.ByteBufOutputStream;
@ -19,8 +19,13 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.spacehq.opennbt.tag.builtin.ByteTag; import org.spacehq.opennbt.tag.builtin.ByteTag;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.packets.PacketType; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.util.ReflectionUtil; import us.myles.ViaVersion.util.ReflectionUtil;
import java.io.DataOutput; import java.io.DataOutput;
@ -55,6 +60,11 @@ public class CommandBlockListener implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onInteract(PlayerInteractEvent e) { public void onInteract(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && plugin.isPorted(e.getPlayer()) && e.getPlayer().isOp()) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK && plugin.isPorted(e.getPlayer()) && e.getPlayer().isOp()) {
// Ensure that the player is on our pipe
UserConnection userConnection = ((ViaVersionPlugin)ViaVersion.getInstance()).getConnection(e.getPlayer());
if(userConnection == null) return;
if(!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
try { try {
sendCommandBlockPacket(e.getClickedBlock(), e.getPlayer()); sendCommandBlockPacket(e.getClickedBlock(), e.getPlayer());
} catch (Exception ex) { } catch (Exception ex) {
@ -65,11 +75,19 @@ public class CommandBlockListener implements Listener {
private void sendOp(Player p) { private void sendOp(Player p) {
if (p.isOp() && plugin.isPorted(p)) { if (p.isOp() && plugin.isPorted(p)) {
ByteBuf buf = Unpooled.buffer(); // Ensure that the player is on our pipe
PacketUtil.writeVarInt(PacketType.PLAY_ENTITY_STATUS.getNewPacketID(), buf); UserConnection userConnection = ((ViaVersionPlugin) ViaVersion.getInstance()).getConnection(p);
buf.writeInt(p.getEntityId()); if(userConnection == null) return;
buf.writeByte(26); if(!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
plugin.sendRawPacket(p, buf);
try {
ByteBuf buf = Unpooled.buffer();
Type.VAR_INT.write(buf, 0x1B); // Entity Status
buf.writeInt(p.getEntityId());
buf.writeByte(26);
plugin.sendRawPacket(p, buf);
} catch (Exception ignored) {
}
} }
} }
@ -86,9 +104,9 @@ public class CommandBlockListener implements Listener {
private ByteBuf packetToByteBuf(Object updatePacket) throws Exception { private ByteBuf packetToByteBuf(Object updatePacket) throws Exception {
ByteBuf buf = Unpooled.buffer(); ByteBuf buf = Unpooled.buffer();
PacketUtil.writeVarInt(PacketType.PLAY_UPDATE_BLOCK_ENTITY.getNewPacketID(), buf); //Packet ID Type.VAR_INT.write(buf, 0x09); //Block Entity Packet ID
long[] pos = getPosition(ReflectionUtil.get(updatePacket, "a", ReflectionUtil.nms("BlockPosition"))); long[] pos = getPosition(ReflectionUtil.get(updatePacket, "a", ReflectionUtil.nms("BlockPosition")));
PacketUtil.writeBlockPosition(buf, pos[0], pos[1], pos[2]); //Block position Type.POSITION.write(buf, new Position(pos[0], pos[1], pos[2])); //Block position
buf.writeByte(2); //Action id always 2 buf.writeByte(2); //Action id always 2
CompoundTag nbt = getNBT(ReflectionUtil.get(updatePacket, "c", ReflectionUtil.nms("NBTTagCompound"))); CompoundTag nbt = getNBT(ReflectionUtil.get(updatePacket, "c", ReflectionUtil.nms("NBTTagCompound")));
if (nbt == null) { if (nbt == null) {
@ -98,7 +116,7 @@ public class CommandBlockListener implements Listener {
nbt.put(new ByteTag("powered", (byte) 0)); nbt.put(new ByteTag("powered", (byte) 0));
nbt.put(new ByteTag("auto", (byte) 0)); nbt.put(new ByteTag("auto", (byte) 0));
nbt.put(new ByteTag("conditionMet", (byte) 0)); nbt.put(new ByteTag("conditionMet", (byte) 0));
PacketUtil.writeNBT(buf, nbt); //NBT tag Type.NBT.write(buf, nbt); //NBT tag
return buf; return buf;
} }
@ -115,7 +133,7 @@ public class CommandBlockListener implements Listener {
Method m = ReflectionUtil.nms("NBTCompressedStreamTools").getMethod("a", ReflectionUtil.nms("NBTTagCompound"), DataOutput.class); Method m = ReflectionUtil.nms("NBTCompressedStreamTools").getMethod("a", ReflectionUtil.nms("NBTTagCompound"), DataOutput.class);
m.invoke(null, obj, new DataOutputStream(new ByteBufOutputStream(buf))); m.invoke(null, obj, new DataOutputStream(new ByteBufOutputStream(buf)));
try { try {
return PacketUtil.readNBT(buf); return Type.NBT.read(buf);
} finally { } finally {
buf.release(); buf.release();
} }

Datei anzeigen

@ -1,192 +1,192 @@
package us.myles.ViaVersion.metadata; package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
import lombok.Getter; import lombok.Getter;
import org.bukkit.entity.*; import org.bukkit.entity.*;
@Getter @Getter
public enum MetaIndex { public enum MetaIndex {
// entity // entity
ENTITY_STATUS(org.bukkit.entity.Entity.class, 0, Type.Byte, NewType.Byte), ENTITY_STATUS(org.bukkit.entity.Entity.class, 0, Type.Byte, NewType.Byte),
ENTITY_AIR(org.bukkit.entity.Entity.class, 1, Type.Short, NewType.VarInt), ENTITY_AIR(org.bukkit.entity.Entity.class, 1, Type.Short, NewType.VarInt),
ENTITY_SILENT(org.bukkit.entity.Entity.class, 4, Type.Byte, NewType.Boolean), ENTITY_SILENT(org.bukkit.entity.Entity.class, 4, Type.Byte, NewType.Boolean),
// living entity // living entity
LIVINGENTITY_NAMETAG(LivingEntity.class, 2, Type.String, NewType.String), LIVINGENTITY_NAMETAG(LivingEntity.class, 2, Type.String, NewType.String),
LIVINGENTITY_ALWAYS_SHOW_NAMETAG(LivingEntity.class, 3, Type.Byte, NewType.Boolean), LIVINGENTITY_ALWAYS_SHOW_NAMETAG(LivingEntity.class, 3, Type.Byte, NewType.Boolean),
LIVINGENTITY_HEALTH(LivingEntity.class, 6, Type.Float, NewType.Float), LIVINGENTITY_HEALTH(LivingEntity.class, 6, Type.Float, NewType.Float),
LIVINGENTITY_POTION_EFFECT_COLOR(LivingEntity.class, 7, Type.Int, NewType.VarInt), LIVINGENTITY_POTION_EFFECT_COLOR(LivingEntity.class, 7, Type.Int, NewType.VarInt),
LIVINGENTITY_IS_POTION_AMBIENT(LivingEntity.class, 8, Type.Byte, NewType.Boolean), LIVINGENTITY_IS_POTION_AMBIENT(LivingEntity.class, 8, Type.Byte, NewType.Boolean),
LIVINGENTITY_NUMBER_OF_ARROWS_IN(LivingEntity.class, 9, Type.Byte, NewType.VarInt), LIVINGENTITY_NUMBER_OF_ARROWS_IN(LivingEntity.class, 9, Type.Byte, NewType.VarInt),
LIVINGENTITY_NO_AI(LivingEntity.class, 15, Type.Byte, 10, NewType.Byte), // in 1.9 this is combined with Left handed, oh. LIVINGENTITY_NO_AI(LivingEntity.class, 15, Type.Byte, 10, NewType.Byte), // in 1.9 this is combined with Left handed, oh.
// ageable // ageable
AGEABLE_AGE(Ageable.class, 12, Type.Byte, 11, NewType.Boolean), AGEABLE_AGE(Ageable.class, 12, Type.Byte, 11, NewType.Boolean),
// armour stand // armour stand
STAND_INFO(ArmorStand.class, 10, Type.Byte, NewType.Byte), STAND_INFO(ArmorStand.class, 10, Type.Byte, NewType.Byte),
STAND_HEAD_POS(ArmorStand.class, 11, Type.Rotation, NewType.Vector3F), STAND_HEAD_POS(ArmorStand.class, 11, Type.Rotation, NewType.Vector3F),
STAND_BODY_POS(ArmorStand.class, 12, Type.Rotation, NewType.Vector3F), STAND_BODY_POS(ArmorStand.class, 12, Type.Rotation, NewType.Vector3F),
STAND_LA_POS(ArmorStand.class, 13, Type.Rotation, NewType.Vector3F), STAND_LA_POS(ArmorStand.class, 13, Type.Rotation, NewType.Vector3F),
STAND_RA_POS(ArmorStand.class, 14, Type.Rotation, NewType.Vector3F), STAND_RA_POS(ArmorStand.class, 14, Type.Rotation, NewType.Vector3F),
STAND_LL_POS(ArmorStand.class, 15, Type.Rotation, NewType.Vector3F), STAND_LL_POS(ArmorStand.class, 15, Type.Rotation, NewType.Vector3F),
STAND_RL_POS(ArmorStand.class, 16, Type.Rotation, NewType.Vector3F), STAND_RL_POS(ArmorStand.class, 16, Type.Rotation, NewType.Vector3F),
// human, discountined? // human, discountined?
PLAYER_SKIN_FLAGS(HumanEntity.class, 10, Type.Byte, 12, NewType.Byte), // unsigned on 1.8 PLAYER_SKIN_FLAGS(HumanEntity.class, 10, Type.Byte, 12, NewType.Byte), // unsigned on 1.8
PLAYER_HUMAN_BYTE(HumanEntity.class, 16, Type.Byte, NewType.Discontinued), // unused on 1.8 PLAYER_HUMAN_BYTE(HumanEntity.class, 16, Type.Byte, NewType.Discontinued), // unused on 1.8
PLAYER_ADDITIONAL_HEARTS(HumanEntity.class, 17, Type.Float, 10, NewType.Float), PLAYER_ADDITIONAL_HEARTS(HumanEntity.class, 17, Type.Float, 10, NewType.Float),
PLAYER_SCORE(HumanEntity.class, 18, Type.Int, 11, NewType.VarInt), PLAYER_SCORE(HumanEntity.class, 18, Type.Int, 11, NewType.VarInt),
PLAYER_HAND(HumanEntity.class, -1, Type.NonExistent, 5, NewType.Byte), // new in 1.9 PLAYER_HAND(HumanEntity.class, -1, Type.NonExistent, 5, NewType.Byte), // new in 1.9
SOMETHING_ANTICHEAT_PLUGINS_FOR_SOME_REASON_USE(HumanEntity.class, 11, Type.Byte, NewType.Discontinued), //For what we know, This doesn't exists. If you think it exists and knows what it does. Please tell us. SOMETHING_ANTICHEAT_PLUGINS_FOR_SOME_REASON_USE(HumanEntity.class, 11, Type.Byte, NewType.Discontinued), //For what we know, This doesn't exists. If you think it exists and knows what it does. Please tell us.
// horse // horse
HORSE_INFO(Horse.class, 16, Type.Int, 12, NewType.Byte), HORSE_INFO(Horse.class, 16, Type.Int, 12, NewType.Byte),
HORSE_TYPE(Horse.class, 19, Type.Byte, 13, NewType.VarInt), HORSE_TYPE(Horse.class, 19, Type.Byte, 13, NewType.VarInt),
HORSE_SUBTYPE(Horse.class, 20, Type.Int, 14, NewType.VarInt), HORSE_SUBTYPE(Horse.class, 20, Type.Int, 14, NewType.VarInt),
HORSE_OWNER(Horse.class, 21, Type.String, 15, NewType.OptUUID), HORSE_OWNER(Horse.class, 21, Type.String, 15, NewType.OptUUID),
HORSE_ARMOR(Horse.class, 22, Type.Int, 16, NewType.VarInt), HORSE_ARMOR(Horse.class, 22, Type.Int, 16, NewType.VarInt),
// bat // bat
BAT_ISHANGING(Bat.class, 16, Type.Byte, 11, NewType.Byte), BAT_ISHANGING(Bat.class, 16, Type.Byte, 11, NewType.Byte),
// tameable // tameable
TAMING_INFO(Tameable.class, 16, Type.Byte, 12, NewType.Byte), TAMING_INFO(Tameable.class, 16, Type.Byte, 12, NewType.Byte),
TAMING_OWNER(Tameable.class, 17, Type.String, 13, NewType.OptUUID), TAMING_OWNER(Tameable.class, 17, Type.String, 13, NewType.OptUUID),
// ocelot // ocelot
OCELOT_TYPE(Ocelot.class, 18, Type.Byte, 14, NewType.VarInt), OCELOT_TYPE(Ocelot.class, 18, Type.Byte, 14, NewType.VarInt),
// wolf // wolf
WOLF_HEALTH(Wolf.class, 18, Type.Float, 14, NewType.Float), WOLF_HEALTH(Wolf.class, 18, Type.Float, 14, NewType.Float),
WOLF_BEGGING(Wolf.class, 19, Type.Byte, 15, NewType.Boolean), WOLF_BEGGING(Wolf.class, 19, Type.Byte, 15, NewType.Boolean),
WOLF_COLLAR(Wolf.class, 20, Type.Byte, 16, NewType.VarInt), WOLF_COLLAR(Wolf.class, 20, Type.Byte, 16, NewType.VarInt),
// pig // pig
PIG_SADDLE(Pig.class, 16, Type.Byte, 12, NewType.Boolean), PIG_SADDLE(Pig.class, 16, Type.Byte, 12, NewType.Boolean),
// rabbit // rabbit
RABBIT_TYPE(Rabbit.class, 18, Type.Byte, 12, NewType.VarInt), RABBIT_TYPE(Rabbit.class, 18, Type.Byte, 12, NewType.VarInt),
// sheep // sheep
SHEEP_COLOR(Sheep.class, 16, Type.Byte, 12, NewType.Byte), SHEEP_COLOR(Sheep.class, 16, Type.Byte, 12, NewType.Byte),
// villager // villager
VILLAGER_PROFESSION(Villager.class, 16, Type.Int, 12, NewType.VarInt), // TODO write this to wiki.vg VILLAGER_PROFESSION(Villager.class, 16, Type.Int, 12, NewType.VarInt), // TODO write this to wiki.vg
// enderman // enderman
ENDERMAN_BLOCK(Enderman.class, 16, Type.Short, 11, NewType.BlockID), // special case ENDERMAN_BLOCK(Enderman.class, 16, Type.Short, 11, NewType.BlockID), // special case
ENDERMAN_BLOCKDATA(Enderman.class, 17, Type.Byte, 11, NewType.BlockID), // special case ENDERMAN_BLOCKDATA(Enderman.class, 17, Type.Byte, 11, NewType.BlockID), // special case
ENDERMAN_ISSCREAMING(Enderman.class, 18, Type.Byte, 12, NewType.Boolean), ENDERMAN_ISSCREAMING(Enderman.class, 18, Type.Byte, 12, NewType.Boolean),
// zombie // zombie
ZOMBIE_ISCHILD(Zombie.class, 12, Type.Byte, 11, NewType.Boolean), ZOMBIE_ISCHILD(Zombie.class, 12, Type.Byte, 11, NewType.Boolean),
ZOMBIE_ISVILLAGER(Zombie.class, 13, Type.Byte, 12, NewType.VarInt), ZOMBIE_ISVILLAGER(Zombie.class, 13, Type.Byte, 12, NewType.VarInt),
ZOMBIE_ISCONVERTING(Zombie.class, 14, Type.Byte, 13, NewType.Boolean), ZOMBIE_ISCONVERTING(Zombie.class, 14, Type.Byte, 13, NewType.Boolean),
// ZOMBIE_RISINGHANDS added in 1.9 // ZOMBIE_RISINGHANDS added in 1.9
// blaze // blaze
BLAZE_ONFIRE(Blaze.class, 16, Type.Byte, 11, NewType.Byte), BLAZE_ONFIRE(Blaze.class, 16, Type.Byte, 11, NewType.Byte),
// spider // spider
SPIDER_CIMBING(Spider.class, 16, Type.Byte, 11, NewType.Byte), SPIDER_CIMBING(Spider.class, 16, Type.Byte, 11, NewType.Byte),
// creeper // creeper
CREEPER_FUSE(Creeper.class, 16, Type.Byte, 11, NewType.VarInt), // -1 idle, 1 is fuse CREEPER_FUSE(Creeper.class, 16, Type.Byte, 11, NewType.VarInt), // -1 idle, 1 is fuse
CREEPER_ISPOWERED(Creeper.class, 17, Type.Byte, 12, NewType.Boolean), CREEPER_ISPOWERED(Creeper.class, 17, Type.Byte, 12, NewType.Boolean),
CREEPER_ISIGNITED(Creeper.class, 18, Type.Byte, 13, NewType.Boolean), CREEPER_ISIGNITED(Creeper.class, 18, Type.Byte, 13, NewType.Boolean),
// ghast // ghast
GHAST_ISATTACKING(Ghast.class, 16, Type.Byte, 11, NewType.Boolean), GHAST_ISATTACKING(Ghast.class, 16, Type.Byte, 11, NewType.Boolean),
// slime // slime
SLIME_SIZE(Slime.class, 16, Type.Byte, 11, NewType.VarInt), SLIME_SIZE(Slime.class, 16, Type.Byte, 11, NewType.VarInt),
// skeleton // skeleton
SKELETON_TYPE(Skeleton.class, 13, Type.Byte, 11, NewType.VarInt), SKELETON_TYPE(Skeleton.class, 13, Type.Byte, 11, NewType.VarInt),
// witch // witch
WITCH_AGGRO(Witch.class, 21, Type.Byte, 11, NewType.Boolean), WITCH_AGGRO(Witch.class, 21, Type.Byte, 11, NewType.Boolean),
// iron golem // iron golem
IRON_PLAYERMADE(IronGolem.class, 16, Type.Byte, 11, NewType.Byte), IRON_PLAYERMADE(IronGolem.class, 16, Type.Byte, 11, NewType.Byte),
// wither // wither
WITHER_TARGET1(Wither.class, 17, Type.Int, 11, NewType.VarInt), WITHER_TARGET1(Wither.class, 17, Type.Int, 11, NewType.VarInt),
WITHER_TARGET2(Wither.class, 18, Type.Int, 12, NewType.VarInt), WITHER_TARGET2(Wither.class, 18, Type.Int, 12, NewType.VarInt),
WITHER_TARGET3(Wither.class, 19, Type.Int, 13, NewType.VarInt), WITHER_TARGET3(Wither.class, 19, Type.Int, 13, NewType.VarInt),
WITHER_INVULN_TIME(Wither.class, 20, Type.Int, 14, NewType.VarInt), WITHER_INVULN_TIME(Wither.class, 20, Type.Int, 14, NewType.VarInt),
WITHER_PROPERTIES(Wither.class, 10, Type.Byte, NewType.Byte), WITHER_PROPERTIES(Wither.class, 10, Type.Byte, NewType.Byte),
WITHER_UNKNOWN(Wither.class, 11, Type.Byte, NewType.Discontinued), WITHER_UNKNOWN(Wither.class, 11, Type.Byte, NewType.Discontinued),
// wither skull // wither skull
WITHERSKULL_INVULN(WitherSkull.class, 10, Type.Byte, 5, NewType.Boolean), WITHERSKULL_INVULN(WitherSkull.class, 10, Type.Byte, 5, NewType.Boolean),
// guardian // guardian
GUARDIAN_INFO(Guardian.class, 16, Type.Int, 11, NewType.Byte), GUARDIAN_INFO(Guardian.class, 16, Type.Int, 11, NewType.Byte),
GUARDIAN_TARGET(Guardian.class, 17, Type.Int, 12, NewType.VarInt), GUARDIAN_TARGET(Guardian.class, 17, Type.Int, 12, NewType.VarInt),
// boat // boat
BOAT_SINCEHIT(Boat.class, 17, Type.Int, 5, NewType.VarInt), BOAT_SINCEHIT(Boat.class, 17, Type.Int, 5, NewType.VarInt),
BOAT_FORWARDDIR(Boat.class, 18, Type.Int, 6, NewType.VarInt), BOAT_FORWARDDIR(Boat.class, 18, Type.Int, 6, NewType.VarInt),
BOAT_DMGTAKEN(Boat.class, 19, Type.Float, 7, NewType.Float), BOAT_DMGTAKEN(Boat.class, 19, Type.Float, 7, NewType.Float),
// BOAT_TYPE in 1.9 // BOAT_TYPE in 1.9
// minecart // minecart
MINECART_SHAKINGPOWER(Minecart.class, 17, Type.Int, 5, NewType.VarInt), MINECART_SHAKINGPOWER(Minecart.class, 17, Type.Int, 5, NewType.VarInt),
MINECART_SHAKINGDIRECTION(Minecart.class, 18, Type.Int, 6, NewType.VarInt), MINECART_SHAKINGDIRECTION(Minecart.class, 18, Type.Int, 6, NewType.VarInt),
MINECART_DAMAGETAKEN(Minecart.class, 19, Type.Float, 7, NewType.Float), // also shaking modifier :P MINECART_DAMAGETAKEN(Minecart.class, 19, Type.Float, 7, NewType.Float), // also shaking modifier :P
MINECART_BLOCK(Minecart.class, 20, Type.Int, 8, NewType.VarInt), MINECART_BLOCK(Minecart.class, 20, Type.Int, 8, NewType.VarInt),
MINECART_BLOCK_Y(Minecart.class, 21, Type.Int, 9, NewType.VarInt), MINECART_BLOCK_Y(Minecart.class, 21, Type.Int, 9, NewType.VarInt),
MINECART_SHOWBLOCK(Minecart.class, 22, Type.Byte, 10, NewType.Boolean), MINECART_SHOWBLOCK(Minecart.class, 22, Type.Byte, 10, NewType.Boolean),
// Command minecart (they are still broken) // Command minecart (they are still broken)
MINECART_COMMANDBLOCK_COMMAND(Minecart.class, 23, Type.String, 11, NewType.String), MINECART_COMMANDBLOCK_COMMAND(Minecart.class, 23, Type.String, 11, NewType.String),
MINECART_COMMANDBLOCK_OUTPUT(Minecart.class, 24, Type.String, 12, NewType.Chat), MINECART_COMMANDBLOCK_OUTPUT(Minecart.class, 24, Type.String, 12, NewType.Chat),
// furnace cart // furnace cart
FURNACECART_ISPOWERED(Minecart.class, 16, Type.Byte, 11, NewType.Boolean), FURNACECART_ISPOWERED(Minecart.class, 16, Type.Byte, 11, NewType.Boolean),
// item drop // item drop
ITEM_ITEM(Item.class, 10, Type.Slot, 5, NewType.Slot), ITEM_ITEM(Item.class, 10, Type.Slot, 5, NewType.Slot),
// arrow // arrow
ARROW_ISCRIT(Arrow.class, 16, Type.Byte, 5, NewType.Byte), ARROW_ISCRIT(Arrow.class, 16, Type.Byte, 5, NewType.Byte),
// firework // firework
FIREWORK_INFO(Firework.class, 8, Type.Slot, 5, NewType.Slot), FIREWORK_INFO(Firework.class, 8, Type.Slot, 5, NewType.Slot),
// item frame // item frame
ITEMFRAME_ITEM(ItemFrame.class, 8, Type.Slot, 5, NewType.Slot), ITEMFRAME_ITEM(ItemFrame.class, 8, Type.Slot, 5, NewType.Slot),
ITEMFRAME_ROTATION(ItemFrame.class, 9, Type.Byte, 6, NewType.VarInt), ITEMFRAME_ROTATION(ItemFrame.class, 9, Type.Byte, 6, NewType.VarInt),
// ender crystal // ender crystal
ENDERCRYSTAL_HEALTH(EnderCrystal.class, 8, Type.Int, NewType.Discontinued), ENDERCRYSTAL_HEALTH(EnderCrystal.class, 8, Type.Int, NewType.Discontinued),
// Ender dragon boss bar issues // Ender dragon boss bar issues
ENDERDRAGON_UNKNOWN(EnderDragon.class, 5, Type.Byte, NewType.Discontinued), ENDERDRAGON_UNKNOWN(EnderDragon.class, 5, Type.Byte, NewType.Discontinued),
ENDERDRAGON_NAME(EnderDragon.class, 10, Type.String, NewType.Discontinued), ENDERDRAGON_NAME(EnderDragon.class, 10, Type.String, NewType.Discontinued),
// Normal Ender dragon // Normal Ender dragon
ENDERDRAGON_FLAG(EnderDragon.class, 15, Type.Byte, NewType.Discontinued), ENDERDRAGON_FLAG(EnderDragon.class, 15, Type.Byte, NewType.Discontinued),
ENDERDRAGON_PHASE(EnderDragon.class, 11, Type.Byte, NewType.VarInt); ENDERDRAGON_PHASE(EnderDragon.class, 11, Type.Byte, NewType.VarInt);
private Class<?> clazz; private Class<?> clazz;
private int newIndex; private int newIndex;
private NewType newType; private NewType newType;
private Type oldType; private Type oldType;
private int index; private int index;
MetaIndex(Class<?> type, int index, Type oldType, NewType newType) { MetaIndex(Class<?> type, int index, Type oldType, NewType newType) {
this.clazz = type; this.clazz = type;
this.index = index; this.index = index;
this.newIndex = index; this.newIndex = index;
this.oldType = oldType; this.oldType = oldType;
this.newType = newType; this.newType = newType;
} }
MetaIndex(Class<?> type, int index, Type oldType, int newIndex, NewType newType) { MetaIndex(Class<?> type, int index, Type oldType, int newIndex, NewType newType) {
this.clazz = type; this.clazz = type;
this.index = index; this.index = index;
this.oldType = oldType; this.oldType = oldType;
this.newIndex = newIndex; this.newIndex = newIndex;
this.newType = newType; this.newType = newType;
} }
public static MetaIndex getIndex(EntityType type, int index) { public static MetaIndex getIndex(EntityType type, int index) {
Class<? extends org.bukkit.entity.Entity> entityClass = type.getEntityClass(); Class<? extends org.bukkit.entity.Entity> entityClass = type.getEntityClass();
if (entityClass == null) { if (entityClass == null) {
System.out.println("Could not get entity class for " + type); System.out.println("Could not get entity class for " + type);
return null; return null;
} }
for (MetaIndex mi : MetaIndex.values()) { for (MetaIndex mi : MetaIndex.values()) {
if (mi.getIndex() == index) { if (mi.getIndex() == index) {
// To fix issue with armour stands colliding with new values // To fix issue with armour stands colliding with new values
if (mi.getApplicableClass().equals(LivingEntity.class)) continue; if (mi.getApplicableClass().equals(LivingEntity.class)) continue;
if ((mi.getApplicableClass().isAssignableFrom(entityClass) || if ((mi.getApplicableClass().isAssignableFrom(entityClass) ||
mi.getApplicableClass().equals(entityClass))) { mi.getApplicableClass().equals(entityClass))) {
return mi; return mi;
} }
} }
} }
// fall back to living entity // fall back to living entity
for (MetaIndex mi : MetaIndex.values()) { for (MetaIndex mi : MetaIndex.values()) {
if (mi.getIndex() == index) { if (mi.getIndex() == index) {
if (mi.getApplicableClass().isAssignableFrom(LivingEntity.class) || if (mi.getApplicableClass().isAssignableFrom(LivingEntity.class) ||
mi.getApplicableClass().equals(LivingEntity.class)) { mi.getApplicableClass().equals(LivingEntity.class)) {
return mi; return mi;
} }
} }
} }
return null; return null;
} }
public Class<?> getApplicableClass() { public Class<?> getApplicableClass() {
return this.clazz; return this.clazz;
} }
} }

Datei anzeigen

@ -1,17 +1,14 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.metadata; package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.metadata.MetaIndex; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.metadata.NewType; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.metadata.Type; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.metadata.Metadata;
import us.myles.ViaVersion2.api.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -32,7 +29,7 @@ public class MetadataRewriter {
Object value = entry.getValue(); Object value = entry.getValue();
switch (metaIndex.getNewType()) { switch (metaIndex.getNewType()) {
case Byte: case Byte:
entry.setType(us.myles.ViaVersion2.api.type.Type.BYTE); entry.setType(us.myles.ViaVersion.api.type.Type.BYTE);
// convert from int, byte // convert from int, byte
if (metaIndex.getOldType() == Type.Byte) { if (metaIndex.getOldType() == Type.Byte) {
entry.setValue(value); entry.setValue(value);
@ -48,12 +45,12 @@ public class MetadataRewriter {
} }
int newIndex = MetaIndex.PLAYER_HAND.getNewIndex(); int newIndex = MetaIndex.PLAYER_HAND.getNewIndex();
int typeID = MetaIndex.PLAYER_HAND.getNewType().getTypeID(); int typeID = MetaIndex.PLAYER_HAND.getNewType().getTypeID();
Metadata metadata = new Metadata(newIndex, typeID, us.myles.ViaVersion2.api.type.Type.BYTE, val); Metadata metadata = new Metadata(newIndex, typeID, us.myles.ViaVersion.api.type.Type.BYTE, val);
list.add(metadata); list.add(metadata);
} }
break; break;
case OptUUID: case OptUUID:
entry.setType(us.myles.ViaVersion2.api.type.Type.OPTIONAL_UUID); entry.setType(us.myles.ViaVersion.api.type.Type.OPTIONAL_UUID);
String owner = (String) value; String owner = (String) value;
UUID toWrite = null; UUID toWrite = null;
if (owner.length() != 0) { if (owner.length() != 0) {
@ -65,7 +62,7 @@ public class MetadataRewriter {
entry.setValue(toWrite); entry.setValue(toWrite);
break; break;
case BlockID: case BlockID:
entry.setType(us.myles.ViaVersion2.api.type.Type.VAR_INT); entry.setType(us.myles.ViaVersion.api.type.Type.VAR_INT);
// if we have both sources :)) // if we have both sources :))
if (metaIndex.getOldType() == Type.Byte) { if (metaIndex.getOldType() == Type.Byte) {
data = (Byte) value; data = (Byte) value;
@ -83,7 +80,7 @@ public class MetadataRewriter {
} }
break; break;
case VarInt: case VarInt:
entry.setType(us.myles.ViaVersion2.api.type.Type.VAR_INT); entry.setType(us.myles.ViaVersion.api.type.Type.VAR_INT);
// convert from int, short, byte // convert from int, short, byte
if (metaIndex.getOldType() == Type.Byte) { if (metaIndex.getOldType() == Type.Byte) {
entry.setValue(((Byte) value).intValue()); entry.setValue(((Byte) value).intValue());
@ -96,37 +93,37 @@ public class MetadataRewriter {
} }
break; break;
case Float: case Float:
entry.setType(us.myles.ViaVersion2.api.type.Type.FLOAT); entry.setType(us.myles.ViaVersion.api.type.Type.FLOAT);
entry.setValue(value); entry.setValue(value);
break; break;
case String: case String:
entry.setType(us.myles.ViaVersion2.api.type.Type.STRING); entry.setType(us.myles.ViaVersion.api.type.Type.STRING);
entry.setValue(value); entry.setValue(value);
break; break;
case Boolean: case Boolean:
entry.setType(us.myles.ViaVersion2.api.type.Type.BOOLEAN); entry.setType(us.myles.ViaVersion.api.type.Type.BOOLEAN);
if (metaIndex == MetaIndex.AGEABLE_AGE) if (metaIndex == MetaIndex.AGEABLE_AGE)
entry.setValue((Byte) value < 0); entry.setValue((Byte) value < 0);
else else
entry.setValue((Byte) value != 0); entry.setValue((Byte) value != 0);
break; break;
case Slot: case Slot:
entry.setType(us.myles.ViaVersion2.api.type.Type.ITEM); entry.setType(us.myles.ViaVersion.api.type.Type.ITEM);
entry.setValue(value); entry.setValue(value);
ItemRewriter.toClient((Item) entry.getValue()); ItemRewriter.toClient((Item) entry.getValue());
break; break;
case Position: case Position:
entry.setType(us.myles.ViaVersion2.api.type.Type.VECTOR); entry.setType(us.myles.ViaVersion.api.type.Type.VECTOR);
Vector vector = (Vector) value; Vector vector = (Vector) value;
entry.setValue(vector); entry.setValue(vector);
break; break;
case Vector3F: case Vector3F:
entry.setType(us.myles.ViaVersion2.api.type.Type.ROTATION); entry.setType(us.myles.ViaVersion.api.type.Type.ROTATION);
EulerAngle angle = (EulerAngle) value; EulerAngle angle = (EulerAngle) value;
entry.setValue(angle); entry.setValue(angle);
break; break;
case Chat: case Chat:
entry.setType(us.myles.ViaVersion2.api.type.Type.STRING); entry.setType(us.myles.ViaVersion.api.type.Type.STRING);
value = Protocol1_9TO1_8.fixJson((String) value); value = Protocol1_9TO1_8.fixJson((String) value);
entry.setValue(value); entry.setValue(value);
break; break;

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.metadata; package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@RequiredArgsConstructor @RequiredArgsConstructor
@Getter @Getter

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.metadata; package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.metadata; package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

Datei anzeigen

@ -1,21 +1,21 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.packets; package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import org.bukkit.Material; import org.bukkit.Material;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
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.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.metadata.Metadata; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
import us.myles.ViaVersion2.api.protocol.Protocol; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol1_9to1_8.metadata.MetadataRewriter;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.remapper.PacketHandler;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.remapper.ValueTransformer;
import us.myles.ViaVersion2.api.type.Type;
import java.util.List; import java.util.List;
@ -187,8 +187,8 @@ public class EntityPackets {
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
Item stack = wrapper.get(Type.ITEM, 0); Item stack = wrapper.get(Type.ITEM, 0);
if(stack != null){ if (stack != null) {
if(Material.getMaterial(stack.getId()).name().endsWith("SWORD")){ if (Material.getMaterial(stack.getId()).name().endsWith("SWORD")) {
entityTracker.getValidBlocking().add(entityID); entityTracker.getValidBlocking().add(entityID);
return; return;
} }
@ -211,9 +211,9 @@ public class EntityPackets {
List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if(tracker.getClientEntityTypes().containsKey(entityID)) { if (tracker.getClientEntityTypes().containsKey(entityID)) {
MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList); MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList);
}else{ } else {
System.out.println("Unable to find entity for metadata, entity ID: " + entityID); System.out.println("Unable to find entity for metadata, entity ID: " + entityID);
} }
} }

Datei anzeigen

@ -1,17 +1,17 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.packets; package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.item.Item;
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.remapper.ValueCreator;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol.Protocol; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.ItemRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.InventoryTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.InventoryTracker;
import us.myles.ViaVersion2.api.remapper.PacketHandler;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.remapper.ValueCreator;
import us.myles.ViaVersion2.api.type.Type;
public class InventoryPackets { public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {

Datei anzeigen

@ -1,21 +1,21 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.packets; package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueCreator;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.protocols.protocol1_9to1_8.PlayerMovementMapper;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol.Protocol; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo;
import us.myles.ViaVersion2.api.protocol1_9to1_8.PlayerMovementMapper;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.remapper.PacketHandler;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.remapper.ValueCreator;
import us.myles.ViaVersion2.api.type.Type;
public class PlayerPackets { public class PlayerPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
@ -230,7 +230,7 @@ public class PlayerPackets {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
String name = wrapper.get(Type.STRING, 0); String name = wrapper.get(Type.STRING, 0);
if(name.equalsIgnoreCase("MC|BOpen")){ if (name.equalsIgnoreCase("MC|BOpen")) {
wrapper.passthrough(Type.REMAINING_BYTES); // This is so ugly, :( wrapper.passthrough(Type.REMAINING_BYTES); // This is so ugly, :(
wrapper.write(Type.VAR_INT, 0); wrapper.write(Type.VAR_INT, 0);
} }
@ -239,6 +239,47 @@ public class PlayerPackets {
} }
}); });
/* Removed packets */
// Map Bulk
protocol.registerOutgoing(State.PLAY, 0x26, 0x26, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
}
});
}
});
// Update Entity NBT
protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
}
});
}
});
// Set Compression
protocol.registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
}
});
}
});
/* Packets which do not have any field remapping or handlers */ /* Packets which do not have any field remapping or handlers */
protocol.registerOutgoing(State.PLAY, 0x3A, 0x0E); // Tab Complete Response Packet protocol.registerOutgoing(State.PLAY, 0x3A, 0x0E); // Tab Complete Response Packet
@ -383,13 +424,13 @@ public class PlayerPackets {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
String name = wrapper.get(Type.STRING, 0); String name = wrapper.get(Type.STRING, 0);
if(name.equalsIgnoreCase("MC|BSign")){ if (name.equalsIgnoreCase("MC|BSign")) {
Item item = wrapper.passthrough(Type.ITEM); Item item = wrapper.passthrough(Type.ITEM);
if(item != null){ if (item != null) {
item.setId((short) Material.WRITTEN_BOOK.getId()); item.setId((short) Material.WRITTEN_BOOK.getId());
} }
} }
if(name.equalsIgnoreCase("MC|AutoCmd")){ if (name.equalsIgnoreCase("MC|AutoCmd")) {
wrapper.set(Type.STRING, 0, "MC|AdvCdm"); wrapper.set(Type.STRING, 0, "MC|AdvCdm");
wrapper.write(Type.BYTE, (byte) 0); wrapper.write(Type.BYTE, (byte) 0);
wrapper.passthrough(Type.INT); // X wrapper.passthrough(Type.INT); // X
@ -399,7 +440,7 @@ public class PlayerPackets {
wrapper.passthrough(Type.BOOLEAN); // Flag wrapper.passthrough(Type.BOOLEAN); // Flag
wrapper.clearInputBuffer(); wrapper.clearInputBuffer();
} }
if(name.equalsIgnoreCase("MC|AdvCmd")){ if (name.equalsIgnoreCase("MC|AdvCmd")) {
wrapper.set(Type.STRING, 0, "MC|AdvCdm"); wrapper.set(Type.STRING, 0, "MC|AdvCdm");
} }
} }
@ -420,6 +461,5 @@ public class PlayerPackets {
protocol.registerIncoming(State.PLAY, 0x06, 0x0D, new PlayerMovementMapper()); // Player Move & Look Packet protocol.registerIncoming(State.PLAY, 0x06, 0x0D, new PlayerMovementMapper()); // Player Move & Look Packet
protocol.registerIncoming(State.PLAY, 0x05, 0x0E, new PlayerMovementMapper()); // Player Look Packet protocol.registerIncoming(State.PLAY, 0x05, 0x0E, new PlayerMovementMapper()); // Player Look Packet
protocol.registerIncoming(State.PLAY, 0x03, 0x0F, new PlayerMovementMapper()); // Player Packet protocol.registerIncoming(State.PLAY, 0x03, 0x0F, new PlayerMovementMapper()); // Player Packet
} }
} }

Datei anzeigen

@ -1,19 +1,19 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.packets; package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
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.remapper.ValueCreator;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion.util.EntityUtil; import us.myles.ViaVersion.util.EntityUtil;
import us.myles.ViaVersion2.api.PacketWrapper;
import us.myles.ViaVersion2.api.metadata.Metadata;
import us.myles.ViaVersion2.api.protocol.Protocol;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol1_9to1_8.metadata.MetadataRewriter;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.remapper.PacketHandler;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.remapper.ValueCreator;
import us.myles.ViaVersion2.api.remapper.ValueTransformer;
import us.myles.ViaVersion2.api.type.Type;
import java.util.List; import java.util.List;
@ -176,9 +176,9 @@ public class SpawnPackets {
List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if(tracker.getClientEntityTypes().containsKey(entityID)) { if (tracker.getClientEntityTypes().containsKey(entityID)) {
MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList); MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList);
}else{ } else {
System.out.println("Unable to find entity for metadata, entity ID: " + entityID); System.out.println("Unable to find entity for metadata, entity ID: " + entityID);
} }
} }
@ -252,9 +252,9 @@ public class SpawnPackets {
List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0);
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if(tracker.getClientEntityTypes().containsKey(entityID)) { if (tracker.getClientEntityTypes().containsKey(entityID)) {
MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList); MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList);
}else{ } else {
System.out.println("Unable to find entity for metadata, entity ID: " + entityID); System.out.println("Unable to find entity for metadata, entity ID: " + entityID);
} }
} }

Datei anzeigen

@ -1,25 +1,23 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.packets; package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.StringTag; import org.spacehq.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.item.Item;
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.remapper.ValueCreator;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.sounds.SoundEffect; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds.SoundEffect;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.protocol.Protocol; import us.myles.ViaVersion.protocols.protocol1_9to1_8.types.ChunkType;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.ClientChunks;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion2.api.protocol1_9to1_8.types.ChunkType;
import us.myles.ViaVersion2.api.remapper.PacketHandler;
import us.myles.ViaVersion2.api.remapper.PacketRemapper;
import us.myles.ViaVersion2.api.remapper.ValueCreator;
import us.myles.ViaVersion2.api.type.Type;
public class WorldPackets { public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.sounds; package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

Datei anzeigen

@ -1,283 +1,283 @@
package us.myles.ViaVersion.sounds; package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
import lombok.Getter; import lombok.Getter;
@Getter @Getter
public enum SoundEffect { public enum SoundEffect {
MOB_HORSE_ZOMBIE_IDLE("mob.horse.zombie.idle", "entity.zombie_horse.ambient", SoundCategory.NEUTRAL), MOB_HORSE_ZOMBIE_IDLE("mob.horse.zombie.idle", "entity.zombie_horse.ambient", SoundCategory.NEUTRAL),
NOTE_SNARE("note.snare", "block.note.snare", SoundCategory.RECORD), NOTE_SNARE("note.snare", "block.note.snare", SoundCategory.RECORD),
RANDOM_WOOD_CLICK("random.wood_click", "block.wood_button.click_on", SoundCategory.BLOCK), RANDOM_WOOD_CLICK("random.wood_click", "block.wood_button.click_on", SoundCategory.BLOCK),
DIG_GRAVEL("dig.gravel", "block.gravel.place", SoundCategory.BLOCK), DIG_GRAVEL("dig.gravel", "block.gravel.place", SoundCategory.BLOCK),
RANDOM_BOWHIT("random.bowhit", "block.tripwire.detach", SoundCategory.NEUTRAL), RANDOM_BOWHIT("random.bowhit", "block.tripwire.detach", SoundCategory.NEUTRAL),
DIG_GLASS("dig.glass", "block.glass.break", SoundCategory.BLOCK), DIG_GLASS("dig.glass", "block.glass.break", SoundCategory.BLOCK),
MOB_ZOMBIE_SAY("mob.zombie.say", "entity.zombie_villager.ambient", SoundCategory.HOSTILE), MOB_ZOMBIE_SAY("mob.zombie.say", "entity.zombie_villager.ambient", SoundCategory.HOSTILE),
MOB_PIG_DEATH("mob.pig.death", "entity.pig.death", SoundCategory.NEUTRAL), MOB_PIG_DEATH("mob.pig.death", "entity.pig.death", SoundCategory.NEUTRAL),
MOB_HORSE_DONKEY_HIT("mob.horse.donkey.hit", "entity.donkey.hurt", SoundCategory.NEUTRAL), MOB_HORSE_DONKEY_HIT("mob.horse.donkey.hit", "entity.donkey.hurt", SoundCategory.NEUTRAL),
GAME_NEUTRAL_SWIM("game.neutral.swim", "entity.player.swim", SoundCategory.NEUTRAL), GAME_NEUTRAL_SWIM("game.neutral.swim", "entity.player.swim", SoundCategory.NEUTRAL),
GAME_PLAYER_SWIM("game.player.swim", "entity.player.swim", SoundCategory.PLAYER), GAME_PLAYER_SWIM("game.player.swim", "entity.player.swim", SoundCategory.PLAYER),
MOB_ENDERMEN_IDLE("mob.endermen.idle", "entity.endermen.ambient", SoundCategory.HOSTILE), MOB_ENDERMEN_IDLE("mob.endermen.idle", "entity.endermen.ambient", SoundCategory.HOSTILE),
PORTAL_PORTAL("portal.portal", "block.portal.ambient", SoundCategory.BLOCK), PORTAL_PORTAL("portal.portal", "block.portal.ambient", SoundCategory.BLOCK),
RANDOM_FIZZ("random.fizz", "entity.generic.extinguish_fire", SoundCategory.BLOCK), RANDOM_FIZZ("random.fizz", "entity.generic.extinguish_fire", SoundCategory.BLOCK),
NOTE_HARP("note.harp", "block.note.harp", SoundCategory.RECORD), NOTE_HARP("note.harp", "block.note.harp", SoundCategory.RECORD),
STEP_SNOW("step.snow", "block.snow.step", SoundCategory.NEUTRAL), STEP_SNOW("step.snow", "block.snow.step", SoundCategory.NEUTRAL),
RANDOM_SUCCESSFUL_HIT("random.successful_hit", "entity.arrow.hit_player", SoundCategory.PLAYER), RANDOM_SUCCESSFUL_HIT("random.successful_hit", "entity.arrow.hit_player", SoundCategory.PLAYER),
MOB_ZOMBIEPIG_ZPIGHURT("mob.zombiepig.zpighurt", "entity.zombie_pig.hurt", SoundCategory.HOSTILE), MOB_ZOMBIEPIG_ZPIGHURT("mob.zombiepig.zpighurt", "entity.zombie_pig.hurt", SoundCategory.HOSTILE),
MOB_WOLF_HOWL("mob.wolf.howl", "entity.wolf.howl", SoundCategory.NEUTRAL), MOB_WOLF_HOWL("mob.wolf.howl", "entity.wolf.howl", SoundCategory.NEUTRAL),
FIREWORKS_LAUNCH("fireworks.launch", "entity.firework.launch", SoundCategory.AMBIENT), FIREWORKS_LAUNCH("fireworks.launch", "entity.firework.launch", SoundCategory.AMBIENT),
MOB_COW_HURT("mob.cow.hurt", "entity.cow.death", SoundCategory.NEUTRAL), MOB_COW_HURT("mob.cow.hurt", "entity.cow.death", SoundCategory.NEUTRAL),
FIREWORKS_LARGEBLAST("fireworks.largeBlast", "entity.firework.large_blast", SoundCategory.AMBIENT), FIREWORKS_LARGEBLAST("fireworks.largeBlast", "entity.firework.large_blast", SoundCategory.AMBIENT),
MOB_BLAZE_HIT("mob.blaze.hit", "entity.blaze.hurt", SoundCategory.HOSTILE), MOB_BLAZE_HIT("mob.blaze.hit", "entity.blaze.hurt", SoundCategory.HOSTILE),
MOB_VILLAGER_DEATH("mob.villager.death", "entity.villager.death", SoundCategory.NEUTRAL), MOB_VILLAGER_DEATH("mob.villager.death", "entity.villager.death", SoundCategory.NEUTRAL),
MOB_BLAZE_DEATH("mob.blaze.death", "entity.blaze.death", SoundCategory.HOSTILE), MOB_BLAZE_DEATH("mob.blaze.death", "entity.blaze.death", SoundCategory.HOSTILE),
MOB_HORSE_ZOMBIE_DEATH("mob.horse.zombie.death", "entity.zombie_horse.death", SoundCategory.NEUTRAL), MOB_HORSE_ZOMBIE_DEATH("mob.horse.zombie.death", "entity.zombie_horse.death", SoundCategory.NEUTRAL),
MOB_SILVERFISH_KILL("mob.silverfish.kill", "entity.endermite.death", SoundCategory.HOSTILE), MOB_SILVERFISH_KILL("mob.silverfish.kill", "entity.endermite.death", SoundCategory.HOSTILE),
MOB_WOLF_PANTING("mob.wolf.panting", "entity.wolf.pant", SoundCategory.NEUTRAL), MOB_WOLF_PANTING("mob.wolf.panting", "entity.wolf.pant", SoundCategory.NEUTRAL),
NOTE_BASS("note.bass", "null", SoundCategory.RECORD), NOTE_BASS("note.bass", "null", SoundCategory.RECORD),
DIG_STONE("dig.stone", "block.glass.place", SoundCategory.BLOCK), DIG_STONE("dig.stone", "block.glass.place", SoundCategory.BLOCK),
MOB_ENDERMEN_STARE("mob.endermen.stare", "entity.endermen.stare", SoundCategory.HOSTILE), MOB_ENDERMEN_STARE("mob.endermen.stare", "entity.endermen.stare", SoundCategory.HOSTILE),
GAME_PLAYER_SWIM_SPLASH("game.player.swim.splash", "entity.generic.splash", SoundCategory.BLOCK), GAME_PLAYER_SWIM_SPLASH("game.player.swim.splash", "entity.generic.splash", SoundCategory.BLOCK),
MOB_SLIME_SMALL("mob.slime.small", "block.slime.hit", SoundCategory.HOSTILE), MOB_SLIME_SMALL("mob.slime.small", "block.slime.hit", SoundCategory.HOSTILE),
MOB_GHAST_DEATH("mob.ghast.death", "entity.ghast.death", SoundCategory.HOSTILE), MOB_GHAST_DEATH("mob.ghast.death", "entity.ghast.death", SoundCategory.HOSTILE),
MOB_GUARDIAN_ATTACK("mob.guardian.attack", "entity.guardian.attack", SoundCategory.HOSTILE), MOB_GUARDIAN_ATTACK("mob.guardian.attack", "entity.guardian.attack", SoundCategory.HOSTILE),
RANDOM_CLICK("random.click", "block.wood_pressureplate.click_on", SoundCategory.BLOCK), RANDOM_CLICK("random.click", "block.wood_pressureplate.click_on", SoundCategory.BLOCK),
MOB_ZOMBIEPIG_ZPIG("mob.zombiepig.zpig", "entity.zombie_pig.ambient", SoundCategory.HOSTILE), MOB_ZOMBIEPIG_ZPIG("mob.zombiepig.zpig", "entity.zombie_pig.ambient", SoundCategory.HOSTILE),
GAME_PLAYER_DIE("game.player.die", "entity.player.death", SoundCategory.PLAYER), GAME_PLAYER_DIE("game.player.die", "entity.player.death", SoundCategory.PLAYER),
FIREWORKS_TWINKLE_FAR("fireworks.twinkle_far", "entity.firework.twinkle_far", SoundCategory.AMBIENT), FIREWORKS_TWINKLE_FAR("fireworks.twinkle_far", "entity.firework.twinkle_far", SoundCategory.AMBIENT),
MOB_GUARDIAN_LAND_IDLE("mob.guardian.land.idle", "entity.guardian.ambient_land", SoundCategory.HOSTILE), MOB_GUARDIAN_LAND_IDLE("mob.guardian.land.idle", "entity.guardian.ambient_land", SoundCategory.HOSTILE),
DIG_GRASS("dig.grass", "block.grass.place", SoundCategory.BLOCK), DIG_GRASS("dig.grass", "block.grass.place", SoundCategory.BLOCK),
MOB_SKELETON_STEP("mob.skeleton.step", "entity.skeleton.step", SoundCategory.HOSTILE), MOB_SKELETON_STEP("mob.skeleton.step", "entity.skeleton.step", SoundCategory.HOSTILE),
MOB_WITHER_DEATH("mob.wither.death", "entity.wither.death", SoundCategory.HOSTILE), MOB_WITHER_DEATH("mob.wither.death", "entity.wither.death", SoundCategory.HOSTILE),
MOB_WOLF_HURT("mob.wolf.hurt", "entity.wolf.hurt", SoundCategory.NEUTRAL), MOB_WOLF_HURT("mob.wolf.hurt", "entity.wolf.hurt", SoundCategory.NEUTRAL),
MOB_HORSE_LEATHER("mob.horse.leather", "entity.horse.saddle", SoundCategory.NEUTRAL), MOB_HORSE_LEATHER("mob.horse.leather", "entity.horse.saddle", SoundCategory.NEUTRAL),
MOB_BAT_LOOP("mob.bat.loop", "entity.bat.loop", SoundCategory.NEUTRAL), MOB_BAT_LOOP("mob.bat.loop", "entity.bat.loop", SoundCategory.NEUTRAL),
MOB_GHAST_SCREAM("mob.ghast.scream", "entity.ghast.hurt", SoundCategory.HOSTILE), MOB_GHAST_SCREAM("mob.ghast.scream", "entity.ghast.hurt", SoundCategory.HOSTILE),
GAME_PLAYER_HURT("game.player.hurt", "entity.player.death", SoundCategory.PLAYER), GAME_PLAYER_HURT("game.player.hurt", "entity.player.death", SoundCategory.PLAYER),
GAME_NEUTRAL_DIE("game.neutral.die", "entity.player.death", SoundCategory.NEUTRAL), GAME_NEUTRAL_DIE("game.neutral.die", "entity.player.death", SoundCategory.NEUTRAL),
MOB_CREEPER_DEATH("mob.creeper.death", "entity.creeper.death", SoundCategory.HOSTILE), MOB_CREEPER_DEATH("mob.creeper.death", "entity.creeper.death", SoundCategory.HOSTILE),
MOB_HORSE_GALLOP("mob.horse.gallop", "entity.horse.gallop", SoundCategory.NEUTRAL), MOB_HORSE_GALLOP("mob.horse.gallop", "entity.horse.gallop", SoundCategory.NEUTRAL),
MOB_WITHER_SPAWN("mob.wither.spawn", "entity.wither.spawn", SoundCategory.HOSTILE), MOB_WITHER_SPAWN("mob.wither.spawn", "entity.wither.spawn", SoundCategory.HOSTILE),
MOB_ENDERMEN_HIT("mob.endermen.hit", "entity.endermen.hurt", SoundCategory.HOSTILE), MOB_ENDERMEN_HIT("mob.endermen.hit", "entity.endermen.hurt", SoundCategory.HOSTILE),
MOB_CREEPER_SAY("mob.creeper.say", "entity.creeper.hurt", SoundCategory.HOSTILE), MOB_CREEPER_SAY("mob.creeper.say", "entity.creeper.hurt", SoundCategory.HOSTILE),
MOB_HORSE_WOOD("mob.horse.wood", "entity.horse.step_wood", SoundCategory.NEUTRAL), MOB_HORSE_WOOD("mob.horse.wood", "entity.horse.step_wood", SoundCategory.NEUTRAL),
MOB_ZOMBIE_UNFECT("mob.zombie.unfect", "entity.zombie_villager.converted", SoundCategory.HOSTILE), MOB_ZOMBIE_UNFECT("mob.zombie.unfect", "entity.zombie_villager.converted", SoundCategory.HOSTILE),
RANDOM_ANVIL_USE("random.anvil_use", "block.anvil.use", SoundCategory.BLOCK), RANDOM_ANVIL_USE("random.anvil_use", "block.anvil.use", SoundCategory.BLOCK),
RANDOM_CHESTCLOSED("random.chestclosed", "block.enderchest.close", SoundCategory.BLOCK), RANDOM_CHESTCLOSED("random.chestclosed", "block.enderchest.close", SoundCategory.BLOCK),
MOB_SHEEP_SHEAR("mob.sheep.shear", "entity.sheep.shear", SoundCategory.NEUTRAL), MOB_SHEEP_SHEAR("mob.sheep.shear", "entity.sheep.shear", SoundCategory.NEUTRAL),
RANDOM_POP("random.pop", "entity.item.pickup", SoundCategory.PLAYER), RANDOM_POP("random.pop", "entity.item.pickup", SoundCategory.PLAYER),
MOB_BAT_DEATH("mob.bat.death", "entity.bat.death", SoundCategory.NEUTRAL), MOB_BAT_DEATH("mob.bat.death", "entity.bat.death", SoundCategory.NEUTRAL),
DIG_WOOD("dig.wood", "block.ladder.break", SoundCategory.BLOCK), DIG_WOOD("dig.wood", "block.ladder.break", SoundCategory.BLOCK),
MOB_HORSE_DONKEY_DEATH("mob.horse.donkey.death", "entity.donkey.death", SoundCategory.NEUTRAL), MOB_HORSE_DONKEY_DEATH("mob.horse.donkey.death", "entity.donkey.death", SoundCategory.NEUTRAL),
FIREWORKS_BLAST("fireworks.blast", "entity.firework.blast", SoundCategory.AMBIENT), FIREWORKS_BLAST("fireworks.blast", "entity.firework.blast", SoundCategory.AMBIENT),
MOB_ZOMBIEPIG_ZPIGANGRY("mob.zombiepig.zpigangry", "entity.zombie_pig.angry", SoundCategory.HOSTILE), MOB_ZOMBIEPIG_ZPIGANGRY("mob.zombiepig.zpigangry", "entity.zombie_pig.angry", SoundCategory.HOSTILE),
GAME_HOSTILE_SWIM("game.hostile.swim", "entity.player.swim", SoundCategory.HOSTILE), GAME_HOSTILE_SWIM("game.hostile.swim", "entity.player.swim", SoundCategory.HOSTILE),
MOB_GUARDIAN_FLOP("mob.guardian.flop", "entity.guardian.flop", SoundCategory.HOSTILE), MOB_GUARDIAN_FLOP("mob.guardian.flop", "entity.guardian.flop", SoundCategory.HOSTILE),
MOB_VILLAGER_YES("mob.villager.yes", "entity.villager.yes", SoundCategory.NEUTRAL), MOB_VILLAGER_YES("mob.villager.yes", "entity.villager.yes", SoundCategory.NEUTRAL),
MOB_GHAST_CHARGE("mob.ghast.charge", "entity.ghast.warn", SoundCategory.HOSTILE), MOB_GHAST_CHARGE("mob.ghast.charge", "entity.ghast.warn", SoundCategory.HOSTILE),
CREEPER_PRIMED("creeper.primed", "entity.creeper.primed", SoundCategory.HOSTILE), CREEPER_PRIMED("creeper.primed", "entity.creeper.primed", SoundCategory.HOSTILE),
DIG_SAND("dig.sand", "block.sand.break", SoundCategory.BLOCK), DIG_SAND("dig.sand", "block.sand.break", SoundCategory.BLOCK),
MOB_CHICKEN_SAY("mob.chicken.say", "entity.chicken.ambient", SoundCategory.NEUTRAL), MOB_CHICKEN_SAY("mob.chicken.say", "entity.chicken.ambient", SoundCategory.NEUTRAL),
RANDOM_DOOR_CLOSE("random.door_close", "null", SoundCategory.BLOCK), RANDOM_DOOR_CLOSE("random.door_close", "null", SoundCategory.BLOCK),
MOB_GUARDIAN_ELDER_DEATH("mob.guardian.elder.death", "entity.elder_guardian.death", SoundCategory.HOSTILE), MOB_GUARDIAN_ELDER_DEATH("mob.guardian.elder.death", "entity.elder_guardian.death", SoundCategory.HOSTILE),
FIREWORKS_TWINKLE("fireworks.twinkle", "entity.firework.twinkle", SoundCategory.AMBIENT), FIREWORKS_TWINKLE("fireworks.twinkle", "entity.firework.twinkle", SoundCategory.AMBIENT),
MOB_HORSE_SKELETON_DEATH("mob.horse.skeleton.death", "entity.skeleton_horse.death", SoundCategory.NEUTRAL), MOB_HORSE_SKELETON_DEATH("mob.horse.skeleton.death", "entity.skeleton_horse.death", SoundCategory.NEUTRAL),
AMBIENT_WEATHER_RAIN("ambient.weather.rain", "weather.rain.above", SoundCategory.WEATHER), AMBIENT_WEATHER_RAIN("ambient.weather.rain", "weather.rain.above", SoundCategory.WEATHER),
PORTAL_TRIGGER("portal.trigger", "block.portal.trigger", SoundCategory.BLOCK), PORTAL_TRIGGER("portal.trigger", "block.portal.trigger", SoundCategory.BLOCK),
RANDOM_CHESTOPEN("random.chestopen", "block.enderchest.open", SoundCategory.BLOCK), RANDOM_CHESTOPEN("random.chestopen", "block.enderchest.open", SoundCategory.BLOCK),
MOB_HORSE_LAND("mob.horse.land", "entity.horse.land", SoundCategory.NEUTRAL), MOB_HORSE_LAND("mob.horse.land", "entity.horse.land", SoundCategory.NEUTRAL),
MOB_SILVERFISH_STEP("mob.silverfish.step", "entity.silverfish.step", SoundCategory.HOSTILE), MOB_SILVERFISH_STEP("mob.silverfish.step", "entity.silverfish.step", SoundCategory.HOSTILE),
MOB_BAT_TAKEOFF("mob.bat.takeoff", "entity.bat.takeoff", SoundCategory.NEUTRAL), MOB_BAT_TAKEOFF("mob.bat.takeoff", "entity.bat.takeoff", SoundCategory.NEUTRAL),
MOB_VILLAGER_NO("mob.villager.no", "entity.villager.no", SoundCategory.NEUTRAL), MOB_VILLAGER_NO("mob.villager.no", "entity.villager.no", SoundCategory.NEUTRAL),
GAME_HOSTILE_HURT_FALL_BIG("game.hostile.hurt.fall.big", "entity.hostile.big_fall", SoundCategory.HOSTILE), GAME_HOSTILE_HURT_FALL_BIG("game.hostile.hurt.fall.big", "entity.hostile.big_fall", SoundCategory.HOSTILE),
MOB_IRONGOLEM_WALK("mob.irongolem.walk", "entity.irongolem.step", SoundCategory.NEUTRAL), MOB_IRONGOLEM_WALK("mob.irongolem.walk", "entity.irongolem.step", SoundCategory.NEUTRAL),
NOTE_HAT("note.hat", "block.note.hat", SoundCategory.RECORD), NOTE_HAT("note.hat", "block.note.hat", SoundCategory.RECORD),
MOB_ZOMBIE_METAL("mob.zombie.metal", "entity.zombie.attack_iron_door", SoundCategory.HOSTILE), MOB_ZOMBIE_METAL("mob.zombie.metal", "entity.zombie.attack_iron_door", SoundCategory.HOSTILE),
MOB_VILLAGER_HAGGLE("mob.villager.haggle", "entity.villager.trading", SoundCategory.NEUTRAL), MOB_VILLAGER_HAGGLE("mob.villager.haggle", "entity.villager.trading", SoundCategory.NEUTRAL),
MOB_GHAST_FIREBALL("mob.ghast.fireball", "entity.blaze.shoot", SoundCategory.HOSTILE), MOB_GHAST_FIREBALL("mob.ghast.fireball", "entity.blaze.shoot", SoundCategory.HOSTILE),
MOB_IRONGOLEM_DEATH("mob.irongolem.death", "entity.irongolem.death", SoundCategory.NEUTRAL), MOB_IRONGOLEM_DEATH("mob.irongolem.death", "entity.irongolem.death", SoundCategory.NEUTRAL),
RANDOM_BREAK("random.break", "item.shield.break", SoundCategory.PLAYER), RANDOM_BREAK("random.break", "item.shield.break", SoundCategory.PLAYER),
MOB_ZOMBIE_REMEDY("mob.zombie.remedy", "entity.zombie_villager.cure", SoundCategory.HOSTILE), MOB_ZOMBIE_REMEDY("mob.zombie.remedy", "entity.zombie_villager.cure", SoundCategory.HOSTILE),
RANDOM_BOW("random.bow", "entity.splash_potion.throw", SoundCategory.NEUTRAL), RANDOM_BOW("random.bow", "entity.splash_potion.throw", SoundCategory.NEUTRAL),
MOB_VILLAGER_IDLE("mob.villager.idle", "entity.villager.ambient", SoundCategory.NEUTRAL), MOB_VILLAGER_IDLE("mob.villager.idle", "entity.villager.ambient", SoundCategory.NEUTRAL),
STEP_CLOTH("step.cloth", "block.cloth.fall", SoundCategory.NEUTRAL), STEP_CLOTH("step.cloth", "block.cloth.fall", SoundCategory.NEUTRAL),
MOB_SILVERFISH_HIT("mob.silverfish.hit", "entity.endermite.hurt", SoundCategory.HOSTILE), MOB_SILVERFISH_HIT("mob.silverfish.hit", "entity.endermite.hurt", SoundCategory.HOSTILE),
LIQUID_LAVA("liquid.lava", "block.lava.ambient", SoundCategory.BLOCK), LIQUID_LAVA("liquid.lava", "block.lava.ambient", SoundCategory.BLOCK),
GAME_NEUTRAL_HURT_FALL_BIG("game.neutral.hurt.fall.big", "entity.hostile.big_fall", SoundCategory.NEUTRAL), GAME_NEUTRAL_HURT_FALL_BIG("game.neutral.hurt.fall.big", "entity.hostile.big_fall", SoundCategory.NEUTRAL),
FIRE_FIRE("fire.fire", "block.fire.ambient", SoundCategory.BLOCK), FIRE_FIRE("fire.fire", "block.fire.ambient", SoundCategory.BLOCK),
MOB_ZOMBIE_WOOD("mob.zombie.wood", "entity.zombie.attack_door_wood", SoundCategory.HOSTILE), MOB_ZOMBIE_WOOD("mob.zombie.wood", "entity.zombie.attack_door_wood", SoundCategory.HOSTILE),
MOB_CHICKEN_STEP("mob.chicken.step", "entity.chicken.step", SoundCategory.NEUTRAL), MOB_CHICKEN_STEP("mob.chicken.step", "entity.chicken.step", SoundCategory.NEUTRAL),
MOB_GUARDIAN_LAND_HIT("mob.guardian.land.hit", "entity.guardian.hurt_land", SoundCategory.HOSTILE), MOB_GUARDIAN_LAND_HIT("mob.guardian.land.hit", "entity.guardian.hurt_land", SoundCategory.HOSTILE),
MOB_CHICKEN_PLOP("mob.chicken.plop", "entity.donkey.chest", SoundCategory.NEUTRAL), MOB_CHICKEN_PLOP("mob.chicken.plop", "entity.donkey.chest", SoundCategory.NEUTRAL),
MOB_ENDERDRAGON_WINGS("mob.enderdragon.wings", "entity.enderdragon.flap", SoundCategory.HOSTILE), MOB_ENDERDRAGON_WINGS("mob.enderdragon.wings", "entity.enderdragon.flap", SoundCategory.HOSTILE),
STEP_GRASS("step.grass", "block.grass.hit", SoundCategory.NEUTRAL), STEP_GRASS("step.grass", "block.grass.hit", SoundCategory.NEUTRAL),
MOB_HORSE_BREATHE("mob.horse.breathe", "entity.horse.breathe", SoundCategory.NEUTRAL), MOB_HORSE_BREATHE("mob.horse.breathe", "entity.horse.breathe", SoundCategory.NEUTRAL),
GAME_PLAYER_HURT_FALL_BIG("game.player.hurt.fall.big", "entity.hostile.big_fall", SoundCategory.PLAYER), GAME_PLAYER_HURT_FALL_BIG("game.player.hurt.fall.big", "entity.hostile.big_fall", SoundCategory.PLAYER),
MOB_HORSE_DONKEY_IDLE("mob.horse.donkey.idle", "entity.donkey.ambient", SoundCategory.NEUTRAL), MOB_HORSE_DONKEY_IDLE("mob.horse.donkey.idle", "entity.donkey.ambient", SoundCategory.NEUTRAL),
MOB_SPIDER_STEP("mob.spider.step", "entity.spider.step", SoundCategory.HOSTILE), MOB_SPIDER_STEP("mob.spider.step", "entity.spider.step", SoundCategory.HOSTILE),
GAME_NEUTRAL_HURT("game.neutral.hurt", "entity.player.death", SoundCategory.NEUTRAL), GAME_NEUTRAL_HURT("game.neutral.hurt", "entity.player.death", SoundCategory.NEUTRAL),
MOB_COW_SAY("mob.cow.say", "entity.cow.ambient", SoundCategory.NEUTRAL), MOB_COW_SAY("mob.cow.say", "entity.cow.ambient", SoundCategory.NEUTRAL),
MOB_HORSE_JUMP("mob.horse.jump", "entity.horse.jump", SoundCategory.NEUTRAL), MOB_HORSE_JUMP("mob.horse.jump", "entity.horse.jump", SoundCategory.NEUTRAL),
MOB_HORSE_SOFT("mob.horse.soft", "entity.horse.step", SoundCategory.NEUTRAL), MOB_HORSE_SOFT("mob.horse.soft", "entity.horse.step", SoundCategory.NEUTRAL),
GAME_NEUTRAL_SWIM_SPLASH("game.neutral.swim.splash", "entity.generic.splash", SoundCategory.NEUTRAL), GAME_NEUTRAL_SWIM_SPLASH("game.neutral.swim.splash", "entity.generic.splash", SoundCategory.NEUTRAL),
MOB_GUARDIAN_HIT("mob.guardian.hit", "entity.guardian.hurt", SoundCategory.HOSTILE), MOB_GUARDIAN_HIT("mob.guardian.hit", "entity.guardian.hurt", SoundCategory.HOSTILE),
MOB_ENDERDRAGON_END("mob.enderdragon.end", "entity.enderdragon.death", SoundCategory.HOSTILE), MOB_ENDERDRAGON_END("mob.enderdragon.end", "entity.enderdragon.death", SoundCategory.HOSTILE),
MOB_ZOMBIE_STEP("mob.zombie.step", "entity.zombie.step", SoundCategory.HOSTILE), MOB_ZOMBIE_STEP("mob.zombie.step", "entity.zombie.step", SoundCategory.HOSTILE),
MOB_ENDERDRAGON_GROWL("mob.enderdragon.growl", "entity.enderdragon.growl", SoundCategory.HOSTILE), MOB_ENDERDRAGON_GROWL("mob.enderdragon.growl", "entity.enderdragon.growl", SoundCategory.HOSTILE),
MOB_WOLF_SHAKE("mob.wolf.shake", "entity.wolf.shake", SoundCategory.NEUTRAL), MOB_WOLF_SHAKE("mob.wolf.shake", "entity.wolf.shake", SoundCategory.NEUTRAL),
MOB_ENDERMEN_DEATH("mob.endermen.death", "entity.endermen.death", SoundCategory.HOSTILE), MOB_ENDERMEN_DEATH("mob.endermen.death", "entity.endermen.death", SoundCategory.HOSTILE),
RANDOM_ANVIL_LAND("random.anvil_land", "block.anvil.land", SoundCategory.BLOCK), RANDOM_ANVIL_LAND("random.anvil_land", "block.anvil.land", SoundCategory.BLOCK),
GAME_HOSTILE_HURT("game.hostile.hurt", "entity.player.death", SoundCategory.HOSTILE), GAME_HOSTILE_HURT("game.hostile.hurt", "entity.player.death", SoundCategory.HOSTILE),
MINECART_INSIDE("minecart.inside", "entity.minecart.inside", SoundCategory.PLAYER), MINECART_INSIDE("minecart.inside", "entity.minecart.inside", SoundCategory.PLAYER),
MOB_SLIME_BIG("mob.slime.big", "entity.slime.death", SoundCategory.HOSTILE), MOB_SLIME_BIG("mob.slime.big", "entity.slime.death", SoundCategory.HOSTILE),
LIQUID_WATER("liquid.water", "block.water.ambient", SoundCategory.BLOCK), LIQUID_WATER("liquid.water", "block.water.ambient", SoundCategory.BLOCK),
MOB_PIG_SAY("mob.pig.say", "entity.pig.ambient", SoundCategory.NEUTRAL), MOB_PIG_SAY("mob.pig.say", "entity.pig.ambient", SoundCategory.NEUTRAL),
MOB_WITHER_SHOOT("mob.wither.shoot", "entity.wither.shoot", SoundCategory.HOSTILE), MOB_WITHER_SHOOT("mob.wither.shoot", "entity.wither.shoot", SoundCategory.HOSTILE),
ITEM_FIRECHARGE_USE("item.fireCharge.use", "entity.blaze.shoot", SoundCategory.BLOCK), ITEM_FIRECHARGE_USE("item.fireCharge.use", "entity.blaze.shoot", SoundCategory.BLOCK),
STEP_SAND("step.sand", "block.sand.fall", SoundCategory.NEUTRAL), STEP_SAND("step.sand", "block.sand.fall", SoundCategory.NEUTRAL),
MOB_IRONGOLEM_HIT("mob.irongolem.hit", "entity.irongolem.hurt", SoundCategory.NEUTRAL), MOB_IRONGOLEM_HIT("mob.irongolem.hit", "entity.irongolem.hurt", SoundCategory.NEUTRAL),
MOB_HORSE_DEATH("mob.horse.death", "entity.horse.death", SoundCategory.NEUTRAL), MOB_HORSE_DEATH("mob.horse.death", "entity.horse.death", SoundCategory.NEUTRAL),
MOB_BAT_HURT("mob.bat.hurt", "entity.bat.hurt", SoundCategory.NEUTRAL), MOB_BAT_HURT("mob.bat.hurt", "entity.bat.hurt", SoundCategory.NEUTRAL),
MOB_GHAST_AFFECTIONATE_SCREAM("mob.ghast.affectionate_scream", "entity.ghast.scream", SoundCategory.HOSTILE), MOB_GHAST_AFFECTIONATE_SCREAM("mob.ghast.affectionate_scream", "entity.ghast.scream", SoundCategory.HOSTILE),
MOB_GUARDIAN_ELDER_IDLE("mob.guardian.elder.idle", "entity.elder_guardian.ambient", SoundCategory.HOSTILE), MOB_GUARDIAN_ELDER_IDLE("mob.guardian.elder.idle", "entity.elder_guardian.ambient", SoundCategory.HOSTILE),
MOB_ZOMBIEPIG_ZPIGDEATH("mob.zombiepig.zpigdeath", "entity.zombie_pig.death", SoundCategory.HOSTILE), MOB_ZOMBIEPIG_ZPIGDEATH("mob.zombiepig.zpigdeath", "entity.zombie_pig.death", SoundCategory.HOSTILE),
AMBIENT_WEATHER_THUNDER("ambient.weather.thunder", "entity.lightning.thunder", SoundCategory.WEATHER), AMBIENT_WEATHER_THUNDER("ambient.weather.thunder", "entity.lightning.thunder", SoundCategory.WEATHER),
MINECART_BASE("minecart.base", "entity.minecart.riding", SoundCategory.NEUTRAL), MINECART_BASE("minecart.base", "entity.minecart.riding", SoundCategory.NEUTRAL),
STEP_LADDER("step.ladder", "block.ladder.hit", SoundCategory.NEUTRAL), STEP_LADDER("step.ladder", "block.ladder.hit", SoundCategory.NEUTRAL),
MOB_HORSE_DONKEY_ANGRY("mob.horse.donkey.angry", "entity.donkey.angry", SoundCategory.NEUTRAL), MOB_HORSE_DONKEY_ANGRY("mob.horse.donkey.angry", "entity.donkey.angry", SoundCategory.NEUTRAL),
AMBIENT_CAVE_CAVE("ambient.cave.cave", "ambient.cave", SoundCategory.AMBIENT), AMBIENT_CAVE_CAVE("ambient.cave.cave", "ambient.cave", SoundCategory.AMBIENT),
FIREWORKS_BLAST_FAR("fireworks.blast_far", "entity.firework.blast_far", SoundCategory.AMBIENT), FIREWORKS_BLAST_FAR("fireworks.blast_far", "entity.firework.blast_far", SoundCategory.AMBIENT),
GAME_NEUTRAL_HURT_FALL_SMALL("game.neutral.hurt.fall.small", "entity.generic.small_fall", SoundCategory.NEUTRAL), GAME_NEUTRAL_HURT_FALL_SMALL("game.neutral.hurt.fall.small", "entity.generic.small_fall", SoundCategory.NEUTRAL),
GAME_HOSTILE_SWIM_SPLASH("game.hostile.swim.splash", "entity.generic.splash", SoundCategory.HOSTILE), GAME_HOSTILE_SWIM_SPLASH("game.hostile.swim.splash", "entity.generic.splash", SoundCategory.HOSTILE),
RANDOM_DRINK("random.drink", "entity.generic.drink", SoundCategory.PLAYER), RANDOM_DRINK("random.drink", "entity.generic.drink", SoundCategory.PLAYER),
GAME_HOSTILE_DIE("game.hostile.die", "entity.player.death", SoundCategory.HOSTILE), GAME_HOSTILE_DIE("game.hostile.die", "entity.player.death", SoundCategory.HOSTILE),
MOB_CAT_HISS("mob.cat.hiss", "entity.cat.hiss", SoundCategory.NEUTRAL), MOB_CAT_HISS("mob.cat.hiss", "entity.cat.hiss", SoundCategory.NEUTRAL),
NOTE_BD("note.bd", "block.note.basedrum", SoundCategory.RECORD), NOTE_BD("note.bd", "block.note.basedrum", SoundCategory.RECORD),
MOB_SPIDER_SAY("mob.spider.say", "entity.spider.hurt", SoundCategory.HOSTILE), MOB_SPIDER_SAY("mob.spider.say", "entity.spider.hurt", SoundCategory.HOSTILE),
STEP_STONE("step.stone", "block.anvil.hit", SoundCategory.NEUTRAL), STEP_STONE("step.stone", "block.anvil.hit", SoundCategory.NEUTRAL),
RANDOM_LEVELUP("random.levelup", "entity.player.levelup", SoundCategory.PLAYER), RANDOM_LEVELUP("random.levelup", "entity.player.levelup", SoundCategory.PLAYER),
LIQUID_LAVAPOP("liquid.lavapop", "block.lava.pop", SoundCategory.BLOCK), LIQUID_LAVAPOP("liquid.lavapop", "block.lava.pop", SoundCategory.BLOCK),
MOB_SHEEP_SAY("mob.sheep.say", "entity.sheep.ambient", SoundCategory.NEUTRAL), MOB_SHEEP_SAY("mob.sheep.say", "entity.sheep.ambient", SoundCategory.NEUTRAL),
MOB_SKELETON_SAY("mob.skeleton.say", "entity.skeleton.ambient", SoundCategory.HOSTILE), MOB_SKELETON_SAY("mob.skeleton.say", "entity.skeleton.ambient", SoundCategory.HOSTILE),
MOB_BLAZE_BREATHE("mob.blaze.breathe", "entity.blaze.ambient", SoundCategory.HOSTILE), MOB_BLAZE_BREATHE("mob.blaze.breathe", "entity.blaze.ambient", SoundCategory.HOSTILE),
MOB_BAT_IDLE("mob.bat.idle", "entity.bat.ambient", SoundCategory.NEUTRAL), MOB_BAT_IDLE("mob.bat.idle", "entity.bat.ambient", SoundCategory.NEUTRAL),
MOB_MAGMACUBE_BIG("mob.magmacube.big", "entity.magmacube.squish", SoundCategory.HOSTILE), MOB_MAGMACUBE_BIG("mob.magmacube.big", "entity.magmacube.squish", SoundCategory.HOSTILE),
MOB_HORSE_IDLE("mob.horse.idle", "entity.horse.ambient", SoundCategory.NEUTRAL), MOB_HORSE_IDLE("mob.horse.idle", "entity.horse.ambient", SoundCategory.NEUTRAL),
GAME_HOSTILE_HURT_FALL_SMALL("game.hostile.hurt.fall.small", "entity.generic.small_fall", SoundCategory.HOSTILE), GAME_HOSTILE_HURT_FALL_SMALL("game.hostile.hurt.fall.small", "entity.generic.small_fall", SoundCategory.HOSTILE),
MOB_HORSE_ZOMBIE_HIT("mob.horse.zombie.hit", "entity.zombie_horse.hurt", SoundCategory.NEUTRAL), MOB_HORSE_ZOMBIE_HIT("mob.horse.zombie.hit", "entity.zombie_horse.hurt", SoundCategory.NEUTRAL),
MOB_IRONGOLEM_THROW("mob.irongolem.throw", "entity.irongolem.attack", SoundCategory.NEUTRAL), MOB_IRONGOLEM_THROW("mob.irongolem.throw", "entity.irongolem.attack", SoundCategory.NEUTRAL),
DIG_CLOTH("dig.cloth", "block.cloth.place", SoundCategory.BLOCK), DIG_CLOTH("dig.cloth", "block.cloth.place", SoundCategory.BLOCK),
STEP_GRAVEL("step.gravel", "block.gravel.hit", SoundCategory.NEUTRAL), STEP_GRAVEL("step.gravel", "block.gravel.hit", SoundCategory.NEUTRAL),
MOB_SILVERFISH_SAY("mob.silverfish.say", "entity.silverfish.ambient", SoundCategory.HOSTILE), MOB_SILVERFISH_SAY("mob.silverfish.say", "entity.silverfish.ambient", SoundCategory.HOSTILE),
MOB_CAT_PURR("mob.cat.purr", "entity.cat.purr", SoundCategory.NEUTRAL), MOB_CAT_PURR("mob.cat.purr", "entity.cat.purr", SoundCategory.NEUTRAL),
MOB_ZOMBIE_INFECT("mob.zombie.infect", "entity.zombie.infect", SoundCategory.HOSTILE), MOB_ZOMBIE_INFECT("mob.zombie.infect", "entity.zombie.infect", SoundCategory.HOSTILE),
RANDOM_EAT("random.eat", "entity.generic.eat", SoundCategory.PLAYER), RANDOM_EAT("random.eat", "entity.generic.eat", SoundCategory.PLAYER),
MOB_WOLF_BARK("mob.wolf.bark", "entity.wolf.ambient", SoundCategory.NEUTRAL), MOB_WOLF_BARK("mob.wolf.bark", "entity.wolf.ambient", SoundCategory.NEUTRAL),
GAME_TNT_PRIMED("game.tnt.primed", "entity.creeper.primed", SoundCategory.BLOCK), GAME_TNT_PRIMED("game.tnt.primed", "entity.creeper.primed", SoundCategory.BLOCK),
MOB_SHEEP_STEP("mob.sheep.step", "entity.sheep.step", SoundCategory.NEUTRAL), MOB_SHEEP_STEP("mob.sheep.step", "entity.sheep.step", SoundCategory.NEUTRAL),
MOB_ZOMBIE_DEATH("mob.zombie.death", "entity.zombie.death", SoundCategory.HOSTILE), MOB_ZOMBIE_DEATH("mob.zombie.death", "entity.zombie.death", SoundCategory.HOSTILE),
RANDOM_DOOR_OPEN("random.door_open", "null", SoundCategory.BLOCK), RANDOM_DOOR_OPEN("random.door_open", "null", SoundCategory.BLOCK),
MOB_ENDERMEN_PORTAL("mob.endermen.portal", "entity.endermen.teleport", SoundCategory.HOSTILE), MOB_ENDERMEN_PORTAL("mob.endermen.portal", "entity.endermen.teleport", SoundCategory.HOSTILE),
MOB_HORSE_ANGRY("mob.horse.angry", "entity.horse.angry", SoundCategory.NEUTRAL), MOB_HORSE_ANGRY("mob.horse.angry", "entity.horse.angry", SoundCategory.NEUTRAL),
MOB_WOLF_GROWL("mob.wolf.growl", "entity.wolf.growl", SoundCategory.NEUTRAL), MOB_WOLF_GROWL("mob.wolf.growl", "entity.wolf.growl", SoundCategory.NEUTRAL),
DIG_SNOW("dig.snow", "block.snow.place", SoundCategory.BLOCK), DIG_SNOW("dig.snow", "block.snow.place", SoundCategory.BLOCK),
TILE_PISTON_OUT("tile.piston.out", "block.piston.extend", SoundCategory.BLOCK), TILE_PISTON_OUT("tile.piston.out", "block.piston.extend", SoundCategory.BLOCK),
RANDOM_BURP("random.burp", "entity.player.burp", SoundCategory.PLAYER), RANDOM_BURP("random.burp", "entity.player.burp", SoundCategory.PLAYER),
MOB_COW_STEP("mob.cow.step", "entity.cow.step", SoundCategory.NEUTRAL), MOB_COW_STEP("mob.cow.step", "entity.cow.step", SoundCategory.NEUTRAL),
MOB_WITHER_HURT("mob.wither.hurt", "entity.wither.hurt", SoundCategory.HOSTILE), MOB_WITHER_HURT("mob.wither.hurt", "entity.wither.hurt", SoundCategory.HOSTILE),
MOB_GUARDIAN_LAND_DEATH("mob.guardian.land.death", "entity.elder_guardian.death_land", SoundCategory.HOSTILE), MOB_GUARDIAN_LAND_DEATH("mob.guardian.land.death", "entity.elder_guardian.death_land", SoundCategory.HOSTILE),
MOB_CHICKEN_HURT("mob.chicken.hurt", "entity.chicken.death", SoundCategory.NEUTRAL), MOB_CHICKEN_HURT("mob.chicken.hurt", "entity.chicken.death", SoundCategory.NEUTRAL),
MOB_WOLF_STEP("mob.wolf.step", "entity.wolf.step", SoundCategory.NEUTRAL), MOB_WOLF_STEP("mob.wolf.step", "entity.wolf.step", SoundCategory.NEUTRAL),
MOB_WOLF_DEATH("mob.wolf.death", "entity.wolf.death", SoundCategory.NEUTRAL), MOB_WOLF_DEATH("mob.wolf.death", "entity.wolf.death", SoundCategory.NEUTRAL),
MOB_WOLF_WHINE("mob.wolf.whine", "entity.wolf.whine", SoundCategory.NEUTRAL), MOB_WOLF_WHINE("mob.wolf.whine", "entity.wolf.whine", SoundCategory.NEUTRAL),
NOTE_PLING("note.pling", "block.note.pling", SoundCategory.RECORD), NOTE_PLING("note.pling", "block.note.pling", SoundCategory.RECORD),
GAME_PLAYER_HURT_FALL_SMALL("game.player.hurt.fall.small", "entity.generic.small_fall", SoundCategory.PLAYER), GAME_PLAYER_HURT_FALL_SMALL("game.player.hurt.fall.small", "entity.generic.small_fall", SoundCategory.PLAYER),
MOB_CAT_PURREOW("mob.cat.purreow", "entity.cat.purreow", SoundCategory.NEUTRAL), MOB_CAT_PURREOW("mob.cat.purreow", "entity.cat.purreow", SoundCategory.NEUTRAL),
FIREWORKS_LARGEBLAST_FAR("fireworks.largeBlast_far", "entity.firework.large_blast_far", SoundCategory.AMBIENT), FIREWORKS_LARGEBLAST_FAR("fireworks.largeBlast_far", "entity.firework.large_blast_far", SoundCategory.AMBIENT),
MOB_SKELETON_HURT("mob.skeleton.hurt", "entity.skeleton.hurt", SoundCategory.HOSTILE), MOB_SKELETON_HURT("mob.skeleton.hurt", "entity.skeleton.hurt", SoundCategory.HOSTILE),
MOB_SPIDER_DEATH("mob.spider.death", "entity.spider.death", SoundCategory.HOSTILE), MOB_SPIDER_DEATH("mob.spider.death", "entity.spider.death", SoundCategory.HOSTILE),
RANDOM_ANVIL_BREAK("random.anvil_break", "block.anvil.destroy", SoundCategory.BLOCK), RANDOM_ANVIL_BREAK("random.anvil_break", "block.anvil.destroy", SoundCategory.BLOCK),
MOB_WITHER_IDLE("mob.wither.idle", "entity.wither.ambient", SoundCategory.HOSTILE), MOB_WITHER_IDLE("mob.wither.idle", "entity.wither.ambient", SoundCategory.HOSTILE),
MOB_GUARDIAN_ELDER_HIT("mob.guardian.elder.hit", "entity.elder_guardian.hurt", SoundCategory.HOSTILE), MOB_GUARDIAN_ELDER_HIT("mob.guardian.elder.hit", "entity.elder_guardian.hurt", SoundCategory.HOSTILE),
MOB_ENDERMEN_SCREAM("mob.endermen.scream", "entity.endermen.scream", SoundCategory.HOSTILE), MOB_ENDERMEN_SCREAM("mob.endermen.scream", "entity.endermen.scream", SoundCategory.HOSTILE),
MOB_CAT_HITT("mob.cat.hitt", "entity.cat.hurt", SoundCategory.NEUTRAL), MOB_CAT_HITT("mob.cat.hitt", "entity.cat.hurt", SoundCategory.NEUTRAL),
MOB_MAGMACUBE_SMALL("mob.magmacube.small", "entity.small_magmacube.squish", SoundCategory.HOSTILE), MOB_MAGMACUBE_SMALL("mob.magmacube.small", "entity.small_magmacube.squish", SoundCategory.HOSTILE),
FIRE_IGNITE("fire.ignite", "item.flintandsteel.use", SoundCategory.BLOCK, true), FIRE_IGNITE("fire.ignite", "item.flintandsteel.use", SoundCategory.BLOCK, true),
MOB_ENDERDRAGON_HIT("mob.enderdragon.hit", "entity.enderdragon.hurt", SoundCategory.HOSTILE), MOB_ENDERDRAGON_HIT("mob.enderdragon.hit", "entity.enderdragon.hurt", SoundCategory.HOSTILE),
MOB_ZOMBIE_HURT("mob.zombie.hurt", "entity.zombie_villager.hurt", SoundCategory.HOSTILE), MOB_ZOMBIE_HURT("mob.zombie.hurt", "entity.zombie_villager.hurt", SoundCategory.HOSTILE),
RANDOM_EXPLODE("random.explode", "block.end_gateway.spawn", SoundCategory.BLOCK), RANDOM_EXPLODE("random.explode", "block.end_gateway.spawn", SoundCategory.BLOCK),
MOB_SLIME_ATTACK("mob.slime.attack", "entity.slime.attack", SoundCategory.HOSTILE), MOB_SLIME_ATTACK("mob.slime.attack", "entity.slime.attack", SoundCategory.HOSTILE),
MOB_MAGMACUBE_JUMP("mob.magmacube.jump", "entity.magmacube.jump", SoundCategory.HOSTILE), MOB_MAGMACUBE_JUMP("mob.magmacube.jump", "entity.magmacube.jump", SoundCategory.HOSTILE),
RANDOM_SPLASH("random.splash", "entity.bobber.splash", SoundCategory.PLAYER), RANDOM_SPLASH("random.splash", "entity.bobber.splash", SoundCategory.PLAYER),
MOB_HORSE_SKELETON_HIT("mob.horse.skeleton.hit", "entity.skeleton_horse.hurt", SoundCategory.NEUTRAL), MOB_HORSE_SKELETON_HIT("mob.horse.skeleton.hit", "entity.skeleton_horse.hurt", SoundCategory.NEUTRAL),
MOB_GHAST_MOAN("mob.ghast.moan", "entity.ghast.ambient", SoundCategory.HOSTILE), MOB_GHAST_MOAN("mob.ghast.moan", "entity.ghast.ambient", SoundCategory.HOSTILE),
MOB_GUARDIAN_CURSE("mob.guardian.curse", "entity.elder_guardian.curse", SoundCategory.HOSTILE), MOB_GUARDIAN_CURSE("mob.guardian.curse", "entity.elder_guardian.curse", SoundCategory.HOSTILE),
GAME_POTION_SMASH("game.potion.smash", "block.glass.break", SoundCategory.NEUTRAL), GAME_POTION_SMASH("game.potion.smash", "block.glass.break", SoundCategory.NEUTRAL),
NOTE_BASSATTACK("note.bassattack", "block.note.bass", SoundCategory.RECORD), NOTE_BASSATTACK("note.bassattack", "block.note.bass", SoundCategory.RECORD),
GUI_BUTTON_PRESS("gui.button.press", "block.wood_pressureplate.click_on", SoundCategory.MASTER), GUI_BUTTON_PRESS("gui.button.press", "block.wood_pressureplate.click_on", SoundCategory.MASTER),
RANDOM_ORB("random.orb", "entity.experience_orb.pickup", SoundCategory.PLAYER), RANDOM_ORB("random.orb", "entity.experience_orb.pickup", SoundCategory.PLAYER),
MOB_ZOMBIE_WOODBREAK("mob.zombie.woodbreak", "entity.zombie.break_door_wood", SoundCategory.HOSTILE), MOB_ZOMBIE_WOODBREAK("mob.zombie.woodbreak", "entity.zombie.break_door_wood", SoundCategory.HOSTILE),
MOB_HORSE_ARMOR("mob.horse.armor", "entity.horse.armor", SoundCategory.NEUTRAL), MOB_HORSE_ARMOR("mob.horse.armor", "entity.horse.armor", SoundCategory.NEUTRAL),
TILE_PISTON_IN("tile.piston.in", "block.piston.contract", SoundCategory.BLOCK), TILE_PISTON_IN("tile.piston.in", "block.piston.contract", SoundCategory.BLOCK),
MOB_CAT_MEOW("mob.cat.meow", "entity.cat.ambient", SoundCategory.NEUTRAL), MOB_CAT_MEOW("mob.cat.meow", "entity.cat.ambient", SoundCategory.NEUTRAL),
MOB_PIG_STEP("mob.pig.step", "entity.pig.step", SoundCategory.NEUTRAL), MOB_PIG_STEP("mob.pig.step", "entity.pig.step", SoundCategory.NEUTRAL),
STEP_WOOD("step.wood", "block.wood.step", SoundCategory.NEUTRAL), STEP_WOOD("step.wood", "block.wood.step", SoundCategory.NEUTRAL),
PORTAL_TRAVEL("portal.travel", "block.portal.travel", SoundCategory.PLAYER), PORTAL_TRAVEL("portal.travel", "block.portal.travel", SoundCategory.PLAYER),
MOB_GUARDIAN_DEATH("mob.guardian.death", "entity.guardian.death", SoundCategory.HOSTILE), MOB_GUARDIAN_DEATH("mob.guardian.death", "entity.guardian.death", SoundCategory.HOSTILE),
MOB_SKELETON_DEATH("mob.skeleton.death", "entity.skeleton.death", SoundCategory.HOSTILE), MOB_SKELETON_DEATH("mob.skeleton.death", "entity.skeleton.death", SoundCategory.HOSTILE),
MOB_HORSE_HIT("mob.horse.hit", "entity.horse.hurt", SoundCategory.NEUTRAL), MOB_HORSE_HIT("mob.horse.hit", "entity.horse.hurt", SoundCategory.NEUTRAL),
MOB_VILLAGER_HIT("mob.villager.hit", "entity.villager.hurt", SoundCategory.NEUTRAL), MOB_VILLAGER_HIT("mob.villager.hit", "entity.villager.hurt", SoundCategory.NEUTRAL),
MOB_HORSE_SKELETON_IDLE("mob.horse.skeleton.idle", "entity.skeleton_horse.ambient", SoundCategory.NEUTRAL), MOB_HORSE_SKELETON_IDLE("mob.horse.skeleton.idle", "entity.skeleton_horse.ambient", SoundCategory.NEUTRAL),
RECORDS_CHIRP("records.chirp", "record.chirp", SoundCategory.RECORD), RECORDS_CHIRP("records.chirp", "record.chirp", SoundCategory.RECORD),
MOB_RABBIT_HURT("mob.rabbit.hurt", "entity.rabbit.hurt", SoundCategory.NEUTRAL), MOB_RABBIT_HURT("mob.rabbit.hurt", "entity.rabbit.hurt", SoundCategory.NEUTRAL),
RECORDS_STAL("records.stal", "record.stal", SoundCategory.RECORD), RECORDS_STAL("records.stal", "record.stal", SoundCategory.RECORD),
MUSIC_GAME_NETHER("music.game.nether", "music.nether", SoundCategory.MUSIC), MUSIC_GAME_NETHER("music.game.nether", "music.nether", SoundCategory.MUSIC),
MUSIC_MENU("music.menu", "music.menu", SoundCategory.MUSIC), MUSIC_MENU("music.menu", "music.menu", SoundCategory.MUSIC),
RECORDS_MELLOHI("records.mellohi", "record.mellohi", SoundCategory.RECORD), RECORDS_MELLOHI("records.mellohi", "record.mellohi", SoundCategory.RECORD),
RECORDS_CAT("records.cat", "record.cat", SoundCategory.RECORD), RECORDS_CAT("records.cat", "record.cat", SoundCategory.RECORD),
RECORDS_FAR("records.far", "record.far", SoundCategory.RECORD), RECORDS_FAR("records.far", "record.far", SoundCategory.RECORD),
MUSIC_GAME_END_DRAGON("music.game.end.dragon", "music.dragon", SoundCategory.MUSIC), MUSIC_GAME_END_DRAGON("music.game.end.dragon", "music.dragon", SoundCategory.MUSIC),
MOB_RABBIT_DEATH("mob.rabbit.death", "entity.rabbit.death", SoundCategory.NEUTRAL), MOB_RABBIT_DEATH("mob.rabbit.death", "entity.rabbit.death", SoundCategory.NEUTRAL),
MOB_RABBIT_IDLE("mob.rabbit.idle", "entity.rabbit.ambient", SoundCategory.NEUTRAL), MOB_RABBIT_IDLE("mob.rabbit.idle", "entity.rabbit.ambient", SoundCategory.NEUTRAL),
MUSIC_GAME_END("music.game.end", "music.end", SoundCategory.MUSIC), MUSIC_GAME_END("music.game.end", "music.end", SoundCategory.MUSIC),
MUSIC_GAME("music.game", "music.game", SoundCategory.MUSIC), MUSIC_GAME("music.game", "music.game", SoundCategory.MUSIC),
MOB_GUARDIAN_IDLE("mob.guardian.idle", "null", SoundCategory.HOSTILE), MOB_GUARDIAN_IDLE("mob.guardian.idle", "null", SoundCategory.HOSTILE),
RECORDS_WARD("records.ward", "record.ward", SoundCategory.RECORD), RECORDS_WARD("records.ward", "record.ward", SoundCategory.RECORD),
RECORDS_13("records.13", "record.13", SoundCategory.RECORD), RECORDS_13("records.13", "record.13", SoundCategory.RECORD),
MOB_RABBIT_HOP("mob.rabbit.hop", "entity.rabbit.jump", SoundCategory.NEUTRAL), MOB_RABBIT_HOP("mob.rabbit.hop", "entity.rabbit.jump", SoundCategory.NEUTRAL),
RECORDS_STRAD("records.strad", "record.strad", SoundCategory.RECORD), RECORDS_STRAD("records.strad", "record.strad", SoundCategory.RECORD),
RECORDS_11("records.11", "record.11", SoundCategory.RECORD), RECORDS_11("records.11", "record.11", SoundCategory.RECORD),
RECORDS_MALL("records.mall", "record.mall", SoundCategory.RECORD), RECORDS_MALL("records.mall", "record.mall", SoundCategory.RECORD),
RECORDS_BLOCKS("records.blocks", "record.blocks", SoundCategory.RECORD), RECORDS_BLOCKS("records.blocks", "record.blocks", SoundCategory.RECORD),
RECORDS_WAIT("records.wait", "record.wait", SoundCategory.RECORD), RECORDS_WAIT("records.wait", "record.wait", SoundCategory.RECORD),
MUSIC_GAME_END_CREDITS("music.game.end.credits", "music.credits", SoundCategory.MUSIC), MUSIC_GAME_END_CREDITS("music.game.end.credits", "music.credits", SoundCategory.MUSIC),
MUSIC_GAME_CREATIVE("music.game.creative", "music.creative", SoundCategory.MUSIC); MUSIC_GAME_CREATIVE("music.game.creative", "music.creative", SoundCategory.MUSIC);
private final String name; private final String name;
private final String newName; private final String newName;
private final SoundCategory category; private final SoundCategory category;
private final boolean breaksound; private final boolean breaksound;
SoundEffect(String name, String newname, SoundCategory cat) { SoundEffect(String name, String newname, SoundCategory cat) {
this.category = cat; this.category = cat;
this.newName = newname; this.newName = newname;
this.name = name; this.name = name;
this.breaksound = name.startsWith("dig."); this.breaksound = name.startsWith("dig.");
} }
SoundEffect(String name, String newname, SoundCategory cat, boolean shouldIgnore) { SoundEffect(String name, String newname, SoundCategory cat, boolean shouldIgnore) {
this.category = cat; this.category = cat;
this.newName = newname; this.newName = newname;
this.name = name; this.name = name;
this.breaksound = name.startsWith("dig.") || shouldIgnore; this.breaksound = name.startsWith("dig.") || shouldIgnore;
} }
public static SoundEffect getByName(String name) { public static SoundEffect getByName(String name) {
name = name.toLowerCase(); name = name.toLowerCase();
for (SoundEffect e : SoundEffect.values()) { for (SoundEffect e : SoundEffect.values()) {
if (e.getName().equals(name)) if (e.getName().equals(name))
return e; return e;
} }
return null; return null;
} }
} }

Datei anzeigen

@ -1,12 +1,12 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.storage; package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.util.ReflectionUtil; import us.myles.ViaVersion.util.ReflectionUtil;
import us.myles.ViaVersion2.api.data.StoredObject;
import us.myles.ViaVersion2.api.data.UserConnection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -14,8 +14,6 @@ import java.util.logging.Level;
@Getter @Getter
public class ClientChunks extends StoredObject { public class ClientChunks extends StoredObject {
private final Set<Long> loadedChunks = Sets.newConcurrentHashSet();
private final Set<Long> bulkChunks = Sets.newConcurrentHashSet();
// Reflection // Reflection
private static ReflectionUtil.ClassReflection mapChunkBulkRef; private static ReflectionUtil.ClassReflection mapChunkBulkRef;
private static ReflectionUtil.ClassReflection mapChunkRef; private static ReflectionUtil.ClassReflection mapChunkRef;
@ -29,10 +27,17 @@ public class ClientChunks extends StoredObject {
} }
} }
private final Set<Long> loadedChunks = Sets.newConcurrentHashSet();
private final Set<Long> bulkChunks = Sets.newConcurrentHashSet();
public ClientChunks(UserConnection user) { public ClientChunks(UserConnection user) {
super(user); super(user);
} }
private static long toLong(int msw, int lsw) {
return ((long) msw << 32) + lsw - -2147483648L;
}
public List<Object> transformMapChunkBulk(Object packet) { public List<Object> transformMapChunkBulk(Object packet) {
List<Object> list = Lists.newArrayList(); List<Object> list = Lists.newArrayList();
try { try {
@ -56,9 +61,4 @@ public class ClientChunks extends StoredObject {
} }
return list; return list;
} }
private static long toLong(int msw, int lsw) {
return ((long) msw << 32) + lsw - -2147483648L;
}
} }

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.storage; package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.Getter; import lombok.Getter;
@ -7,18 +7,17 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.boss.BossBar; import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor; import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle; import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion2.api.PacketWrapper; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion2.api.data.StoredObject; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion2.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion2.api.item.Item; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion2.api.metadata.Metadata; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.protocol.base.ProtocolInfo;
import us.myles.ViaVersion2.api.type.Type;
import java.util.*; import java.util.*;
@ -119,15 +118,18 @@ public class EntityTracker extends StoredObject {
if ((data & 0x20) == 0x20) { if ((data & 0x20) == 0x20) {
if (!knownHolograms.contains(entityID)) { if (!knownHolograms.contains(entityID)) {
knownHolograms.add(entityID); knownHolograms.add(entityID);
// Send movement try {
ByteBuf buf = getUser().getChannel().alloc().buffer(); // Send movement
PacketUtil.writeVarInt(0x25, buf); // Relative Move Packet ByteBuf buf = getUser().getChannel().alloc().buffer();
PacketUtil.writeVarInt(entityID, buf); Type.VAR_INT.write(buf, 0x25); // Relative Move Packet
buf.writeShort(0); Type.VAR_INT.write(buf, entityID);
buf.writeShort((short) (128D * (((ViaVersionPlugin) ViaVersion.getInstance()).getHologramYOffset() * 32D))); buf.writeShort(0);
buf.writeShort(0); buf.writeShort((short) (128D * (((ViaVersionPlugin) ViaVersion.getInstance()).getHologramYOffset() * 32D)));
buf.writeBoolean(true); buf.writeShort(0);
getUser().sendRawPacket(buf, false); buf.writeBoolean(true);
getUser().sendRawPacket(buf, false);
} catch (Exception ignored) {
}
} }
} }
} }

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.storage; package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import us.myles.ViaVersion2.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion2.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@Getter @Getter
@Setter @Setter

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.storage; package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
import lombok.Getter; import lombok.Getter;
import us.myles.ViaVersion2.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion2.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
public class MovementTracker extends StoredObject{ public class MovementTracker extends StoredObject {
private static final long IDLE_PACKET_DELAY = 50L; // Update every 50ms (20tps) private static final long IDLE_PACKET_DELAY = 50L; // Update every 50ms (20tps)
private static final long IDLE_PACKET_LIMIT = 20; // Max 20 ticks behind private static final long IDLE_PACKET_LIMIT = 20; // Max 20 ticks behind
@Getter @Getter

Datei anzeigen

@ -1,13 +1,13 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.types; package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import us.myles.ViaVersion.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.chunks.ChunkSection; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.api.type.PartialType;
import us.myles.ViaVersion2.api.protocol1_9to1_8.storage.ClientChunks; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.PartialType; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@ -33,14 +33,18 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
super(chunks, Chunk.class); super(chunks, Chunk.class);
} }
private static long toLong(int msw, int lsw) {
return ((long) msw << 32) + lsw - -2147483648L;
}
@Override @Override
public Chunk read(ByteBuf input, ClientChunks param) { public Chunk read(ByteBuf input, ClientChunks param) throws Exception {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
long chunkHash = toLong(chunkX, chunkZ); long chunkHash = toLong(chunkX, chunkZ);
boolean groundUp = input.readByte() != 0; boolean groundUp = input.readByte() != 0;
int bitmask = input.readUnsignedShort(); int bitmask = input.readUnsignedShort();
int dataLength = PacketUtil.readVarInt(input); int dataLength = Type.VAR_INT.read(input);
// Data to be read // Data to be read
BitSet usedSections = new BitSet(16); BitSet usedSections = new BitSet(16);
@ -123,40 +127,36 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
} }
@Override @Override
public void write(ByteBuf output, ClientChunks param, Chunk chunk) { public void write(ByteBuf output, ClientChunks param, Chunk chunk) throws Exception {
if(chunk.isUnloadPacket()) { if (chunk.isUnloadPacket()) {
output.clear(); output.clear();
PacketUtil.writeVarInt(0x1D, output); // Unload packet ID Type.VAR_INT.write(output, 0x1D); // Unload packet ID
} }
// Write primary info // Write primary info
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
if(chunk.isUnloadPacket()) return; if (chunk.isUnloadPacket()) return;
output.writeByte(chunk.isGroundUp() ? 0x01 : 0x00); output.writeByte(chunk.isGroundUp() ? 0x01 : 0x00);
PacketUtil.writeVarInt(chunk.getPrimaryBitmask(), output); Type.VAR_INT.write(output, chunk.getPrimaryBitmask());
ByteBuf buf = Unpooled.buffer(); ByteBuf buf = Unpooled.buffer();
for(int i = 0; i < SECTION_COUNT; i++) { for (int i = 0; i < SECTION_COUNT; i++) {
ChunkSection section = chunk.getSections()[i]; ChunkSection section = chunk.getSections()[i];
if(section == null) continue; // Section not set if (section == null) continue; // Section not set
section.writeBlocks(buf); section.writeBlocks(buf);
section.writeBlockLight(buf); section.writeBlockLight(buf);
if(!section.hasSkyLight()) continue; // No sky light, we're done here. if (!section.hasSkyLight()) continue; // No sky light, we're done here.
section.writeSkyLight(buf); section.writeSkyLight(buf);
} }
buf.readerIndex(0); buf.readerIndex(0);
PacketUtil.writeVarInt(buf.readableBytes() + (chunk.hasBiomeData() ? 256 : 0), output); Type.VAR_INT.write(output, buf.readableBytes() + (chunk.hasBiomeData() ? 256 : 0));
output.writeBytes(buf); output.writeBytes(buf);
buf.release(); // release buffer buf.release(); // release buffer
// Write biome data // Write biome data
if(chunk.hasBiomeData()) { if (chunk.hasBiomeData()) {
output.writeBytes(chunk.getBiomeData()); output.writeBytes(chunk.getBiomeData());
} }
} }
private static long toLong(int msw, int lsw) {
return ((long) msw << 32) + lsw - -2147483648L;
}
} }

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.types; package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion2.api.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion2.api.protocol1_9to1_8.types; package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion2.api.protocol1_9to1_8.metadata.MetadataTypes; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion2.api.type.Type; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataTypes;
public class MetadataType extends Type<Metadata> { public class MetadataType extends Type<Metadata> {

Datei anzeigen

@ -9,14 +9,14 @@ import org.bukkit.plugin.Plugin;
@RequiredArgsConstructor @RequiredArgsConstructor
public class UpdateListener implements Listener { public class UpdateListener implements Listener {
private final Plugin plugin; private final Plugin plugin;
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
if(e.getPlayer().hasPermission("viaversion.update") if (e.getPlayer().hasPermission("viaversion.update")
&& plugin.getConfig().getBoolean("checkforupdates", true)) { && plugin.getConfig().getBoolean("checkforupdates", true)) {
UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId(), plugin); UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId(), plugin);
} }
} }
} }

Datei anzeigen

@ -20,11 +20,10 @@ import java.util.UUID;
public class UpdateUtil { public class UpdateUtil {
public final static String PREFIX = ChatColor.GREEN + "" + ChatColor.BOLD + "[ViaVersion] " + ChatColor.GREEN;
private final static String URL = "http://api.spiget.org/v1/resources/"; private final static String URL = "http://api.spiget.org/v1/resources/";
private final static int PLUGIN = 19254; private final static int PLUGIN = 19254;
public final static String PREFIX = ChatColor.GREEN + "" + ChatColor.BOLD + "[ViaVersion] " + ChatColor.GREEN;
public static void sendUpdateMessage(final UUID uuid, final Plugin plugin) { public static void sendUpdateMessage(final UUID uuid, final Plugin plugin) {
new BukkitRunnable() { new BukkitRunnable() {

Datei anzeigen

@ -17,9 +17,9 @@ import java.util.logging.Level;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class Configuration extends YamlConfiguration { public class Configuration extends YamlConfiguration {
private List<String> mainHeader = Lists.newArrayList();
private final Map<String, List<String>> headers = Maps.newConcurrentMap(); private final Map<String, List<String>> headers = Maps.newConcurrentMap();
private final File file; private final File file;
private List<String> mainHeader = Lists.newArrayList();
private boolean loadHeaders; private boolean loadHeaders;
public Configuration(File file) { public Configuration(File file) {
@ -47,7 +47,7 @@ public class Configuration extends YamlConfiguration {
/** /**
* Set option header. * Set option header.
* *
* @param key of option (or section) * @param key of option (or section)
* @param header of option (or section) * @param header of option (or section)
*/ */
public void header(String key, String... header) { public void header(String key, String... header) {
@ -85,14 +85,14 @@ public class Configuration extends YamlConfiguration {
this.loadHeaders = loadHeaders; this.loadHeaders = loadHeaders;
try { try {
load(file); load(file);
} catch(Exception e) { } catch (Exception e) {
Bukkit.getLogger().log(Level.WARNING, "failed to reload file", e); Bukkit.getLogger().log(Level.WARNING, "failed to reload file", e);
} }
} }
@Override @Override
public void loadFromString(String contents) throws InvalidConfigurationException { public void loadFromString(String contents) throws InvalidConfigurationException {
if(!loadHeaders) { if (!loadHeaders) {
super.loadFromString(contents); super.loadFromString(contents);
return; return;
} }
@ -105,12 +105,12 @@ public class Configuration extends YamlConfiguration {
int currentIndents = 0; int currentIndents = 0;
String key = ""; String key = "";
List<String> headers = Lists.newArrayList(); List<String> headers = Lists.newArrayList();
for(String line : contents.split("\n")) { for (String line : contents.split("\n")) {
if(line.isEmpty()) continue; // Skip empty lines if (line.isEmpty()) continue; // Skip empty lines
int indent = getSuccessiveCharCount(line, ' '); int indent = getSuccessiveCharCount(line, ' ');
String subline = indent > 0 ? line.substring(indent) : line; String subline = indent > 0 ? line.substring(indent) : line;
if(subline.startsWith("#")) { if (subline.startsWith("#")) {
if(subline.startsWith("#>")) { if (subline.startsWith("#>")) {
String txt = subline.startsWith("#> ") ? subline.substring(3) : subline.substring(2); String txt = subline.startsWith("#> ") ? subline.substring(3) : subline.substring(2);
mainHeader.add(txt); mainHeader.add(txt);
continue; // Main header, handled by bukkit continue; // Main header, handled by bukkit
@ -123,7 +123,7 @@ public class Configuration extends YamlConfiguration {
} }
int indents = indent / indentLength; int indents = indent / indentLength;
if(indents <= currentIndents) { if (indents <= currentIndents) {
// Remove last section of key // Remove last section of key
String[] array = key.split(Pattern.quote(pathSeparator)); String[] array = key.split(Pattern.quote(pathSeparator));
int backspace = currentIndents - indents + 1; int backspace = currentIndents - indents + 1;
@ -138,7 +138,7 @@ public class Configuration extends YamlConfiguration {
currentIndents = indents; currentIndents = indents;
memoryData.append(line).append('\n'); memoryData.append(line).append('\n');
if(!headers.isEmpty()) { if (!headers.isEmpty()) {
this.headers.put(key, headers); this.headers.put(key, headers);
headers = Lists.newArrayList(); headers = Lists.newArrayList();
} }
@ -155,10 +155,10 @@ public class Configuration extends YamlConfiguration {
* Save config to file * Save config to file
*/ */
public void save() { public void save() {
if(headers.isEmpty() && mainHeader.isEmpty()) { if (headers.isEmpty() && mainHeader.isEmpty()) {
try { try {
super.save(file); super.save(file);
} catch(IOException e) { } catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "Failed to save file", e); Bukkit.getLogger().log(Level.WARNING, "Failed to save file", e);
} }
return; return;
@ -171,17 +171,17 @@ public class Configuration extends YamlConfiguration {
StringBuilder fileData = new StringBuilder(buildHeader()); StringBuilder fileData = new StringBuilder(buildHeader());
int currentIndents = 0; int currentIndents = 0;
String key = ""; String key = "";
for(String h : mainHeader) { for (String h : mainHeader) {
// Append main header to top of file // Append main header to top of file
fileData.append("#> ").append(h).append('\n'); fileData.append("#> ").append(h).append('\n');
} }
for(String line : content.split("\n")) { for (String line : content.split("\n")) {
if(line.isEmpty()) continue; // Skip empty lines if (line.isEmpty()) continue; // Skip empty lines
int indent = getSuccessiveCharCount(line, ' '); int indent = getSuccessiveCharCount(line, ' ');
int indents = indent / indentLength; int indents = indent / indentLength;
String indentText = indent > 0 ? line.substring(0, indent) : ""; String indentText = indent > 0 ? line.substring(0, indent) : "";
if(indents <= currentIndents) { if (indents <= currentIndents) {
// Remove last section of key // Remove last section of key
String[] array = key.split(Pattern.quote(pathSeparator)); String[] array = key.split(Pattern.quote(pathSeparator));
int backspace = currentIndents - indents + 1; int backspace = currentIndents - indents + 1;
@ -206,13 +206,13 @@ public class Configuration extends YamlConfiguration {
writer = new FileWriter(file); writer = new FileWriter(file);
writer.write(fileData.toString()); writer.write(fileData.toString());
writer.flush(); writer.flush();
} catch(IOException e) { } catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "Failed to save file", e); Bukkit.getLogger().log(Level.WARNING, "Failed to save file", e);
} finally { } finally {
if(writer != null) { if (writer != null) {
try { try {
writer.close(); writer.close();
} catch(IOException e) { } catch (IOException ignored) {
} }
} }
} }
@ -220,7 +220,7 @@ public class Configuration extends YamlConfiguration {
private String addHeaderTags(List<String> header, String indent) { private String addHeaderTags(List<String> header, String indent) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for(String line : header) { for (String line : header) {
builder.append(indent).append("# ").append(line).append('\n'); builder.append(indent).append("# ").append(line).append('\n');
} }
return builder.toString(); return builder.toString();
@ -234,8 +234,8 @@ public class Configuration extends YamlConfiguration {
private int getSuccessiveCharCount(String text, char key) { private int getSuccessiveCharCount(String text, char key) {
int count = 0; int count = 0;
for(int i = 0; i < text.length(); i++) { for (int i = 0; i < text.length(); i++) {
if(text.charAt(i) == key) { if (text.charAt(i) == key) {
count += 1; count += 1;
} else { } else {
break; break;

Datei anzeigen

@ -1,294 +0,0 @@
package us.myles.ViaVersion.util;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;
import org.spacehq.opennbt.NBTIO;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class PacketUtil {
private static Method DECODE_METHOD;
private static Method ENCODE_METHOD;
static {
try {
DECODE_METHOD = ByteToMessageDecoder.class.getDeclaredMethod("decode", ChannelHandlerContext.class, ByteBuf.class, List.class);
DECODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
try {
ENCODE_METHOD = MessageToByteEncoder.class.getDeclaredMethod("encode", ChannelHandlerContext.class, Object.class, ByteBuf.class);
ENCODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
}
public static CompoundTag readNBT(ByteBuf input) throws IOException {
// Default client is limited to 2097152 bytes. (2.09mb)
Preconditions.checkArgument(input.readableBytes() <= 2097152, "Cannot read NBT (got %s bytes)", input.readableBytes());
int readerIndex = input.readerIndex();
byte b = input.readByte();
if (b == 0) {
return null;
} else {
input.readerIndex(readerIndex);
ByteBufInputStream bytebufStream = new ByteBufInputStream(input);
DataInputStream dataInputStream = new DataInputStream(bytebufStream);
try {
return (CompoundTag) NBTIO.readTag(dataInputStream);
} finally {
dataInputStream.close();
}
}
}
public static void writeNBT(ByteBuf output, CompoundTag tag) throws IOException {
if (tag == null) {
output.writeByte(0);
} else {
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(output);
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream);
NBTIO.writeTag(dataOutputStream, tag);
dataOutputStream.close();
}
}
public static List<Object> callDecode(ByteToMessageDecoder decoder, ChannelHandlerContext ctx, Object input) throws InvocationTargetException {
List<Object> output = new ArrayList<>();
try {
PacketUtil.DECODE_METHOD.invoke(decoder, ctx, input, output);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return output;
}
public static void callEncode(MessageToByteEncoder encoder, ChannelHandlerContext ctx, Object msg, ByteBuf output) throws InvocationTargetException {
try {
PacketUtil.ENCODE_METHOD.invoke(encoder, ctx, msg, output);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
/* I take no credit, these are taken from BungeeCord */
// https://github.com/SpigotMC/BungeeCord/blob/master/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
public static void writeString(String s, ByteBuf buf) {
Preconditions.checkArgument(s.length() <= Short.MAX_VALUE, "Cannot send string longer than Short.MAX_VALUE (got %s characters)", s.length());
byte[] b = s.getBytes(Charsets.UTF_8);
writeVarInt(b.length, buf);
buf.writeBytes(b);
}
public static String readString(ByteBuf buf) {
int len = readVarInt(buf);
Preconditions.checkArgument(len <= Short.MAX_VALUE, "Cannot receive string longer than Short.MAX_VALUE (got %s characters)", len);
byte[] b = new byte[len];
buf.readBytes(b);
return new String(b, Charsets.UTF_8);
}
public static void writeArrayLegacy(byte[] b, ByteBuf buf, boolean allowExtended) {
// (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit
if (allowExtended) {
Preconditions.checkArgument(b.length <= (Integer.MAX_VALUE & 0x1FFF9A), "Cannot send array longer than 2097050 (got %s bytes)", b.length);
} else {
Preconditions.checkArgument(b.length <= Short.MAX_VALUE, "Cannot send array longer than Short.MAX_VALUE (got %s bytes)", b.length);
}
// Write a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only)
// No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour.
writeVarShort(buf, b.length);
buf.writeBytes(b);
}
public static byte[] readArrayLegacy(ByteBuf buf) {
// Read in a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only)
// No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour.
int len = readVarShort(buf);
// (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit
Preconditions.checkArgument(len <= (Integer.MAX_VALUE & 0x1FFF9A), "Cannot receive array longer than 2097050 (got %s bytes)", len);
byte[] ret = new byte[len];
buf.readBytes(ret);
return ret;
}
public static void writeArray(byte[] b, ByteBuf buf) {
writeVarInt(b.length, buf);
buf.writeBytes(b);
}
public static byte[] readArray(ByteBuf buf) {
byte[] ret = new byte[readVarInt(buf)];
buf.readBytes(ret);
return ret;
}
public static void writeStringArray(List<String> s, ByteBuf buf) {
writeVarInt(s.size(), buf);
for (String str : s) {
writeString(str, buf);
}
}
public static List<String> readStringArray(ByteBuf buf) {
int len = readVarInt(buf);
List<String> ret = new ArrayList<>(len);
for (int i = 0; i < len; i++) {
ret.add(readString(buf));
}
return ret;
}
public static int readVarInt(ByteBuf input) {
return readVarInt(input, 5);
}
public static int readVarInt(ByteBuf input, int maxBytes) {
int out = 0;
int bytes = 0;
byte in;
while (true) {
in = input.readByte();
out |= (in & 0x7F) << (bytes++ * 7);
if (bytes > maxBytes) {
throw new RuntimeException("VarInt too big");
}
if ((in & 0x80) != 0x80) {
break;
}
}
return out;
}
public static void writeVarInt(int value, ByteBuf output) {
int part;
while (true) {
part = value & 0x7F;
value >>>= 7;
if (value != 0) {
part |= 0x80;
}
output.writeByte(part);
if (value == 0) {
break;
}
}
}
public static void writeVarIntArray(List<Integer> integers, ByteBuf output) {
writeVarInt(integers.size(), output);
for (Integer i : integers) {
writeVarInt(i, output);
}
}
public static int readVarShort(ByteBuf buf) {
int low = buf.readUnsignedShort();
int high = 0;
if ((low & 0x8000) != 0) {
low = low & 0x7FFF;
high = buf.readUnsignedByte();
}
return ((high & 0xFF) << 15) | low;
}
public static void writeVarShort(ByteBuf buf, int toWrite) {
int low = toWrite & 0x7FFF;
int high = (toWrite & 0x7F8000) >> 15;
if (high != 0) {
low = low | 0x8000;
}
buf.writeShort(low);
if (high != 0) {
buf.writeByte(high);
}
}
public static void writeUUID(UUID value, ByteBuf output) {
output.writeLong(value.getMostSignificantBits());
output.writeLong(value.getLeastSignificantBits());
}
public static UUID readUUID(ByteBuf input) {
return new UUID(input.readLong(), input.readLong());
}
public static void writeLongs(long[] data, ByteBuf output) {
for (long aData : data) {
output.writeLong(aData);
}
}
public static long[] readLongs(int amount, ByteBuf output) {
long data[] = new long[amount];
for (int index = 0; index < amount; index++) {
data[index] = output.readLong();
}
return data;
}
public static long[] readBlockPosition(ByteBuf buf) {
long val = buf.readLong();
long x = (val >> 38); // signed
long y = (val >> 26) & 0xfff; // unsigned
// this shifting madness is used to preserve sign
long z = (val << 38) >> 38; // signed
return new long[]{x, y, z};
}
public static void writeBlockPosition(ByteBuf buf, long x, long y, long z) {
buf.writeLong(((x & 0x3ffffff) << 38) | ((y & 0xfff) << 26) | (z & 0x3ffffff));
}
public static int[] readVarInts(int amount, ByteBuf input) {
int data[] = new int[amount];
for (int index = 0; index < amount; index++) {
data[index] = PacketUtil.readVarInt(input);
}
return data;
}
public static boolean containsCause(Throwable t, Class<? extends Throwable> c) {
while (t != null) {
t = t.getCause();
if (t != null)
if (c.isAssignableFrom(t.getClass())) return true;
}
return false;
}
}

Datei anzeigen

@ -0,0 +1,60 @@
package us.myles.ViaVersion.util;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class PipelineUtil {
private static Method DECODE_METHOD;
private static Method ENCODE_METHOD;
static {
try {
DECODE_METHOD = ByteToMessageDecoder.class.getDeclaredMethod("decode", ChannelHandlerContext.class, ByteBuf.class, List.class);
DECODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
try {
ENCODE_METHOD = MessageToByteEncoder.class.getDeclaredMethod("encode", ChannelHandlerContext.class, Object.class, ByteBuf.class);
ENCODE_METHOD.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.out.println("Netty issue?");
}
}
public static List<Object> callDecode(ByteToMessageDecoder decoder, ChannelHandlerContext ctx, Object input) throws InvocationTargetException {
List<Object> output = new ArrayList<>();
try {
PipelineUtil.DECODE_METHOD.invoke(decoder, ctx, input, output);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return output;
}
public static void callEncode(MessageToByteEncoder encoder, ChannelHandlerContext ctx, Object msg, ByteBuf output) throws InvocationTargetException {
try {
PipelineUtil.ENCODE_METHOD.invoke(encoder, ctx, msg, output);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
public static boolean containsCause(Throwable t, Class<? extends Throwable> c) {
while (t != null) {
t = t.getCause();
if (t != null)
if (c.isAssignableFrom(t.getClass())) return true;
}
return false;
}
}

Datei anzeigen

@ -17,6 +17,7 @@ public class ReflectionUtil {
public static Class<?> nms(String className) throws ClassNotFoundException { public static Class<?> nms(String className) throws ClassNotFoundException {
return Class.forName(NMS + "." + className); return Class.forName(NMS + "." + className);
} }
public static Class<?> obc(String className) throws ClassNotFoundException { public static Class<?> obc(String className) throws ClassNotFoundException {
return Class.forName(BASE + "." + className); return Class.forName(BASE + "." + className);
} }
@ -77,22 +78,22 @@ public class ReflectionUtil {
} }
private void scanFields(Class<?> host, boolean recursive) { private void scanFields(Class<?> host, boolean recursive) {
if(host.getSuperclass() != null && recursive) { if (host.getSuperclass() != null && recursive) {
scanFields(host.getSuperclass(), true); scanFields(host.getSuperclass(), true);
} }
for(Field field : host.getDeclaredFields()) { for (Field field : host.getDeclaredFields()) {
field.setAccessible(true); field.setAccessible(true);
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
} }
private void scanMethods(Class<?> host, boolean recursive) { private void scanMethods(Class<?> host, boolean recursive) {
if(host.getSuperclass() != null && recursive) { if (host.getSuperclass() != null && recursive) {
scanMethods(host.getSuperclass(), true); scanMethods(host.getSuperclass(), true);
} }
for(Method method : host.getDeclaredMethods()) { for (Method method : host.getDeclaredMethods()) {
method.setAccessible(true); method.setAccessible(true);
methods.put(method.getName(), method); methods.put(method.getName(), method);
} }

Datei anzeigen

@ -1,8 +0,0 @@
package us.myles.ViaVersion2.api.remapper;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion2.api.PacketWrapper;
public interface ValueReader<T> {
public T read(PacketWrapper wrapper) throws Exception;
}

Datei anzeigen

@ -1,7 +0,0 @@
package us.myles.ViaVersion2.api.remapper;
import us.myles.ViaVersion2.api.PacketWrapper;
public interface ValueWriter<T> {
public void write(PacketWrapper writer, T inputValue) throws Exception;
}

Datei anzeigen

@ -1,7 +0,0 @@
package us.myles.ViaVersion2.api.type;
import io.netty.buffer.ByteBuf;
public interface ByteBufReader<T> {
public T read(ByteBuf buffer) throws Exception;
}

Datei anzeigen

@ -1,7 +0,0 @@
package us.myles.ViaVersion2.api.type;
import io.netty.buffer.ByteBuf;
public interface ByteBufWriter<T> {
public void write(ByteBuf buffer, T object) throws Exception;
}

Datei anzeigen

@ -1,5 +0,0 @@
package us.myles.ViaVersion2.api.type;
public interface TypeConverter<T> {
public T from(Object o);
}