3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00
Dieser Commit ist enthalten in:
Matsv 2017-06-08 18:29:38 +02:00
Ursprung 34d9ccbd5b
Commit 85286095d7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 97CEC2A2EA31350F
5 geänderte Dateien mit 70 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -171,7 +171,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_11To1_11_1> {
Optional<EntityData> optEntDat = getEntityData(type);
if (optEntDat.isPresent()) {
EntityData data = optEntDat.get();
wrapper.set(Type.UNSIGNED_BYTE, 0, ((Integer) data.getReplacementId()).shortValue());
wrapper.set(Type.VAR_INT, 1, data.getReplacementId());
if (data.hasBaseMeta())
data.getDefaultMeta().handle(storage);
}

Datei anzeigen

@ -13,8 +13,10 @@ package nl.matsv.viabackwards.protocol.protocol1_12to1_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_12to1_11_1.packets.BlockItemPackets1_12;
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets.ChangedPacketIds;
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets.EntityPackets1_12;
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets.SoundPackets1_12;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@ -26,6 +28,8 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol {
protected void registerPackets() {
new ChangedPacketIds().register(this);
(entityPackets = new EntityPackets1_12()).register(this);
new SoundPackets1_12().register(this);
new BlockItemPackets1_12().register(this);
}
@Override

Datei anzeigen

@ -0,0 +1,46 @@
/*
* 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_12to1_11_1.packets;
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
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.packets.State;
public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12> {
@Override
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
// Client Status
protocol.registerIncoming(State.PLAY, 0x04, 0x03, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Action ID
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
// Open Inventory
if (wrapper.get(Type.VAR_INT, 0) == 2)
wrapper.cancel(); // TODO is this replaced by something else?
}
});
}
});
}
@Override
protected void registerRewrites() {
}
}

Datei anzeigen

@ -89,7 +89,7 @@ public class ChangedPacketIds extends Rewriter<Protocol1_11_1To1_12> {
p.registerIncoming(State.PLAY, 0x01, -1); // Prepare Crafting Grid
p.registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (Serverbound)
p.registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (Serverbound)
p.registerIncoming(State.PLAY, 0x04, 0x03); // Client Status
// 0x04->0x03 Client Status handled in BlockItemPackets1_12.java
p.registerIncoming(State.PLAY, 0x05, 0x04); // Client Settings
p.registerIncoming(State.PLAY, 0x06, 0x05); // Confirm Transaction (Serverbound)
p.registerIncoming(State.PLAY, 0x07, 0x06); // Enchant Item

Datei anzeigen

@ -19,6 +19,8 @@ import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
@ -28,7 +30,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.Optional;
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.getTypeFromId;
import static nl.matsv.viabackwards.api.entities.types.EntityType1_12.*;
public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
@Override
@ -62,7 +64,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
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));
Optional<EntityType1_12.ObjectType> type = ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent()) {
Optional<EntityData> optEntDat = getObjectData(type.get());
@ -95,7 +97,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
addTrackedEntity(
wrapper.user(),
wrapper.get(Type.VAR_INT, 0),
EntityType1_12.ObjectType.THROWN_EXP_BOTTLE.getType()
ObjectType.THROWN_EXP_BOTTLE.getType()
);
}
});
@ -116,7 +118,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
addTrackedEntity(
wrapper.user(),
wrapper.get(Type.VAR_INT, 0),
EntityType1_12.EntityType.WEATHER // Always thunder according to wiki.vg
EntityType.WEATHER // Always thunder according to wiki.vg
);
}
});
@ -171,7 +173,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
Optional<EntityData> optEntDat = getEntityData(type);
if (optEntDat.isPresent()) {
EntityData data = optEntDat.get();
wrapper.set(Type.UNSIGNED_BYTE, 0, ((Integer) data.getReplacementId()).shortValue());
wrapper.set(Type.VAR_INT, 1, data.getReplacementId());
if (data.hasBaseMeta())
data.getDefaultMeta().handle(storage);
}
@ -200,7 +202,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
addTrackedEntity(
wrapper.user(),
wrapper.get(Type.VAR_INT, 0),
EntityType1_12.EntityType.PAINTING
EntityType.PAINTING
);
}
});
@ -227,7 +229,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
addTrackedEntity(
wrapper.user(),
wrapper.get(Type.VAR_INT, 0),
EntityType1_12.EntityType.PLAYER
EntityType.PLAYER
);
}
});
@ -264,7 +266,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
addTrackedEntity(
wrapper.user(),
wrapper.get(Type.INT, 0),
EntityType1_12.EntityType.PLAYER
EntityType.PLAYER
);
}
});
@ -340,15 +342,18 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
@Override
protected void registerRewrites() {
// Todo handle IllusionIllager and do research what it is
// Todo handle Parrot and do research what it is
regEntType(EntityType.PARROT, EntityType.BAT).spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
// Parrot Variant TODO
registerMetaHandler().filter(EntityType1_12.EntityType.PARROT, 15).removed();
// Parrot remove animal metadata
registerMetaHandler().filter(EntityType.PARROT, 12).removed(); // Is baby
registerMetaHandler().filter(EntityType.PARROT, 13).removed(); // Flags (Is sitting etc, might be useful in the future (bat inactive TODO do more research about this entity)
registerMetaHandler().filter(EntityType.PARROT, 14).removed(); // Owner
registerMetaHandler().filter(EntityType.PARROT, 15).removed(); // Variant
// Left shoulder entity data
registerMetaHandler().filter(EntityType1_12.EntityType.PLAYER, 15).removed();
registerMetaHandler().filter(EntityType.PLAYER, 15).removed();
// Right shoulder entity data
registerMetaHandler().filter(EntityType1_12.EntityType.PLAYER, 16).removed();
registerMetaHandler().filter(EntityType.PLAYER, 16).removed();
}
}