Conflicts:
	container/implementations/ContainerStorageBus.java
	core/sync/packets/PacketValueConfig.java
This commit is contained in:
AlgorithmX2 2014-05-22 18:49:02 -05:00
commit 01bf88061d
12 changed files with 196 additions and 92 deletions

View file

@ -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)

View file

@ -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<IAEItemStack> cellInv = storageBus.getInternalHandler();
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
if ( cellInv != null )
{
IItemList<IAEItemStack> 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();
}
}

View file

@ -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();

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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() {

View file

@ -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<? extends GuiContainer> getGuiClass()
{
return GuiInscriber.class;
return GuiGrinder.class;
}
@Override

View file

@ -157,7 +157,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
if ( host == null || host.getTile() == null || host.getTile().getWorldObj() == null )
return;
IMEInventory<IAEItemStack> in = getHandler();
IMEInventory<IAEItemStack> in = getInternalHandler();
IItemList<IAEItemStack> 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<IAEItemStack> out = getHandler();
IMEInventory<IAEItemStack> out = getInternalHandler();
IItemList<IAEItemStack> 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 } );
}

View file

@ -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<IAEItemStack> 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<IAEItemStack> 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<IAEItemStack> 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();

View file

@ -20,27 +20,27 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
private final TreeMap<StackType, StackType> records = new TreeMap();
private final Class<? extends IAEStack> clz;
// private int currentPriority = Integer.MIN_VALUE;
int iteration = Integer.MIN_VALUE;
public Throwable stacktrace;
public ItemList( Class<? extends IAEStack> cla) {
public ItemList(Class<? extends IAEStack> 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<StackType extends IAEStack> implements IItemList<Sta
{
StackType low = (StackType) filter.getLow( fuzzy, ignoreMeta );
StackType high = (StackType) filter.getHigh( fuzzy, ignoreMeta );
return records.subMap( low, high ).values();
return records.subMap( low, true, high, true ).values();
}
@Override
@ -198,7 +198,7 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
{
if ( checkStackType( filter ) )
return new ArrayList();
if ( filter instanceof IAEFluidStack )
return filter.equals( this ) ? (List<StackType>) Arrays.asList( new IAEFluidStack[] { (IAEFluidStack) filter } ) : (List<StackType>) Arrays
.asList( new IAEFluidStack[] {} );

View file

@ -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() )