mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-25 12:45:35 +01:00
Start working on the 1.11 update (Far from stable)
This commit is contained in:
parent
04508e8c5c
commit
58810243dc
@ -10,6 +10,7 @@
|
||||
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
|
@ -11,6 +11,7 @@
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
|
||||
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
||||
|
||||
|
@ -12,6 +12,7 @@ package nl.matsv.viabackwards;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
|
||||
public class ViaBackwards {
|
||||
@Getter
|
||||
|
@ -8,8 +8,10 @@
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards;
|
||||
package nl.matsv.viabackwards.api;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
@ -24,6 +26,7 @@ public interface ViaBackwardsPlatform {
|
||||
default void init() {
|
||||
ViaBackwards.init(this);
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_9_4To1_10(), Collections.singletonList(ProtocolVersion.v1_9_3.getId()), ProtocolVersion.v1_10.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_10To1_11(), Collections.singletonList(ProtocolVersion.v1_10.getId()), ProtocolVersion.v1_11.getId());
|
||||
}
|
||||
|
||||
/**
|
@ -57,8 +57,8 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
||||
if (item == null || item.getTag() == null)
|
||||
return null;
|
||||
CompoundTag tag = item.getTag();
|
||||
if (tag.contains("ViaBackwards")) {
|
||||
CompoundTag via = tag.get("ViaBackwards");
|
||||
if (tag.contains("ViaBackwards|" + getProtocolName())) {
|
||||
CompoundTag via = tag.get("ViaBackwards|" + getProtocolName());
|
||||
|
||||
short id = (short) via.get("id").getValue();
|
||||
short data = (short) via.get("data").getValue();
|
||||
@ -70,7 +70,7 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
||||
item.setAmount(amount);
|
||||
item.setTag(converter.convert("", converter.convert(extras)));
|
||||
// Remove data tag
|
||||
tag.remove("ViaBackwards");
|
||||
tag.remove("ViaBackwards|" + getProtocolName());
|
||||
}
|
||||
return item;
|
||||
}
|
||||
@ -87,7 +87,7 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
||||
}
|
||||
|
||||
private CompoundTag createViaNBT(Item i) {
|
||||
CompoundTag tag = new CompoundTag("ViaBackwards");
|
||||
CompoundTag tag = new CompoundTag("ViaBackwards|" + getProtocolName());
|
||||
tag.put(new ShortTag("id", i.getId()));
|
||||
tag.put(new ShortTag("data", i.getData()));
|
||||
tag.put(new ByteTag("amount", i.getAmount()));
|
||||
@ -104,4 +104,8 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
||||
((CompoundTag) tag.get("display")).put(new StringTag("Name", text));
|
||||
return tag;
|
||||
}
|
||||
|
||||
private String getProtocolName() {
|
||||
return getProtocol().getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,12 @@
|
||||
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
|
||||
public abstract class Rewriter<T extends BackwardsProtocol> {
|
||||
@Getter
|
||||
private T protocol;
|
||||
|
||||
/**
|
||||
* Register everything
|
||||
@ -20,6 +23,7 @@ public abstract class Rewriter<T extends BackwardsProtocol> {
|
||||
* @param protocol Protocol instance
|
||||
*/
|
||||
public void register(T protocol) {
|
||||
this.protocol = protocol;
|
||||
registerPackets(protocol);
|
||||
registerRewrites();
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_10to1_11;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.EntityPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
public class Protocol1_10To1_11 extends BackwardsProtocol {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
new EntityPackets().register(this);
|
||||
new PlayerPackets().register(this);
|
||||
new BlockItemPackets().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.chunks.Chunk1_10;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.chunks.Chunk1_10Type;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.chunks.ChunkSection1_10;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class BlockItemPackets extends BlockItemRewriter<Protocol1_10To1_11> {
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_10To1_11 protocol) {
|
||||
/* Item packets */
|
||||
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x16, 0x16, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item stack = wrapper.get(Type.ITEM, 0);
|
||||
wrapper.set(Type.ITEM, 0, handleItemToClient(stack));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Window items packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x14, 0x14, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.ITEM_ARRAY); // 1 - Window Values
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
for (int i = 0; i < stacks.length; i++)
|
||||
stacks[i] = handleItemToClient(stacks[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3C, 0x3C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item stack = wrapper.get(Type.ITEM, 0);
|
||||
wrapper.set(Type.ITEM, 0, handleItemToClient(stack));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem)
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x07, 0x07, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
handleItemToServer(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Creative Inventory Action
|
||||
protocol.registerIncoming(State.PLAY, 0x18, 0x18, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.ITEM); // 1 - Clicked Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
handleItemToServer(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Block packets */
|
||||
|
||||
// Chunk packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_10Type type = new Chunk1_10Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
Chunk1_10 chunk = (Chunk1_10) wrapper.passthrough(type);
|
||||
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection1_10 section = chunk.getSections()[i];
|
||||
if (section == null)
|
||||
continue;
|
||||
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int block = section.getBlockId(x, y, z);
|
||||
if (containsBlock(block)) {
|
||||
Block b = handleBlock(block);
|
||||
section.setBlock(x, y, z, b.getId(), b.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Multi Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int count = wrapper.passthrough(Type.VAR_INT); // Array length
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Horizontal position
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Y coords
|
||||
|
||||
int id = wrapper.read(Type.VAR_INT); // Block ID
|
||||
wrapper.write(Type.VAR_INT, handleBlockID(id));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected int handleBlockID(int idx) {
|
||||
int type = idx >> 4;
|
||||
|
||||
if (!containsBlock(type))
|
||||
return idx;
|
||||
|
||||
Block b = handleBlock(type);
|
||||
return (b.getId() << 4 | (b.getData() & 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// ShulkerBoxes to chests
|
||||
for (int i = 219; i < 235; i++)
|
||||
rewriteBlockItem(i,
|
||||
new Item((short) 54, (byte) 1, (short) 0, getNamedTag("1.11 Shulker Box (Color #" + (i - 219) + ")")),
|
||||
new Block(i, 1));
|
||||
|
||||
// Observer to Dispenser
|
||||
rewriteBlockItem(218, new Item((short) 23, (byte) 1, (short) 0, getNamedTag("1.11 Observer")), new Block(23, 0));
|
||||
|
||||
// Totem of Undying to Dead Bush
|
||||
rewriteItem(449, new Item((short) 32, (byte) 1, (short) 0, getNamedTag("1.11 Totem of Undying")));
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
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.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class EntityPackets extends EntityRewriter<Protocol1_10To1_11> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_10To1_11 protocol) {
|
||||
// Spawn Mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// TODO
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
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.protocols.protocol1_11to1_10.Protocol1_11To1_10;
|
||||
|
||||
public class PlayerPackets {
|
||||
private static final ValueTransformer<Short, Float> toNewFloat = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@Override
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
|
||||
return (float) (inputValue / 16);
|
||||
}
|
||||
};
|
||||
|
||||
public void register(Protocol1_10To1_11 protocol) {
|
||||
/* Outgoing packets */
|
||||
|
||||
// Title packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x45, 0x45, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
// Handle the new ActionBar
|
||||
if (action == 2) {
|
||||
// Convert to the old actionbar way
|
||||
PacketWrapper actionbar = new PacketWrapper(0x0F, null, wrapper.user()); // Chat Message packet
|
||||
actionbar.write(Type.STRING, wrapper.read(Type.STRING));
|
||||
actionbar.write(Type.BYTE, (byte) 2); // Above hotbar
|
||||
|
||||
actionbar.send(Protocol1_11To1_10.class);
|
||||
|
||||
wrapper.cancel(); // Cancel the title packet
|
||||
return;
|
||||
}
|
||||
|
||||
if (action > 2)
|
||||
wrapper.set(Type.VAR_INT, 0, action - 1); // Move everything one position down
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// Collect item packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x48, 0x48, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Collected entity id
|
||||
map(Type.VAR_INT); // 1 - Collector entity id
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
packetWrapper.read(Type.VAR_INT); // Ignore pickup item count
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* Incoming packets */
|
||||
|
||||
// Block placement packet
|
||||
protocol.registerIncoming(State.PLAY, 0x1C, 0x1C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Location
|
||||
map(Type.VAR_INT); // 1 - Face
|
||||
map(Type.VAR_INT); // 2 - Hand
|
||||
|
||||
map(Type.UNSIGNED_BYTE, toNewFloat);
|
||||
map(Type.UNSIGNED_BYTE, toNewFloat);
|
||||
map(Type.UNSIGNED_BYTE, toNewFloat);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -25,7 +25,6 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
// TODO REWRITE PLUGINS MESSAGE ITEMS
|
||||
public class BlockItemPackets extends BlockItemRewriter<Protocol1_9_4To1_10> {
|
||||
|
||||
protected void registerPackets(Protocol1_9_4To1_10 protocol) {
|
||||
|
2
pom.xml
2
pom.xml
@ -58,7 +58,7 @@
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -11,6 +11,7 @@
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import nl.matsv.viabackwards.sponge.VersionInfo;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user