Compare commits

..
6 Commits
9 changed files with 35 additions and 31 deletions

No files matched your search

+6 -6
View File
@@ -1,17 +1,17 @@
##### What version of ViaBackwards are you using? Type /ver ViaBackwards:
### What version of ViaBackwards are you using? Type /ver ViaBackwards:
##### What version of ViaVersion are you using? Type /ver ViaVersion:
### What version of ViaVersion are you using? Type /ver ViaVersion:
##### What version of Spigot are you using? Type /ver:
### What version of Spigot are you using? Type /ver:
##### What plugins are you using? Type /plugins:
### What plugins are you using? Type /plugins:
##### How/when does this error happen? login?:
### How/when does this error happen? login?:
##### Is there an error in the console? Use pastebin.com. Is there a kick message?:
### Is there an error in the console? Use pastebin.com. Is there a kick message?:
+1 -1
View File
@@ -24,7 +24,7 @@
<groupId>nl.matsv</groupId>
<artifactId>viabackwards</artifactId>
<version>1.0</version>
<version>1.0.1</version>
<repositories>
<repository>
@@ -24,6 +24,8 @@ import nl.matsv.viabackwards.api.MetaRewriter;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.storage.EntityTracker;
import nl.matsv.viabackwards.api.storage.EntityType;
import org.bukkit.Bukkit;
import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@@ -32,6 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
@RequiredArgsConstructor
public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
@@ -107,6 +110,13 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
}
newMeta.add(nmd);
} catch (RemovedValueException ignored) {
} catch (Exception e) {
if (ViaVersion.getInstance().isDebug()) {
Logger log = Bukkit.getPluginManager().getPlugin("ViaBackwards").getLogger();
log.warning("Unable to handle metadata " + md);
log.warning("Full metadata list " + metaData);
e.printStackTrace();
}
}
}
@@ -24,6 +24,8 @@ public abstract class Rewriter<T extends BackwardsProtocol> {
/**
* Register everything
*
* @param protocol Protocol instance
*/
public void register(T protocol) {
registerPackets(protocol);
@@ -40,7 +40,9 @@ public class Protocol1_9To1_10 extends BackwardsProtocol {
}
public void init(UserConnection user) {
user.put(new ClientWorld(user));
// Register ClientWorld
if (!user.has(ClientWorld.class))
user.put(new ClientWorld(user));
// Register EntityTracker if it doesn't exist yet.
if (!user.has(EntityTracker.class))
@@ -34,7 +34,7 @@ public class Chunk1_10 implements Chunk {
private int bitmask;
private ChunkSection1_10[] sections;
private byte[] biomeData;
List<CompoundTag> blockEntities;
private List<CompoundTag> blockEntities;
@Override
public boolean isBiomeData() {
@@ -20,6 +20,7 @@ package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.chunks;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.apache.commons.lang.IllegalClassException;
import org.bukkit.World;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
@@ -46,7 +47,7 @@ public class Chunk1_10Type extends PartialType<Chunk, ClientWorld> {
boolean groundUp = input.readBoolean();
int primaryBitmask = Type.VAR_INT.read(input);
int size = Type.VAR_INT.read(input);
Type.VAR_INT.read(input);
BitSet usedSections = new BitSet(16);
ChunkSection1_10[] sections = new ChunkSection1_10[16];
@@ -82,7 +83,7 @@ public class Chunk1_10Type extends PartialType<Chunk, ClientWorld> {
@Override
public void write(ByteBuf output, ClientWorld world, Chunk input) throws Exception {
if (!(input instanceof Chunk1_10))
throw new Exception("Tried to send the wrong chunk type from 1.9.3-4 chunk: " + input.getClass());
throw new IllegalClassException("Tried to send the wrong chunk type from 1.9.3-4 chunk: " + input.getClass());
Chunk1_10 chunk = (Chunk1_10) input;
output.writeInt(chunk.getX());
@@ -124,9 +124,7 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_9To1_10> {
});
// Click window packet
protocol.registerIncoming(State.PLAY, 0x07, 0x07, new
PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x07, 0x07, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
@@ -145,13 +143,10 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_9To1_10> {
});
}
}
);
// Creative Inventory Action
protocol.registerIncoming(State.PLAY, 0x18, 0x18, new
PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x18, 0x18, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.SHORT); // 0 - Slot
@@ -166,15 +161,12 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_9To1_10> {
});
}
}
);
/* Block packets */
// Chunk packet
protocol.registerOutgoing(State.PLAY, 0x20, 0x20, new
PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@@ -206,13 +198,10 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_9To1_10> {
});
}
}
);
// Block Change Packet
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new
PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION); // 0 - Block Position
@@ -227,13 +216,10 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_9To1_10> {
});
}
}
);
// Multi Block Change Packet
protocol.registerOutgoing(State.PLAY, 0x10, 0x10, new
PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Chunk X
@@ -255,7 +241,6 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_9To1_10> {
});
}
}
);
/* Register Metadata */
@@ -322,6 +322,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
protected void registerRewrites() {
rewriteEntityId(102, 91); // Replace polar bear with sheep
// Handle Polar bear
registerMetaRewriter((isObject, entityType, data) -> { // Change the sheep color when the polar bear is stending up
if (!isObject && entityType != 102)
return data;
@@ -337,6 +338,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
return data;
});
// Handle Husk
registerMetaRewriter((isObject, entityType, data) -> { // Change husk to normal zombie
if (isObject || entityType != 54)
return data;
@@ -346,6 +348,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
return data;
});
// Handle stray
registerMetaRewriter((isObject, entityType, data) -> { // Change stray- to normal skeleton
if (isObject || entityType != 51)
return data;
@@ -355,6 +358,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
return data;
});
// Handle the missing NoGravity tag
registerMetaRewriter((isObject, entityType, m) -> {
if (m.getId() == 5)
throw new RemovedValueException();