Substitute generic damage when caster is null, fixes #362
This commit is contained in:
@@ -18,6 +18,7 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.potion.PotionEffect;
|
import net.minecraft.potion.PotionEffect;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.EnumBlockRenderType;
|
import net.minecraft.util.EnumBlockRenderType;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
@@ -62,8 +63,10 @@ public class BlockSnare extends Block implements ITileEntityProvider {
|
|||||||
|
|
||||||
if(AllyDesignationSystem.isValidTarget(tileentity.getCaster(), entity)){
|
if(AllyDesignationSystem.isValidTarget(tileentity.getCaster(), entity)){
|
||||||
|
|
||||||
entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(tileentity.getCaster(), DamageType.MAGIC),
|
DamageSource source = tileentity.getCaster() == null ? DamageSource.CACTUS
|
||||||
Spells.snare.getProperty(Spell.DAMAGE).floatValue());
|
: MagicDamage.causeDirectMagicDamage(tileentity.getCaster(), DamageType.MAGIC);
|
||||||
|
|
||||||
|
entity.attackEntityFrom(source, Spells.snare.getProperty(Spell.DAMAGE).floatValue());
|
||||||
|
|
||||||
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS,
|
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS,
|
||||||
Spells.snare.getProperty(Spell.EFFECT_DURATION).intValue(),
|
Spells.snare.getProperty(Spell.EFFECT_DURATION).intValue(),
|
||||||
|
|||||||
@@ -137,9 +137,11 @@ public class BlockThorns extends BlockBush implements ITileEntityProvider {
|
|||||||
TileEntity tileentity = world.getTileEntity(pos);
|
TileEntity tileentity = world.getTileEntity(pos);
|
||||||
|
|
||||||
if(tileentity instanceof TileEntityPlayerSaveTimed){
|
if(tileentity instanceof TileEntityPlayerSaveTimed){
|
||||||
if(AllyDesignationSystem.isValidTarget(((TileEntityPlayerSaveTimed)tileentity).getCaster(), target)){
|
|
||||||
source = MagicDamage.causeDirectMagicDamage(((TileEntityPlayerSaveTimed)tileentity).getCaster(),
|
EntityLivingBase caster = ((TileEntityPlayerSaveTimed)tileentity).getCaster();
|
||||||
MagicDamage.DamageType.MAGIC);
|
|
||||||
|
if(caster != null && AllyDesignationSystem.isValidTarget(caster, target)){
|
||||||
|
source = MagicDamage.causeDirectMagicDamage(caster, MagicDamage.DamageType.MAGIC);
|
||||||
}else{
|
}else{
|
||||||
return false; // Don't attack or slow allies of the caster
|
return false; // Don't attack or slow allies of the caster
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user