diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java index 4de55a1b..2768df1e 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java @@ -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 TYPE = EntityDataManager.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); diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java index b57d987b..ee061adf 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java @@ -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) { diff --git a/src/main/java/WayofTime/bloodmagic/inversion/CorruptionHandler.java b/src/main/java/WayofTime/bloodmagic/inversion/CorruptionHandler.java new file mode 100644 index 00000000..9dd39e66 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/inversion/CorruptionHandler.java @@ -0,0 +1,67 @@ +package WayofTime.bloodmagic.inversion; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import org.apache.commons.lang3.tuple.Pair; + +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; + +public class CorruptionHandler +{ + public static Map, Map> corruptBlockMap = new HashMap, Map>(); + + public static void registerBlockCorruption(EnumDemonWillType type, Block block, int meta, IBlockState corruptedState) + { + Pair pair = Pair.of(block, meta); + if (corruptBlockMap.containsKey(pair)) + { + Map stateMap = corruptBlockMap.get(pair); + stateMap.put(type, corruptedState); + } else + { + Map stateMap = new HashMap(); + stateMap.put(type, corruptedState); + corruptBlockMap.put(pair, stateMap); + } + } + + public static boolean isBlockCorruptible(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) + { + int meta = block.getMetaFromState(state); + Pair pair = Pair.of(block, meta); + if (corruptBlockMap.containsKey(pair)) + { + Map stateMap = corruptBlockMap.get(pair); + return stateMap.containsKey(type); + } + + return false; + } + + public static boolean corruptBlock(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) + { + int meta = block.getMetaFromState(state); + Pair pair = Pair.of(block, meta); + if (corruptBlockMap.containsKey(pair)) + { + Map stateMap = corruptBlockMap.get(pair); + if (stateMap.containsKey(type)) + { + return world.setBlockState(pos, stateMap.get(type)); + } + } + + return false; + } + + public static boolean corruptSurroundingBlocks(World world, EnumDemonWillType type, BlockPos centerPos, int radius) + { + return false; + } +}