sk9zist :l
Исправился
- 981
- 18
- 157
как создать взрыв при ударе по мобу? я планирую это делать в эвенте а ещё чтобы у игрока в инвентаре был спец.предмет
оо даже так! До чего продуманная системаидти урон от взрыва.
@SubscribeEvent
public void onAttackEvent(LivingAttackEvent e)
{
EntityPlayer pl = (EntityPlayer) e.getSource().getImmediateSource();
if (pl.getHeldItemMainhand().getItem() instanceof pbb)
{
if (e.getSource().getImmediateSource() instanceof EntityPlayer)
{
if(!pl.world.isRemote)
{
e.getEntity().world.createExplosion(e.getSource().getImmediateSource(), e.getEntity().posX, e.getEntity().posY, e.getEntity().posZ, 4.0F, true);
}
}
}
}
EntityPlayer pl = (EntityPlayer) e.getSource().getImmediateSource();
Не сложно но даже если бы я узнал причину ошибки я бы не смог решить потому что не заметил бы насток простогоНеужели так сложно отдебажить?
@SubscribeEvent
public void onAttackEvent(LivingAttackEvent e)
{
if(e.getSource().getImmediateSource() instanceof EntityPlayer)
{
EntityPlayer pl = (EntityPlayer) e.getSource().getImmediateSource();
if (pl.getHeldItemOffhand().getItem() instanceof pbb)
{
if (e.getSource().getImmediateSource() instanceof EntityPlayer)
{
if(!pl.world.isRemote)
{
e.getEntity().world.createExplosion(e.getSource().getImmediateSource(), e.getEntity().posX, e.getEntity().posY, e.getEntity().posZ, 4.0F, true);
}
}
}
}
}
где проверка на null?e.getSource().getImmediateSource()
где проверка на null?pl.getHeldItemOffhand().getItem()
извини уже исправилгде проверка на null?