diff --git a/client/gui/widgets/GuiImgButton.java b/client/gui/widgets/GuiImgButton.java index 8549dedc..cc4b1328 100644 --- a/client/gui/widgets/GuiImgButton.java +++ b/client/gui/widgets/GuiImgButton.java @@ -112,7 +112,7 @@ public class GuiImgButton extends GuiButton implements ITooltip registerApp( 16 * 10 + 0, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName ); registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName ); registerApp( 16 * 10 + 2, Settings.POWER_UNITS, PowerUnits.MJ, ButtonToolTips.PowerUnits, PowerUnits.MJ.unlocalizedName ); - registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.KJ, ButtonToolTips.PowerUnits, PowerUnits.KJ.unlocalizedName ); + registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.MK, ButtonToolTips.PowerUnits, PowerUnits.MK.unlocalizedName ); registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.WA, ButtonToolTips.PowerUnits, PowerUnits.WA.unlocalizedName ); registerApp( 16 * 10 + 5, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName ); diff --git a/core/AEConfig.java b/core/AEConfig.java index 0e776d26..3b769300 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -107,11 +107,10 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo final double DEFAULT_IC2_EXCHANGE = 2.0; final double DEFAULT_RTC_EXCHANGE = 1.0 / 11256.0; final double DEFAULT_RF_EXCHANGE = 0.5; + final double DEFAULT_MEKANISM_EXCHANGE = 0.2; PowerUnits.MJ.conversionRatio = get( "PowerRatios", "BuildCraft", DEFAULT_BC_EXCHANGE ).getDouble( DEFAULT_BC_EXCHANGE ); - // PowerUnits.KJ.conversionRatio = get( "PowerRatios", - // "UniversalElectricity", DEFAULT_UE_EXCHANGE ).getDouble( - // DEFAULT_UE_EXCHANGE ); + PowerUnits.MK.conversionRatio = get( "PowerRatios", "Mekanism", DEFAULT_MEKANISM_EXCHANGE ).getDouble( DEFAULT_MEKANISM_EXCHANGE ); PowerUnits.EU.conversionRatio = get( "PowerRatios", "IC2", DEFAULT_IC2_EXCHANGE ).getDouble( DEFAULT_IC2_EXCHANGE ); PowerUnits.WA.conversionRatio = get( "PowerRatios", "RotaryCraft", DEFAULT_RTC_EXCHANGE ).getDouble( DEFAULT_RTC_EXCHANGE ); PowerUnits.RF.conversionRatio = get( "PowerRatios", "ThermalExpansion", DEFAULT_RF_EXCHANGE ).getDouble( DEFAULT_RF_EXCHANGE ); diff --git a/core/Registration.java b/core/Registration.java index 19585ce2..29008b80 100644 --- a/core/Registration.java +++ b/core/Registration.java @@ -147,6 +147,8 @@ import appeng.recipes.handlers.Grind; import appeng.recipes.handlers.GrindFZ; import appeng.recipes.handlers.Inscribe; import appeng.recipes.handlers.Macerator; +import appeng.recipes.handlers.MekCrusher; +import appeng.recipes.handlers.MekEnrichment; import appeng.recipes.handlers.Press; import appeng.recipes.handlers.Pulverizer; import appeng.recipes.handlers.Shaped; @@ -191,6 +193,8 @@ public class Registration IRecipeHandlerRegistry recipeRegistery = AEApi.instance().registries().recipes(); recipeRegistery.addNewSubItemResolver( new AEItemResolver() ); + recipeRegistery.addNewCraftHandler( "mekcrusher", MekCrusher.class ); + recipeRegistery.addNewCraftHandler( "mekechamber", MekEnrichment.class ); recipeRegistery.addNewCraftHandler( "grind", Grind.class ); recipeRegistery.addNewCraftHandler( "crusher", Crusher.class ); recipeRegistery.addNewCraftHandler( "grindfz", GrindFZ.class ); diff --git a/integration/IntegrationType.java b/integration/IntegrationType.java index 947e1d41..164efa3d 100644 --- a/integration/IntegrationType.java +++ b/integration/IntegrationType.java @@ -1,50 +1,50 @@ package appeng.integration; - public enum IntegrationType { IC2(IntegrationSide.BOTH, "Industrial Craft 2", "IC2"), - + RotaryCraft(IntegrationSide.BOTH, "Rotary Craft", "RotaryCraft"), - + RC(IntegrationSide.BOTH, "Railcraft", "Railcraft"), BC(IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon"), - - MJ6(IntegrationSide.BOTH, "BuildCraft6 Power", null), - - MJ5( IntegrationSide.BOTH, "BuildCraft5 Power", null ), - - RF(IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", null), - - RFItem( IntegrationSide.BOTH, "RedstoneFlux Power - Items", null ), - - MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded" ), - - DSU( IntegrationSide.BOTH, "Deep Storage Unit", null ), - - FZ( IntegrationSide.BOTH, "Factorization", "factorization" ), - - FMP( IntegrationSide.BOTH, "Forge MultiPart", "McMultipart" ), - RB( IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks" ), - - CLApi( IntegrationSide.BOTH, "Colored Lights Core", "coloredlightscore" ), - - Waila( IntegrationSide.CLIENT, "Waila", "Waila" ), - - InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" ), - - NEI( IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems" ), - - CraftGuide( IntegrationSide.CLIENT, "Craft Guide", "craftguide" ); - + MJ6(IntegrationSide.BOTH, "BuildCraft6 Power", null), + + MJ5(IntegrationSide.BOTH, "BuildCraft5 Power", null), + + RF(IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", null), + + RFItem(IntegrationSide.BOTH, "RedstoneFlux Power - Items", null), + + MFR(IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded"), + + DSU(IntegrationSide.BOTH, "Deep Storage Unit", null), + + FZ(IntegrationSide.BOTH, "Factorization", "factorization"), + + FMP(IntegrationSide.BOTH, "Forge MultiPart", "McMultipart"), + + RB(IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks"), + + CLApi(IntegrationSide.BOTH, "Colored Lights Core", "coloredlightscore"), + + Waila(IntegrationSide.CLIENT, "Waila", "Waila"), + + InvTweaks(IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks"), + + NEI(IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems"), + + CraftGuide(IntegrationSide.CLIENT, "Craft Guide", "craftguide"), + + Mekanism(IntegrationSide.BOTH, "Mekanism", "Mekanism"); public final IntegrationSide side; public final String dspName; public final String modID; - - private IntegrationType( IntegrationSide side, String Name, String modid ) { + + private IntegrationType(IntegrationSide side, String Name, String modid) { this.side = side; this.dspName = Name; this.modID = modid; diff --git a/integration/abstraction/IMekanism.java b/integration/abstraction/IMekanism.java index cc9fb1f9..518f8d5b 100644 --- a/integration/abstraction/IMekanism.java +++ b/integration/abstraction/IMekanism.java @@ -5,6 +5,8 @@ import net.minecraft.item.ItemStack; public interface IMekanism { - void addMaceratorRecipe(ItemStack in, ItemStack out); + void addCrusherRecipe(ItemStack in, ItemStack out); + + void addEnrichmentChamberRecipe(ItemStack in, ItemStack out); } diff --git a/integration/modules/Mekanism.java b/integration/modules/Mekanism.java new file mode 100644 index 00000000..f53a0ee3 --- /dev/null +++ b/integration/modules/Mekanism.java @@ -0,0 +1,37 @@ +package appeng.integration.modules; + +import mekanism.api.RecipeHelper; +import net.minecraft.item.ItemStack; +import appeng.integration.BaseModule; +import appeng.integration.abstraction.IMekanism; + +public class Mekanism extends BaseModule implements IMekanism +{ + + public static Mekanism instance; + + @Override + public void Init() throws Throwable + { + TestClass( mekanism.api.energy.IStrictEnergyAcceptor.class ); + } + + @Override + public void PostInit() throws Throwable + { + + } + + @Override + public void addCrusherRecipe(ItemStack in, ItemStack out) + { + RecipeHelper.addCrusherRecipe( in, out ); + } + + @Override + public void addEnrichmentChamberRecipe(ItemStack in, ItemStack out) + { + RecipeHelper.addEnrichmentChamberRecipe( in, out ); + } + +} diff --git a/recipes/handlers/MekCrusher.java b/recipes/handlers/MekCrusher.java new file mode 100644 index 00000000..583eaee6 --- /dev/null +++ b/recipes/handlers/MekCrusher.java @@ -0,0 +1,72 @@ +package appeng.recipes.handlers; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import appeng.api.exceptions.MissingIngredientError; +import appeng.api.exceptions.RecipeError; +import appeng.api.exceptions.RegistrationError; +import appeng.api.recipes.ICraftHandler; +import appeng.api.recipes.IIngredient; +import appeng.core.AELog; +import appeng.core.AppEng; +import appeng.integration.IntegrationType; +import appeng.integration.abstraction.IMekanism; +import appeng.recipes.RecipeHandler; +import appeng.util.Platform; + +public class MekCrusher implements ICraftHandler, IWebsiteSeralizer +{ + + IIngredient pro_input; + IIngredient pro_output[]; + + @Override + public void setup(List> input, List> output) throws RecipeError + { + if ( input.size() == 1 && output.size() == 1 ) + { + int outs = output.get( 0 ).size(); + if ( input.get( 0 ).size() == 1 && outs == 1 ) + { + pro_input = input.get( 0 ).get( 0 ); + pro_output = output.get( 0 ).toArray( new IIngredient[outs] ); + return; + } + } + new RecipeError( "MekCrusher must have a single input, and single output." ); + } + + @Override + public void register() throws RegistrationError, MissingIngredientError + { + if ( AppEng.instance.isIntegrationEnabled( IntegrationType.Mekanism ) ) + { + IMekanism rc = (IMekanism) AppEng.instance.getIntegration( IntegrationType.Mekanism ); + for (ItemStack is : pro_input.getItemStackSet()) + { + try + { + rc.addCrusherRecipe( is, pro_output[0].getItemStack() ); + } + catch (java.lang.RuntimeException err) + { + AELog.info( "Mekanism not happy - " + err.getMessage() ); + } + } + } + } + + @Override + public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError + { + return Platform.isSameItemPrecise( pro_output[0].getItemStack(), output ); + } + + @Override + public String getPattern(RecipeHandler h) + { + return null; + } + +} diff --git a/recipes/handlers/MekEnrichment.java b/recipes/handlers/MekEnrichment.java new file mode 100644 index 00000000..f842b370 --- /dev/null +++ b/recipes/handlers/MekEnrichment.java @@ -0,0 +1,72 @@ +package appeng.recipes.handlers; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import appeng.api.exceptions.MissingIngredientError; +import appeng.api.exceptions.RecipeError; +import appeng.api.exceptions.RegistrationError; +import appeng.api.recipes.ICraftHandler; +import appeng.api.recipes.IIngredient; +import appeng.core.AELog; +import appeng.core.AppEng; +import appeng.integration.IntegrationType; +import appeng.integration.abstraction.IMekanism; +import appeng.recipes.RecipeHandler; +import appeng.util.Platform; + +public class MekEnrichment implements ICraftHandler, IWebsiteSeralizer +{ + + IIngredient pro_input; + IIngredient pro_output[]; + + @Override + public void setup(List> input, List> output) throws RecipeError + { + if ( input.size() == 1 && output.size() == 1 ) + { + int outs = output.get( 0 ).size(); + if ( input.get( 0 ).size() == 1 && outs == 1 ) + { + pro_input = input.get( 0 ).get( 0 ); + pro_output = output.get( 0 ).toArray( new IIngredient[outs] ); + return; + } + } + new RecipeError( "MekCrusher must have a single input, and single output." ); + } + + @Override + public void register() throws RegistrationError, MissingIngredientError + { + if ( AppEng.instance.isIntegrationEnabled( IntegrationType.Mekanism ) ) + { + IMekanism rc = (IMekanism) AppEng.instance.getIntegration( IntegrationType.Mekanism ); + for (ItemStack is : pro_input.getItemStackSet()) + { + try + { + rc.addEnrichmentChamberRecipe( is, pro_output[0].getItemStack() ); + } + catch (java.lang.RuntimeException err) + { + AELog.info( "Mekanism not happy - " + err.getMessage() ); + } + } + } + } + + @Override + public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError + { + return Platform.isSameItemPrecise( pro_output[0].getItemStack(), output ); + } + + @Override + public String getPattern(RecipeHandler h) + { + return null; + } + +} diff --git a/tile/powersink/AEBasePoweredTile.java b/tile/powersink/AEBasePoweredTile.java index e656172f..40739804 100644 --- a/tile/powersink/AEBasePoweredTile.java +++ b/tile/powersink/AEBasePoweredTile.java @@ -1,6 +1,6 @@ package appeng.tile.powersink; -public abstract class AEBasePoweredTile extends RedstoneFlux +public abstract class AEBasePoweredTile extends MekJoules { } diff --git a/tile/powersink/MekJoules.java b/tile/powersink/MekJoules.java new file mode 100644 index 00000000..95decd1d --- /dev/null +++ b/tile/powersink/MekJoules.java @@ -0,0 +1,43 @@ +package appeng.tile.powersink; + +import mekanism.api.energy.IStrictEnergyAcceptor; +import net.minecraftforge.common.util.ForgeDirection; +import appeng.api.config.PowerUnits; +import appeng.transformer.annotations.integration.Interface; + +@Interface(iname = "Mekanism", iface = "mekanism.api.energy.IStrictEnergyAcceptor") +public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcceptor { + + @Override + public double getEnergy() { + return 0; + } + + @Override + public void setEnergy(double energy) { + double extra = injectExternalPower( PowerUnits.MK, energy ); + internalCurrentPower += PowerUnits.MK.convertTo(PowerUnits.AE, extra ); + } + + @Override + public double getMaxEnergy() { + return this.getExternalPowerDemand( PowerUnits.MK, 100000 ); + } + + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) + { + double demand = getExternalPowerDemand( PowerUnits.MK, Double.MAX_VALUE ); + if ( amount > demand ) + amount = demand; + + double overflow = injectExternalPower( PowerUnits.MK, amount ); + return amount - overflow; + } + + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return getPowerSides().contains(side); + } + +} diff --git a/util/Platform.java b/util/Platform.java index c5944f95..e92c9d76 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -152,12 +152,8 @@ public class Platform if ( displayUnits == PowerUnits.WA ) unitName = "J"; - if ( displayUnits == PowerUnits.KJ ) - { - Lvl = preFixes[offset]; + if ( displayUnits == PowerUnits.MK ) unitName = "J"; - offset++; - } while (p > 1000 && offset < preFixes.length) {