Skip to content

Commit

Permalink
Made some animations for the hissing demons
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackJar72 committed Jun 23, 2021
1 parent 3ac01db commit 4d15798
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 41 deletions.
35 changes: 35 additions & 0 deletions src/main/java/com/gw/dm/ai/AIHissingDemonAttack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.gw.dm.ai;

import com.gw.dm.entity.EntityHissingDemon;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.util.EnumHand;

public class AIHissingDemonAttack extends EntityAIAttackMelee {
EntityHissingDemon demon;

public AIHissingDemonAttack(EntityHissingDemon creature, double speedIn, boolean useLongMemory) {
super(creature, speedIn, useLongMemory);
demon = creature;
}

// TODO: Archvile-like attack
// TODO: List of extra enemies
// TODO: Re-write to not depend on or extend EntityAIAttackMelee?


@Override
protected void checkAndPerformAttack(EntityLivingBase victim, double dist) {
double distance = this.getAttackReachSqr(victim);

if (dist <= distance && this.attackTick <= 0)
{
this.attackTick = 4;
this.attacker.swingArm(EnumHand.MAIN_HAND);
this.attacker.attackEntityAsMob(victim);
}
}


}
31 changes: 0 additions & 31 deletions src/main/java/com/gw/dm/ai/AIHissingDemonMelee.java

This file was deleted.

20 changes: 10 additions & 10 deletions src/main/java/com/gw/dm/entity/EntityHissingDemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.gw.dm.DungeonMobs;
import com.gw.dm.EntityDungeonMob;
import com.gw.dm.ai.AIHissingDemonAttack;
import com.gw.dm.util.AudioHandler;
import com.gw.dm.util.ConfigHandler;

Expand All @@ -15,7 +16,6 @@
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
Expand Down Expand Up @@ -76,7 +76,7 @@ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLi
protected void initEntityAI() {
//TODO: Stand-in code here, replace with specific
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(2, new AIHissingDemonAttack(this, 1.0d, false));
this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
this.tasks.addTask(7, new EntityAIWanderAvoidWater(this, 1.0D));
this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
Expand Down Expand Up @@ -145,9 +145,9 @@ private void setHandWeapons(DifficultyInstance difficulty) {


private ItemStack getHandWeapon(DifficultyInstance difficulty) {
int die = rand.nextInt(12);
int die = rand.nextInt(10);
ItemStack out;
if(die < 3) {
if(die < 2) {
if(rand.nextInt(3) < 2) {
out = new ItemStack(Items.STONE_SWORD);
} else {
Expand All @@ -159,7 +159,7 @@ private ItemStack getHandWeapon(DifficultyInstance difficulty) {
} else {
out = new ItemStack(Items.IRON_AXE);
}
} else if(die < 10) {
} else if(die < 9) {
if(rand.nextInt(3) < 2) {
out = new ItemStack(Items.GOLDEN_SWORD);
} else {
Expand All @@ -180,12 +180,12 @@ private ItemStack getHandWeapon(DifficultyInstance difficulty) {
}
break;
case HARD:
if(rand.nextGaussian() < 0.30f * d) {
out = EnchantmentHelper.addRandomEnchantment(rand, out, 10 + (int)((rand.nextFloat() * d) * 20), false);
if(rand.nextGaussian() < 0.35f * d) {
out = EnchantmentHelper.addRandomEnchantment(rand, out, 15 + (int)((rand.nextFloat() * d) * 15), false);
}
break;
case NORMAL:
if(rand.nextGaussian() < 0.35f * d) {
if(rand.nextGaussian() < 0.30f * d) {
out = EnchantmentHelper.addRandomEnchantment(rand, out, 10 + (int)((rand.nextFloat() * d) * 15), false);
}
break;
Expand All @@ -209,7 +209,7 @@ public int getHandToSwing() {


@Override
public boolean attackEntityAsMob(Entity entity) {
public boolean attackEntityAsMob(Entity entity) {
float damage;
int knockback = 0;
boolean hit = false;
Expand All @@ -227,7 +227,7 @@ public boolean attackEntityAsMob(Entity entity) {
damage += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)victim).getCreatureAttribute());
knockback += EnchantmentHelper.getKnockbackModifier(this);
}
hit = victim.attackEntityFrom(DamageSource.causeMobDamage(this), damage);
hit = victim.attackEntityFrom(DamageSource.causeMobDamage(this).setDifficultyScaled(), damage);
if(hit) {
int burn;
if((burn = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FIRE_ASPECT, victim)) > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"format_version": "1.8.0",
"animations": {
"animation.hd.swinga1": {
"animation_length": 0.20833,
"bones": {
"ab1": {
"rotation": {
"0.0": {"pre": [0, 0, 0], "post": [0, 0, 0]},
"0.0417": [60, -7.5, 0],
"0.0833": [97.5, -20, -40],
"0.125": [125.63, 1.25, -40],
"0.1667": [56.25, -14.17, 0],
"0.2083": [0, 0, 0]
}
}
}
},
"animation.hd.swinga4": {
"animation_length": 0.16667,
"bones": {
"ab4": {
"rotation": {
"0.0": [0, 0, 0],
"0.0417": [70, 27.5, 0],
"0.0833": [100, 50, 0],
"0.125": [147.5, 50, -30],
"0.1667": [247.5, 50, -30]
}
}
}
},
"animation.hd.swinga2": {
"animation_length": 0.16667,
"bones": {
"ab2": {
"rotation": {
"0.0": [0, 0, 0],
"0.0417": [0, -32.5, -35],
"0.0833": [0, -70, -102.5],
"0.125": [0, -65, -242.5],
"0.1667": [0, -72.5, -275]
}
},
"ab4": {
"rotation": [0, 0, 0]
}
}
},
"animation.hd.swinga5": {
"animation_length": 0.20833,
"bones": {
"ab5": {
"rotation": {
"0.0": [0, 0, 0],
"0.0417": [0, 52.5, 45],
"0.0833": [0, 65, 92.5],
"0.125": [0, 65, 147.5],
"0.1667": [0, 57.5, 205],
"0.2083": [0, 60, 322.5]
}
}
}
},
"animation.hd.swinga3": {
"animation_length": 0.20833,
"bones": {
"ab3": {
"rotation": {
"0.0": [0, 0, 0],
"0.0417": [-27.5, -65, 0],
"0.0833": [-62.5, -95, 0],
"0.125": [-190, -95, 0],
"0.1667": [-300, -95, 0],
"0.2083": [0, 0, 0]
}
}
}
},
"animation.hd.swinga6": {
"animation_length": 0.20833,
"bones": {
"ab6": {
"rotation": {
"0.0": [0, 0, 0],
"0.0417": [-40, 37.5, 0],
"0.0833": [-62.5, 50, 0],
"0.125": [-150, 50, 0],
"0.1667": [-192.5, 55, 0],
"0.2083": [-360, 0, 0]
}
}
}
}
},
"geckolib_format_version": 2
}

0 comments on commit 4d15798

Please sign in to comment.