Moved lenses to API side

Bump API version to 13
This commit is contained in:
Ellpeck 2016-05-15 12:00:42 +02:00
parent 09ecb708aa
commit 3403947af0
6 changed files with 32 additions and 21 deletions

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.api;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import de.ellpeck.actuallyadditions.api.recipe.*;
import net.minecraft.item.Item;
@ -28,7 +29,7 @@ public class ActuallyAdditionsAPI{
public static final String MOD_ID = "actuallyadditions";
public static final String API_ID = MOD_ID+"api";
public static final String API_VERSION = "12";
public static final String API_VERSION = "13";
/**
* Use this to handle things that aren't based in the API itself
@ -59,6 +60,14 @@ public class ActuallyAdditionsAPI{
public static IBookletEntry entryCrossover;
public static IBookletEntry allAndSearch;
//These are getting initialized in Actually Additions' PreInit phase
//DO NOT CHANGE/OVERRIDE THESE!!
public static LensConversion lensDefaultConversion;
public static Lens lensDetonation;
public static Lens lensDeath;
public static Lens lensColor;
public static Lens lensDisruption;
/**
* Adds a Recipe to the Crusher Recipe Registry
* The second output will be nothing
@ -162,7 +171,7 @@ public class ActuallyAdditionsAPI{
}
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse){
addReconstructorLensConversionRecipe(input, output, energyUse, LensConversion.DEFAULT_CONVERSION);
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
/**
@ -179,7 +188,7 @@ public class ActuallyAdditionsAPI{
}
public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse){
addReconstructorLensConversionRecipe(input, output, energyUse, LensConversion.DEFAULT_CONVERSION);
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
/**

View file

@ -21,12 +21,10 @@ import net.minecraft.util.math.BlockPos;
* via the ActuallyAdditionsAPI.reconstructorLensConversionRecipes list.
*
* If you want to make a new type of conversion, just use your type in the recipe
* If you want to use the default type of conversion, use DEFAULT_CONVERSION below.
* If you want to use the default type of conversion, use ActuallyAdditionsAPI.lensDefaultConversion.
*/
public class LensConversion extends Lens{
public static final LensConversion DEFAULT_CONVERSION = new LensConversion();
@SuppressWarnings("unchecked")
@Override
public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA;
import de.ellpeck.actuallyadditions.mod.items.base.ItemHoeAA;
@ -215,9 +216,9 @@ public class InitItems{
itemSpawnerChanger = new ItemSpawnerChanger("itemSpawnerChanger");
itemMisc = new ItemMisc("itemMisc");
itemCrateKeeper = new ItemGeneric("itemCrateKeeper");
itemColorLens = new ItemLens("itemColorLens", Lenses.LENS_COLOR);
itemExplosionLens = new ItemLens("itemExplosionLens", Lenses.LENS_DETONATION);
itemDamageLens = new ItemLens("itemDamageLens", Lenses.LENS_DEATH);
itemColorLens = new ItemLens("itemColorLens", ActuallyAdditionsAPI.lensColor);
itemExplosionLens = new ItemLens("itemExplosionLens", ActuallyAdditionsAPI.lensDetonation);
itemDamageLens = new ItemLens("itemDamageLens", ActuallyAdditionsAPI.lensDeath);
itemCrystal = new ItemCrystal("itemCrystal");
itemLaserWrench = new ItemLaserWrench("itemLaserWrench");
itemChestToCrateUpgrade = new ItemChestToCrateUpgrade("itemChestToCrateUpgrade");

View file

@ -3,6 +3,7 @@ package de.ellpeck.actuallyadditions.mod.items;
import cofh.api.energy.IEnergyContainerItem;
import de.canitzp.rarmor.api.InventoryBase;
import de.canitzp.rarmor.api.modules.IRarmorModule;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
@ -60,18 +61,17 @@ public class ItemRarmorModuleReconstructor extends ItemBase implements IRarmorMo
public void onModuleTickInArmor(World world, EntityPlayer player, ItemStack armorChestplate, ItemStack module, InventoryBase inventory){
if(!world.isRemote && player.isSneaking() && player.onGround){
if(world.getTotalWorldTime()%50 == 0){
RayTraceResult result = WorldUtil.getNearestPositionWithAir(world, player, Lenses.LENS_CONVERSION.getDistance());
IAtomicReconstructor fake = this.getFakeReconstructor(world, player, armorChestplate);
RayTraceResult result = WorldUtil.getNearestPositionWithAir(world, player, fake.getLens().getDistance());
if(result != null){
BlockPos pos = result.getBlockPos();
if(pos != null){
IAtomicReconstructor fake = this.getFakeReconstructor(world, player, armorChestplate);
int energyUse = TileEntityAtomicReconstructor.ENERGY_USE*2;
if(fake.getEnergy() >= energyUse){
fake.getLens().invoke(world.getBlockState(pos), pos, fake);
EnumFacing hit = result.sideHit;
TileEntityAtomicReconstructor.shootLaser(world, player.posX-player.width/2, player.posY+player.getYOffset()+player.getEyeHeight()/2, player.posZ-player.width/2, pos.getX()+hit.getFrontOffsetX(), pos.getY()+hit.getFrontOffsetY(), pos.getZ()+hit.getFrontOffsetZ(), Lenses.LENS_CONVERSION);
TileEntityAtomicReconstructor.shootLaser(world, player.posX-player.width/2, player.posY+player.getYOffset()+player.getEyeHeight()/2, player.posZ-player.width/2, pos.getX()+hit.getFrontOffsetX(), pos.getY()+hit.getFrontOffsetY(), pos.getZ()+hit.getFrontOffsetZ(), fake.getLens());
fake.extractEnergy(energyUse);
}
@ -124,7 +124,7 @@ public class ItemRarmorModuleReconstructor extends ItemBase implements IRarmorMo
@Override
public Lens getLens(){
return Lenses.LENS_CONVERSION;
return ActuallyAdditionsAPI.lensDefaultConversion;
}
};
}

View file

@ -10,14 +10,16 @@
package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
public class Lenses{
public static final LensConversion LENS_CONVERSION = LensConversion.DEFAULT_CONVERSION;
public static final Lens LENS_DETONATION = new LensDetonation();
public static final Lens LENS_DEATH = new LensDeath();
public static final Lens LENS_COLOR = new LensColor();
public static final Lens LENS_DISRUPTION = new LensDisruption();
public static void init(){
ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion();
ActuallyAdditionsAPI.lensDetonation = new LensDetonation();
ActuallyAdditionsAPI.lensDeath = new LensDeath();
ActuallyAdditionsAPI.lensColor = new LensColor();
ActuallyAdditionsAPI.lensDisruption = new LensDisruption();
}
}

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyReceiver;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.api.lens.Lens;
@ -128,7 +129,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
return ((ILensItem)this.slots[0].getItem()).getLens();
}
}
return this.counter >= 500 ? Lenses.LENS_DISRUPTION : Lenses.LENS_CONVERSION;
return this.counter >= 500 ? ActuallyAdditionsAPI.lensDisruption : ActuallyAdditionsAPI.lensDefaultConversion;
}
@Override