Added legacy Controller base functionality
This commit is contained in:
parent
bfa013b73c
commit
66f03f1abe
|
@ -0,0 +1,19 @@
|
|||
package appeng.block.legacy;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.legacy.TileLegacyController;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class BlockLegacyController extends AEBaseTileBlock {
|
||||
|
||||
public BlockLegacyController() {
|
||||
super(Material.iron);
|
||||
this.setTileEntity(TileLegacyController.class);
|
||||
this.setFeature( EnumSet.of(AEFeature.Legacy) );
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -101,6 +101,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||
private double WirelessBoosterExp = 1.5;
|
||||
public int ItemTypeLimit = 63;
|
||||
public boolean NeedController = false;
|
||||
public boolean HardLegacyController = false;
|
||||
|
||||
public AEConfig( final File configFile )
|
||||
{
|
||||
|
@ -163,6 +164,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||
|
||||
this.ItemTypeLimit = this.get( "tileraedition", "typeLimit", this.ItemTypeLimit ).getInt( this.ItemTypeLimit );
|
||||
this.NeedController = this.get("tileraedition", "needController", this.NeedController).getBoolean( this.NeedController );
|
||||
this.HardLegacyController = this.get("tileraedition", "hardLegacyController", this.HardLegacyController).getBoolean( this.HardLegacyController );
|
||||
|
||||
this.clientSync();
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import appeng.block.grindstone.BlockCrank;
|
|||
import appeng.block.grindstone.BlockGrinder;
|
||||
import appeng.block.legacy.BlockCraftMonitor;
|
||||
import appeng.block.legacy.BlockCraftTerminal;
|
||||
import appeng.block.legacy.BlockLegacyController;
|
||||
import appeng.block.legacy.BlockTerminal;
|
||||
import appeng.block.misc.*;
|
||||
import appeng.block.networking.*;
|
||||
|
@ -136,6 +137,7 @@ public final class ApiBlocks implements IBlocks
|
|||
private final ITileDefinition terminal;
|
||||
private final ITileDefinition craftTerminal;
|
||||
private final ITileDefinition craftMonitor;
|
||||
private final ITileDefinition legacyController;
|
||||
|
||||
public ApiBlocks( final DefinitionConstructor constructor )
|
||||
{
|
||||
|
@ -229,7 +231,8 @@ public final class ApiBlocks implements IBlocks
|
|||
//Legacy
|
||||
this.terminal = constructor.registerTileDefinition( new BlockTerminal() );
|
||||
this.craftTerminal = constructor.registerTileDefinition( new BlockCraftTerminal() );
|
||||
this.craftMonitor = constructor.registerTileDefinition( new BlockCraftMonitor());
|
||||
this.craftMonitor = constructor.registerTileDefinition( new BlockCraftMonitor() );
|
||||
this.legacyController = constructor.registerTileDefinition( new BlockLegacyController() );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import appeng.core.stats.Achievements;
|
|||
import appeng.me.GridConnection;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.pathfinding.*;
|
||||
import appeng.tile.legacy.TileLegacyController;
|
||||
import appeng.tile.networking.TileController;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -45,6 +46,7 @@ public class PathGridCache implements IPathingGrid
|
|||
|
||||
private final LinkedList<PathSegment> active = new LinkedList<PathSegment>();
|
||||
private final Set<TileController> controllers = new HashSet<TileController>();
|
||||
private final Set<TileLegacyController> legacyControllers = new HashSet<TileLegacyController>();
|
||||
private final Set<IGridNode> requireChannels = new HashSet<IGridNode>();
|
||||
private final Set<IGridNode> blockDense = new HashSet<IGridNode>();
|
||||
private final IGrid myGrid;
|
||||
|
@ -193,6 +195,10 @@ public class PathGridCache implements IPathingGrid
|
|||
this.controllers.remove( machine );
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
else if (machine instanceof TileLegacyController) {
|
||||
this.legacyControllers.remove(machine);
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
final EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
|
@ -217,6 +223,10 @@ public class PathGridCache implements IPathingGrid
|
|||
this.controllers.add( (TileController) machine );
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
else if(machine instanceof TileLegacyController) {
|
||||
this.legacyControllers.add((TileLegacyController) machine);
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
final EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
|
@ -256,12 +266,17 @@ public class PathGridCache implements IPathingGrid
|
|||
this.recalculateControllerNextTick = false;
|
||||
final ControllerState old = this.controllerState;
|
||||
|
||||
if( this.controllers.isEmpty() )
|
||||
if (this.legacyControllers.size() > 1) {
|
||||
this.controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
}
|
||||
else if (this.legacyControllers.size() == 1 && !AEConfig.instance.HardLegacyController) {
|
||||
this.controllerState = ControllerState.CONTROLLER_INFINITE;
|
||||
}
|
||||
else if( this.controllers.isEmpty() )
|
||||
{
|
||||
this.controllerState = ControllerState.NO_CONTROLLER;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
final IGridNode startingNode = this.controllers.iterator().next().getGridNode( ForgeDirection.UNKNOWN );
|
||||
if( startingNode == null )
|
||||
{
|
||||
|
@ -276,9 +291,11 @@ public class PathGridCache implements IPathingGrid
|
|||
|
||||
if( cv.isValid() && cv.getFound() == this.controllers.size() )
|
||||
{
|
||||
if (AEConfig.instance.isFeatureEnabled( AEFeature.Channels )) {
|
||||
if (this.legacyControllers.size() == 1 && this.controllers.size() >= 68) {
|
||||
this.controllerState = ControllerState.CONTROLLER_INFINITE;
|
||||
} else if (AEConfig.instance.isFeatureEnabled( AEFeature.Channels )) {
|
||||
this.controllerState = ControllerState.CONTROLLER_ONLINE;
|
||||
} else {
|
||||
} else {
|
||||
this.controllerState = ControllerState.CONTROLLER_INFINITE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package appeng.tile.legacy;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileLegacyController extends AENetworkPowerTile {
|
||||
|
||||
private static final IInventory NULL_INVENTORY = new AppEngInternalInventory( null, 0 );
|
||||
private static final int[] ACCESSIBLE_SLOTS_BY_SIDE = {};
|
||||
|
||||
public TileLegacyController() {
|
||||
this.setInternalMaxPower( 8000 );
|
||||
this.setInternalPublicPowerStorage( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory() {
|
||||
return NULL_INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
|
||||
return ACCESSIBLE_SLOTS_BY_SIDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getFunnelPowerDemand( final double maxReceived )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.getProxy().getEnergy().getEnergyDemand( 8000 );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// no grid? use local...
|
||||
return super.getFunnelPowerDemand( maxReceived );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
|
||||
{
|
||||
try
|
||||
{
|
||||
final double ret = this.getProxy().getEnergy().injectPower( power, mode );
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// no grid? use local...
|
||||
return super.funnelPowerIntoStorage( power, mode );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -55,6 +55,7 @@ tile.appliedenergistics2.BlockMolecularAssembler.name=Molecular Assembler
|
|||
tile.appliedenergistics2.BlockTerminal.name=ME Access Terminal
|
||||
tile.appliedenergistics2.BlockCraftTerminal.name=ME Crafting Terminal
|
||||
tile.appliedenergistics2.BlockCraftMonitor.name=ME Crafting Monitor
|
||||
tile.appliedenergistics2.BlockLegacyController.name=ME Controller (W.I.P)
|
||||
|
||||
item.appliedenergistics2.ItemMaterial.ConversionMatrix.name=Conversion Matrix
|
||||
|
||||
|
|
Loading…
Reference in New Issue