mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-18 16:17:45 +01:00
Handle FallingBlocks in 1.9.4-1.11.2
This commit is contained in:
parent
2a1f6602ba
commit
a8e81935cc
@ -14,7 +14,7 @@ import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
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.EntityPackets1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.SoundPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
@ -23,13 +23,15 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_10To1_11 extends BackwardsProtocol {
|
||||
@Getter
|
||||
private EntityPackets entityPackets; // Required for the item rewriter
|
||||
private EntityPackets1_11 entityPackets; // Required for the item rewriter
|
||||
@Getter
|
||||
private BlockItemPackets blockItemPackets;
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
(entityPackets = new EntityPackets()).register(this);
|
||||
(entityPackets = new EntityPackets1_11()).register(this);
|
||||
new PlayerPackets().register(this);
|
||||
new BlockItemPackets().register(this);
|
||||
(blockItemPackets = new BlockItemPackets()).register(this);
|
||||
new SoundPackets().register(this);
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,12 @@ import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
@ -34,7 +36,7 @@ import java.util.Optional;
|
||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.*;
|
||||
|
||||
|
||||
public class EntityPackets extends EntityRewriter<Protocol1_10To1_11> {
|
||||
public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_10To1_11 protocol) {
|
||||
@ -84,6 +86,23 @@ public class EntityPackets extends EntityRewriter<Protocol1_10To1_11> {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Optional<EntityType1_12.ObjectType> type = EntityType1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get().equals(EntityType1_12.ObjectType.FALLING_BLOCK)) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
|
||||
Block block = getProtocol().getBlockItemPackets().handleBlock(objType, data);
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -13,18 +13,18 @@ package nl.matsv.viabackwards.protocol.protocol1_11to1_11_1;
|
||||
import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
@Getter
|
||||
public class Protocol1_11To1_11_1 extends BackwardsProtocol {
|
||||
private EntityPackets entityPackets;
|
||||
private EntityPackets1_11_1 entityPackets;
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
(entityPackets = new EntityPackets()).register(this);
|
||||
(entityPackets = new EntityPackets1_11_1()).register(this);
|
||||
new ItemPackets().register(this);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ import java.util.Optional;
|
||||
|
||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.*;
|
||||
|
||||
public class EntityPackets extends EntityRewriter<Protocol1_11To1_11_1> {
|
||||
public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_11To1_11_1 protocol) {
|
@ -83,7 +83,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
||||
}
|
||||
});
|
||||
|
||||
// Replace falling blocks
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
|
@ -15,20 +15,21 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.ChangedPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.SoundPackets;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
@Getter
|
||||
public class Protocol1_9_4To1_10 extends BackwardsProtocol {
|
||||
private EntityPackets entityPackets; // Required for the item rewriter
|
||||
private EntityPackets1_10 entityPackets; // Required for the item rewriter
|
||||
private BlockItemPackets blockItemPackets;
|
||||
|
||||
protected void registerPackets() {
|
||||
new ChangedPackets().register(this);
|
||||
new SoundPackets().register(this);
|
||||
(entityPackets = new EntityPackets()).register(this);
|
||||
new BlockItemPackets().register(this);
|
||||
(entityPackets = new EntityPackets1_10()).register(this);
|
||||
(blockItemPackets = new BlockItemPackets()).register(this);
|
||||
}
|
||||
|
||||
public void init(UserConnection user) {
|
||||
|
@ -16,9 +16,11 @@ import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_10;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_11;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
@ -35,7 +37,7 @@ import java.util.Optional;
|
||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_10.EntityType;
|
||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.getTypeFromId;
|
||||
|
||||
public class EntityPackets extends EntityRewriter<Protocol1_9_4To1_10> {
|
||||
public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_9_4To1_10 protocol) {
|
||||
@ -86,6 +88,23 @@ public class EntityPackets extends EntityRewriter<Protocol1_9_4To1_10> {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Optional<EntityType1_12.ObjectType> type = EntityType1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get().equals(EntityType1_12.ObjectType.FALLING_BLOCK)) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
|
||||
Block block = getProtocol().getBlockItemPackets().handleBlock(objType, data);
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user