Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into vehicles
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/dragonet/proxy/protocol/Protocol.java
  • Loading branch information
HoverEpic committed Dec 24, 2017
2 parents cb316ea + 3aa7ee9 commit fdeaf62
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public final class PacketTranslatorRegister {
PC_TO_PE_TRANSLATOR.put(ServerEntityRotationPacket.class, new PCEntityRotationPacketTranslator());
PC_TO_PE_TRANSLATOR.put(ServerEntityVelocityPacket.class, new PCEntityVelocityPacketTranslator());
PC_TO_PE_TRANSLATOR.put(ServerEntityEffectPacket.class, new PCEntityEffectPacketTranslator());
PC_TO_PE_TRANSLATOR.put(ServerEntityEquipmentPacket.class, new PCEntityEquipmentPacketTranslator());
PC_TO_PE_TRANSLATOR.put(ServerEntityRemoveEffectPacket.class, new PCEntityRemoveEffectPacketTranslator());
PC_TO_PE_TRANSLATOR.put(ServerPlayerHealthPacket.class, new PCUpdateHealthPacketTranslator());
PC_TO_PE_TRANSLATOR.put(ServerEntityAnimationPacket.class, new PCAnimationPacketTranslator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import java.util.UUID;

import org.dragonet.proxy.data.entity.EntityType;
import org.dragonet.proxy.protocol.type.Slot;

import com.github.steveice10.mc.protocol.data.game.entity.EquipmentSlot;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType;
import java.util.HashMap;
Expand Down Expand Up @@ -46,10 +48,15 @@ public class CachedEntity {
public float yaw;
public float headYaw;
public float pitch;

public boolean shouldMove = false;

public BlockPosition spawnPosition;

public Slot helmet;
public Slot chestplate;
public Slot leggings;
public Slot boots;

// cache riding datas for dismount
public long riding = 0;
public Set<Long> passengers = new HashSet();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.dragonet.proxy.network.translator.pc;

import org.dragonet.proxy.network.CacheKey;
import org.dragonet.proxy.network.UpstreamSession;
import org.dragonet.proxy.network.cache.CachedEntity;
import org.dragonet.proxy.network.translator.IPCPacketTranslator;
import org.dragonet.proxy.network.translator.ItemBlockTranslator;
import org.dragonet.proxy.protocol.PEPacket;
import org.dragonet.proxy.protocol.packets.MobArmorEquipmentPacket;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityEquipmentPacket;

public class PCEntityEquipmentPacketTranslator implements IPCPacketTranslator<ServerEntityEquipmentPacket> {

@Override
public PEPacket[] translate(UpstreamSession session, ServerEntityEquipmentPacket packet) {
CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
if (entity == null) {
if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
entity = session.getEntityCache().getClientEntity();
} else {
return null;
}
return null;
}

ItemStack items = packet.getItem();
MobArmorEquipmentPacket aeq = new MobArmorEquipmentPacket();
switch(packet.getSlot()) {
case HELMET:
entity.helmet = ItemBlockTranslator.translateSlotToPE(items);
break;
case CHESTPLATE:
entity.chestplate = ItemBlockTranslator.translateSlotToPE(items);
break;
case LEGGINGS:
entity.leggings = ItemBlockTranslator.translateSlotToPE(items);
break;
case BOOTS:
entity.boots = ItemBlockTranslator.translateSlotToPE(items);
break;
case MAIN_HAND:
break;
case OFF_HAND:
break;
}
aeq.helmet = entity.helmet;
aeq.chestplate = entity.chestplate;
aeq.leggings = entity.leggings;
aeq.boots = entity.boots;
aeq.rtid = entity.proxyEid;
return new PEPacket[]{aeq};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.dragonet.proxy.protocol.packets;

import org.dragonet.proxy.protocol.PEPacket;
import org.dragonet.proxy.protocol.ProtocolInfo;
import org.dragonet.proxy.protocol.type.Slot;

public class MobArmorEquipmentPacket extends PEPacket {

public long rtid;
public Slot helmet;
public Slot chestplate;
public Slot leggings;
public Slot boots;

@Override
public int pid() {
return ProtocolInfo.MOB_ARMOR_EQUIPMENT_PACKET;
}

@Override
public void encodePayload() {
putUnsignedVarLong(rtid);
putSlot(helmet);
putSlot(chestplate);
putSlot(leggings);
putSlot(boots);

}

@Override
public void decodePayload() {
rtid = getUnsignedVarLong();
helmet = getSlot();
chestplate = getSlot();
leggings = getSlot();
boots = getSlot();
}

}

0 comments on commit fdeaf62

Please sign in to comment.