mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Made Reconstructor react to redstone mode changing
This commit is contained in:
parent
cf091dce54
commit
222cac8e74
3 changed files with 44 additions and 20 deletions
|
@ -82,6 +82,9 @@ public class BlockAtomicReconstructor extends BlockContainerBase{
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(this.tryToggleRedstone(world, x, y, z, player)){
|
||||
return true;
|
||||
}
|
||||
if(!world.isRemote){
|
||||
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(x, y, z);
|
||||
if(reconstructor != null){
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver{
|
||||
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver, IRedstoneToggle{
|
||||
|
||||
public static final int ENERGY_USE = 1000;
|
||||
public EnergyStorage storage = new EnergyStorage(3000000);
|
||||
|
@ -44,24 +44,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
//Extract energy for shooting the laser itself too!
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
|
||||
//The Lens the Reconstructor currently has installed
|
||||
Lens currentLens = this.getCurrentLens();
|
||||
int distance = currentLens.getDistance();
|
||||
for(int i = 0; i < distance; i++){
|
||||
WorldPos hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
|
||||
if(currentLens.invoke(hitBlock, this)){
|
||||
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
||||
break;
|
||||
}
|
||||
else if(i >= distance-1){
|
||||
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
||||
}
|
||||
}
|
||||
this.doWork();
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -72,6 +55,27 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
|
||||
}
|
||||
|
||||
private void doWork(){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
//Extract energy for shooting the laser itself too!
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
|
||||
//The Lens the Reconstructor currently has installed
|
||||
Lens currentLens = this.getCurrentLens();
|
||||
int distance = currentLens.getDistance();
|
||||
for(int i = 0; i < distance; i++){
|
||||
WorldPos hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
|
||||
if(currentLens.invoke(hitBlock, this)){
|
||||
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
||||
break;
|
||||
}
|
||||
else if(i >= distance-1){
|
||||
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Lens getCurrentLens(){
|
||||
if(this.slots[0] != null){
|
||||
if(this.slots[0].getItem() instanceof ItemLens){
|
||||
|
@ -161,4 +165,21 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
public void setEnergy(int energy){
|
||||
this.storage.setEnergyStored(energy);
|
||||
}
|
||||
|
||||
private boolean activateOnceWithSignal;
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activateOnPulse(){
|
||||
this.doWork();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -651,7 +651,7 @@ booklet.actuallyadditions.chapter.blackLotus.text.2=<i>No, not that one, Vaz
|
|||
|
||||
booklet.actuallyadditions.chapter.crystals.name=Crystals and Reconstructor
|
||||
booklet.actuallyadditions.chapter.crystals.text.1=The <item>Atomic Reconstructor<r> is used to craft <item>Crystals<r>, which are the main crafting ingredient in most items from <imp>Actually Additions<r>. <n>Upon being supplied with power, it shoots out a Laser. When the Laser hits a block, it will convert all surrounding items and blocks, provided they can be converted. <n>When shooting a laser, it uses <imp><rf> RF<r>, but additional rates vary depending on the conversion.
|
||||
booklet.actuallyadditions.chapter.crystals.text.2=There are various <item>Lenses<r> that can be attached to the Reconstructor that don't all follow the default behavior of the Reconstructor and are able to do some neat things. <n>See the <imp>"Reconstructor Lenses & Misc"<r> chapter in the booklet's Miscellaneous section <imp>for more information<r>.
|
||||
booklet.actuallyadditions.chapter.crystals.text.2=There are various <item>Lenses<r> that can be attached to the Reconstructor that don't all follow the default behavior of the Reconstructor and are able to do some neat things. <n>See the <imp>"Reconstructor Lenses & Misc"<r> chapter in the booklet's Miscellaneous section <imp>for more information<r>. <n><n> <n>When right-clicking the Reconstructor with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>.
|
||||
booklet.actuallyadditions.chapter.crystals.text.4=When you have crafted a couple of items, you might want to find a way to <imp>automate this<r>. <n>There is a very simple way to do accomplish this: <n>Place the <item>Atomic Reconstructor<r> down facing into a <item>Precision Dropper<r> (to find it, look it up in the <imp>All Items and Search<r> Entry!). <n>Next, place a <item>Ranged Collector<r> in the area that has the converted items set as a whitelist. <n>Now you can just chuck your raw materials into the Dropper to convert them!
|
||||
|
||||
booklet.actuallyadditions.chapter.bookTutorial.name=Intro to the Manual
|
||||
|
|
Loading…
Reference in a new issue