From 6185bcd694d1de495ed0b31c3f878cefced08cf3 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 30 May 2015 11:27:15 +0100 Subject: [PATCH] added speedMultiplier to the crafter --- .../techreborn/api/recipe/RecipeCrafter.java | 29 +++++++++++++++++-- .../blocks/machine/BlockAlloySmelter.java | 2 +- .../techreborn/blocks/machine/BlockLathe.java | 2 +- .../machine/BlockPlateCuttingMachine.java | 2 +- .../client/gui/GuiAlloySmelter.java | 2 +- .../techreborn/client/gui/GuiCentrifuge.java | 2 +- .../techreborn/client/gui/GuiGrinder.java | 2 +- 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 218801498..18da8c84d 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -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; + } } diff --git a/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java b/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java index e634a8eac..23c307773 100644 --- a/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java +++ b/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java @@ -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; } diff --git a/src/main/java/techreborn/blocks/machine/BlockLathe.java b/src/main/java/techreborn/blocks/machine/BlockLathe.java index c601c40b4..cc6975555 100644 --- a/src/main/java/techreborn/blocks/machine/BlockLathe.java +++ b/src/main/java/techreborn/blocks/machine/BlockLathe.java @@ -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; } diff --git a/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java b/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java index c162842d4..257d6b307 100644 --- a/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java +++ b/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java @@ -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 diff --git a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java index 018091fb2..4674bea7c 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java +++ b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java @@ -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); diff --git a/src/main/java/techreborn/client/gui/GuiCentrifuge.java b/src/main/java/techreborn/client/gui/GuiCentrifuge.java index c9413aca7..eb5a779cf 100644 --- a/src/main/java/techreborn/client/gui/GuiCentrifuge.java +++ b/src/main/java/techreborn/client/gui/GuiCentrifuge.java @@ -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); diff --git a/src/main/java/techreborn/client/gui/GuiGrinder.java b/src/main/java/techreborn/client/gui/GuiGrinder.java index a4cf564d2..b4a63d48b 100644 --- a/src/main/java/techreborn/client/gui/GuiGrinder.java +++ b/src/main/java/techreborn/client/gui/GuiGrinder.java @@ -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);