mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 04:09:43 +00:00
#738 dupe bug with sag mill
This commit is contained in:
1 parent
6f65ce5088
commit
1478efedb3
9 files changed
+64
-15
No files matched your search
@@ -327,7 +327,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected PoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
|
||||
protected IPoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
|
||||
return new PoweredTask(nextRecipe, chance, getInputs());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,4 +21,6 @@ public interface IPoweredTask {
|
||||
|
||||
IMachineRecipe getRecipe();
|
||||
|
||||
public abstract MachineRecipeInput[] getInputs();
|
||||
|
||||
}
|
||||
@@ -82,6 +82,7 @@ public class PoweredTask implements IPoweredTask {
|
||||
return recipe.getCompletedResult(chance, inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineRecipeInput[] getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
@@ -136,7 +137,7 @@ public class PoweredTask implements IPoweredTask {
|
||||
nbtRoot.setFloat(KEY_CHANCE, chance);
|
||||
}
|
||||
|
||||
public static PoweredTask readFromNBT(NBTTagCompound nbtRoot) {
|
||||
public static IPoweredTask readFromNBT(NBTTagCompound nbtRoot) {
|
||||
if(nbtRoot == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.crafting.IRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
@@ -36,6 +37,8 @@ public class CrusherRecipeManager {
|
||||
}
|
||||
|
||||
private final List<Recipe> recipes = new ArrayList<Recipe>();
|
||||
|
||||
private final List<RecipeInput> ballExcludes = new ArrayList<RecipeInput>();
|
||||
|
||||
private final List<GrindingBall> balls = new ArrayList<GrindingBall>();
|
||||
|
||||
@@ -52,6 +55,19 @@ public class CrusherRecipeManager {
|
||||
public boolean isValidSagBall(ItemStack stack) {
|
||||
return getGrindballFromStack(stack) != null;
|
||||
}
|
||||
|
||||
public boolean isExcludedFromBallBonus(MachineRecipeInput[] inputs) {
|
||||
if(inputs == null || inputs.length < 1) {
|
||||
return true;
|
||||
}
|
||||
for(RecipeInput input : ballExcludes) {
|
||||
if(input != null && input.isInput(inputs[0].item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public IGrindingMultiplier getGrindballFromStack(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
@@ -76,7 +92,9 @@ public class CrusherRecipeManager {
|
||||
GrindingBallTagHandler th = new GrindingBallTagHandler();
|
||||
RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, th);
|
||||
balls.addAll(th.balls);
|
||||
ballExcludes.addAll(th.excludes);
|
||||
Log.info("Loaded " + balls.size() + " grinding balls from SAG Mill config.");
|
||||
Log.info("Excluding " + ballExcludes.size() + " recipes from grinding balls bonus.");
|
||||
if(config != null) {
|
||||
processConfig(config);
|
||||
} else {
|
||||
@@ -168,6 +186,4 @@ public class CrusherRecipeManager {
|
||||
return balls;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -6,24 +6,29 @@ import java.util.List;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import crazypants.enderio.crafting.IRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.CustomTagHandler;
|
||||
import crazypants.enderio.machine.recipe.RecipeConfigParser;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
|
||||
public class GrindingBallTagHandler implements CustomTagHandler{
|
||||
public class GrindingBallTagHandler implements CustomTagHandler {
|
||||
|
||||
private static final String ELEMENT_ROOT = "grindingBalls";
|
||||
|
||||
private static final String BALL_ROOT = "grindingBall";
|
||||
|
||||
private static final String EXCLUDES_ROOT = "excludes";
|
||||
|
||||
private static final String AT_GM = "grindingMultiplier";
|
||||
private static final String AT_PM = "powerMultiplier";
|
||||
private static final String AT_CM = "chanceMultiplier";
|
||||
private static final String AT_DMJ = "durationMJ";
|
||||
|
||||
List<GrindingBall> balls = new ArrayList<GrindingBall>();
|
||||
List<RecipeInput> excludes = new ArrayList<RecipeInput>();
|
||||
|
||||
boolean processStack = false;
|
||||
boolean processExclude = false;
|
||||
|
||||
private float gm;
|
||||
private float pm;
|
||||
@@ -43,10 +48,22 @@ public class GrindingBallTagHandler implements CustomTagHandler{
|
||||
processStack = true;
|
||||
return true;
|
||||
}
|
||||
if(EXCLUDES_ROOT.equals(localName)) {
|
||||
processExclude = true;
|
||||
return true;
|
||||
}
|
||||
if(processStack && RecipeConfigParser.ELEMENT_ITEM_STACK.equals(localName)) {
|
||||
RecipeInput ri = RecipeConfigParser.getItemStack(attributes);
|
||||
GrindingBall gb = new GrindingBall(ri,gm,cm,pm,dmj);
|
||||
balls.add(gb);
|
||||
if(ri != null) {
|
||||
GrindingBall gb = new GrindingBall(ri, gm, cm, pm, dmj);
|
||||
balls.add(gb);
|
||||
}
|
||||
}
|
||||
if(processExclude && RecipeConfigParser.ELEMENT_ITEM_STACK.equals(localName)) {
|
||||
RecipeInput ri = RecipeConfigParser.getItemStack(attributes);
|
||||
if(ri != null) {
|
||||
excludes.add(ri);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -54,8 +71,9 @@ public class GrindingBallTagHandler implements CustomTagHandler{
|
||||
|
||||
@Override
|
||||
public boolean endElement(String uri, String localName, String qName) throws SAXException {
|
||||
if(ELEMENT_ROOT.equals(localName) || BALL_ROOT.equals(localName)) {
|
||||
if(ELEMENT_ROOT.equals(localName) || BALL_ROOT.equals(localName) || EXCLUDES_ROOT.equals(localName)) {
|
||||
processStack = false;
|
||||
processExclude = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
|
||||
IPoweredTask ct = currentTask;
|
||||
super.taskComplete();
|
||||
//run it again if the ball says so
|
||||
if(gb != null) {
|
||||
if(gb != null && !CrusherRecipeManager.getInstance().isExcludedFromBallBonus(ct.getInputs())) {
|
||||
float chance = random.nextFloat();
|
||||
float mul = gb.getGrindingMultiplier() - 1;
|
||||
while(mul > 0) {
|
||||
@@ -95,7 +95,7 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
|
||||
protected IPoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
|
||||
PoweredTask res;
|
||||
if(gb != null) {
|
||||
res = new PoweredTask(nextRecipe, chance * gb.getChanceMultiplier(), getInputs());
|
||||
|
||||
@@ -22,6 +22,7 @@ import crazypants.enderio.machine.AbstractPoweredTaskEntity;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
|
||||
import crazypants.enderio.machine.IPoweredTask;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
@@ -467,6 +468,11 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
|
||||
public float getChance() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineRecipeInput[] getInputs() {
|
||||
return new MachineRecipeInput[0];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,10 +9,11 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.fluid.Fluids;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
|
||||
import crazypants.enderio.machine.IPoweredTask;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.PoweredTask;
|
||||
import crazypants.gui.GuiToolTip;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.Lang;
|
||||
@@ -92,14 +93,14 @@ public class GuiVat extends GuiMachineBase {
|
||||
drawTexturedModalRect(guiLeft + 81, guiTop + 76 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
|
||||
IIcon inputIcon = null;
|
||||
PoweredTask task = (PoweredTask)vat.getCurrentTask();
|
||||
IPoweredTask task = vat.getCurrentTask();
|
||||
for (MachineRecipeInput input : task.getInputs()) {
|
||||
if(input.fluid != null && input.fluid.getFluid() != null) {
|
||||
inputIcon = input.fluid.getFluid().getStillIcon();
|
||||
break;
|
||||
}
|
||||
}
|
||||
VatMachineRecipe rec = (VatMachineRecipe) task.getRecipe();
|
||||
IMachineRecipe rec = task.getRecipe();
|
||||
IIcon outputIcon = null;
|
||||
for (ResultStack res : rec.getCompletedResult(1.0f, task.getInputs())) {
|
||||
if(res.fluid != null && res.fluid.getFluid() != null) {
|
||||
|
||||
Reference in new issue
Block a user