Eifel
Модератор
- 1,624
- 79
- 609
В общем столкнулся с такой проблемой: написал код для сохранения эффектов а так же копировании их если игрок прыгнет в энд портал после смерти дракона. На клиенте/сервере среды все работает просто божественно. Другое дело когда установил мод на сервер с ядром KCauldron-1.7.10-1614.201. Нифига не работает, эффекты не сохраняються как после смерти так при переходе через портал. Так вот задаюсь вопросом, это я где-то напартачил в коде или может быть баг в ядре ...
Код:
Зареган:
Код:
Код:
public class BionisationEffectSyncEventHandler {
public HashMap<String, Collection<PotionEffect>> effects = new HashMap<String, Collection<PotionEffect>>();
@SubscribeEvent
public void onPlayerDeath(LivingDeathEvent event) {
if(event.entity instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)event.entity;
Collection coll = player.getActivePotionEffects();
if(!coll.isEmpty()){
for (Object o : coll) {
PotionEffect effect = (PotionEffect)o;
if(effect.getPotionID() == BionisationPotionList.AncientFlowerEffect.id || effect.getPotionID() == BionisationPotionList.EnderFlowerEffect.id || effect.getPotionID() == BionisationPotionList.FireFlowerEffect.id || effect.getPotionID() == BionisationPotionList.WaterFlowerEffect.id || effect.getPotionID() == BionisationPotionList.ImmunityRegenEffect.id)
coll.remove(effect);
}
if(!coll.isEmpty())
effects.put(player.getCommandSenderName(), coll);
}
}
}
@SubscribeEvent
public void onPlayerRespawn(PlayerRespawnEvent event) {
EntityPlayer player = (EntityPlayer)event.player;
if(effects.containsKey(player.getCommandSenderName())){
Collection coll = effects.get(player.getCommandSenderName());
if(!coll.isEmpty()){
for (Object o : coll) {
PotionEffect effect = (PotionEffect)o;
player.addPotionEffect(effect);
}
effects.remove(player.getCommandSenderName());
}
}
}
@SubscribeEvent
public void onCloneEffectsPlayer(PlayerEvent.Clone event) {
Collection coll = event.original.getActivePotionEffects();
if(!coll.isEmpty()){
for (Object o : coll) {
PotionEffect effect = (PotionEffect)o;
event.entityPlayer.addPotionEffect(effect);
}
}
}
Зареган:
Код:
public static final BionisationEffectSyncEventHandler eventListener = new BionisationEffectSyncEventHandler();
MinecraftForge.EVENT_BUS.register(eventListener);
FMLCommonHandler.instance().bus().register(eventListener);