diff --git a/src/main/java/appeng/block/legacy/BlockLegacyController.java b/src/main/java/appeng/block/legacy/BlockLegacyController.java new file mode 100644 index 00000000..471e2450 --- /dev/null +++ b/src/main/java/appeng/block/legacy/BlockLegacyController.java @@ -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) ); + } + + +} diff --git a/src/main/java/appeng/core/AEConfig.java b/src/main/java/appeng/core/AEConfig.java index 0b407857..5e430344 100644 --- a/src/main/java/appeng/core/AEConfig.java +++ b/src/main/java/appeng/core/AEConfig.java @@ -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(); diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index 274ff9f6..128cc4e1 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -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() ); } diff --git a/src/main/java/appeng/me/cache/PathGridCache.java b/src/main/java/appeng/me/cache/PathGridCache.java index b0eb212e..7a72983a 100644 --- a/src/main/java/appeng/me/cache/PathGridCache.java +++ b/src/main/java/appeng/me/cache/PathGridCache.java @@ -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 active = new LinkedList(); private final Set controllers = new HashSet(); + private final Set legacyControllers = new HashSet(); private final Set requireChannels = new HashSet(); private final Set blockDense = new HashSet(); 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 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 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; } } diff --git a/src/main/java/appeng/tile/legacy/TileLegacyController.java b/src/main/java/appeng/tile/legacy/TileLegacyController.java new file mode 100644 index 00000000..fcfb15bc --- /dev/null +++ b/src/main/java/appeng/tile/legacy/TileLegacyController.java @@ -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 ); + } + } + +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang index 4bc04f02..f77e8ea0 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang +++ b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang @@ -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