use of net.minecraftforge.entity.PartEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAIAttackSpecialSpinAttack method continueAttack.
@Override
public void continueAttack(AbstractEntityCQR attacker, LivingEntity target, int tick) {
final boolean oldTargetWasNull = this.targetWasNullInLastCycle;
this.targetWasNullInLastCycle = target == null || target.isDeadOrDying();
if (attacker.horizontalCollision) {
this.ticksCollided++;
} else {
this.ticksCollided = 0;
}
if (!this.targetWasNullInLastCycle && oldTargetWasNull != this.targetWasNullInLastCycle) {
this.calcAttackDirection(attacker, target);
}
Vector3d deltaMovement = new Vector3d(this.attackDirection.x, attacker.getDeltaMovement().y(), this.attackDirection.z);
/*attacker.motionX = this.attackDirection.x;
attacker.motionZ = this.attackDirection.z;
atacker.velocityChanged = true;*/
attacker.setDeltaMovement(deltaMovement);
attacker.hasImpulse = true;
// First: Damage all entities around us
final double radius = 1.5 * attacker.getSizeVariation();
List<Entity> affectedEntities = attacker.getWorld().getEntities(attacker, attacker.getBoundingBox().inflate(radius), TargetUtil.createPredicateNonAlly(attacker.getFaction()));
affectedEntities.forEach((Entity entity) -> {
if (entity == null) {
return;
}
if (entity instanceof PartEntity) {
return;
}
if (attacker.distanceTo(entity) > radius) {
return;
}
if (entity instanceof LivingEntity) {
LivingEntity living = (LivingEntity) entity;
float dmg = (float) attacker.getAttribute(Attributes.ATTACK_DAMAGE).getValue();
dmg += 0.75 * EnchantmentHelper.getDamageBonus(attacker.getOffhandItem(), living.getMobType());
dmg += 0.75 * EnchantmentHelper.getDamageBonus(attacker.getMainHandItem(), living.getMobType());
/*
* living.attackEntityFrom(DamageSource.causeThornsDamage(attacker), dmg);
* final Vec3d v = living.getPositionVector().subtract(attacker.getPositionVector()).normalize().scale(1.25).add(0,
* 0.25, 0).scale(attacker.getSizeVariation()).add(attackDirection);
* living.motionX += v.x;
* living.motionY += v.y;
* living.motionZ += v.z;
* living.velocityChanged = true;
*/
final float knockbackStrength = 0.6125F * attacker.getSizeVariation();
living.hurt(DamageSource.mobAttack(attacker), dmg);
// Correct replacement?
living.knockback(/*entity,*/
knockbackStrength, 1, 1);
}
});
}
use of net.minecraftforge.entity.PartEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class ISizable method setSizeVariation.
// Always use this to change the size, never call resize directly!!
default void setSizeVariation(float size) {
this.applySizeVariation(size);
if (this instanceof Entity) {
Entity myself = (Entity) this;
// Copy from SlimeEntity code
this.reapplyPositionClone(myself);
double d0 = myself.getX();
double d1 = myself.getY();
double d2 = myself.getZ();
myself.refreshDimensions();
myself.setPos(d0, d1, d2);
if (myself.getParts() != null) {
for (PartEntity part : myself.getParts()) {
if (part instanceof ISizable) {
((ISizable) part).setSizeVariation(size);
}
}
}
}
}
use of net.minecraftforge.entity.PartEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class ItemMobToSpawner method onLeftClickEntity.
/*
* @Override public boolean canDestroyBlockInCreative(World world, BlockPos pos, ItemStack stack, EntityPlayer player) {
* Block block =
* world.getBlockState(pos).getBlock(); return block != ModBlocks.SPAWNER && block != Blocks.MOB_SPAWNER; }
*/
@Override
public boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity) {
if (player.isCreative()) {
if (!player.world.isRemote && !(entity instanceof PartEntity)) {
SpawnerFactory.placeSpawner(new Entity[] { entity }, false, null, player.world, new BlockPos(entity));
entity.setDead();
for (Entity passenger : entity.getPassengers()) {
passenger.setDead();
}
this.spawnAdditions(entity.world, entity.posX, entity.posY + entity.height * 0.5D, entity.posZ);
}
return true;
}
return false;
}
Aggregations