#1238, #1251 Improved control and modification of grinding balls via the SAGMillRecipes_User.xml file

Fixed BoP bone segment SAG Mill recipes.
This commit is contained in:
CrazyPants committed 2014-11-18 15:12:24 +08:00
1 parent e957985a80
commit 4135a5acfb
5 files changed
+522 -425

No files matched your search

@@ -4,7 +4,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.item.ItemStack;
@@ -117,7 +116,7 @@ public class CrusherRecipeManager {
public void loadRecipesFromConfig() {
GrindingBallTagHandler th = new GrindingBallTagHandler();
RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, th);
balls.addAll(th.balls);
balls.addAll(th.balls.values());
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.");
@@ -1,11 +1,14 @@
package crazypants.enderio.machine.crusher;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import crazypants.enderio.Log;
import crazypants.enderio.machine.recipe.CustomTagHandler;
import crazypants.enderio.machine.recipe.RecipeConfigParser;
import crazypants.enderio.machine.recipe.RecipeInput;
@@ -18,17 +21,20 @@ public class GrindingBallTagHandler implements CustomTagHandler {
private static final String EXCLUDES_ROOT = "excludes";
private static final String AT_ID = "id";
private static final String AT_REMOVE = "remove";
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 = "durationRF";
List<GrindingBall> balls = new ArrayList<GrindingBall>();
Map<String, GrindingBall> balls = new HashMap<String, GrindingBall>();
List<RecipeInput> excludes = new ArrayList<RecipeInput>();
boolean processStack = false;
boolean processExclude = false;
private String id;
private float gm;
private float pm;
private float cm;
@@ -40,6 +46,23 @@ public class GrindingBallTagHandler implements CustomTagHandler {
return true;
}
if(BALL_ROOT.equals(localName)) {
id = RecipeConfigParser.getStringValue(AT_ID, attributes, null);
if(id == null) {
Log.warn("GrindingBallTagHandler: grinding ball specified without the '" + AT_ID + "' attribute. It will be ignored.");
processStack = false;
return true;
}
boolean remove = RecipeConfigParser.getBooleanValue(AT_REMOVE, attributes, false);
if(remove) {
GrindingBall res = balls.remove(id);
if(res == null) {
Log.warn("User config requested removal of grinding ball with id: " + id + " but it was not found.");
} else {
Log.info("Removed grinding ball with id=" + id + " due to user config.");
}
processStack = false;
return true;
}
gm = RecipeConfigParser.getFloatValue(AT_GM, attributes, 1);
cm = RecipeConfigParser.getFloatValue(AT_CM, attributes, 1);
pm = RecipeConfigParser.getFloatValue(AT_PM, attributes, 1);
@@ -55,13 +78,19 @@ public class GrindingBallTagHandler implements CustomTagHandler {
RecipeInput ri = RecipeConfigParser.getItemStack(attributes);
if(ri != null) {
GrindingBall gb = new GrindingBall(ri, gm, cm, pm, drf);
balls.add(gb);
balls.put(id, gb);
}
}
if(processExclude && RecipeConfigParser.ELEMENT_ITEM_STACK.equals(localName)) {
RecipeInput ri = RecipeConfigParser.getItemStack(attributes);
if(ri != null) {
excludes.add(ri);
boolean remove = RecipeConfigParser.getBooleanValue(AT_REMOVE, attributes, false);
if(remove) {
excludes.remove(ri);
Log.info("Removed grinding ball exclude for " + ri.getInput().getDisplayName() + " due to user config.");
} else {
excludes.add(ri);
}
}
}