mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Update the way lenses work for what's coming up
This commit is contained in:
parent
8ea5a3a330
commit
5b924bbd3a
8 changed files with 49 additions and 19 deletions
|
@ -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<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
|
||||
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
|
||||
public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<TreasureChestLoot>();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<EntityItem> items = (ArrayList<EntityItem>)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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue