use of com.witchworks.common.core.net.PotionMessage in project Witchworks by Um-Mitternacht.
the class BrewEvents method onWorldJoin.
@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityPlayerMP) {
EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
if (optional.isPresent()) {
PacketHandler.sendTo(entity, new PotionMessage(optional.get().getBrews().keySet(), entity.getUniqueID()));
}
}
}
use of com.witchworks.common.core.net.PotionMessage in project Witchworks by Um-Mitternacht.
the class BrewEvents method onUpdate.
@SubscribeEvent
public void onUpdate(LivingEvent.LivingUpdateEvent event) {
final EntityLivingBase entity = event.getEntityLiving();
if (entity == null)
return;
Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
if (optional.isPresent()) {
IBrewStorage storage = optional.get();
Map<IBrew, BrewEffect> brews = storage.getBrews();
if (brews.isEmpty())
return;
Map<IBrew, BrewEffect> updated = new HashMap<>();
for (IBrew brew : brews.keySet()) {
BrewEffect effect = brews.get(brew);
if (effect.isInstant() || effect.getDuration() <= 0) {
effect.end(entity.world, entity.getPosition(), entity);
} else {
effect.update(entity.world, entity.getPosition(), entity);
updated.put(effect.getBrew(), effect);
}
}
storage.setBrews(updated);
if (entity instanceof EntityPlayer) {
PacketHandler.sendTo((EntityPlayerMP) entity, new PotionMessage(updated.keySet(), entity.getUniqueID()));
}
}
}
Aggregations