Firework Box reacts to redstone torch mode changing now

This commit is contained in:
Ellpeck 2015-12-18 16:25:12 +01:00
parent 222cac8e74
commit 11935c0698
4 changed files with 59 additions and 31 deletions

View file

@ -52,6 +52,9 @@ public class BlockFireworkBox 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){
TileEntityFireworkBox box = (TileEntityFireworkBox)world.getTileEntity(x, y, z);
if(box != null){

View file

@ -40,7 +40,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
public void updateEntity(){
super.updateEntity();
if(!this.worldObj.isRemote){
if(!this.isRedstonePowered && this.storage.getEnergyStored() >= ENERGY_USE){
if(!this.isRedstonePowered){
if(this.currentTime > 0){
this.currentTime--;
if(this.currentTime <= 0){
@ -56,22 +56,24 @@ 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);
if(this.storage.getEnergyStored() >= ENERGY_USE){
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);
//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);
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);
}
}
}
}

View file

@ -22,7 +22,7 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver{
public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IRedstoneToggle{
public EnergyStorage storage = new EnergyStorage(20000);
@ -35,19 +35,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
if(!this.worldObj.isRemote && !this.isRedstonePowered){
if(this.timeUntilNextFirework > 0){
this.timeUntilNextFirework--;
if(this.timeUntilNextFirework <= 0 && this.storage.getEnergyStored() >= USE_PER_SHOT){
int range = 4;
int amount = Util.RANDOM.nextInt(5)+1;
for(int i = 0; i < amount; i++){
ItemStack firework = this.makeFirework();
double x = this.xCoord+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
double z = this.zCoord+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
EntityFireworkRocket rocket = new EntityFireworkRocket(this.worldObj, x, this.yCoord+0.5, z, firework);
this.worldObj.spawnEntityInWorld(rocket);
}
this.storage.extractEnergy(USE_PER_SHOT, false);
if(this.timeUntilNextFirework <= 0){
this.doWork();
}
}
else{
@ -56,6 +45,23 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
}
}
private void doWork(){
if(this.storage.getEnergyStored() >= USE_PER_SHOT){
int range = 4;
int amount = Util.RANDOM.nextInt(5)+1;
for(int i = 0; i < amount; i++){
ItemStack firework = this.makeFirework();
double x = this.xCoord+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
double z = this.zCoord+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
EntityFireworkRocket rocket = new EntityFireworkRocket(this.worldObj, x, this.yCoord+0.5, z, firework);
this.worldObj.spawnEntityInWorld(rocket);
}
this.storage.extractEnergy(USE_PER_SHOT, false);
}
}
private ItemStack makeFirework(){
NBTTagList list = new NBTTagList();
int chargesAmount = Util.RANDOM.nextInt(2)+1;
@ -118,4 +124,21 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
public boolean canConnectEnergy(ForgeDirection from){
return true;
}
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();
}
}

View file

@ -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>. <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.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>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
@ -678,4 +678,4 @@ booklet.actuallyadditions.chapter.miner.text.2=(Works with any colored Drill) <n
booklet.actuallyadditions.chapter.fireworkBox.name=Firework Box
booklet.actuallyadditions.chapter.fireworkBox.text.1=The <item>Firework Box<r> is a perfect thing for New Year's! When placed down and supplied with some <imp>RF<r>, it will shoot out some <imp>randomly generated<r> <item>Fireworks<r> around it. <n>For each shot, it uses <rf> RF. <n><n><i>You know, Vanilla Fireworks are just too bloody annoying to craft, but too awesome not to use. So here's the solution.
booklet.actuallyadditions.chapter.fireworkBox.text.2=<n><n><n><i>Keep it safe. <n>It won't explode.
booklet.actuallyadditions.chapter.fireworkBox.text.2=When right-clicking it 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>.