2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
2015-12-03 22:49:31 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2016-01-05 14:57:50 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.misc.DamageSources;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-12-03 22:49:31 +01:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-12-03 22:49:31 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class LensDeath extends Lens {
|
2015-12-03 22:49:31 +01:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
|
|
|
ArrayList<EntityLivingBase> entities = (ArrayList<EntityLivingBase>) tile.getWorldObject().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1));
|
|
|
|
for (EntityLivingBase entity : entities) {
|
2016-11-02 18:49:57 +01:00
|
|
|
int use = this.getUsePerEntity();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (tile.getEnergy() >= use) {
|
2016-11-02 18:49:57 +01:00
|
|
|
tile.extractEnergy(use);
|
2015-12-03 22:49:31 +01:00
|
|
|
|
2016-11-02 18:49:57 +01:00
|
|
|
this.onAttacked(entity, tile);
|
2015-12-03 22:49:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-04 20:15:41 +02:00
|
|
|
return hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
|
2015-12-03 22:49:31 +01:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile) {
|
2016-11-02 18:49:57 +01:00
|
|
|
entity.attackEntityFrom(DamageSources.DAMAGE_ATOMIC_RECONSTRUCTOR, 20F);
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
protected int getUsePerEntity() {
|
2016-11-02 18:49:57 +01:00
|
|
|
return 350;
|
|
|
|
}
|
|
|
|
|
2015-12-03 22:49:31 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public float[] getColor() {
|
|
|
|
return new float[] { 188F / 255F, 222F / 255F, 1F };
|
2015-12-03 22:49:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public int getDistance() {
|
2015-12-03 22:49:31 +01:00
|
|
|
return 15;
|
|
|
|
}
|
|
|
|
}
|