diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index f061d87ec..16e402b42 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -30,7 +30,8 @@ public final class ActuallyAdditionsAPI{ public static final String MOD_ID = "actuallyadditions"; public static final String API_ID = MOD_ID+"api"; - public static final String API_VERSION = "17"; + public static final String API_VERSION = "18"; + public static final List CRUSHER_RECIPES = new ArrayList(); public static final List BALL_OF_FUR_RETURN_ITEMS = new ArrayList(); public static final List TREASURE_CHEST_LOOT = new ArrayList(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java index d1a1c3004..0d43d2696 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java @@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.api.lens; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; /** @@ -50,4 +51,11 @@ public abstract class Lens{ public void setLensItem(Item item){ this.lensItem = item; } + + /** + * @return If the lens can be invoked at the current time + */ + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ + return true; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java index 186210036..7a95199a7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java @@ -14,6 +14,7 @@ package de.ellpeck.actuallyadditions.api.lens; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; /** diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java index 5f63cf9e4..253833668 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java @@ -22,6 +22,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -106,4 +107,9 @@ public class LensColor extends Lens{ public int getDistance(){ return 10; } + + @Override + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ + return tile.getEnergy()-energyUsePerShot >= ENERGY_USE; + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java index 0fd6f8e0f..ef1d92ae6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java @@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.mod.misc.DamageSources; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java index 125e802fa..d1ca4a273 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java @@ -13,17 +13,19 @@ package de.ellpeck.actuallyadditions.mod.items.lens; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; public class LensDetonation extends Lens{ + private static final int ENERGY_USE = 250000; + @Override public boolean invoke(IBlockState state, BlockPos hitBlock, IAtomicReconstructor tile){ if(hitBlock != null && !state.getBlock().isAir(state, tile.getWorldObject(), hitBlock)){ - int use = 250000; - if(tile.getEnergy() >= use){ + if(tile.getEnergy() >= ENERGY_USE){ tile.getWorldObject().newExplosion(null, hitBlock.getX()+0.5, hitBlock.getY()+0.5, hitBlock.getZ()+0.5, 10F, true, true); - tile.extractEnergy(use); + tile.extractEnergy(ENERGY_USE); } return true; } @@ -39,4 +41,9 @@ public class LensDetonation extends Lens{ public int getDistance(){ return 30; } + + @Override + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ + return tile.getEnergy()-energyUsePerShot >= ENERGY_USE; + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java index a3ee4e3c0..2dbfbdddf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java @@ -21,6 +21,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -28,10 +29,11 @@ import java.util.ArrayList; public class LensDisruption extends Lens{ + private static final int ENERGY_USE = 150000; + @Override public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ - int energyUse = 150000; - if(tile.getEnergy() >= energyUse && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)){ + if(tile.getEnergy() >= ENERGY_USE && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)){ int range = 2; ArrayList items = (ArrayList)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-range, hitBlock.getY()-range, hitBlock.getZ()-range, hitBlock.getX()+range, hitBlock.getY()+range, hitBlock.getZ()+range)); for(EntityItem item : items){ @@ -62,7 +64,7 @@ public class LensDisruption extends Lens{ EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack); tile.getWorldObject().spawnEntityInWorld(newItem); - tile.extractEnergy(energyUse); + tile.extractEnergy(ENERGY_USE); } } } @@ -80,4 +82,9 @@ public class LensDisruption extends Lens{ public int getDistance(){ return 3; } + + @Override + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ + return tile.getEnergy()-energyUsePerShot >= ENERGY_USE; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java index d14dedc16..b0ddeb168 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java @@ -101,21 +101,20 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple if(this.storage.getEnergyStored() >= ENERGY_USE){ IBlockState state = this.worldObj.getBlockState(this.pos); EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(state.getBlock().getMetaFromState(state)); - //Extract energy for shooting the laser itself too! - this.storage.extractEnergy(ENERGY_USE, false); - //The Lens the Reconstructor currently has installed Lens currentLens = this.getLens(); - int distance = currentLens.getDistance(); - for(int i = 0; i < distance; i++){ - BlockPos hitBlock = this.pos.offset(sideToManipulate, i+1); + if(currentLens.canInvoke(this, sideToManipulate, ENERGY_USE)){ + //Extract energy for shooting the laser itself too! + this.storage.extractEnergy(ENERGY_USE, false); - if(currentLens.invoke(this.worldObj.getBlockState(hitBlock), hitBlock, this)){ - shootLaser(this.worldObj, this.getX(), this.getY(), this.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); - break; - } - else if(i >= distance-1){ - shootLaser(this.worldObj, this.getX(), this.getY(), this.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); + int distance = currentLens.getDistance(); + for(int i = 0; i < distance; i++){ + BlockPos hitBlock = this.pos.offset(sideToManipulate, i+1); + + if(currentLens.invoke(this.worldObj.getBlockState(hitBlock), hitBlock, this) || i >= distance-1){ + shootLaser(this.worldObj, this.getX(), this.getY(), this.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); + break; + } } } }