mirror of
https://github.com/FatherToast/SpecialMobs.git
synced 2025-08-06 02:11:49 +00:00
rebase variance as a normal multiplier, fix blaze variance
This commit is contained in:
parent
f6c24ecda0
commit
9f372a5261
13 changed files with 29 additions and 18 deletions
|
@ -64,7 +64,7 @@ public class SpecialMobData<T extends LivingEntity & ISpecialMob<T>> {
|
|||
/** The damage the entity uses for its ranged attacks, when applicable. */
|
||||
public float rangedAttackDamage;
|
||||
/** The spread (inaccuracy) of the entity's ranged attacks. */
|
||||
public float rangedAttackSpread;
|
||||
public float rangedAttackSpread = 1.0F;
|
||||
/** The movement speed multiplier the entity uses during its ranged attack ai. Requires an AI reload to take effect. */
|
||||
public float rangedWalkSpeed = 1.0F;
|
||||
/** The delay (in ticks) before a new ranged attack can begin after firing. Requires an AI reload to take effect. */
|
||||
|
|
|
@ -11,9 +11,11 @@ import net.minecraft.entity.EntityType;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.FireballEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -73,7 +75,7 @@ public class HellfireBlazeEntity extends _SpecialBlazeEntity {
|
|||
/** Override to change this entity's AI goals. */
|
||||
@Override
|
||||
protected void registerVariantGoals() {
|
||||
getSpecialData().rangedAttackSpread = 0.0F;
|
||||
getSpecialData().rangedAttackSpread *= 0.05F;
|
||||
setRangedAI( 1, 0, 60, 100, 40.0F );
|
||||
}
|
||||
|
||||
|
@ -82,7 +84,7 @@ public class HellfireBlazeEntity extends _SpecialBlazeEntity {
|
|||
public void performRangedAttack( LivingEntity target, float damageMulti ) {
|
||||
if( !isSilent() ) level.levelEvent( null, 1018, blockPosition(), 0 );
|
||||
|
||||
final float accelVariance = MathHelper.sqrt( distanceTo( target ) ) * getSpecialData().rangedAttackSpread / 28.0F;
|
||||
final float accelVariance = MathHelper.sqrt( distanceTo( target ) ) * 0.5F * getSpecialData().rangedAttackSpread;
|
||||
final double dX = target.getX() - getX() + getRandom().nextGaussian() * accelVariance;
|
||||
final double dY = target.getY( 0.5 ) - getY( 0.5 );
|
||||
final double dZ = target.getZ() - getZ() + getRandom().nextGaussian() * accelVariance;
|
||||
|
@ -93,6 +95,18 @@ public class HellfireBlazeEntity extends _SpecialBlazeEntity {
|
|||
level.addFreshEntity( fireball );
|
||||
}
|
||||
|
||||
/** @return Attempts to damage this entity; returns true if the hit was successful. */
|
||||
@Override
|
||||
public boolean hurt( DamageSource source, float amount ) {
|
||||
if( isInvulnerableTo( source ) ) return false;
|
||||
|
||||
if( source.getDirectEntity() instanceof FireballEntity && source.getEntity() instanceof PlayerEntity ) {
|
||||
super.hurt( source, 1000.0F ); // Die from returned fireballs (like ghasts)
|
||||
return true;
|
||||
}
|
||||
return super.hurt( source, amount );
|
||||
}
|
||||
|
||||
/** Override to save data to this entity's NBT data. */
|
||||
@Override
|
||||
public void addVariantSaveData( CompoundNBT saveTag ) {
|
||||
|
|
|
@ -86,6 +86,7 @@ public class _SpecialBlazeEntity extends BlazeEntity implements IRangedAttackMob
|
|||
goalSelector.addGoal( 4, new SpecialBlazeAttackGoal( this ) );
|
||||
AIHelper.replaceHurtByTarget( this, new SpecialHurtByTargetGoal( this, BlazeEntity.class ).setAlertOthers() );
|
||||
|
||||
getSpecialData().rangedAttackDamage = 2.0F;
|
||||
setRangedAI( 3, 6, 60, 100, 48.0F );
|
||||
registerVariantGoals();
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ public class _SpecialBlazeEntity extends BlazeEntity implements IRangedAttackMob
|
|||
public void performRangedAttack( LivingEntity target, float damageMulti ) {
|
||||
if( !isSilent() ) level.levelEvent( null, 1018, blockPosition(), 0 );
|
||||
|
||||
final float accelVariance = MathHelper.sqrt( distanceTo( target ) ) * getSpecialData().rangedAttackSpread / 28.0F;
|
||||
final float accelVariance = MathHelper.sqrt( distanceTo( target ) ) * 0.5F * getSpecialData().rangedAttackSpread;
|
||||
final double dX = target.getX() - getX() + getRandom().nextGaussian() * accelVariance;
|
||||
final double dY = target.getY( 0.5 ) - getY( 0.5 );
|
||||
final double dZ = target.getZ() - getZ() + getRandom().nextGaussian() * accelVariance;
|
||||
|
|
|
@ -78,7 +78,7 @@ public class _SpecialCaveSpiderEntity extends CaveSpiderEntity implements ISpeci
|
|||
super.registerGoals();
|
||||
|
||||
getSpecialData().rangedAttackDamage = 1.0F;
|
||||
getSpecialData().rangedAttackSpread = 18.0F;
|
||||
getSpecialData().rangedAttackSpread = 1.3F;
|
||||
getSpecialData().rangedAttackCooldown = 40;
|
||||
getSpecialData().rangedAttackMaxCooldown = getSpecialData().rangedAttackCooldown;
|
||||
getSpecialData().rangedAttackMaxRange = 10.0F;
|
||||
|
|
|
@ -76,7 +76,7 @@ public class FishingSilverfishEntity extends _SpecialSilverfishEntity implements
|
|||
/** Override to change this entity's AI goals. */
|
||||
@Override
|
||||
protected void registerVariantGoals() {
|
||||
getSpecialData().rangedAttackSpread = 10.0F;
|
||||
getSpecialData().rangedAttackSpread *= 0.7F;
|
||||
getSpecialData().rangedAttackCooldown = 32;
|
||||
getSpecialData().rangedAttackMaxCooldown = 48;
|
||||
getSpecialData().rangedAttackMaxRange = 10.0F;
|
||||
|
|
|
@ -83,7 +83,6 @@ public class _SpecialSilverfishEntity extends SilverfishEntity implements ISpeci
|
|||
AIHelper.replaceHurtByTarget( this, new SpecialHurtByTargetGoal( this, SilverfishEntity.class ).setAlertOthers() );
|
||||
|
||||
getSpecialData().rangedAttackDamage = 1.0F;
|
||||
getSpecialData().rangedAttackSpread = 14.0F;
|
||||
getSpecialData().rangedAttackCooldown = 40;
|
||||
getSpecialData().rangedAttackMaxCooldown = getSpecialData().rangedAttackCooldown;
|
||||
getSpecialData().rangedAttackMaxRange = 10.0F;
|
||||
|
|
|
@ -97,7 +97,6 @@ public class _SpecialSkeletonEntity extends AbstractSkeletonEntity implements IS
|
|||
super.registerGoals();
|
||||
|
||||
getSpecialData().rangedAttackDamage = 2.0F;
|
||||
getSpecialData().rangedAttackSpread = 14.0F;
|
||||
getSpecialData().rangedAttackCooldown = 20;
|
||||
getSpecialData().rangedAttackMaxCooldown = getSpecialData().rangedAttackCooldown;
|
||||
getSpecialData().rangedAttackMaxRange = 15.0F;
|
||||
|
@ -152,7 +151,7 @@ public class _SpecialSkeletonEntity extends AbstractSkeletonEntity implements IS
|
|||
final double dZ = target.getZ() - getZ();
|
||||
final double dH = MathHelper.sqrt( dX * dX + dZ * dZ );
|
||||
arrow.shoot( dX, dY + dH * 0.2, dZ, 1.6F,
|
||||
getSpecialData().rangedAttackSpread * (1.0F - 0.2858F * level.getDifficulty().getId()) );
|
||||
getSpecialData().rangedAttackSpread * (14 - 4 * level.getDifficulty().getId()) );
|
||||
|
||||
playSound( SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 0.8F) );
|
||||
level.addFreshEntity( arrow );
|
||||
|
|
|
@ -78,7 +78,7 @@ public class _SpecialSpiderEntity extends SpiderEntity implements ISpecialMob<_S
|
|||
super.registerGoals();
|
||||
|
||||
getSpecialData().rangedAttackDamage = 2.0F;
|
||||
getSpecialData().rangedAttackSpread = 18.0F;
|
||||
getSpecialData().rangedAttackSpread = 1.3F;
|
||||
getSpecialData().rangedAttackCooldown = 40;
|
||||
getSpecialData().rangedAttackMaxCooldown = getSpecialData().rangedAttackCooldown;
|
||||
getSpecialData().rangedAttackMaxRange = 10.0F;
|
||||
|
|
|
@ -94,7 +94,6 @@ public class _SpecialWitherSkeletonEntity extends WitherSkeletonEntity implement
|
|||
super.registerGoals();
|
||||
|
||||
getSpecialData().rangedAttackDamage = 2.0F;
|
||||
getSpecialData().rangedAttackSpread = 14.0F;
|
||||
getSpecialData().rangedAttackCooldown = 20;
|
||||
getSpecialData().rangedAttackMaxCooldown = getSpecialData().rangedAttackCooldown;
|
||||
getSpecialData().rangedAttackMaxRange = 15.0F;
|
||||
|
@ -149,7 +148,7 @@ public class _SpecialWitherSkeletonEntity extends WitherSkeletonEntity implement
|
|||
final double dZ = target.getZ() - getZ();
|
||||
final double dH = MathHelper.sqrt( dX * dX + dZ * dZ );
|
||||
arrow.shoot( dX, dY + dH * 0.2, dZ, 1.6F,
|
||||
getSpecialData().rangedAttackSpread * (1.0F - 0.2858F * level.getDifficulty().getId()) );
|
||||
getSpecialData().rangedAttackSpread * (14 - 4 * level.getDifficulty().getId()) );
|
||||
|
||||
playSound( SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 0.8F) );
|
||||
level.addFreshEntity( arrow );
|
||||
|
|
|
@ -84,7 +84,7 @@ public class FishingZombieEntity extends _SpecialZombieEntity implements IAngler
|
|||
/** Override to change this entity's AI goals. */
|
||||
@Override
|
||||
protected void registerVariantGoals() {
|
||||
getSpecialData().rangedAttackSpread = 10.0F;
|
||||
getSpecialData().rangedAttackSpread *= 0.7F;
|
||||
getSpecialData().rangedAttackCooldown = 32;
|
||||
getSpecialData().rangedAttackMaxCooldown = 48;
|
||||
getSpecialData().rangedAttackMaxRange = 10.0F;
|
||||
|
|
|
@ -97,7 +97,7 @@ public class _SpecialZombieEntity extends ZombieEntity implements IRangedAttackM
|
|||
.setAlertOthers( ZombifiedPiglinEntity.class ) );
|
||||
|
||||
getSpecialData().rangedAttackDamage = 2.0F;
|
||||
getSpecialData().rangedAttackSpread = 20.0F;
|
||||
getSpecialData().rangedAttackSpread = 1.4F;
|
||||
getSpecialData().rangedWalkSpeed = 0.8F;
|
||||
getSpecialData().rangedAttackCooldown = 30;
|
||||
getSpecialData().rangedAttackMaxCooldown = getSpecialData().rangedAttackCooldown;
|
||||
|
@ -153,7 +153,7 @@ public class _SpecialZombieEntity extends ZombieEntity implements IRangedAttackM
|
|||
final double dZ = target.getZ() - getZ();
|
||||
final double dH = MathHelper.sqrt( dX * dX + dZ * dZ );
|
||||
arrow.shoot( dX, dY + dH * 0.2, dZ, 1.6F,
|
||||
getSpecialData().rangedAttackSpread * (1.0F - 0.2858F * level.getDifficulty().getId()) );
|
||||
getSpecialData().rangedAttackSpread * (14 - 4 * level.getDifficulty().getId()) );
|
||||
|
||||
playSound( SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 0.8F) );
|
||||
level.addFreshEntity( arrow );
|
||||
|
|
|
@ -84,7 +84,7 @@ public class FishingZombifiedPiglinEntity extends _SpecialZombifiedPiglinEntity
|
|||
/** Override to change this entity's AI goals. */
|
||||
@Override
|
||||
protected void registerVariantGoals() {
|
||||
getSpecialData().rangedAttackSpread = 10.0F;
|
||||
getSpecialData().rangedAttackSpread *= 0.7F;
|
||||
getSpecialData().rangedAttackCooldown = 32;
|
||||
getSpecialData().rangedAttackMaxCooldown = 48;
|
||||
getSpecialData().rangedAttackMaxRange = 10.0F;
|
||||
|
|
|
@ -95,7 +95,6 @@ public class _SpecialZombifiedPiglinEntity extends ZombifiedPiglinEntity impleme
|
|||
AIHelper.replaceHurtByTarget( this, new SpecialHurtByTargetGoal( this, ZombifiedPiglinEntity.class ).setAlertOthers() );
|
||||
|
||||
getSpecialData().rangedAttackDamage = 2.0F;
|
||||
getSpecialData().rangedAttackSpread = 14.0F;
|
||||
getSpecialData().rangedWalkSpeed = 0.8F;
|
||||
getSpecialData().rangedAttackCooldown = 20;
|
||||
getSpecialData().rangedAttackMaxCooldown = getSpecialData().rangedAttackCooldown;
|
||||
|
@ -157,7 +156,7 @@ public class _SpecialZombifiedPiglinEntity extends ZombifiedPiglinEntity impleme
|
|||
final double dZ = target.getZ() - getZ();
|
||||
final double dH = MathHelper.sqrt( dX * dX + dZ * dZ );
|
||||
arrow.shoot( dX, dY + dH * 0.2, dZ, 1.6F,
|
||||
getSpecialData().rangedAttackSpread * (1.0F - 0.2858F * level.getDifficulty().getId()) );
|
||||
getSpecialData().rangedAttackSpread * (14 - 4 * level.getDifficulty().getId()) );
|
||||
|
||||
playSound( SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 0.8F) );
|
||||
level.addFreshEntity( arrow );
|
||||
|
|
Loading…
Add table
Reference in a new issue