diff --git a/client/gui/implementations/GuiStorageBus.java b/client/gui/implementations/GuiStorageBus.java index 894e3b36..096f9f73 100644 --- a/client/gui/implementations/GuiStorageBus.java +++ b/client/gui/implementations/GuiStorageBus.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.input.Mouse; import appeng.api.config.AccessRestriction; +import appeng.api.config.ActionItems; import appeng.api.config.FuzzyMode; import appeng.api.config.Settings; import appeng.client.gui.widgets.GuiImgButton; @@ -19,6 +20,7 @@ import appeng.core.sync.GuiBridge; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketConfigButton; import appeng.core.sync.packets.PacketSwitchGuis; +import appeng.core.sync.packets.PacketValueConfig; import appeng.parts.misc.PartStorageBus; public class GuiStorageBus extends GuiUpgradeable @@ -26,6 +28,8 @@ public class GuiStorageBus extends GuiUpgradeable GuiImgButton rwMode; GuiTabButton priority; + GuiImgButton partition; + GuiImgButton clear; public GuiStorageBus(InventoryPlayer inventoryPlayer, PartStorageBus te) { super( new ContainerStorageBus( inventoryPlayer, te ) ); @@ -54,13 +58,17 @@ public class GuiStorageBus extends GuiUpgradeable @Override protected void addButtons() { - fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - rwMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACCESS, AccessRestriction.READ_WRITE ); + clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE ); + partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH ); + rwMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE ); + fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) ); buttonList.add( fuzzyMode ); buttonList.add( rwMode ); + buttonList.add( partition ); + buttonList.add( clear ); } @Override @@ -70,23 +78,21 @@ public class GuiStorageBus extends GuiUpgradeable boolean backwards = Mouse.isButtonDown( 1 ); - if ( btn == priority ) - { - try - { - NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) ); - } - catch (IOException e) - { - AELog.error( e ); - } - } try { - if ( btn == fuzzyMode ) + if ( btn == partition ) + NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) ); + + else if ( btn == clear ) + NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) ); + + else if ( btn == priority ) + NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) ); + + else if ( btn == fuzzyMode ) NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) ); - if ( btn == rwMode ) + else if ( btn == rwMode ) NetworkHandler.instance.sendToServer( new PacketConfigButton( rwMode.getSetting(), backwards ) ); } catch (IOException e) diff --git a/container/implementations/ContainerStorageBus.java b/container/implementations/ContainerStorageBus.java index fa711ae4..1308b8f5 100644 --- a/container/implementations/ContainerStorageBus.java +++ b/container/implementations/ContainerStorageBus.java @@ -1,12 +1,19 @@ package appeng.container.implementations; +import java.util.Iterator; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import appeng.api.AEApi; import appeng.api.config.AccessRestriction; import appeng.api.config.FuzzyMode; import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; import appeng.api.config.Upgrades; +import appeng.api.storage.IMEInventory; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; import appeng.container.guisync.GuiSync; import appeng.container.slot.OptionalSlotFakeTypeOnly; import appeng.container.slot.SlotFakeTypeOnly; @@ -14,6 +21,7 @@ import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; import appeng.parts.misc.PartStorageBus; import appeng.util.Platform; +import appeng.util.iterators.NullIterator; public class ContainerStorageBus extends ContainerUpgradeable { @@ -94,4 +102,40 @@ public class ContainerStorageBus extends ContainerUpgradeable standardDetectAndSendChanges(); } + public void clear() + { + IInventory inv = myte.getInventoryByName( "config" ); + for (int x = 0; x < inv.getSizeInventory(); x++) + inv.setInventorySlotContents( x, null ); + detectAndSendChanges(); + } + + public void partition() + { + IInventory inv = myte.getInventoryByName( "config" ); + + IMEInventory cellInv = storageBus.getInternalHandler(); + + Iterator i = new NullIterator(); + if ( cellInv != null ) + { + IItemList list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() ); + i = list.iterator(); + } + + for (int x = 0; x < inv.getSizeInventory(); x++) + { + if ( i.hasNext() && isSlotEnabled( (x / 9) - 2 ) ) + { + ItemStack g = i.next().getItemStack(); + g.stackSize = 1; + inv.setInventorySlotContents( x, g ); + } + else + inv.setInventorySlotContents( x, null ); + } + + detectAndSendChanges(); + } + } diff --git a/core/AEConfig.java b/core/AEConfig.java index 8b56b001..8b13491b 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -134,6 +134,8 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo minMeteoriteDistanceSq = minMeteoriteDistance * minMeteoriteDistance; + addCustomCategoryComment("wireless", "Range= WirelessBaseRange + WirelessBoosterRangeMultiplier * Math.pow( boosters, WirelessBoosterExp )\nPowerDrain= WirelessBaseCost + WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / WirelessHighWirelessCount )" ); + WirelessBaseCost = get( "wireless", "WirelessBaseCost", WirelessBaseCost ).getDouble( WirelessBaseCost ); WirelessCostMultiplier = get( "wireless", "WirelessCostMultiplier", WirelessCostMultiplier ).getDouble( WirelessCostMultiplier ); WirelessBaseRange = get( "wireless", "WirelessBaseRange", WirelessBaseRange ).getDouble( WirelessBaseRange ); @@ -166,10 +168,10 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo for (Enum e : settings.getSettings()) { String Category = e.getClass().getSimpleName(); - Enum value = settings.getSetting( e ); - Property p = this.get( Category, e.name(), value.name() ); - + + Property p = this.get( Category, e.name(), value.name(), getListComment( value ) ); + try { value = Enum.valueOf( value.getClass(), p.getString() ); @@ -184,7 +186,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo try { - selectedPowerUnit = PowerUnits.valueOf( get( "Client", "PowerUnit", selectedPowerUnit.name() ).getString() ); + selectedPowerUnit = PowerUnits.valueOf( get( "Client", "PowerUnit", selectedPowerUnit.name(), getListComment(selectedPowerUnit) ).getString() ); } catch (Throwable t) { @@ -216,6 +218,27 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo } } + private String getListComment(Enum value) + { + String comment = null; + + if ( value != null ) + { + EnumSet set = EnumSet.allOf(value.getClass() ); + + for ( Object Oeg : set ) + { + Enum eg = (Enum)Oeg; + if ( comment == null ) + comment = "Possible Values: " + eg.name(); + else + comment += ", "+eg.name(); + } + } + + return comment; + } + @Override public void updateSetting(IConfigManager manager, Enum setting, Enum newValue) { @@ -224,7 +247,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo if ( e == setting ) { String Category = e.getClass().getSimpleName(); - Property p = this.get( Category, e.name(), settings.getSetting( e ).name() ); + Property p = this.get( Category, e.name(), settings.getSetting( e ).name(), getListComment( newValue ) ); p.set( newValue.name() ); } } @@ -247,7 +270,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo get( "spatialio", "storageProviderID", storageProviderID ).set( storageProviderID ); } - get( "Client", "PowerUnit", selectedPowerUnit.name() ).set( selectedPowerUnit.name() ); + get( "Client", "PowerUnit", selectedPowerUnit.name(), getListComment(selectedPowerUnit) ).set( selectedPowerUnit.name() ); if ( hasChanged() ) super.save(); diff --git a/core/crash/CrashEnhancement.java b/core/crash/CrashEnhancement.java index 864162d3..47253716 100644 --- a/core/crash/CrashEnhancement.java +++ b/core/crash/CrashEnhancement.java @@ -7,51 +7,47 @@ import cpw.mods.fml.common.ICrashCallable; public class CrashEnhancement implements ICrashCallable { - final CrashInfo Output; + private final String name; + private final String value; - final String ModVersion = AEConfig.CHANNEL + " " + AEConfig.VERSION + " for Forge " + // WHAT? + private final String ModVersion = AEConfig.CHANNEL + " " + AEConfig.VERSION + " for Forge " + // WHAT? net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion + net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion + net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion + net.minecraftforge.common.ForgeVersion.buildVersion; - final String IntegrationInfo; - - public CrashEnhancement(CrashInfo ci) { - Output = ci; - - if ( IntegrationRegistry.instance != null ) - IntegrationInfo = IntegrationRegistry.instance.getStatus(); + public CrashEnhancement(CrashInfo Output) { + + if ( Output == CrashInfo.MOD_VERSION ) + { + name = "AE2 Version"; + value = ModVersion; + } + else if ( Output == CrashInfo.INTEGRATION ) + { + name ="AE2 Integration"; + if ( IntegrationRegistry.instance != null ) + value = IntegrationRegistry.instance.getStatus(); + else + value = "N/A"; + } else - IntegrationInfo = "N/A"; + { + name = "AE2_UNKNOWN"; + value = "UNKNOWN_VALUE"; + } } @Override public String call() throws Exception { - switch (Output) - { - case MOD_VERSION: - return ModVersion; - case INTEGRATION: - return IntegrationInfo; - } - - return "UNKNOWN_VALUE"; + return value; } @Override public String getLabel() { - switch (Output) - { - case MOD_VERSION: - return "AE2 Version"; - case INTEGRATION: - return "AE2 Integration"; - } - - return "AE2_UNKNOWN"; + return name; } } diff --git a/core/features/AEFeature.java b/core/features/AEFeature.java index 59d6a301..9505e74c 100644 --- a/core/features/AEFeature.java +++ b/core/features/AEFeature.java @@ -52,7 +52,7 @@ public enum AEFeature enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false), - AlphaPass("Rendering"), AlphaMigration("Migration", true); + AlphaPass("Rendering"); String Category; boolean visible = true; diff --git a/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index 9cf433fa..ad57f64f 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -21,6 +21,7 @@ import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPriority; import appeng.container.implementations.ContainerQuartzKnife; import appeng.container.implementations.ContainerSecurity; +import appeng.container.implementations.ContainerStorageBus; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; @@ -83,6 +84,21 @@ public class PacketValueConfig extends AppEngPacket cpt.clear(); } } + else if ( Name.startsWith( "StorageBus." ) && c instanceof ContainerStorageBus ) + { + ContainerStorageBus ccw = (ContainerStorageBus) c; + if ( Name.equals( "StorageBus.Action" ) ) + { + if ( Value.equals( "Partition" ) ) + { + ccw.partition(); + } + else if ( Value.equals( "Clear" ) ) + { + ccw.clear(); + } + } + } else if ( Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench ) { ContainerCellWorkbench ccw = (ContainerCellWorkbench) c; diff --git a/integration/modules/MJ6.java b/integration/modules/MJ6.java index ed61940c..71e87cf4 100644 --- a/integration/modules/MJ6.java +++ b/integration/modules/MJ6.java @@ -41,7 +41,11 @@ public class MJ6 extends BaseModule implements IMJ6 if ( te instanceof IPowerReceptor ) { final IPowerReceptor recp = (IPowerReceptor) te; + if ( recp == null ) + return null; final PowerReceiver ph = recp.getPowerReceiver( side ); + if ( ph == null ) + return null; return new IBatteryObject() { diff --git a/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java b/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java index b5789d57..0e9a646e 100644 --- a/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java +++ b/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java @@ -18,7 +18,7 @@ import org.lwjgl.opengl.GL11; import appeng.api.AEApi; import appeng.api.features.IGrinderEntry; -import appeng.client.gui.implementations.GuiInscriber; +import appeng.client.gui.implementations.GuiGrinder; import appeng.core.localization.GuiText; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; @@ -64,12 +64,12 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler public void loadTransferRects() { - this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "inscriber", new Object[0] ) ); + this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "grindstone", new Object[0] ) ); } public Class getGuiClass() { - return GuiInscriber.class; + return GuiGrinder.class; } @Override diff --git a/parts/misc/PartStorageBus.java b/parts/misc/PartStorageBus.java index fa40f8e3..e2ef5c16 100644 --- a/parts/misc/PartStorageBus.java +++ b/parts/misc/PartStorageBus.java @@ -157,7 +157,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC if ( host == null || host.getTile() == null || host.getTile().getWorldObj() == null ) return; - IMEInventory in = getHandler(); + IMEInventory in = getInternalHandler(); IItemList before = AEApi.instance().storage().createItemList(); if ( in != null ) before = in.getAvailableItems( before ); @@ -175,7 +175,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC // :3 } - IMEInventory out = getHandler(); + IMEInventory out = getInternalHandler(); IItemList after = AEApi.instance().storage().createItemList(); if ( out != null ) after = out.getAvailableItems( after ); @@ -198,6 +198,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC resetCache( true ); } + @Override + public void upgradesChanged() + { + super.upgradesChanged(); + resetCache( true ); + } + @Override public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) { @@ -213,7 +220,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC resetCache( true ); } - private MEInventoryHandler getHandler() + public MEInventoryHandler getInternalHandler() { if ( cached ) return handler; @@ -390,7 +397,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC { if ( channel == StorageChannel.ITEMS ) { - IMEInventoryHandler out = proxy.isActive() ? getHandler() : null; + IMEInventoryHandler out = proxy.isActive() ? getInternalHandler() : null; if ( out != null ) return Arrays.asList( new IMEInventoryHandler[] { out } ); } diff --git a/util/item/AEItemStack.java b/util/item/AEItemStack.java index da3f337a..64e7d3f8 100644 --- a/util/item/AEItemStack.java +++ b/util/item/AEItemStack.java @@ -18,7 +18,6 @@ import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAETagCompound; import appeng.util.Platform; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -329,7 +328,7 @@ public final class AEItemStack extends AEStack implements IAEItemS data.readBytes( bd ); ByteArrayInputStream di = new ByteArrayInputStream( bd ); - d.setTag( "tag", CompressedStreamTools.read( new DataInputStream( di) ) ); + d.setTag( "tag", CompressedStreamTools.read( new DataInputStream( di ) ) ); } // long priority = getPacketValue( PriorityType, data ); @@ -483,18 +482,20 @@ public final class AEItemStack extends AEStack implements IAEItemS return bottom; } - if ( fuzzy == FuzzyMode.IGNORE_ALL ) - { - newDef.dspDamage = 0; - } - else - { - int low = fuzzy.calculateBreakPoint( def.maxDamage ); - newDef.dspDamage = low < def.dspDamage ? low : 0; - } - if ( newDef.item.isDamageable() ) + { + if ( fuzzy == FuzzyMode.IGNORE_ALL ) + { + newDef.dspDamage = 0; + } + else + { + int low = fuzzy.calculateBreakPoint( def.maxDamage ); + newDef.dspDamage = low < def.dspDamage ? low : 0; + } + newDef.damageValue = newDef.dspDamage; + } newDef.tagCompound = AEItemDef.lowTag; newDef.reHash(); @@ -513,18 +514,20 @@ public final class AEItemStack extends AEStack implements IAEItemS return top; } - if ( fuzzy == FuzzyMode.IGNORE_ALL ) - { - newDef.dspDamage = def.maxDamage + 1; - } - else - { - int high = fuzzy.calculateBreakPoint( def.maxDamage ) + 1; - newDef.dspDamage = high > def.dspDamage ? high : def.maxDamage + 1; - } - if ( newDef.item.isDamageable() ) + { + if ( fuzzy == FuzzyMode.IGNORE_ALL ) + { + newDef.dspDamage = def.maxDamage + 1; + } + else + { + int high = fuzzy.calculateBreakPoint( def.maxDamage ) + 1; + newDef.dspDamage = high > def.dspDamage ? high : def.maxDamage + 1; + } + newDef.damageValue = top.def.dspDamage; + } newDef.tagCompound = AEItemDef.highTag; newDef.reHash(); diff --git a/util/item/ItemList.java b/util/item/ItemList.java index dadcdb7a..97af438b 100644 --- a/util/item/ItemList.java +++ b/util/item/ItemList.java @@ -20,27 +20,27 @@ public final class ItemList implements IItemList records = new TreeMap(); private final Class clz; - + // private int currentPriority = Integer.MIN_VALUE; int iteration = Integer.MIN_VALUE; public Throwable stacktrace; - - public ItemList( Class cla) { + + public ItemList(Class cla) { clz = cla; } - private boolean checkStackType( StackType st ) + private boolean checkStackType(StackType st) { - if ( st == null) + if ( st == null ) return true; - - if ( !clz.isInstance(st) ) - throw new RuntimeException("WRONG TYPE - got "+st.getClass().getName()+" expected "+clz.getName() ); - + + if ( !clz.isInstance( st ) ) + throw new RuntimeException( "WRONG TYPE - got " + st.getClass().getName() + " expected " + clz.getName() ); + return false; } - + @Override synchronized public void add(StackType option) { @@ -190,7 +190,7 @@ public final class ItemList implements IItemList implements IItemList) Arrays.asList( new IAEFluidStack[] { (IAEFluidStack) filter } ) : (List) Arrays .asList( new IAEFluidStack[] {} ); diff --git a/util/item/OreHelper.java b/util/item/OreHelper.java index b4a9c8e0..2bb61936 100644 --- a/util/item/OreHelper.java +++ b/util/item/OreHelper.java @@ -79,12 +79,17 @@ public class OreHelper if ( OreDictionary.itemMatches( oreItem, ItemStack, false ) ) { add = true; - set.add( oreItem.copy() ); + break; } } if ( add ) + { + for (ItemStack oreItem : OreDictionary.getOres( ore )) + set.add( oreItem.copy() ); + ores.add( OreDictionary.getOreID( ore ) ); + } } if ( !set.isEmpty() )