From 222cac8e743b17be42f4d919a8f20bf670680580 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 18 Dec 2015 16:22:39 +0100 Subject: [PATCH] Made Reconstructor react to redstone mode changing --- .../blocks/BlockAtomicReconstructor.java | 3 + .../tile/TileEntityAtomicReconstructor.java | 59 +++++++++++++------ .../assets/actuallyadditions/lang/en_US.lang | 2 +- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java index b72c2bc96..7a760dc03 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java @@ -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){ diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java index 6af24dcad..6594217ff 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java @@ -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(); + } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 72a51a71e..fa2cef2c0 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -651,7 +651,7 @@ booklet.actuallyadditions.chapter.blackLotus.text.2=No, not that one, Vaz booklet.actuallyadditions.chapter.crystals.name=Crystals and Reconstructor booklet.actuallyadditions.chapter.crystals.text.1=The Atomic Reconstructor is used to craft Crystals, which are the main crafting ingredient in most items from Actually Additions. 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. When shooting a laser, it uses RF, but additional rates vary depending on the conversion. -booklet.actuallyadditions.chapter.crystals.text.2=There are various Lenses 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. See the "Reconstructor Lenses & Misc" chapter in the booklet's Miscellaneous section for more information. +booklet.actuallyadditions.chapter.crystals.text.2=There are various Lenses 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. See the "Reconstructor Lenses & Misc" chapter in the booklet's Miscellaneous section for more information. When right-clicking the Reconstructor with a Redstone Torch in hand, it will change between a mode where it gets deactivated by Redstone and a mode where it responds to pulses. booklet.actuallyadditions.chapter.crystals.text.4=When you have crafted a couple of items, you might want to find a way to automate this. There is a very simple way to do accomplish this: Place the Atomic Reconstructor down facing into a Precision Dropper (to find it, look it up in the All Items and Search Entry!). Next, place a Ranged Collector in the area that has the converted items set as a whitelist. Now you can just chuck your raw materials into the Dropper to convert them! booklet.actuallyadditions.chapter.bookTutorial.name=Intro to the Manual