Added a corruption handler so that blocks can be corrupted by a wide variety of processes.

This commit is contained in:
WayofTime 2016-09-18 10:07:02 -04:00
parent e12b1a7042
commit f7ff728c0d
3 changed files with 130 additions and 10 deletions

View file

@ -3,12 +3,14 @@ package WayofTime.bloodmagic.entity.mob;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.gson.Serializers;
public class EntityAspectedDemonBase extends EntityDemonBase
public abstract class EntityAspectedDemonBase extends EntityDemonBase
{
protected static final DataParameter<EnumDemonWillType> TYPE = EntityDataManager.<EnumDemonWillType>createKey(EntityAspectedDemonBase.class, Serializers.WILL_TYPE_SERIALIZER);
@ -24,6 +26,47 @@ public class EntityAspectedDemonBase extends EntityDemonBase
this.dataManager.register(TYPE, EnumDemonWillType.DEFAULT);
}
public double getMeleeResist()
{
return 0;
}
public double getProjectileResist()
{
return 0;
}
public double getMagicResist()
{
return 0;
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isEntityInvulnerable(source))
{
return false;
} else
{
float newAmount = amount;
if (source.isProjectile())
{
newAmount *= MathHelper.clamp_double(1 - getProjectileResist(), 0, 1);
} else
{
newAmount *= MathHelper.clamp_double(1 - getMeleeResist(), 0, 1);
}
if (source.isMagicDamage())
{
newAmount *= MathHelper.clamp_double(1 - getMagicResist(), 0, 1);
}
return super.attackEntityFrom(source, newAmount);
}
}
public EnumDemonWillType getType()
{
return this.dataManager.get(TYPE);

View file

@ -96,8 +96,19 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(8.0D);
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D);
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30);
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25);
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6);
}
public double getMeleeResist()
{
return 0.2;
}
public double getProjectileResist()
{
return 0.6;
}
@Override
@ -120,13 +131,6 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
}
@Override
//TODO: Add fun stuff for when interacted with - explode?
public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack)
{
return super.processInteract(player, hand, stack);
}
@SideOnly(Side.CLIENT)
public float getHeadRotationPointY(float partialTick)
{
@ -180,6 +184,12 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
return SoundEvents.ENTITY_SHEEP_DEATH;
}
@Override
protected float getSoundPitch()
{
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{