Merge branch 'master' of https://bitbucket.org/AlgorithmX2/appliedenergistics2
This commit is contained in:
commit
96f3c72bfd
3 changed files with 158 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
package appeng.helpers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -8,6 +9,7 @@ import net.minecraftforge.event.world.WorldEvent;
|
|||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.AELog;
|
||||
import appeng.me.Grid;
|
||||
import appeng.me.NetworkList;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
@ -22,12 +24,12 @@ public class TickHandler
|
|||
|
||||
public Queue<AEBaseTile> tiles = new LinkedList();
|
||||
|
||||
public LinkedList<Grid> networks = new LinkedList();
|
||||
public Collection<Grid> networks = new NetworkList();
|
||||
|
||||
public void clear()
|
||||
{
|
||||
tiles = new LinkedList();
|
||||
networks = new LinkedList();
|
||||
networks = new NetworkList();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
103
me/NetworkList.java
Normal file
103
me/NetworkList.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
package appeng.me;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class NetworkList implements Collection<Grid>
|
||||
{
|
||||
|
||||
private List<Grid> networks = new LinkedList();
|
||||
|
||||
@Override
|
||||
public boolean add(Grid e)
|
||||
{
|
||||
copy();
|
||||
return networks.add( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends Grid> c)
|
||||
{
|
||||
copy();
|
||||
return networks.addAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
networks = new LinkedList<Grid>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
return networks.contains( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c)
|
||||
{
|
||||
return networks.containsAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return networks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Grid> iterator()
|
||||
{
|
||||
return networks.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o)
|
||||
{
|
||||
copy();
|
||||
return networks.remove( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c)
|
||||
{
|
||||
copy();
|
||||
return networks.removeAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c)
|
||||
{
|
||||
copy();
|
||||
return networks.retainAll( c );
|
||||
}
|
||||
|
||||
private void copy()
|
||||
{
|
||||
List<Grid> old = networks;
|
||||
networks = new LinkedList<Grid>();
|
||||
networks.addAll( old );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return networks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray()
|
||||
{
|
||||
return networks.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a)
|
||||
{
|
||||
return networks.toArray( a );
|
||||
}
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ import appeng.api.config.Upgrades;
|
|||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
|
@ -96,6 +97,17 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
|||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
boolean currentActive = proxy.isActive();
|
||||
if ( wasActive != currentActive )
|
||||
{
|
||||
wasActive = currentActive;
|
||||
updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels(MENetworkChannelsChanged chann)
|
||||
{
|
||||
|
@ -103,14 +115,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
|||
if ( wasActive != currentActive )
|
||||
{
|
||||
wasActive = currentActive;
|
||||
try
|
||||
{
|
||||
proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,8 +380,42 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
|||
if ( i instanceof ItemBlock || i instanceof IPlantable )
|
||||
{
|
||||
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
|
||||
player.prevCameraPitch = player.cameraPitch = 0;
|
||||
player.prevCameraYaw = player.cameraYaw = 0;
|
||||
|
||||
float pitch = 0.0f, yaw = 0.0f;
|
||||
player.yOffset = 1.8f;
|
||||
|
||||
switch (side)
|
||||
{
|
||||
case DOWN:
|
||||
pitch = 90.0f;
|
||||
player.yOffset = -1.8f;
|
||||
break;
|
||||
case EAST:
|
||||
yaw = -90.0f;
|
||||
break;
|
||||
case NORTH:
|
||||
yaw = 180.0f;
|
||||
break;
|
||||
case SOUTH:
|
||||
yaw = 0.0f;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
case UP:
|
||||
pitch = 90.0f;
|
||||
break;
|
||||
case WEST:
|
||||
yaw = 90.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
player.posX = (float) tile.xCoord + 0.5;
|
||||
player.posY = (float) tile.yCoord + 0.5;
|
||||
player.posZ = (float) tile.zCoord + 0.5;
|
||||
|
||||
player.rotationPitch = player.prevCameraPitch = player.cameraPitch = pitch;
|
||||
player.rotationYaw = player.prevCameraYaw = player.cameraYaw = yaw;
|
||||
|
||||
maxStorage = is.stackSize;
|
||||
worked = true;
|
||||
if ( type == Actionable.MODULATE )
|
||||
|
@ -415,6 +454,8 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
|||
{
|
||||
IAEItemStack out = input.copy();
|
||||
out.decStackSize( maxStorage );
|
||||
if ( out.getStackSize() == 0 )
|
||||
return null;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue