2015-12-03 22:49:31 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("LensDetonation.java") is part of the Actually Additions mod for Minecraft.
|
2015-12-03 22:49:31 +01:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-12-03 22:49:31 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-12-03 22:49:31 +01:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
2015-12-03 22:49:31 +01:00
|
|
|
|
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;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-07-20 09:49:19 +02:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-12-03 22:49:31 +01:00
|
|
|
|
|
|
|
public class LensDetonation extends Lens{
|
|
|
|
|
2016-07-20 09:49:19 +02:00
|
|
|
private static final int ENERGY_USE = 250000;
|
|
|
|
|
2015-12-03 22:49:31 +01:00
|
|
|
@Override
|
2016-03-18 23:47:22 +01:00
|
|
|
public boolean invoke(IBlockState state, BlockPos hitBlock, IAtomicReconstructor tile){
|
2016-07-04 20:15:41 +02:00
|
|
|
if(hitBlock != null && !state.getBlock().isAir(state, tile.getWorldObject(), hitBlock)){
|
2016-07-20 09:49:19 +02:00
|
|
|
if(tile.getEnergy() >= ENERGY_USE){
|
2016-01-07 23:42:42 +01:00
|
|
|
tile.getWorldObject().newExplosion(null, hitBlock.getX()+0.5, hitBlock.getY()+0.5, hitBlock.getZ()+0.5, 10F, true, true);
|
2016-07-20 09:49:19 +02:00
|
|
|
tile.extractEnergy(ENERGY_USE);
|
2015-12-03 22:49:31 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float[] getColor(){
|
|
|
|
return new float[]{158F/255F, 43F/255F, 39F/255F};
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getDistance(){
|
|
|
|
return 30;
|
|
|
|
}
|
2016-07-20 09:49:19 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){
|
|
|
|
return tile.getEnergy()-energyUsePerShot >= ENERGY_USE;
|
|
|
|
}
|
2016-01-05 04:47:35 +01:00
|
|
|
}
|