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

View file

@ -41,10 +41,58 @@ public class SpatialSkyRender extends IRenderHandler
fade /= 1000;
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_ALPHA_TEST );
GL11.glEnable( GL11.GL_BLEND );
@ -52,7 +100,6 @@ public class SpatialSkyRender extends IRenderHandler
GL11.glEnable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_ALPHA_TEST );
GL11.glEnable( GL11.GL_BLEND );
GL11.glDisable( GL11.GL_TEXTURE_2D );
OpenGlHelper.glBlendFunc( 770, 771, 1, 0 );
RenderHelper.disableStandardItemLighting();
@ -60,9 +107,11 @@ public class SpatialSkyRender extends IRenderHandler
GL11.glColor4f( fade, fade, fade, 1.0f );
GL11.glCallList( dspList );
GL11.glPopAttrib();
}
GL11.glPopAttrib();
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
private void renderTwinkles()

View file

@ -676,7 +676,7 @@ public abstract class AEBaseContainer extends Container
else
addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) );
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
@ -731,6 +731,16 @@ public abstract class AEBaseContainer extends Container
else
s.putStack( hand.copy() );
break;
case PLACE_SINGLE:
if ( hand != null )
{
ItemStack is = hand.copy();
is.stackSize = 1;
s.putStack( is );
}
break;
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.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;
import appeng.api.AEApi;
@ -187,7 +188,8 @@ public class Registration
public RecipeHandler recipeHandler;
public BiomeGenBase storageBiome;
private Registration() {
private Registration()
{
recipeHandler = new RecipeHandler();
}
@ -707,6 +709,9 @@ public class Registration
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.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
*/

View file

@ -47,7 +47,8 @@ public class CraftingJob implements Runnable, ICraftingJob
return output;
}
public CraftingJob(World w, NBTTagCompound data) {
public CraftingJob(World w, NBTTagCompound data)
{
world = wrapWorld( w );
storage = AEApi.instance().storage().createItemList();
prophecies = new HashSet();
@ -65,7 +66,8 @@ public class CraftingJob implements Runnable, ICraftingJob
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 );
output = what.copy();
storage = AEApi.instance().storage().createItemList();
@ -75,7 +77,8 @@ public class CraftingJob implements Runnable, ICraftingJob
this.callback = callback;
ICraftingGrid cc = grid.getCache( ICraftingGrid.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 );
availableCheck = null;
}

View file

@ -44,7 +44,8 @@ public class CraftingTreeNode
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;
parent = par;
this.slot = slot;
@ -206,7 +207,8 @@ public class CraftingTreeNode
if ( available != null )
{
subInv.commit( src );
if ( !subInv.commit( src ) )
throw new CraftBranchFailure( what, l );
bytes += available.getStackSize();
l -= available.getStackSize();

View file

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

View file

@ -9,5 +9,5 @@ public enum InventoryAction
CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT,
// 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;
}
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max) {
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max)
{
min = _min;
max = _max;
}
@ -786,32 +787,39 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
waitingFor.resetStatus();
((CraftingJob) job).tree.setJob( ci, this, src );
ci.commit( src );
finalOutput = job.getOutput();
waiting = false;
isComplete = false;
markDirty();
if ( ci.commit( src ) )
{
finalOutput = job.getOutput();
waiting = false;
isComplete = false;
markDirty();
updateCPU();
String craftID = generateCraftingID();
updateCPU();
String craftID = generateCraftingID();
myLastLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, false ), this );
myLastLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, false ), this );
if ( requestingMachine == null )
return myLastLink;
if ( requestingMachine == null )
return myLastLink;
ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, true ), requestingMachine );
ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, true ), requestingMachine );
submitLink( myLastLink );
submitLink( whatLink );
submitLink( myLastLink );
submitLink( whatLink );
IItemList<IAEItemStack> list;
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
IItemList<IAEItemStack> list;
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
for (IAEItemStack ge : list)
postChange( ge, machineSrc );
for (IAEItemStack ge : list)
postChange( ge, machineSrc );
return whatLink;
return whatLink;
}
else
{
tasks.clear();
inventory.getItemList().resetStatus();
}
}
catch (CraftBranchFailure e)
{

View file

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

View file

@ -38,6 +38,12 @@ public class StorageWorldProvider extends WorldProvider
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
public float getStarBrightness(float par1)
{
@ -77,7 +83,7 @@ public class StorageWorldProvider extends WorldProvider
@Override
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
@ -96,13 +102,13 @@ public class StorageWorldProvider extends WorldProvider
@SideOnly(Side.CLIENT)
public boolean isSkyColored()
{
return false;
return true;
}
@Override
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
@ -116,7 +122,7 @@ public class StorageWorldProvider extends WorldProvider
{
return "Storage Cell";
}
@Override
public IRenderHandler getSkyRenderer()
{

View file

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