use of com.lying.variousoddities.proxy.CommonProxy in project VariousOddities by Lyinginbedmon.
the class PacketSpeciesOpenScreen method handle.
public static void handle(PacketSpeciesOpenScreen msg, Supplier<NetworkEvent.Context> cxt) {
NetworkEvent.Context context = cxt.get();
if (context.getDirection().getReceptionSide().isServer())
context.setPacketHandled(true);
else {
CommonProxy proxy = (CommonProxy) VariousOddities.proxy;
proxy.openSpeciesSelectScreen(proxy.getPlayerEntity(context));
context.setPacketHandled(true);
}
}
use of com.lying.variousoddities.proxy.CommonProxy in project VariousOddities by Lyinginbedmon.
the class PacketSyncAbilities method handle.
public static void handle(PacketSyncAbilities msg, Supplier<NetworkEvent.Context> cxt) {
NetworkEvent.Context context = cxt.get();
if (context.getDirection().getReceptionSide().isClient()) {
PlayerEntity player = ((CommonProxy) VariousOddities.proxy).getPlayerEntity(context);
if (player != null) {
World world = player.getEntityWorld();
if (world != null) {
LivingEntity entity = null;
for (LivingEntity living : world.getEntitiesWithinAABB(LivingEntity.class, Minecraft.getInstance().player.getBoundingBox().grow(64D))) if (living.getUniqueID().equals(msg.uuid)) {
entity = living;
break;
}
if (entity != null) {
LivingData data = LivingData.forEntity(entity);
data.getAbilities().deserializeNBT(msg.abilitiesData);
}
}
}
} else {
ServerPlayerEntity sender = context.getSender();
if (sender != null) {
Abilities abilities = LivingData.forEntity(sender).getAbilities();
abilities.forceRecache();
CompoundNBT data = abilities.serializeNBT();
PacketHandler.sendToNearby(sender.getEntityWorld(), sender, new PacketSyncAbilities(sender.getUniqueID(), data));
}
}
context.setPacketHandled(true);
}
use of com.lying.variousoddities.proxy.CommonProxy in project VariousOddities by Lyinginbedmon.
the class PacketSyncBludgeoning method handle.
public static void handle(PacketSyncBludgeoning msg, Supplier<NetworkEvent.Context> cxt) {
NetworkEvent.Context context = cxt.get();
context.setPacketHandled(true);
if (context.getDirection().getReceptionSide().isServer())
return;
PlayerEntity sender = ((CommonProxy) VariousOddities.proxy).getPlayerEntity(context);
if (sender != null) {
LivingData data = LivingData.forEntity(sender);
if (data != null)
data.setBludgeoning(msg.bludgeoning);
}
}
use of com.lying.variousoddities.proxy.CommonProxy in project VariousOddities by Lyinginbedmon.
the class PacketSyncLivingData method handle.
public static void handle(PacketSyncLivingData msg, Supplier<NetworkEvent.Context> cxt) {
NetworkEvent.Context context = cxt.get();
if (context.getDirection().getReceptionSide().isServer()) {
ServerPlayerEntity player = context.getSender();
LivingEntity target = null;
if (player.getUniqueID().equals(msg.entityID))
target = player;
else {
World world = player.getEntityWorld();
for (LivingEntity ent : world.getEntitiesWithinAABB(LivingEntity.class, player.getBoundingBox().grow(64D))) if (ent.getUniqueID().equals(msg.entityID)) {
target = ent;
break;
}
}
if (target != null)
PacketHandler.sendTo(player, new PacketSyncLivingData(msg.entityID, LivingData.forEntity(target)));
} else {
PlayerEntity player = ((CommonProxy) VariousOddities.proxy).getPlayerEntity(context);
LivingEntity target = null;
if (player.getUniqueID().equals(msg.entityID))
target = player;
else {
World world = player.getEntityWorld();
for (LivingEntity ent : world.getEntitiesWithinAABB(LivingEntity.class, player.getBoundingBox().grow(64D))) if (ent.getUniqueID().equals(msg.entityID)) {
target = ent;
break;
}
}
if (target != null) {
LivingData data = LivingData.forEntity(target);
if (data != null)
data.deserializeNBT(msg.dataNBT);
}
}
context.setPacketHandled(true);
}
use of com.lying.variousoddities.proxy.CommonProxy in project VariousOddities by Lyinginbedmon.
the class PacketSyncScents method handle.
public static void handle(PacketSyncScents msg, Supplier<NetworkEvent.Context> cxt) {
NetworkEvent.Context context = cxt.get();
if (!context.getDirection().getReceptionSide().isServer()) {
PlayerEntity player = ((CommonProxy) VariousOddities.proxy).getPlayerEntity(context);
ScentsManager manager = VariousOddities.proxy.getScentsManager(player.getEntityWorld());
manager.read(msg.scentData);
}
context.setPacketHandled(true);
}
Aggregations