Added 'Grinding Balls' to the SAG Mill for > 2x ore output.

This commit is contained in:
cp committed 2014-04-22 20:51:43 +08:00
1 parent c1363bc2f3
commit a726e382a2
25 files changed
+570 -69

No files matched your search

+1 -1
View File
@@ -99,7 +99,7 @@ public final class Config {
public static float vanillaSwordSkullLootingModifier = 0.1f;
public static int darkSteelSwordPowerUsePerHit = 750;
public static double darkSteelSwordEnderPearlDropChance = 1;
public static double darkSteelSwordEnderPearlDropChancePerLooting = 0.2;
public static double darkSteelSwordEnderPearlDropChancePerLooting = 0.1;
public static int darkSteelPickPowerUseObsidian = 10000;
public static int darkSteelPickEffeciencyObsidian = 50;
@@ -8,8 +8,12 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.ISpecialArmor;
import net.minecraftforge.common.util.EnumHelper;
import org.lwjgl.input.Keyboard;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -18,16 +22,18 @@ import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.machine.power.PowerDisplayUtil;
import crazypants.enderio.material.Alloy;
import crazypants.util.ItemUtil;
import crazypants.util.Lang;
public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerItem, ISpecialArmor {
public static final ArmorMaterial MATERIAL = EnumHelper.addArmorMaterial("darkSteel", 33, new int[] { 2, 7, 5, 2 }, 25);
public static final int[] CAPACITY = new int[] { Config.darkSteelPowerStorage, Config.darkSteelPowerStorage, Config.darkSteelPowerStorage * 2,
Config.darkSteelPowerStorage * 2 };
Config.darkSteelPowerStorage * 2 };
public static final int[] RF_PER_DAMAGE_POINT = new int[] { Config.darkSteelPowerStorage, Config.darkSteelPowerStorage, Config.darkSteelPowerStorage * 2,
Config.darkSteelPowerStorage * 2 };
Config.darkSteelPowerStorage * 2 };
public static final String[] NAMES = new String[] { "helmet", "chestplate", "leggings", "boots" };
@@ -77,10 +83,13 @@ public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerIte
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
list.add("Durability: " + (itemstack.getMaxDamage() - itemstack.getItemDamage()) + "/" + itemstack.getMaxDamage());
String str = "Power: " + PowerDisplayUtil.formatPower(getEnergyStored(itemstack) / 10) + "/"
+ PowerDisplayUtil.formatPower(getMaxEnergyStored(itemstack) / 10) + " " + PowerDisplayUtil.abrevation();
list.add(str);
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
list.add(Lang.localize("item.darkSteel.tooltip.line1"));
} else {
list.add(ItemUtil.getDurabilityString(itemstack));
list.add(PowerDisplayUtil.getStoredEnergyString(itemstack));
list.add(EnumChatFormatting.WHITE + "" + EnumChatFormatting.ITALIC + Lang.localize("item.tooltip.showDetails"));
}
}
@Override
@@ -162,7 +171,7 @@ public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerIte
// {
// int chance = event.world.rand.nextInt(100);
// int armorType = event.world.rand.nextInt(4);
//
//
// if(chance < 3)
// {
// if(event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntitySkeleton)
@@ -172,7 +181,7 @@ public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerIte
// int chestplate = event.world.rand.nextInt(100);
// int leggings = event.world.rand.nextInt(100);
// int boots = event.world.rand.nextInt(100);
//
//
// if(armorType == 0)
// {
// if(event.entityLiving instanceof EntityZombie && sword < 50) event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(GlowstoneSword));
@@ -12,6 +12,9 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.input.Keyboard;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.registry.GameRegistry;
import crazypants.enderio.Config;
@@ -19,6 +22,8 @@ import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.machine.power.PowerDisplayUtil;
import crazypants.enderio.material.Alloy;
import crazypants.util.ItemUtil;
import crazypants.util.Lang;
public class ItemDarkSteelPickaxe extends ItemPickaxe implements IEnergyContainerItem {
@@ -152,18 +157,20 @@ public class ItemDarkSteelPickaxe extends ItemPickaxe implements IEnergyContaine
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
//TODO: Localize
list.add("Durability: " + (itemstack.getMaxDamage() - itemstack.getItemDamage()) + "/" + itemstack.getMaxDamage());
String str = "Power: " + PowerDisplayUtil.formatPower(getEnergyStored(itemstack) / 10) + "/"
+ PowerDisplayUtil.formatPower(getMaxEnergyStored(itemstack) / 10) + " " + PowerDisplayUtil.abrevation();
list.add(str);
list.add("");
list.add(EnumChatFormatting.BLUE + "+" + Config.darkSteelPickEffeciencyBoostWhenPowered + " Effeciency when powered");
list.add(EnumChatFormatting.BLUE + "+" + Config.darkSteelPickEffeciencyObsidian + " Effeciency breaking obsidian ");
list.add(EnumChatFormatting.BLUE + " (cost "
+ PowerDisplayUtil.formatPower(Config.darkSteelPickPowerUseObsidian / 10) + " "
+ PowerDisplayUtil.abrevation() + ")");
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
//TODO: Localize
list.add(Lang.localize("item.darkSteel.tooltip.line1"));
list.add(EnumChatFormatting.BLUE + "+" + Config.darkSteelPickEffeciencyBoostWhenPowered + " Effeciency when powered");
list.add(EnumChatFormatting.BLUE + "+" + Config.darkSteelPickEffeciencyObsidian + " Effeciency breaking obsidian ");
list.add(EnumChatFormatting.BLUE + " (cost "
+ PowerDisplayUtil.formatPower(Config.darkSteelPickPowerUseObsidian / 10) + " "
+ PowerDisplayUtil.abrevation() + ")");
} else {
list.add(ItemUtil.getDurabilityString(itemstack));
list.add(PowerDisplayUtil.getStoredEnergyString(itemstack));
list.add(EnumChatFormatting.WHITE + "" + EnumChatFormatting.ITALIC + Lang.localize("item.tooltip.showDetails"));
}
}
public ItemStack createItemStack() {
@@ -2,7 +2,6 @@ package crazypants.enderio.item;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityCreeper;
@@ -14,11 +13,13 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovementInput;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import org.lwjgl.input.Keyboard;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -27,6 +28,8 @@ import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.machine.power.PowerDisplayUtil;
import crazypants.enderio.material.Alloy;
import crazypants.util.ItemUtil;
import crazypants.util.Lang;
import crazypants.util.Util;
public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerItem {
@@ -220,15 +223,17 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
//TODO: Localize
list.add("Durability: " + (itemstack.getMaxDamage() - itemstack.getItemDamage()) + "/" + itemstack.getMaxDamage());
String str = "Power: " + PowerDisplayUtil.formatPower(getEnergyStored(itemstack) / 10) + "/"
+ PowerDisplayUtil.formatPower(getMaxEnergyStored(itemstack) / 10) + " " + PowerDisplayUtil.abrevation();
list.add(str);
MovementInput input = Minecraft.getMinecraft().thePlayer.movementInput;
list.add("Increased skull and ender pearl drops.");
list.add("Enderman can't teleport once hit.");
list.add("");
list.add(EnumChatFormatting.BLUE + "+1 Damage when Powered");
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
list.add(Lang.localize("item.darkSteel.tooltip.line1"));
list.add("Increased skull and ender pearl drops.");
list.add("Enderman can't teleport once hit.");
list.add(EnumChatFormatting.BLUE + "+1 Damage when Powered");
} else {
list.add(ItemUtil.getDurabilityString(itemstack));
list.add(PowerDisplayUtil.getStoredEnergyString(itemstack));
list.add(EnumChatFormatting.WHITE + "" + EnumChatFormatting.ITALIC + Lang.localize("item.tooltip.showDetails"));
}
}
@@ -15,7 +15,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
protected PoweredTask currentTask = null;
protected IMachineRecipe lastCompletedRecipe;
private final Random random = new Random();
protected final Random random = new Random();
public AbstractPoweredTaskEntity(SlotDefinition slotDefinition) {
super(slotDefinition);
@@ -80,7 +80,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
boolean requiresClientSync = false;
// Process any current items
requiresClientSync |= checkProgress();
requiresClientSync |= checkProgress(redstoneChecksPassed);
if(currentTask != null || !hasPower() || !hasInputStacks()) {
return requiresClientSync;
@@ -95,15 +95,13 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
return requiresClientSync;
}
protected boolean checkProgress() {
protected boolean checkProgress(boolean redstoneChecksPassed) {
if(currentTask == null || !hasPower()) {
return false;
}
double used = Math.min(powerHandler.getEnergyStored(), getPowerUsePerTick());
powerHandler.setEnergy(powerHandler.getEnergyStored() - used);
currentTask.update((float) used);
if(redstoneChecksPassed) {
usePower();
}
// then check if we are done
if(currentTask.isComplete()) {
taskComplete();
@@ -112,6 +110,13 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
return worldObj.getWorldTime() % 10 == 0;
}
protected double usePower() {
double used = Math.min(powerHandler.getEnergyStored(), getPowerUsePerTick());
powerHandler.setEnergy(powerHandler.getEnergyStored() - used);
currentTask.update((float) used);
return used;
}
protected void taskComplete() {
if(currentTask != null) {
@@ -119,6 +124,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
ResultStack[] output = currentTask.getCompletedResult();
if(output != null && output.length > 0) {
ResultStack[] results = currentTask.getCompletedResult();
List<ItemStack> outputStacks = new ArrayList<ItemStack>(slotDefinition.getNumOutputSlots());
@@ -144,13 +150,21 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
int listIndex = 0;
for (int i = slotDefinition.minOutputSlot; i <= slotDefinition.maxOutputSlot; i++) {
ItemStack st = outputStacks.get(listIndex);
if(st != null) {
st = st.copy();
}
inventory[i] = st;
listIndex++;
}
}
} else {
System.out.println("AbstractPoweredTaskEntity.taskComplete: no output " + output);
}
} else {
System.out.println("AbstractPoweredTaskEntity.taskComplete: current task is null");
}
markDirty();
currentTask = null;
}
@@ -261,8 +275,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
protected boolean startNextTask(IMachineRecipe nextRecipe, float chance) {
if(hasPower() && nextRecipe.isRecipe(getInputs())) {
// then get our recipe and take away the source items
currentTask = new PoweredTask(nextRecipe, chance, getInputs());
currentTask = createTask(nextRecipe, chance);
List<MachineRecipeInput> consumed = nextRecipe.getQuantitiesConsumed(getInputs());
for (MachineRecipeInput item : consumed) {
if(item != null) {
@@ -279,6 +292,10 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
return false;
}
protected PoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
return new PoweredTask(nextRecipe, chance, getInputs());
}
@Override
public void readCustomNBT(NBTTagCompound nbtRoot) {
super.readCustomNBT(nbtRoot);
@@ -158,7 +158,6 @@ public abstract class GuiMachineBase extends GuiContainerBase {
if(showRecipeButton()) {
IconEIO.RECIPE.renderIcon(k + 155, l + 43,16,16,0, true);
//IconEIO.RECIPE.renderIcon(0,0,0,16,16,true);
}
SelectedFace sel = configOverlay.getSelection();
@@ -55,7 +55,7 @@ public class PoweredTask {
this.recipe = recipe;
this.usedEnergy = usedEnergy;
this.chance = chance;
this.chance = MathHelper.clamp_float(chance, 0, 1);
requiredEnergy = recipe.getEnergyRequired(inputsIn);
}
@@ -83,6 +83,22 @@ public class PoweredTask {
this.inputs = inputs;
}
public float getRequiredEnergy() {
return requiredEnergy;
}
public void setRequiredEnergy(float requiredEnergy) {
this.requiredEnergy = requiredEnergy;
}
public float getChance() {
return chance;
}
public void setChance(float chance) {
this.chance = chance;
}
public void writeToNBT(NBTTagCompound nbtRoot) {
NBTTagCompound stackRoot;
@@ -1,8 +1,14 @@
package crazypants.enderio.machine.crusher;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
@@ -10,8 +16,11 @@ import crazypants.enderio.machine.AbstractMachineBlock;
public class BlockCrusher extends AbstractMachineBlock {
public static BlockCrusher create() {
BlockCrusher res = new BlockCrusher();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -19,6 +28,18 @@ public class BlockCrusher extends AbstractMachineBlock {
super(ModObject.blockSagMill, TileCrusher.class);
}
@SubscribeEvent
public void addGrindingBallTooltip(ItemTooltipEvent evt) {
IGrindingMultiplier gb = CrusherRecipeManager.instance.getGrindballFromStack(evt.itemStack);
if(gb != null) {
List<String> list = evt.toolTip;
list.add(EnumChatFormatting.BLUE + "Grinding Ball Properties");
list.add(EnumChatFormatting.GRAY + "Ouput x" + gb.getGrindingMultiplier());
list.add(EnumChatFormatting.GRAY + "Chance Outputs x" + gb.getChanceMultiplier());
list.add(EnumChatFormatting.GRAY + "Power Used x" + gb.getPowerMultiplier());
}
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
// The server needs the container as it manages the adding and removing of
@@ -20,25 +20,32 @@ public class ContainerCrusher extends AbstractMachineContainer {
return tileEntity.isItemValidForSlot(0, itemStack);
}
});
addSlotToContainer(new Slot(tileEntity, 1, 49, 59) {
addSlotToContainer(new Slot(tileEntity, 1, 122, 23) {
@Override
public boolean isItemValid(ItemStack itemStack) {
return tileEntity.isItemValidForSlot(1, itemStack);
}
});
addSlotToContainer(new Slot(tileEntity, 2, 49, 59) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
});
addSlotToContainer(new Slot(tileEntity, 2, 70, 59) {
addSlotToContainer(new Slot(tileEntity, 3, 70, 59) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
});
addSlotToContainer(new Slot(tileEntity, 3, 91, 59) {
addSlotToContainer(new Slot(tileEntity, 4, 91, 59) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
});
addSlotToContainer(new Slot(tileEntity, 4, 112, 59) {
addSlotToContainer(new Slot(tileEntity, 5, 112, 59) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
@@ -33,7 +33,7 @@ public class CrusherMachineRecipe extends AbstractMachineRecipe {
if(input == null) {
return false;
}
return CrusherRecipeManager.instance.getRecipeForInput(input.item) != null;
return CrusherRecipeManager.instance.isValidInput(input);
}
@Override
@@ -57,9 +57,6 @@ public class CrusherMachineRecipe extends AbstractMachineRecipe {
IRecipeOutput output = new crazypants.enderio.crafting.impl.RecipeOutput(co.getOutput(), co.getChance());
components.add(output);
}
// IRecipeInput input = new RecipeInput(CrusherRecipeManager.getInput(cr));
// List<IRecipeComponent> components = new ArrayList<IRecipeComponent>();
// components.add(input);
result.add(new EnderIoRecipe(IEnderIoRecipe.SAG_MILL_ID, cr.getEnergyRequired(), components));
}
return result;
@@ -29,17 +29,54 @@ public class CrusherRecipeManager {
static final CrusherRecipeManager instance = new CrusherRecipeManager();
public static CrusherRecipeManager getInstance() {
return instance;
}
private final List<Recipe> recipes = new ArrayList<Recipe>();
private final List<GrindingBall> balls = new ArrayList<GrindingBall>();
public CrusherRecipeManager() {
// GrindingBall gb = new GrindingBall(new ItemStack(Items.flint));
// gb.setGrindingMultiplier(1.25f);
// gb.setChanceMultiplier(1.25f);
// gb.setPowerMultiplier(0.75f);
// gb.setDurationMJ(ORE_ENERGY_COST * 6);
//
// balls.add(gb);
}
public boolean isValidSagBall(ItemStack stack) {
return getGrindballFromStack(stack) != null;
}
public IGrindingMultiplier getGrindballFromStack(ItemStack stack) {
if(stack == null) {
return null;
}
for(GrindingBall ball : balls) {
if(ball.isInput(stack)) {
return ball;
}
}
return null;
}
public boolean isValidInput(MachineRecipeInput input) {
if(input.slotNumber == 1) {
return isValidSagBall(input.item);
}
return getRecipeForInput(input.item) != null;
}
public void loadRecipesFromConfig() {
RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, null);
GrindingBallTagHandler th = new GrindingBallTagHandler();
RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, th);
balls.addAll(th.balls);
Log.info("Loaded " + balls.size() + " grinding balls from SAG Mill config.");
if(config != null) {
processConfig(config);
} else {
@@ -0,0 +1,84 @@
package crazypants.enderio.machine.crusher;
import net.minecraft.item.ItemStack;
import crazypants.enderio.machine.recipe.RecipeInput;
public class GrindingBall extends RecipeInput implements IGrindingMultiplier {
float chanceMultiplier = 1;
float powerMultiplier = 1;
float grindingMultiplier = 1;
int durationMJ;
RecipeInput ri;
// public GrindingBall(ItemStack item, boolean useMeta, float multiplier, int slot) {
// super(item, useMeta, multiplier, slot);
// }
//
// public GrindingBall(ItemStack input, boolean useMeta) {
// super(input, useMeta);
// }
//
// public GrindingBall(ItemStack input) {
// super(input);
// }
public GrindingBall(RecipeInput ri, float gm, float cm, float pm, int dmj) {
super(ri.getInput());
this.ri = ri;
grindingMultiplier = gm;
chanceMultiplier = cm;
powerMultiplier = pm;
durationMJ = dmj;
}
@Override
public boolean isInput(ItemStack test) {
return ri.isInput(test);
}
@Override
public float getGrindingMultiplier() {
return grindingMultiplier;
}
@Override
public float getChanceMultiplier() {
return chanceMultiplier;
}
@Override
public float getPowerMultiplier() {
return powerMultiplier;
}
@Override
public void setChanceMultiplier(float chanceMultiplier) {
this.chanceMultiplier = chanceMultiplier;
}
@Override
public void setPowerMultiplier(float powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
@Override
public void setGrindingMultiplier(float grindingMultiplier) {
this.grindingMultiplier = grindingMultiplier;
}
@Override
public int getDurationMJ() {
return durationMJ;
}
@Override
public void setDurationMJ(int durationMJ) {
this.durationMJ = durationMJ;
}
}
@@ -0,0 +1,64 @@
package crazypants.enderio.machine.crusher;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import crazypants.enderio.machine.recipe.CustomTagHandler;
import crazypants.enderio.machine.recipe.RecipeConfigParser;
import crazypants.enderio.machine.recipe.RecipeInput;
public class GrindingBallTagHandler implements CustomTagHandler{
private static final String ELEMENT_ROOT = "grindingBalls";
private static final String BALL_ROOT = "grindingBall";
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>();
boolean processStack = false;
private float gm;
private float pm;
private float cm;
private int dmj;
@Override
public boolean startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if(ELEMENT_ROOT.equals(localName)) {
return true;
}
if(BALL_ROOT.equals(localName)) {
gm = RecipeConfigParser.getFloatValue(AT_GM, attributes, 1);
cm = RecipeConfigParser.getFloatValue(AT_CM, attributes, 1);
pm = RecipeConfigParser.getFloatValue(AT_PM, attributes, 1);
dmj = RecipeConfigParser.getIntValue(AT_DMJ, attributes, 2400);
processStack = 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);
}
return false;
}
@Override
public boolean endElement(String uri, String localName, String qName) throws SAXException {
if(ELEMENT_ROOT.equals(localName) || BALL_ROOT.equals(localName)) {
processStack = false;
return true;
}
return false;
}
}
@@ -0,0 +1,86 @@
package crazypants.enderio.machine.crusher;
import net.minecraft.nbt.NBTTagCompound;
public class GrindingMultiplierNBT implements IGrindingMultiplier {
float chanceMultiplier = 1;
float powerMultiplier = 1;
float grindingMultiplier = 1;
int durationMJ;
private static String CM = "grindBall.chanceMultiplier";
private static String PM = "grindBall.powerMultiplier";
private static String GM = "grindBall.grindingMultiplier";
private static String DMJ = "grindBall.durationMJ";
public static GrindingMultiplierNBT readFromNBT(NBTTagCompound nbtRoot) {
if(nbtRoot.hasKey(CM) && nbtRoot.hasKey(PM)&& nbtRoot.hasKey(GM)&& nbtRoot.hasKey(DMJ)) {
return new GrindingMultiplierNBT(nbtRoot.getFloat(CM), nbtRoot.getFloat(PM), nbtRoot.getFloat(GM), nbtRoot.getInteger(DMJ));
}
return null;
}
public static void writeToNBT(IGrindingMultiplier gm, NBTTagCompound nbtRoot) {
if(gm != null) {
nbtRoot.setFloat(CM, gm.getChanceMultiplier());
nbtRoot.setFloat(PM, gm.getPowerMultiplier());
nbtRoot.setFloat(GM, gm.getGrindingMultiplier());
nbtRoot.setInteger(DMJ, gm.getDurationMJ());
}
}
protected GrindingMultiplierNBT(float chanceMultiplier, float powerMultiplier, float grindingMultiplier, int durationMJ) {
this.chanceMultiplier = chanceMultiplier;
this.powerMultiplier = powerMultiplier;
this.grindingMultiplier = grindingMultiplier;
this.durationMJ = durationMJ;
}
@Override
public float getGrindingMultiplier() {
return grindingMultiplier;
}
@Override
public float getChanceMultiplier() {
return chanceMultiplier;
}
@Override
public float getPowerMultiplier() {
return powerMultiplier;
}
@Override
public void setChanceMultiplier(float chanceMultiplier) {
this.chanceMultiplier = chanceMultiplier;
}
@Override
public void setPowerMultiplier(float powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
@Override
public void setGrindingMultiplier(float grindingMultiplier) {
this.grindingMultiplier = grindingMultiplier;
}
@Override
public int getDurationMJ() {
return durationMJ;
}
@Override
public void setDurationMJ(int durationMJ) {
this.durationMJ = durationMJ;
}
}
@@ -4,15 +4,14 @@ import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
import crazypants.enderio.machine.AbstractMachineEntity;
import crazypants.enderio.machine.GuiMachineBase;
import crazypants.render.RenderUtil;
public class GuiCrusher extends GuiMachineBase {
private AbstractMachineEntity tileEntity;
private TileCrusher tileEntity;
public GuiCrusher(InventoryPlayer par1InventoryPlayer, AbstractMachineEntity inventory) {
public GuiCrusher(InventoryPlayer par1InventoryPlayer, TileCrusher inventory) {
super(inventory, new ContainerCrusher(par1InventoryPlayer, inventory));
tileEntity = inventory;
}
@@ -29,11 +28,16 @@ public class GuiCrusher extends GuiMachineBase {
int guiTop = (height - ySize) / 2;
drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
int i1;
i1 = tileEntity.getProgressScaled(24);
drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, i1 + 1);
int barHeight = tileEntity.getProgressScaled(24);
drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, barHeight + 1);
barHeight = tileEntity.getBallDurationScaled(16);
if(barHeight > 0) {
drawTexturedModalRect(guiLeft + 142, guiTop + 23 + (16 - barHeight), 186, 31, 4, barHeight);
}
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
}
}
@@ -0,0 +1,21 @@
package crazypants.enderio.machine.crusher;
public interface IGrindingMultiplier {
void setDurationMJ(int durationMJ);
int getDurationMJ();
void setGrindingMultiplier(float grindingMultiplier);
void setPowerMultiplier(float powerMultiplier);
void setChanceMultiplier(float chanceMultiplier);
float getPowerMultiplier();
float getChanceMultiplier();
float getGrindingMultiplier();
}
@@ -1,14 +1,21 @@
package crazypants.enderio.machine.crusher;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractPoweredTaskEntity;
import crazypants.enderio.machine.IMachineRecipe;
import crazypants.enderio.machine.MachineRecipeInput;
import crazypants.enderio.machine.PoweredTask;
import crazypants.enderio.machine.SlotDefinition;
public class TileCrusher extends AbstractPoweredTaskEntity {
protected IGrindingMultiplier gb;
protected int currGbUse = 0;
public TileCrusher() {
super(new SlotDefinition(1, 4));
super(new SlotDefinition(2, 4));
}
@Override
@@ -23,7 +30,85 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
@Override
protected boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
return CrusherRecipeManager.instance.getRecipeForInput(itemstack) != null;
if(itemstack == null) {
return false;
}
return CrusherRecipeManager.instance.isValidInput(new MachineRecipeInput(i, itemstack));
}
public int getBallDurationScaled(int scale) {
if(gb == null) {
return 0;
}
float res = 1 - (float)currGbUse / (float)gb.getDurationMJ();
return (int)(res * scale);
}
@Override
protected double usePower() {
double res = super.usePower();
if(gb != null) {
currGbUse += res;
if(currGbUse > gb.getDurationMJ()) {
currGbUse = 0;
gb = null;
}
}
if(gb == null ) {
gb = CrusherRecipeManager.getInstance().getGrindballFromStack(inventory[1]);
if(gb != null) {
decrStackSize(1, 1);
markDirty();
}
}
return res;
}
@Override
protected void taskComplete() {
PoweredTask ct = currentTask;
super.taskComplete();
//run it again if the ball says so
if(gb != null) {
float chance = random.nextFloat();
float mul = gb.getGrindingMultiplier() - 1;
while(mul > 0) {
if(chance <= mul){
currentTask = ct;
super.taskComplete();
}
mul--;
}
}
}
@Override
protected PoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
PoweredTask res;
if(gb != null) {
res = new PoweredTask(nextRecipe, chance * gb.getChanceMultiplier(), getInputs());
res.setRequiredEnergy(res.getRequiredEnergy() * gb.getPowerMultiplier());
} else {
res = new PoweredTask(nextRecipe, chance, getInputs());
}
return res;
}
@Override
public void readCustomNBT(NBTTagCompound nbtRoot) {
super.readCustomNBT(nbtRoot);
gb = GrindingMultiplierNBT.readFromNBT(nbtRoot);
currGbUse = nbtRoot.getInteger("currGbUse");
}
@Override
public void writeCustomNBT(NBTTagCompound nbtRoot) {
super.writeCustomNBT(nbtRoot);
if(gb != null) {
GrindingMultiplierNBT.writeToNBT(gb, nbtRoot);
}
nbtRoot.setInteger("currGbUse", currGbUse);
}
@Override
@@ -2,6 +2,8 @@ package crazypants.enderio.machine.power;
import java.text.NumberFormat;
import net.minecraft.item.ItemStack;
import cofh.api.energy.IEnergyContainerItem;
import crazypants.enderio.Config;
import crazypants.util.Lang;
@@ -51,6 +53,21 @@ public class PowerDisplayUtil {
FLOAT_NF.setMaximumFractionDigits(1);
}
public static String getStoredEnergyString(ItemStack item) {
if(item == null) {
return null;
}
if(! (item.getItem() instanceof IEnergyContainerItem) ) {
return null;
}
IEnergyContainerItem ci = (IEnergyContainerItem)item.getItem();
return Lang.localize("item.tooltip.power")+ " "+ PowerDisplayUtil.formatPower(ci.getEnergyStored(item) / 10) + "/"
+ PowerDisplayUtil.formatPower(ci.getMaxEnergyStored(item) / 10) + " " + PowerDisplayUtil.abrevation();
}
public static String formatStoredPower(double amount, double capacity) {
return formatPower(amount) + "/" + formatPower(capacity) + " " + PowerDisplayUtil.abrevation();
}
@@ -8,7 +8,8 @@ public enum Material {
PHASED_IRON_NUGGET("phasedIronNugget"),
VIBRANT_NUGGET("vibrantNugget"),
PULSATING_CYSTAL("pulsatingCrystal"),
VIBRANT_CYSTAL("vibrantCrystal");
VIBRANT_CYSTAL("vibrantCrystal"),
DRAK_GRINDING_BALL("darkGrindingBall");
public final String unlocalisedName;
public final String iconKey;
@@ -53,6 +53,7 @@ public class MaterialRecipes {
ItemStack phasedGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal());
ItemStack phasedIron = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_IRON.ordinal());
ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal());
ItemStack darkSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.DARK_STEEL.ordinal());
//Conduit Binder
ItemStack cbc = binderComposite.copy();
@@ -84,6 +85,11 @@ public class MaterialRecipes {
ItemStack vibCry = new ItemStack(EnderIO.itemMaterial, 1, Material.VIBRANT_CYSTAL.ordinal());
GameRegistry.addShapedRecipe(vibCry, "nnn", "ngn", "nnn", 'n', vibrantNugget, 'g', Items.emerald);
//Balls
ItemStack darkBall = new ItemStack(EnderIO.itemMaterial, 5, Material.DRAK_GRINDING_BALL.ordinal());
GameRegistry.addShapedRecipe(darkBall, " s ", "sss", " s ", 's', darkSteel);
//Smelting
FurnaceRecipes.smelting().func_151394_a(new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal()), new ItemStack(Items.iron_ingot), 0);
FurnaceRecipes.smelting().func_151394_a(new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal()), new ItemStack(Items.gold_ingot), 0);
@@ -138,7 +144,7 @@ public class MaterialRecipes {
GameRegistry.addRecipe(new ShapedOreRecipe(capacitor, " gr", "gcg", "rg ", 'r', Items.redstone, 'g', gold, 'c', "ingotCopper"));
} else {
GameRegistry.
addShapedRecipe(capacitor, " gr", "gig", "rg ", 'r', Items.redstone, 'g', gold, 'i', Items.iron_ingot);
addShapedRecipe(capacitor, " gr", "gig", "rg ", 'r', Items.redstone, 'g', gold, 'i', Items.iron_ingot);
}
int dustCoal = OreDictionary.getOreID("dustCoal");
@@ -11,6 +11,13 @@ import cofh.api.transport.IItemConduit;
public class ItemUtil {
public static String getDurabilityString(ItemStack item) {
if(item == null) {
return null;
}
return Lang.localize("item.darkSteel.tooltip.durability") + " " + (item.getMaxDamage() - item.getItemDamage()) + "/" + item.getMaxDamage();
}
public static int doInsertItem(Object into, ItemStack item, ForgeDirection side) {
if(into == null || item == null) {
return 0;