added speedMultiplier to the crafter
This commit is contained in:
parent
edabf79b1e
commit
6185bcd694
7 changed files with 32 additions and 9 deletions
|
@ -84,6 +84,15 @@ public class RecipeCrafter {
|
|||
double lastEnergy;
|
||||
public boolean isactive = false;
|
||||
|
||||
/**
|
||||
* This is used to change the speed of the crafting operation.
|
||||
*
|
||||
* 0 = none;
|
||||
* 0.2 = 20% speed increase
|
||||
* 0.75 = 75% increase
|
||||
*/
|
||||
double speedMultiplier = 0;
|
||||
|
||||
/**
|
||||
* Call this on the tile tick
|
||||
*/
|
||||
|
@ -102,7 +111,7 @@ public class RecipeCrafter {
|
|||
}
|
||||
if (canGiveInvAll) {
|
||||
currentRecipe = recipe;//Sets the current recipe then syncs
|
||||
this.currentNeededTicks = currentRecipe.tickTime();
|
||||
this.currentNeededTicks = (int)(currentRecipe.tickTime() * (1.0 - speedMultiplier));
|
||||
parentTile.syncWithAll();//update texture
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +122,7 @@ public class RecipeCrafter {
|
|||
currentTickTime = 0;
|
||||
parentTile.syncWithAll();//update texture
|
||||
}
|
||||
if (currentRecipe != null && currentTickTime >= currentRecipe.tickTime()) {//If it has reached the recipe tick time
|
||||
if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time
|
||||
boolean canGiveInvAll = true;
|
||||
for (int i = 0; i < currentRecipe.getOutputs().size(); i++) {//Checks to see if it can fit the output
|
||||
if (!canFitStack(currentRecipe.getOutputs().get(i), outputSlots[i])) {
|
||||
|
@ -134,7 +143,7 @@ public class RecipeCrafter {
|
|||
//Force sync after craft to update texture
|
||||
parentTile.syncWithAll();
|
||||
}
|
||||
} else if (currentRecipe != null && currentTickTime < currentRecipe.tickTime()) {
|
||||
} else if (currentRecipe != null && currentTickTime < currentNeededTicks) {
|
||||
if (energy.canUseEnergy(currentRecipe.euPerTick())) {//This checks to see if it can use the power
|
||||
if (!parentTile.getWorldObj().isRemote) {//remove the power on the server side only
|
||||
this.energy.setEnergyStored(this.energy.getEnergyStored() - currentRecipe.euPerTick());
|
||||
|
@ -250,4 +259,18 @@ public class RecipeCrafter {
|
|||
public boolean isActive() {
|
||||
return isactive;
|
||||
}
|
||||
|
||||
|
||||
public void addSpeedMulti(double amount){
|
||||
if(speedMultiplier + amount >= 0.99)
|
||||
speedMultiplier += amount;
|
||||
}
|
||||
|
||||
public void resetSpeedMulti(){
|
||||
speedMultiplier = 0;
|
||||
}
|
||||
|
||||
public double getSpeedMultiplier(){
|
||||
return speedMultiplier;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class BlockAlloySmelter extends BlockMachineBase {
|
|||
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
|
||||
int metadata = blockAccess.getBlockMetadata(x, y, z);
|
||||
TileAlloySmelter tileAlloySmelter = (TileAlloySmelter) blockAccess.getTileEntity(x, y, z);
|
||||
if(side == metadata && tileAlloySmelter.crafter.currentRecipe != null && tileAlloySmelter.crafter.currentTickTime !=0){
|
||||
if(side == metadata && tileAlloySmelter.crafter.isActive()){
|
||||
return this.iconFrontOn;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class BlockLathe extends BlockMachineBase {
|
|||
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
|
||||
int metadata = blockAccess.getBlockMetadata(x, y, z);
|
||||
TileLathe tileLathe = (TileLathe) blockAccess.getTileEntity(x, y, z);
|
||||
if(side == metadata && tileLathe.crafter.currentRecipe != null){
|
||||
if(side == metadata && tileLathe.crafter.isActive()){
|
||||
return this.iconFrontOn;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class BlockPlateCuttingMachine extends BlockMachineBase {
|
|||
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
|
||||
int metadata = blockAccess.getBlockMetadata(x, y, z);
|
||||
TilePlateCuttingMachine tilePlateCuttingMachine = (TilePlateCuttingMachine) blockAccess.getTileEntity(x, y, z);
|
||||
if(side == metadata && tilePlateCuttingMachine.crafter.currentRecipe != null){
|
||||
if(side == metadata && tilePlateCuttingMachine.crafter.isActive()){
|
||||
return this.iconFrontOn;
|
||||
}
|
||||
return metadata == 0 && side == 3 ? this.iconFront
|
||||
|
|
|
@ -41,7 +41,7 @@ public class GuiAlloySmelter extends GuiContainer {
|
|||
int j = 0;
|
||||
|
||||
if(alloysmelter.crafter.currentRecipe != null) {
|
||||
j = this.alloysmelter.crafter.currentTickTime * 24 / this.alloysmelter.crafter.currentRecipe.tickTime();
|
||||
j = this.alloysmelter.crafter.currentTickTime * 24 / this.alloysmelter.crafter.currentNeededTicks;
|
||||
}
|
||||
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class GuiCentrifuge extends GuiContainer {
|
|||
int j = 0;
|
||||
|
||||
if(centrifuge.crafter.currentRecipe != null) {
|
||||
j = this.centrifuge.crafter.currentTickTime * 11 / this.centrifuge.crafter.currentRecipe.tickTime();
|
||||
j = this.centrifuge.crafter.currentTickTime * 11 / this.centrifuge.crafter.currentNeededTicks;
|
||||
}
|
||||
this.drawTexturedModalRect(k + 83, l + 23 + 10 - j, 177, 15 + 10 - j, 10, j);
|
||||
this.drawTexturedModalRect(k + 98, l + 38, 177, 51, j, 10);
|
||||
|
|
|
@ -34,7 +34,7 @@ public class GuiGrinder extends GuiContainer{
|
|||
int j = 0;
|
||||
|
||||
if(grinder.crafter.currentRecipe != null) {
|
||||
j = this.grinder.crafter.currentTickTime * 24 / this.grinder.crafter.currentRecipe.tickTime();
|
||||
j = this.grinder.crafter.currentTickTime * 24 / this.grinder.crafter.currentNeededTicks;
|
||||
}
|
||||
this.drawTexturedModalRect(k + 51, l + 35, 176, 14, j + 1, 16);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue