use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class PCPlayerListItemPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerPlayerListEntryPacket packet) {
PlayerListPacket pk = new PlayerListPacket();
if (packet.getAction() == PlayerListEntryAction.ADD_PLAYER) {
PlayerListEntry[] entries = packet.getEntries();
Set<org.dragonet.protocol.type.PlayerListEntry> peEntries = new HashSet();
for (PlayerListEntry entry : entries) {
session.getPlayerInfoCache().put(entry.getProfile().getId(), entry);
org.dragonet.protocol.type.PlayerListEntry peEntry = new org.dragonet.protocol.type.PlayerListEntry();
peEntry.uuid = entry.getProfile().getId();
peEntry.eid = 1;
peEntry.username = entry.getProfile().getName();
peEntry.skin = Skin.DEFAULT_SKIN_STEVE;
peEntry.xboxUserId = entry.getProfile().getId().toString();
peEntries.add(peEntry);
}
pk.type = PlayerListPacket.TYPE_ADD;
pk.entries = (org.dragonet.protocol.type.PlayerListEntry[]) peEntries.toArray(new org.dragonet.protocol.type.PlayerListEntry[peEntries.size()]);
} else if (packet.getAction() == PlayerListEntryAction.REMOVE_PLAYER) {
PlayerListEntry[] entries = packet.getEntries();
Set<org.dragonet.protocol.type.PlayerListEntry> peEntries = new HashSet();
for (PlayerListEntry entry : entries) {
session.getPlayerInfoCache().remove(entry.getProfile().getId());
org.dragonet.protocol.type.PlayerListEntry peEntry = new org.dragonet.protocol.type.PlayerListEntry();
peEntry.uuid = entry.getProfile().getId();
peEntry.eid = 1;
peEntry.username = entry.getProfile().getName();
peEntry.skin = Skin.DEFAULT_SKIN_STEVE;
peEntry.xboxUserId = entry.getProfile().getId().toString();
peEntries.add(peEntry);
}
pk.type = PlayerListPacket.TYPE_REMOVE;
pk.entries = (org.dragonet.protocol.type.PlayerListEntry[]) peEntries.toArray(new org.dragonet.protocol.type.PlayerListEntry[peEntries.size()]);
}
return new PEPacket[] { pk };
}
use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class PCSoundEventPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerPlayBuiltinSoundPacket packet) {
LevelSoundEventPacket pk = new LevelSoundEventPacket();
// System.out.println("BuiltIn Sound packet: " + packet.getSound().name());
pk.position = new Vector3F((float) packet.getX(), (float) packet.getY(), (float) packet.getZ());
switch(packet.getSound()) {
case BLOCK_CHEST_OPEN:
pk.sound = LevelSoundEventPacket.Sound.CHEST_OPEN;
break;
case BLOCK_CHEST_CLOSE:
pk.sound = LevelSoundEventPacket.Sound.CHEST_CLOSED;
break;
case BLOCK_SHULKER_BOX_OPEN:
pk.sound = LevelSoundEventPacket.Sound.SHULKER_BOX_OPEN;
break;
case BLOCK_SHULKER_BOX_CLOSE:
pk.sound = LevelSoundEventPacket.Sound.SHULKER_BOX_CLOSE;
break;
case ENCHANT_THORNS_HIT:
pk.sound = LevelSoundEventPacket.Sound.THORNS;
break;
case ENTITY_ARROW_SHOOT:
pk.sound = LevelSoundEventPacket.Sound.SHOOT;
break;
case ENTITY_ARROW_HIT_PLAYER:
pk.sound = LevelSoundEventPacket.Sound.HIT;
break;
case ENTITY_ARROW_HIT:
pk.sound = LevelSoundEventPacket.Sound.BOW_HIT;
break;
case ENTITY_GENERIC_EXTINGUISH_FIRE:
case BLOCK_FIRE_EXTINGUISH:
pk.sound = LevelSoundEventPacket.Sound.EXTINGUISH_FIRE;
break;
case ENTITY_CAT_PURR:
pk.sound = LevelSoundEventPacket.Sound.PURR;
break;
case ENTITY_CAT_PURREOW:
pk.sound = LevelSoundEventPacket.Sound.PURREOW;
break;
case ENTITY_HORSE_GALLOP:
pk.sound = LevelSoundEventPacket.Sound.GALLOP;
break;
case ENTITY_LIGHTNING_THUNDER:
pk.sound = LevelSoundEventPacket.Sound.THUNDER;
break;
case ENTITY_PLAYER_LEVELUP:
pk.sound = LevelSoundEventPacket.Sound.LEVEL_UP;
break;
case ENTITY_LEASHKNOT_PLACE:
pk.sound = LevelSoundEventPacket.Sound.LEASHKNOT_PLACE;
break;
case ENTITY_LEASHKNOT_BREAK:
pk.sound = LevelSoundEventPacket.Sound.LEASHKNOT_BREAK;
break;
case ENTITY_SHULKER_OPEN:
pk.sound = LevelSoundEventPacket.Sound.SHULKER_OPEN;
break;
case ENTITY_SHULKER_CLOSE:
pk.sound = LevelSoundEventPacket.Sound.SHULKER_CLOSE;
break;
case ITEM_BOTTLE_FILL_DRAGONBREATH:
pk.sound = LevelSoundEventPacket.Sound.BOTTLE_DRAGON_BREATH;
break;
case ITEM_BUCKET_FILL_LAVA:
pk.sound = LevelSoundEventPacket.Sound.BUCKET_FILL_LAVA;
break;
case ITEM_BUCKET_EMPTY_LAVA:
pk.sound = LevelSoundEventPacket.Sound.BUCKET_EMPTY_LAVA;
break;
case ITEM_BUCKET_FILL:
pk.sound = LevelSoundEventPacket.Sound.BUCKET_FILL_WATER;
break;
case ITEM_BUCKET_EMPTY:
pk.sound = LevelSoundEventPacket.Sound.BUCKET_EMPTY_WATER;
break;
case RECORD_11:
pk.sound = LevelSoundEventPacket.Sound.RECORD_11;
break;
case RECORD_13:
pk.sound = LevelSoundEventPacket.Sound.RECORD_13;
break;
case RECORD_BLOCKS:
pk.sound = LevelSoundEventPacket.Sound.RECORD_BLOCKS;
break;
case RECORD_CAT:
pk.sound = LevelSoundEventPacket.Sound.RECORD_CAT;
break;
case RECORD_CHIRP:
pk.sound = LevelSoundEventPacket.Sound.RECORD_CHIRP;
break;
case RECORD_FAR:
pk.sound = LevelSoundEventPacket.Sound.RECORD_FAR;
break;
case RECORD_MALL:
pk.sound = LevelSoundEventPacket.Sound.RECORD_MALL;
break;
case RECORD_MELLOHI:
pk.sound = LevelSoundEventPacket.Sound.RECORD_MELLOHI;
break;
case RECORD_STAL:
pk.sound = LevelSoundEventPacket.Sound.RECORD_STAL;
break;
case RECORD_STRAD:
pk.sound = LevelSoundEventPacket.Sound.RECORD_STRAD;
break;
case RECORD_WAIT:
pk.sound = LevelSoundEventPacket.Sound.RECORD_WAIT;
break;
case RECORD_WARD:
pk.sound = LevelSoundEventPacket.Sound.RECORD_WARD;
break;
case ENTITY_ZOMBIE_VILLAGER_CONVERTED:
pk.sound = LevelSoundEventPacket.Sound.UNFECT;
break;
case ENTITY_ZOMBIE_VILLAGER_CURE:
pk.sound = LevelSoundEventPacket.Sound.REMEDY;
break;
case ENTITY_SHEEP_SHEAR:
case ENTITY_MOOSHROOM_SHEAR:
pk.sound = LevelSoundEventPacket.Sound.SHEAR;
break;
case BLOCK_GRASS_BREAK:
case BLOCK_ANVIL_BREAK:
case BLOCK_GLASS_BREAK:
case BLOCK_CLOTH_BREAK:
case BLOCK_GRAVEL_BREAK:
case BLOCK_LADDER_BREAK:
case BLOCK_METAL_BREAK:
case BLOCK_SAND_BREAK:
case BLOCK_SLIME_BREAK:
case BLOCK_SNOW_BREAK:
case BLOCK_STONE_BREAK:
case BLOCK_WOOD_BREAK:
pk.sound = LevelSoundEventPacket.Sound.BREAK_BLOCK;
break;
case BLOCK_GRASS_PLACE:
case BLOCK_ANVIL_PLACE:
case BLOCK_CLOTH_PLACE:
case BLOCK_GLASS_PLACE:
case BLOCK_GRAVEL_PLACE:
case BLOCK_LADDER_PLACE:
case BLOCK_METAL_PLACE:
case BLOCK_SAND_PLACE:
case BLOCK_SLIME_PLACE:
case BLOCK_SNOW_PLACE:
case BLOCK_STONE_PLACE:
case BLOCK_WATERLILY_PLACE:
case BLOCK_WOOD_PLACE:
pk.sound = LevelSoundEventPacket.Sound.PLACE;
break;
case BLOCK_LAVA_POP:
pk.sound = LevelSoundEventPacket.Sound.POP;
break;
case BLOCK_PORTAL_TRAVEL:
pk.sound = LevelSoundEventPacket.Sound.PORTAL;
break;
case BLOCK_LEVER_CLICK:
case BLOCK_COMPARATOR_CLICK:
case BLOCK_STONE_BUTTON_CLICK_ON:
case BLOCK_METAL_PRESSUREPLATE_CLICK_ON:
case BLOCK_STONE_PRESSUREPLATE_CLICK_ON:
case BLOCK_TRIPWIRE_CLICK_ON:
case BLOCK_WOOD_BUTTON_CLICK_ON:
case BLOCK_WOOD_PRESSUREPLATE_CLICK_ON:
pk.sound = LevelSoundEventPacket.Sound.POWER_ON;
break;
case BLOCK_METAL_PRESSUREPLATE_CLICK_OFF:
case BLOCK_STONE_BUTTON_CLICK_OFF:
case BLOCK_STONE_PRESSUREPLATE_CLICK_OFF:
case BLOCK_TRIPWIRE_CLICK_OFF:
case BLOCK_WOOD_BUTTON_CLICK_OFF:
case BLOCK_WOOD_PRESSUREPLATE_CLICK_OFF:
pk.sound = LevelSoundEventPacket.Sound.POWER_OFF;
break;
case BLOCK_NOTE_BASEDRUM:
case BLOCK_NOTE_BASS:
case BLOCK_NOTE_BELL:
case BLOCK_NOTE_CHIME:
case BLOCK_NOTE_FLUTE:
case BLOCK_NOTE_GUITAR:
case BLOCK_NOTE_HARP:
case BLOCK_NOTE_HAT:
case BLOCK_NOTE_PLING:
case BLOCK_NOTE_SNARE:
case BLOCK_NOTE_XYLOPHONE:
pk.sound = LevelSoundEventPacket.Sound.NOTE;
break;
case BLOCK_PISTON_EXTEND:
pk.sound = LevelSoundEventPacket.Sound.PISTON_OUT;
break;
case BLOCK_PISTON_CONTRACT:
pk.sound = LevelSoundEventPacket.Sound.PISTON_IN;
break;
case ENTITY_BOBBER_THROW:
case ENTITY_EGG_THROW:
case ENTITY_ENDERPEARL_THROW:
case ENTITY_EXPERIENCE_BOTTLE_THROW:
case ENTITY_LINGERINGPOTION_THROW:
case ENTITY_SNOWBALL_THROW:
case ENTITY_SPLASH_POTION_THROW:
case ENTITY_WITCH_THROW:
pk.sound = LevelSoundEventPacket.Sound.THROW;
break;
case ITEM_FLINTANDSTEEL_USE:
pk.sound = LevelSoundEventPacket.Sound.IGNITE;
break;
case ENTITY_TNT_PRIMED:
// Fix
pk.sound = LevelSoundEventPacket.Sound.EVENT_SOUND_TNT;
break;
case ENTITY_GENERIC_EXPLODE:
pk.sound = LevelSoundEventPacket.Sound.EXPLODE;
break;
default:
return null;
}
return new PEPacket[] { pk };
}
use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class PCChatPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerChatPacket packet) {
TextPacket pe = new TextPacket();
switch(packet.getType()) {
case NOTIFICATION:
pe.message = pe.message = MessageTranslator.translate(packet.getMessage());
pe.type = TYPE_POPUP;
break;
case CHAT:
if (packet.getMessage() instanceof TranslationMessage) {
pe.type = TYPE_TRANSLATION;
pe.needsTranslation = true;
pe.message = MessageTranslator.translationTranslateText((TranslationMessage) packet.getMessage());
pe.params = MessageTranslator.translationTranslateParams(((TranslationMessage) packet.getMessage()).getTranslationParams());
} else {
pe.message = pe.message = MessageTranslator.translate(packet.getMessage());
pe.type = TYPE_RAW;
}
break;
case SYSTEM:
if (packet.getMessage() instanceof TranslationMessage) {
pe.type = TYPE_TRANSLATION;
pe.needsTranslation = true;
pe.message = MessageTranslator.translationTranslateText((TranslationMessage) packet.getMessage());
pe.params = MessageTranslator.translationTranslateParams(((TranslationMessage) packet.getMessage()).getTranslationParams());
} else {
pe.message = pe.message = MessageTranslator.translate(packet.getMessage());
pe.type = TYPE_RAW;
}
break;
}
return new PEPacket[] { pe };
}
use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class PCEntityEffectPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityEffectPacket 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;
}
}
int effectId = MagicValues.value(Integer.class, packet.getEffect());
PocketPotionEffect effect = PocketPotionEffect.getByID(effectId);
if (effect == null) {
System.out.println("Unknown effect ID: " + effectId);
return null;
}
MobEffectPacket eff = new MobEffectPacket();
eff.rtid = entity.proxyEid;
eff.effectId = effect.getEffect();
if (entity.effects.contains(effectId)) {
eff.eventId = MobEffectPacket.EVENT_MODIFY;
} else {
eff.eventId = MobEffectPacket.EVENT_ADD;
entity.effects.add(effectId);
}
eff.amplifier = packet.getAmplifier();
eff.duration = packet.getDuration();
eff.particles = packet.getShowParticles();
return new PEPacket[] { eff };
}
use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class PCEntityHeadLookPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityHeadLookPacket 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;
}
}
entity.headYaw = packet.getHeadYaw();
MoveEntityPacket pk = new MoveEntityPacket();
pk.rtid = entity.proxyEid;
pk.yaw = (byte) (entity.yaw / (360d / 256d));
pk.headYaw = (byte) (entity.headYaw / (360d / 256d));
pk.pitch = (byte) (entity.pitch / (360d / 256d));
pk.position = new Vector3F((float) entity.x, (float) entity.y + entity.peType.getOffset(), (float) entity.z);
pk.onGround = true;
return new PEPacket[] { pk };
}
Aggregations