This commit is contained in:
AlgorithmX2 2014-09-20 15:12:35 -05:00
commit 8fbc6bbc67
12 changed files with 246 additions and 58 deletions

View file

@ -4,9 +4,11 @@ import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -67,7 +69,8 @@ public abstract class AEBaseGui extends GuiContainer
static public boolean switchingGuis; static public boolean switchingGuis;
private boolean subGui; private boolean subGui;
public AEBaseGui(Container container) { public AEBaseGui(Container container)
{
super( container ); super( container );
subGui = switchingGuis; subGui = switchingGuis;
switchingGuis = false; switchingGuis = false;
@ -158,6 +161,8 @@ public abstract class AEBaseGui extends GuiContainer
@Override @Override
protected void mouseClicked(int xCoord, int yCoord, int btn) protected void mouseClicked(int xCoord, int yCoord, int btn)
{ {
drag_click.clear();
if ( btn == 1 ) if ( btn == 1 )
{ {
for (Object o : this.buttonList) for (Object o : this.buttonList)
@ -170,6 +175,7 @@ public abstract class AEBaseGui extends GuiContainer
} }
} }
} }
super.mouseClicked( xCoord, yCoord, btn ); super.mouseClicked( xCoord, yCoord, btn );
} }
@ -178,6 +184,9 @@ public abstract class AEBaseGui extends GuiContainer
ItemStack dbl_whichItem; ItemStack dbl_whichItem;
Slot bl_clicked; Slot bl_clicked;
// dragy
Set<Slot> drag_click = new HashSet();
@Override @Override
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key) protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key)
{ {
@ -188,6 +197,9 @@ public abstract class AEBaseGui extends GuiContainer
InventoryAction action = null; InventoryAction action = null;
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN; action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
if ( drag_click.size() > 1 )
return;
if ( action != null ) if ( action != null )
{ {
try try
@ -416,17 +428,25 @@ public abstract class AEBaseGui extends GuiContainer
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if ( slot instanceof SlotFake && itemstack != null ) if ( slot instanceof SlotFake && itemstack != null )
{
drag_click.add( slot );
if ( drag_click.size() > 1 )
{ {
try try
{ {
PacketInventoryAction p = new PacketInventoryAction( InventoryAction.PICKUP_OR_SETDOWN, slot.slotNumber, 0 ); for (Slot dr : drag_click)
{
PacketInventoryAction p = new PacketInventoryAction( c == 0 ? InventoryAction.PICKUP_OR_SETDOWN : InventoryAction.PLACE_SINGLE,
dr.slotNumber, 0 );
NetworkHandler.instance.sendToServer( p ); NetworkHandler.instance.sendToServer( p );
} }
}
catch (IOException e) catch (IOException e)
{ {
AELog.error( e ); AELog.error( e );
} }
} }
}
else else
super.mouseClickMove( x, y, c, d ); super.mouseClickMove( x, y, c, d );
} }

View file

@ -41,10 +41,58 @@ public class SpatialSkyRender extends IRenderHandler
fade /= 1000; fade /= 1000;
fade = 0.15f * (1.0f - Math.abs( (fade - 1.0f) * (fade - 1.0f) )); fade = 0.15f * (1.0f - Math.abs( (fade - 1.0f) * (fade - 1.0f) ));
if ( fade > 0.0f )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(false);
GL11.glColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
Tessellator tessellator = Tessellator.instance;
for (int i = 0; i < 6; ++i)
{
GL11.glPushMatrix();
if (i == 1)
{
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
}
if (i == 2)
{
GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
}
if (i == 3)
{
GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
}
if (i == 4)
{
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
}
if (i == 5)
{
GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
}
tessellator.startDrawingQuads();
tessellator.setColorOpaque_I(0);
tessellator.addVertexWithUV(-100.0D, -100.0D, -100.0D, 0.0D, 0.0D);
tessellator.addVertexWithUV(-100.0D, -100.0D, 100.0D, 0.0D, 16.0D);
tessellator.addVertexWithUV(100.0D, -100.0D, 100.0D, 16.0D, 16.0D);
tessellator.addVertexWithUV(100.0D, -100.0D, -100.0D, 16.0D, 0.0D);
tessellator.draw();
GL11.glPopMatrix();
}
GL11.glDepthMask(true);
if ( fade > 0.0f )
{
GL11.glDisable( GL11.GL_FOG ); GL11.glDisable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_ALPHA_TEST ); GL11.glDisable( GL11.GL_ALPHA_TEST );
GL11.glEnable( GL11.GL_BLEND ); GL11.glEnable( GL11.GL_BLEND );
@ -52,7 +100,6 @@ public class SpatialSkyRender extends IRenderHandler
GL11.glEnable( GL11.GL_FOG ); GL11.glEnable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_FOG ); GL11.glDisable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_ALPHA_TEST ); GL11.glDisable( GL11.GL_ALPHA_TEST );
GL11.glEnable( GL11.GL_BLEND );
GL11.glDisable( GL11.GL_TEXTURE_2D ); GL11.glDisable( GL11.GL_TEXTURE_2D );
OpenGlHelper.glBlendFunc( 770, 771, 1, 0 ); OpenGlHelper.glBlendFunc( 770, 771, 1, 0 );
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
@ -60,9 +107,11 @@ public class SpatialSkyRender extends IRenderHandler
GL11.glColor4f( fade, fade, fade, 1.0f ); GL11.glColor4f( fade, fade, fade, 1.0f );
GL11.glCallList( dspList ); GL11.glCallList( dspList );
GL11.glPopAttrib();
} }
GL11.glPopAttrib();
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} }
private void renderTwinkles() private void renderTwinkles()

View file

@ -731,6 +731,16 @@ public abstract class AEBaseContainer extends Container
else else
s.putStack( hand.copy() ); s.putStack( hand.copy() );
break;
case PLACE_SINGLE:
if ( hand != null )
{
ItemStack is = hand.copy();
is.stackSize = 1;
s.putStack( is );
}
break; break;
case SPLIT_OR_PLACESINGLE: case SPLIT_OR_PLACESINGLE:

View file

@ -9,6 +9,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category; import net.minecraftforge.oredict.RecipeSorter.Category;
import appeng.api.AEApi; import appeng.api.AEApi;
@ -187,7 +188,8 @@ public class Registration
public RecipeHandler recipeHandler; public RecipeHandler recipeHandler;
public BiomeGenBase storageBiome; public BiomeGenBase storageBiome;
private Registration() { private Registration()
{
recipeHandler = new RecipeHandler(); recipeHandler = new RecipeHandler();
} }
@ -707,6 +709,9 @@ public class Registration
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class ); mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class ); mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class );
// very silly fix cause Reika decided to pair the item with a block.
OreDictionary.registerOre( "itemWheat", net.minecraft.init.Items.wheat );
/** /**
* Whitelist AE2 * Whitelist AE2
*/ */

View file

@ -47,7 +47,8 @@ public class CraftingJob implements Runnable, ICraftingJob
return output; return output;
} }
public CraftingJob(World w, NBTTagCompound data) { public CraftingJob(World w, NBTTagCompound data)
{
world = wrapWorld( w ); world = wrapWorld( w );
storage = AEApi.instance().storage().createItemList(); storage = AEApi.instance().storage().createItemList();
prophecies = new HashSet(); prophecies = new HashSet();
@ -65,7 +66,8 @@ public class CraftingJob implements Runnable, ICraftingJob
return availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc ); return availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc );
} }
public CraftingJob(World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback) { public CraftingJob(World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback)
{
world = wrapWorld( w ); world = wrapWorld( w );
output = what.copy(); output = what.copy();
storage = AEApi.instance().storage().createItemList(); storage = AEApi.instance().storage().createItemList();
@ -75,7 +77,8 @@ public class CraftingJob implements Runnable, ICraftingJob
this.callback = callback; this.callback = callback;
ICraftingGrid cc = grid.getCache( ICraftingGrid.class ); ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
IStorageGrid sg = grid.getCache( IStorageGrid.class ); IStorageGrid sg = grid.getCache( IStorageGrid.class );
original = new MECraftingInventory( sg.getItemInventory(), false, false, false ); original = new MECraftingInventory( sg.getItemInventory(), actionSrc, false, false, false );
tree = getCraftingTree( cc, what ); tree = getCraftingTree( cc, what );
availableCheck = null; availableCheck = null;
} }

View file

@ -44,7 +44,8 @@ public class CraftingTreeNode
boolean sim; boolean sim;
public CraftingTreeNode(ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth) { public CraftingTreeNode(ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth)
{
what = wat; what = wat;
parent = par; parent = par;
this.slot = slot; this.slot = slot;
@ -206,7 +207,8 @@ public class CraftingTreeNode
if ( available != null ) if ( available != null )
{ {
subInv.commit( src ); if ( !subInv.commit( src ) )
throw new CraftBranchFailure( what, l );
bytes += available.getStackSize(); bytes += available.getStackSize();
l -= available.getStackSize(); l -= available.getStackSize();

View file

@ -4,6 +4,7 @@ import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.StorageChannel; import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
@ -25,7 +26,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
final boolean logMissing; final boolean logMissing;
final IItemList<IAEItemStack> missingCache; final IItemList<IAEItemStack> missingCache;
public MECraftingInventory() { public MECraftingInventory()
{
localCache = AEApi.instance().storage().createItemList(); localCache = AEApi.instance().storage().createItemList();
extractedCache = null; extractedCache = null;
injectedCache = null; injectedCache = null;
@ -37,7 +39,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
par = null; par = null;
} }
public MECraftingInventory(MECraftingInventory parrent) { public MECraftingInventory(MECraftingInventory parrent)
{
this.target = parrent; this.target = parrent;
this.logExtracted = parrent.logExtracted; this.logExtracted = parrent.logExtracted;
this.logInjections = parrent.logInjections; this.logInjections = parrent.logInjections;
@ -63,7 +66,37 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
par = parrent; par = parrent;
} }
public MECraftingInventory(IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing) { public MECraftingInventory(IMEMonitor<IAEItemStack> target, BaseActionSource src, boolean logExtracted, boolean logInjections, boolean logMissing)
{
this.target = target;
this.logExtracted = logExtracted;
this.logInjections = logInjections;
this.logMissing = logMissing;
if ( logMissing )
missingCache = AEApi.instance().storage().createItemList();
else
missingCache = null;
if ( logExtracted )
extractedCache = AEApi.instance().storage().createItemList();
else
extractedCache = null;
if ( logInjections )
injectedCache = AEApi.instance().storage().createItemList();
else
injectedCache = null;
localCache = AEApi.instance().storage().createItemList();
for (IAEItemStack is : target.getStorageList())
localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) );
par = null;
}
public MECraftingInventory(IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing)
{
this.target = target; this.target = target;
this.logExtracted = logExtracted; this.logExtracted = logExtracted;
this.logInjections = logInjections; this.logInjections = logInjections;
@ -114,21 +147,27 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if ( list == null || list.getStackSize() == 0 ) if ( list == null || list.getStackSize() == 0 )
return null; return null;
if ( mode == Actionable.MODULATE && logExtracted )
extractedCache.add( request );
if ( list.getStackSize() >= request.getStackSize() ) if ( list.getStackSize() >= request.getStackSize() )
{ {
if ( mode == Actionable.MODULATE ) if ( mode == Actionable.MODULATE )
{
list.decStackSize( request.getStackSize() ); list.decStackSize( request.getStackSize() );
if ( logExtracted )
extractedCache.add( request );
}
return request; return request;
} }
IAEItemStack ret = request.copy(); IAEItemStack ret = request.copy();
ret.setStackSize( list.getStackSize() ); ret.setStackSize( list.getStackSize() );
if ( mode == Actionable.MODULATE ) if ( mode == Actionable.MODULATE )
{
list.reset(); list.reset();
if ( logExtracted )
extractedCache.add( ret );
}
return ret; return ret;
} }
@ -153,18 +192,59 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
return StorageChannel.ITEMS; return StorageChannel.ITEMS;
} }
public void commit(BaseActionSource src) public boolean commit(BaseActionSource src)
{ {
IItemList<IAEItemStack> added = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> pulled = AEApi.instance().storage().createItemList();
boolean failed = false;
if ( logInjections ) if ( logInjections )
{ {
for (IAEItemStack injec : injectedCache) for (IAEItemStack injec : injectedCache)
target.injectItems( injec, Actionable.MODULATE, src ); {
IAEItemStack result = null;
added.add( result = target.injectItems( injec, Actionable.MODULATE, src ) );
if ( result != null )
{
failed = true;
break;
}
}
}
if ( failed )
{
for (IAEItemStack is : added)
target.extractItems( is, Actionable.MODULATE, src );
return false;
} }
if ( logExtracted ) if ( logExtracted )
{ {
for (IAEItemStack extra : extractedCache) for (IAEItemStack extra : extractedCache)
target.extractItems( extra, Actionable.MODULATE, src ); {
IAEItemStack result = null;
pulled.add( result = target.extractItems( extra, Actionable.MODULATE, src ) );
if ( result == null || result.getStackSize() != extra.getStackSize() )
{
failed = true;
break;
}
}
}
if ( failed )
{
for (IAEItemStack is : added)
target.extractItems( is, Actionable.MODULATE, src );
for (IAEItemStack is : pulled)
target.injectItems( is, Actionable.MODULATE, src );
return false;
} }
if ( logMissing && par != null ) if ( logMissing && par != null )
@ -172,6 +252,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
for (IAEItemStack extra : missingCache) for (IAEItemStack extra : missingCache)
par.addMissing( extra ); par.addMissing( extra );
} }
return true;
} }
public void addMissing(IAEItemStack extra) public void addMissing(IAEItemStack extra)

View file

@ -9,5 +9,5 @@ public enum InventoryAction
CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT, CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT,
// extra... // extra...
MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT, PLACE_SINGLE
} }

View file

@ -198,7 +198,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
return inventory; return inventory;
} }
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max) { public CraftingCPUCluster(WorldCoord _min, WorldCoord _max)
{
min = _min; min = _min;
max = _max; max = _max;
} }
@ -786,7 +787,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{ {
waitingFor.resetStatus(); waitingFor.resetStatus();
((CraftingJob) job).tree.setJob( ci, this, src ); ((CraftingJob) job).tree.setJob( ci, this, src );
ci.commit( src ); if ( ci.commit( src ) )
{
finalOutput = job.getOutput(); finalOutput = job.getOutput();
waiting = false; waiting = false;
isComplete = false; isComplete = false;
@ -813,6 +815,12 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
return whatLink; return whatLink;
} }
else
{
tasks.clear();
inventory.getItemList().resetStatus();
}
}
catch (CraftBranchFailure e) catch (CraftBranchFailure e)
{ {
tasks.clear(); tasks.clear();

View file

@ -229,7 +229,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
{ {
for (CachedItemStack cis : end.values()) for (CachedItemStack cis : end.values())
{ {
if ( cis != null ) if ( cis != null && cis.aeStack != null )
{ {
IAEItemStack a = cis.aeStack.copy(); IAEItemStack a = cis.aeStack.copy();
a.setStackSize( -a.getStackSize() ); a.setStackSize( -a.getStackSize() );

View file

@ -38,6 +38,12 @@ public class StorageWorldProvider extends WorldProvider
super.worldChunkMgr = new WorldChunkManagerHell( Registration.instance.storageBiome, 0.0F ); super.worldChunkMgr = new WorldChunkManagerHell( Registration.instance.storageBiome, 0.0F );
} }
@SideOnly(Side.CLIENT)
public float[] calcSunriseSunsetColors(float p_76560_1_, float p_76560_2_)
{
return null;
}
@Override @Override
public float getStarBrightness(float par1) public float getStarBrightness(float par1)
{ {
@ -77,7 +83,7 @@ public class StorageWorldProvider extends WorldProvider
@Override @Override
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
{ {
return Vec3.createVectorHelper( 0.0, 0.0, 0.0 ); return Vec3.createVectorHelper( 0.07, 0.07, 0.07 );
} }
@Override @Override
@ -96,13 +102,13 @@ public class StorageWorldProvider extends WorldProvider
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean isSkyColored() public boolean isSkyColored()
{ {
return false; return true;
} }
@Override @Override
public Vec3 getFogColor(float par1, float par2) public Vec3 getFogColor(float par1, float par2)
{ {
return Vec3.createVectorHelper( 0.0, 0.0, 0.0 ); return Vec3.createVectorHelper( 0.07, 0.07, 0.07 );
} }
@Override @Override

View file

@ -255,7 +255,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
recalculateDisplay(); recalculateDisplay();
} }
public TileChest() { public TileChest()
{
internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 ); internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 );
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL ); gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
config.registerSetting( Settings.SORT_BY, SortOrder.NAME ); config.registerSetting( Settings.SORT_BY, SortOrder.NAME );
@ -289,7 +290,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
final StorageChannel chan; final StorageChannel chan;
public ChestNetNotifier(StorageChannel chan) { public ChestNetNotifier(StorageChannel chan)
{
this.chan = chan; this.chan = chan;
} }
@ -333,7 +335,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
class ChestMonitorHandler<T extends IAEStack> extends MEMonitorHandler<T> class ChestMonitorHandler<T extends IAEStack> extends MEMonitorHandler<T>
{ {
public ChestMonitorHandler(IMEInventoryHandler<T> t) { public ChestMonitorHandler(IMEInventoryHandler<T> t)
{
super( t ); super( t );
} }
@ -510,7 +513,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
if ( ForgeDirection.SOUTH == side ) if ( ForgeDirection.SOUTH == side )
return front; return front;
if ( gridProxy.isActive() ) if ( isPowered() )
{ {
try try
{ {