Fixed Crash in Formation Plane.
Fixed Bug: #0166 - Combination TPane and FPane seems getting stuck
This commit is contained in:
parent
85b053f6b5
commit
97ae2b78e3
3 changed files with 158 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
package appeng.helpers;
|
package appeng.helpers;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
@ -8,6 +9,7 @@ import net.minecraftforge.event.world.WorldEvent;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.me.Grid;
|
import appeng.me.Grid;
|
||||||
|
import appeng.me.NetworkList;
|
||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
@ -22,12 +24,12 @@ public class TickHandler
|
||||||
|
|
||||||
public Queue<AEBaseTile> tiles = new LinkedList();
|
public Queue<AEBaseTile> tiles = new LinkedList();
|
||||||
|
|
||||||
public LinkedList<Grid> networks = new LinkedList();
|
public Collection<Grid> networks = new NetworkList();
|
||||||
|
|
||||||
public void clear()
|
public void clear()
|
||||||
{
|
{
|
||||||
tiles = new LinkedList();
|
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.MENetworkCellArrayUpdate;
|
||||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||||
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.parts.IPart;
|
import appeng.api.parts.IPart;
|
||||||
import appeng.api.parts.IPartCollsionHelper;
|
import appeng.api.parts.IPartCollsionHelper;
|
||||||
|
@ -96,6 +97,17 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||||
return super.getInventoryByName( name );
|
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
|
@MENetworkEventSubscribe
|
||||||
public void updateChannels(MENetworkChannelsChanged chann)
|
public void updateChannels(MENetworkChannelsChanged chann)
|
||||||
{
|
{
|
||||||
|
@ -103,14 +115,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||||
if ( wasActive != currentActive )
|
if ( wasActive != currentActive )
|
||||||
{
|
{
|
||||||
wasActive = currentActive;
|
wasActive = currentActive;
|
||||||
try
|
updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||||
{
|
|
||||||
proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
|
||||||
}
|
|
||||||
catch (GridAccessException e)
|
|
||||||
{
|
|
||||||
// :P
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,8 +380,42 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||||
if ( i instanceof ItemBlock || i instanceof IPlantable )
|
if ( i instanceof ItemBlock || i instanceof IPlantable )
|
||||||
{
|
{
|
||||||
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
|
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;
|
maxStorage = is.stackSize;
|
||||||
worked = true;
|
worked = true;
|
||||||
if ( type == Actionable.MODULATE )
|
if ( type == Actionable.MODULATE )
|
||||||
|
@ -415,6 +454,8 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||||
{
|
{
|
||||||
IAEItemStack out = input.copy();
|
IAEItemStack out = input.copy();
|
||||||
out.decStackSize( maxStorage );
|
out.decStackSize( maxStorage );
|
||||||
|
if ( out.getStackSize() == 0 )
|
||||||
|
return null;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue