Work on an overhaul of the Logistical Transporter network. Don’t use, completely untested.
This commit is contained in:
parent
d0253444c1
commit
0b70ed5dcc
28 changed files with 476 additions and 464 deletions
|
@ -1,17 +0,0 @@
|
|||
package cofh.api.core;
|
||||
|
||||
/**
|
||||
* Interface which can be put on just about anything to allow for iteration during initialization.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IInitializer {
|
||||
|
||||
public boolean preInit();
|
||||
|
||||
public boolean initialize();
|
||||
|
||||
public boolean postInit();
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cofh.api.core;
|
||||
|
||||
/**
|
||||
* Basic interface for the Cape and Skin Registries.
|
||||
*
|
||||
* @author Zeldo Kavira
|
||||
*
|
||||
*/
|
||||
public interface ISimpleRegistry {
|
||||
|
||||
/**
|
||||
* Register a new entry.
|
||||
*
|
||||
* @param playerName
|
||||
* The player to register.
|
||||
* @param URL
|
||||
* Location of the cape/skin.
|
||||
* @return True if registration was successful.
|
||||
*/
|
||||
public boolean register(String playerName, String URL);
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package cofh.api.core;
|
||||
|
||||
/**
|
||||
* Dummy class used to initialize Cape and Skin Registries to prevent accidental NPEs.
|
||||
*
|
||||
* @author Zeldo Kavira
|
||||
*
|
||||
*/
|
||||
public class NullSimpleRegistry implements ISimpleRegistry {
|
||||
|
||||
@Override
|
||||
public boolean register(String playerName, String URL) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package cofh.api.core;
|
||||
|
||||
/**
|
||||
* Access to the Cape and Skin Registries of CoFH Core.
|
||||
*
|
||||
* @author Zeldo Kavira
|
||||
*
|
||||
*/
|
||||
public class RegistryAccess {
|
||||
|
||||
public static ISimpleRegistry capeRegistry = new NullSimpleRegistry();
|
||||
public static ISimpleRegistry skinRegistry = new NullSimpleRegistry();
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package cofh.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Implement this interface on Item classes that are themselves inventories.
|
||||
*
|
||||
* There's no real interaction here - the point of this is to correctly identify these items and prevent nesting.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IInventoryContainerItem {
|
||||
|
||||
/**
|
||||
* Get the size of this inventory.
|
||||
*/
|
||||
int getSizeInventory(ItemStack container);
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cofh.api.tileentity;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which can report information about their energy usage.
|
||||
*
|
||||
* This is used for reporting purposes - Energy transactions should be handled through IEnergyHandler!
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyInfo {
|
||||
|
||||
public int getEnergyPerTick();
|
||||
|
||||
public int getMaxEnergyPerTick();
|
||||
|
||||
public int getEnergy();
|
||||
|
||||
public int getMaxEnergy();
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package cofh.api.tileentity;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which allow for reconfiguration of their facing.
|
||||
*
|
||||
* Coordination with the containing block is required.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IReconfigurableFacing {
|
||||
|
||||
/**
|
||||
* Returns the current facing of the block.
|
||||
*/
|
||||
public int getFacing();
|
||||
|
||||
/**
|
||||
* Returns whether or not the block's face can be aligned with the Y Axis.
|
||||
*/
|
||||
public boolean allowYAxisFacing();
|
||||
|
||||
/**
|
||||
* Attempt to rotate the block. Arbitrary based on implementation.
|
||||
*
|
||||
* @return True if rotation was successful, false otherwise.
|
||||
*/
|
||||
public boolean rotateBlock();
|
||||
|
||||
/**
|
||||
* Set the facing of the block.
|
||||
*
|
||||
* @param side
|
||||
* The side to set the facing to.
|
||||
* @return True if the facing was set, false otherwise.
|
||||
*/
|
||||
public boolean setFacing(int side);
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package cofh.api.tileentity;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which allow for reconfiguration of their sides.
|
||||
*
|
||||
* Coordination with the containing block is required.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IReconfigurableSides {
|
||||
|
||||
/**
|
||||
* Decrement the config for a given side.
|
||||
*
|
||||
* @param side
|
||||
* The side to decrement.
|
||||
* @return True if config was changed, false otherwise.
|
||||
*/
|
||||
public boolean decrSide(int side);
|
||||
|
||||
/**
|
||||
* Increment the config for a given side.
|
||||
*
|
||||
* @param side
|
||||
* The side to decrement.
|
||||
* @return True if config was changed, false otherwise.
|
||||
*/
|
||||
public boolean incrSide(int side);
|
||||
|
||||
/**
|
||||
* Set the config for a given side.
|
||||
*
|
||||
* @param side
|
||||
* The side to set.
|
||||
* @param config
|
||||
* The config value to use.
|
||||
* @return True of config was set, false otherwise.
|
||||
*/
|
||||
public boolean setSide(int side, int config);
|
||||
|
||||
/**
|
||||
* Reset configs on all sides to their base values.
|
||||
*
|
||||
* @return True if reset was successful, false otherwise.
|
||||
*/
|
||||
public boolean resetSides();
|
||||
|
||||
/**
|
||||
* Returns the number of possible config settings for a given side.
|
||||
*/
|
||||
public int getNumConfig(int side);
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cofh.api.tileentity;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which have redstone control functionality.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IRedstoneControl {
|
||||
|
||||
public boolean getControlDisable();
|
||||
|
||||
public boolean getControlSetting();
|
||||
|
||||
public boolean setControlDisable(boolean disable);
|
||||
|
||||
public boolean setControlSetting(boolean state);
|
||||
|
||||
public boolean setRedstoneConfig(boolean disable, boolean state);
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package cofh.api.tileentity;
|
||||
|
||||
public interface ISecureTile {
|
||||
|
||||
public static enum AccessMode {
|
||||
PUBLIC, RESTRICTED, PRIVATE;
|
||||
|
||||
public boolean isPublic() {
|
||||
|
||||
return this == PUBLIC;
|
||||
}
|
||||
|
||||
public boolean isRestricted() {
|
||||
|
||||
return this == RESTRICTED;
|
||||
}
|
||||
|
||||
public boolean isPrivate() {
|
||||
|
||||
return this == PRIVATE;
|
||||
}
|
||||
|
||||
public static AccessMode stepForward(AccessMode curAccess) {
|
||||
|
||||
return curAccess == AccessMode.PUBLIC ? AccessMode.RESTRICTED : curAccess == AccessMode.PRIVATE ? AccessMode.PUBLIC : AccessMode.PRIVATE;
|
||||
}
|
||||
|
||||
public static AccessMode stepBackward(AccessMode curAccess) {
|
||||
|
||||
return curAccess == AccessMode.PUBLIC ? AccessMode.PRIVATE : curAccess == AccessMode.PRIVATE ? AccessMode.RESTRICTED : AccessMode.PUBLIC;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setAccess(AccessMode access);
|
||||
|
||||
public AccessMode getAccess();
|
||||
|
||||
public boolean setOwnerName(String name);
|
||||
|
||||
public String getOwnerName();
|
||||
|
||||
public boolean canPlayerAccess(String name);
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cofh.api.tileentity;
|
||||
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which can change their block's texture based on the current render pass. The block must defer the call to its Tile
|
||||
* Entity.
|
||||
*
|
||||
* @author Zeldo Kavira
|
||||
*
|
||||
*/
|
||||
public interface ISidedBlockTexture {
|
||||
|
||||
public Icon getBlockTexture(int side, int pass);
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package cofh.api.tileentity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which can send state information through chat.
|
||||
*
|
||||
* @author Zeldo Kavira
|
||||
*
|
||||
*/
|
||||
public interface ITileInfo {
|
||||
|
||||
public List<String> getTileInfo();
|
||||
|
||||
public void sendTileInfoToPlayer(EntityPlayer player);
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package cofh.api.world;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
/**
|
||||
* This interface should be implemented on classes which define a world feature to be generated in a {@link IFeatureHandler}. It is essentially a more robust
|
||||
* version of {@link WorldGenerator}, and may include one or more WorldGenerators should you wish.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IFeatureGenerator {
|
||||
|
||||
/**
|
||||
* Returns the name of the feature, used for displaying in the World.cfg file.
|
||||
*/
|
||||
public String getFeatureName();
|
||||
|
||||
/**
|
||||
* Generates the world feature.
|
||||
*
|
||||
* @param random
|
||||
* Random derived from the world seed.
|
||||
* @param chunkX
|
||||
* Minimum X chunk-coordinate of the chunk. (x16 for block coordinate)
|
||||
* @param chunkZ
|
||||
* Minimum Z chunk-coordinate of the chunk. (x16 for block coordinate)
|
||||
* @param world
|
||||
* The world to generate in.
|
||||
* @param newGen
|
||||
* True on initial generation, false on retrogen.
|
||||
* @return True if generation happened, false otherwise.
|
||||
*/
|
||||
public boolean generateFeature(Random random, int chunkX, int chunkZ, World world, boolean newGen);
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cofh.api.world;
|
||||
|
||||
/**
|
||||
* Provides an interface to allow for the addition of Features to world generation.
|
||||
*
|
||||
* See {@link IFeatureGenerator}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IFeatureHandler {
|
||||
|
||||
/**
|
||||
* Register a feature with an IFeatureHandler.
|
||||
*
|
||||
* @param feature
|
||||
* The feature to register.
|
||||
* @return True if the registration was successful, false if a feature with that name existed.
|
||||
*/
|
||||
public boolean registerFeature(IFeatureGenerator feature);
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package cofh.api.world;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.WeightedRandomItem;
|
||||
|
||||
/**
|
||||
* This class essentially allows for ores to be generated in clusters, with Features randomly choosing one or more blocks from a weighted list.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public final class WeightedRandomBlock extends WeightedRandomItem {
|
||||
|
||||
public final int blockId;
|
||||
public final int metadata;
|
||||
|
||||
public WeightedRandomBlock(ItemStack ore) {
|
||||
|
||||
super(100);
|
||||
this.blockId = ore.itemID;
|
||||
this.metadata = ore.getItemDamage();
|
||||
}
|
||||
|
||||
public WeightedRandomBlock(ItemStack ore, int weight) {
|
||||
|
||||
super(weight);
|
||||
this.blockId = ore.itemID;
|
||||
this.metadata = ore.getItemDamage();
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,6 @@ import mekanism.api.infuse.InfuseObject;
|
|||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import mekanism.api.infuse.InfusionInput;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.common.EnergyNetwork.EnergyTransferEvent;
|
||||
import mekanism.common.FluidNetwork.FluidTransferEvent;
|
||||
|
@ -81,6 +80,7 @@ import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
|
|||
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
||||
import mekanism.common.tileentity.TileEntityElectricBlock;
|
||||
import mekanism.common.tileentity.TileEntityTeleporter;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.common.voice.VoiceServerManager;
|
||||
|
@ -99,7 +99,6 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|||
import rebelkeithy.mods.metallurgy.api.IOreInfo;
|
||||
import rebelkeithy.mods.metallurgy.api.MetallurgyAPI;
|
||||
import thermalexpansion.api.crafting.CraftingManagers;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
@ -1044,6 +1043,7 @@ public class Mekanism
|
|||
teleporters.clear();
|
||||
dynamicInventories.clear();
|
||||
ic2Registered.clear();
|
||||
TransporterManager.flowingStacks.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -10,6 +10,7 @@ import mekanism.api.Object3D;
|
|||
import mekanism.api.SideData;
|
||||
import mekanism.common.tileentity.TileEntityContainerBlock;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
@ -121,9 +122,11 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
}
|
||||
else if(tile instanceof TileEntityLogisticalTransporter)
|
||||
{
|
||||
if(TransporterUtils.insert(tileEntity, (TileEntityLogisticalTransporter)tile, stack, outputColor))
|
||||
ItemStack rejects = TransporterUtils.insert(tileEntity, (TileEntityLogisticalTransporter)tile, stack, outputColor, true);
|
||||
|
||||
if(TransporterManager.didEmit(stack, rejects))
|
||||
{
|
||||
stack = null;
|
||||
stack = rejects;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,8 +128,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
list.add(EnumColor.INDIGO + "Locked: " + EnumColor.GREY + getLocked(itemstack));
|
||||
}
|
||||
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergyStored(itemstack)));
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v");
|
||||
if(itemstack.getItemDamage() != MachineType.LOGISTICAL_SORTER.meta)
|
||||
{
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergyStored(itemstack)));
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v");
|
||||
}
|
||||
|
||||
if(hasTank(itemstack))
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ import mekanism.common.PacketHandler;
|
|||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.item.ItemBlockBasic;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
@ -171,9 +172,11 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
|||
{
|
||||
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)tile;
|
||||
|
||||
if(TransporterUtils.insert(this, transporter, getStack(), null))
|
||||
ItemStack rejects = TransporterUtils.insert(this, transporter, getStack(), null, true);
|
||||
|
||||
if(TransporterManager.didEmit(getStack(), rejects))
|
||||
{
|
||||
setInventorySlotContents(0, null);
|
||||
setInventorySlotContents(0, rejects);
|
||||
}
|
||||
}
|
||||
else if(tile instanceof IInventory)
|
||||
|
|
|
@ -29,6 +29,7 @@ import mekanism.common.miner.ThreadMinerSearch;
|
|||
import mekanism.common.miner.ThreadMinerSearch.State;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.transporter.InvStack;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -199,9 +200,11 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
|||
}
|
||||
else if(getEjectInv() instanceof TileEntityLogisticalTransporter)
|
||||
{
|
||||
if(TransporterUtils.insert(getEjectTile(), (TileEntityLogisticalTransporter)getEjectInv(), getTopEject(false, null), null))
|
||||
ItemStack rejected = TransporterUtils.insert(getEjectTile(), (TileEntityLogisticalTransporter)getEjectInv(), getTopEject(false, null), null, true);
|
||||
|
||||
if(TransporterManager.didEmit(getTopEject(false, null), rejected))
|
||||
{
|
||||
getTopEject(true, null);
|
||||
getTopEject(true, rejected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ import mekanism.common.PacketHandler.Transmission;
|
|||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.transporter.InvStack;
|
||||
import mekanism.common.transporter.TItemStackFilter;
|
||||
import mekanism.common.transporter.TransporterFilter;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
@ -85,6 +87,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
|||
InvStack inInventory = null;
|
||||
boolean hasFilter = false;
|
||||
EnumColor filterColor = color;
|
||||
TItemStackFilter itemFilter = null;
|
||||
|
||||
for(TransporterFilter filter : filters)
|
||||
{
|
||||
|
@ -97,6 +100,12 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
|||
filterColor = filter.color;
|
||||
hasFilter = true;
|
||||
inInventory = invStack;
|
||||
|
||||
if(filter instanceof TItemStackFilter)
|
||||
{
|
||||
itemFilter = (TItemStackFilter)filter;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -109,23 +118,33 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
|||
|
||||
if(inInventory != null && inInventory.getStack() != null)
|
||||
{
|
||||
boolean inserted = false;
|
||||
ItemStack used = null;
|
||||
|
||||
if(!roundRobin)
|
||||
{
|
||||
if(TransporterUtils.insert(this, transporter, inInventory.getStack(), filterColor))
|
||||
ItemStack rejects = TransporterUtils.insert(this, transporter, inInventory.getStack(), filterColor, false);
|
||||
|
||||
if(TransporterManager.didEmit(inInventory.getStack(), rejects))
|
||||
{
|
||||
inserted = true;
|
||||
if(itemFilter == null || itemFilter.canFilter(TransporterManager.getToUse(inInventory.getStack(), rejects)))
|
||||
{
|
||||
used = TransporterManager.getToUse(inInventory.getStack(), rejects);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(TransporterUtils.insertRR(this, transporter, inInventory.getStack(), filterColor))
|
||||
ItemStack rejects = TransporterUtils.insertRR(this, transporter, inInventory.getStack(), filterColor, false);
|
||||
|
||||
if(TransporterManager.didEmit(inInventory.getStack(), rejects))
|
||||
{
|
||||
inserted = true;
|
||||
if(itemFilter == null || itemFilter.canFilter(TransporterManager.getToUse(inInventory.getStack(), rejects)))
|
||||
{
|
||||
used = TransporterManager.getToUse(inInventory.getStack(), rejects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(inserted)
|
||||
if(used != null)
|
||||
{
|
||||
inInventory.use();
|
||||
inventory.onInventoryChanged();
|
||||
|
|
|
@ -12,6 +12,7 @@ import mekanism.common.PacketHandler;
|
|||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketDataRequest;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.transporter.TransporterStack;
|
||||
import mekanism.common.transporter.TransporterStack.Path;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
|
@ -112,6 +113,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
|||
|
||||
if(rejected == null)
|
||||
{
|
||||
TransporterManager.remove(stack);
|
||||
remove.add(stack);
|
||||
continue;
|
||||
}
|
||||
|
@ -207,7 +209,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
|||
{
|
||||
needsSync.add(stack);
|
||||
|
||||
if(!stack.recalculatePath(this))
|
||||
if(!TransporterManager.didEmit(stack.itemStack, stack.recalculatePath(this)))
|
||||
{
|
||||
if(!stack.calculateIdle(this))
|
||||
{
|
||||
|
@ -224,7 +226,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean insert(Object3D original, ItemStack itemStack, EnumColor color)
|
||||
public ItemStack insert(Object3D original, ItemStack itemStack, EnumColor color, boolean doEmit)
|
||||
{
|
||||
TransporterStack stack = new TransporterStack();
|
||||
stack.itemStack = itemStack;
|
||||
|
@ -234,21 +236,26 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
|||
|
||||
if(!stack.canInsertToTransporter(this))
|
||||
{
|
||||
return false;
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if(stack.recalculatePath(this))
|
||||
ItemStack rejected = stack.recalculatePath(this);
|
||||
|
||||
if(TransporterManager.didEmit(stack.itemStack, rejected))
|
||||
{
|
||||
stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected);
|
||||
|
||||
transit.add(stack);
|
||||
TransporterManager.add(stack);
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getSyncPacket(stack, false)), Object3D.get(this), 50D);
|
||||
MekanismUtils.saveChunk(this);
|
||||
return true;
|
||||
return rejected;
|
||||
}
|
||||
|
||||
return false;
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public boolean insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color)
|
||||
public ItemStack insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color, boolean doEmit)
|
||||
{
|
||||
TransporterStack stack = new TransporterStack();
|
||||
stack.itemStack = itemStack;
|
||||
|
@ -258,17 +265,23 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
|||
|
||||
if(!stack.canInsertToTransporter(this))
|
||||
{
|
||||
return false;
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if(stack.recalculateRRPath(outputter, this))
|
||||
ItemStack rejected = stack.recalculateRRPath(outputter, this);
|
||||
|
||||
if(TransporterManager.didEmit(stack.itemStack, rejected))
|
||||
{
|
||||
stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected);
|
||||
|
||||
transit.add(stack);
|
||||
TransporterManager.add(stack);
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getSyncPacket(stack, false)), Object3D.get(this), 50D);
|
||||
return true;
|
||||
MekanismUtils.saveChunk(this);
|
||||
return rejected;
|
||||
}
|
||||
|
||||
return false;
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public void entityEntering(TransporterStack stack)
|
||||
|
@ -393,7 +406,10 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
|||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
transit.add(TransporterStack.readFromNBT((NBTTagCompound)tagList.tagAt(i)));
|
||||
TransporterStack stack = TransporterStack.readFromNBT((NBTTagCompound)tagList.tagAt(i));
|
||||
|
||||
transit.add(stack);
|
||||
TransporterManager.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -491,13 +507,8 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
|||
{
|
||||
TileEntity tile = Object3D.get(this).getFromSide(from).getTileEntity(worldObj);
|
||||
|
||||
if(TransporterUtils.insert(tile, this, stack, null))
|
||||
{
|
||||
return stack.stackSize;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
ItemStack rejects = TransporterUtils.insert(tile, this, stack, null, true);
|
||||
return TransporterManager.getToUse(stack, rejects).stackSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -53,6 +53,24 @@ public final class InvStack
|
|||
itemStacks.add(stack);
|
||||
}
|
||||
|
||||
public void use(int amount)
|
||||
{
|
||||
for(int i = 0; i < slotIDs.size(); i++)
|
||||
{
|
||||
ItemStack stack = itemStacks.get(i);
|
||||
|
||||
if(inventory.getStackInSlot(slotIDs.get(i)).stackSize == stack.stackSize)
|
||||
{
|
||||
inventory.setInventorySlotContents(slotIDs.get(i), null);
|
||||
}
|
||||
else {
|
||||
ItemStack ret = stack.copy();
|
||||
ret.stackSize = inventory.getStackInSlot(slotIDs.get(i)).stackSize - stack.stackSize;
|
||||
inventory.setInventorySlotContents(slotIDs.get(i), ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void use()
|
||||
{
|
||||
for(int i = 0; i < slotIDs.size(); i++)
|
||||
|
|
333
common/mekanism/common/transporter/TransporterManager.java
Normal file
333
common/mekanism/common/transporter/TransporterManager.java
Normal file
|
@ -0,0 +1,333 @@
|
|||
package mekanism.common.transporter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.tileentity.TileEntityBin;
|
||||
import mekanism.common.transporter.TransporterStack.Path;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class TransporterManager
|
||||
{
|
||||
public static Set<TransporterStack> flowingStacks = new HashSet<TransporterStack>();
|
||||
|
||||
public static void add(TransporterStack stack)
|
||||
{
|
||||
flowingStacks.add(stack);
|
||||
|
||||
System.out.println("Added " + flowingStacks.size());
|
||||
}
|
||||
|
||||
public static void remove(TransporterStack stack)
|
||||
{
|
||||
flowingStacks.remove(stack);
|
||||
|
||||
System.out.println("Removed " + flowingStacks.size());
|
||||
}
|
||||
|
||||
public static List<TransporterStack> getStacksToDest(Object3D dest)
|
||||
{
|
||||
List<TransporterStack> ret = new ArrayList<TransporterStack>();
|
||||
|
||||
for(TransporterStack stack : flowingStacks)
|
||||
{
|
||||
if(stack != null && stack.pathType != Path.NONE)
|
||||
{
|
||||
if(stack.getDest().equals(dest))
|
||||
{
|
||||
ret.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack[] copyInvFromSide(IInventory inv, int side)
|
||||
{
|
||||
inv = InventoryUtils.checkChestInv(inv);
|
||||
|
||||
ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
|
||||
|
||||
if(!(inv instanceof ISidedInventory))
|
||||
{
|
||||
for(int i = 0; i <= inv.getSizeInventory() - 1; i++)
|
||||
{
|
||||
ret[i] = inv.getStackInSlot(i).copy();
|
||||
}
|
||||
}
|
||||
else {
|
||||
ISidedInventory sidedInventory = (ISidedInventory)inv;
|
||||
int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal());
|
||||
|
||||
for(int get = 0; get <= slots.length - 1; get++)
|
||||
{
|
||||
int slotID = slots[get];
|
||||
|
||||
ret[slotID] = sidedInventory.getStackInSlot(slotID).copy();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void testInsert(IInventory inv, ItemStack[] testInv, int side, TransporterStack stack)
|
||||
{
|
||||
ItemStack toInsert = stack.itemStack.copy();
|
||||
|
||||
if(stack.pathType != Path.HOME && inv instanceof IConfigurable)
|
||||
{
|
||||
IConfigurable config = (IConfigurable)inv;
|
||||
int tileSide = config.getOrientation();
|
||||
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());
|
||||
|
||||
if(config.getEjector().hasStrictInput() && configColor != null && configColor != stack.color)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!(inv instanceof ISidedInventory))
|
||||
{
|
||||
for(int i = 0; i <= inv.getSizeInventory() - 1; i++)
|
||||
{
|
||||
if(stack.pathType != Path.HOME)
|
||||
{
|
||||
if(!inv.isItemValidForSlot(i, toInsert))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack inSlot = inv.getStackInSlot(i);
|
||||
|
||||
if(inSlot == null)
|
||||
{
|
||||
testInv[i] = toInsert;
|
||||
return;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
ItemStack toSet = toInsert.copy();
|
||||
toSet.stackSize += inSlot.stackSize;
|
||||
|
||||
testInv[i] = toSet;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize();
|
||||
|
||||
ItemStack toSet = toInsert.copy();
|
||||
toSet.stackSize = inSlot.getMaxStackSize();
|
||||
|
||||
ItemStack remains = toInsert.copy();
|
||||
remains.stackSize = rejects;
|
||||
|
||||
testInv[i] = toSet;
|
||||
|
||||
toInsert = remains;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ISidedInventory sidedInventory = (ISidedInventory)inv;
|
||||
int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal());
|
||||
|
||||
if(slots != null && slots.length != 0)
|
||||
{
|
||||
if(stack.pathType != Path.HOME && sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0)
|
||||
{
|
||||
slots = sidedInventory.getAccessibleSlotsFromSide(1);
|
||||
}
|
||||
|
||||
for(int get = 0; get <= slots.length - 1; get++)
|
||||
{
|
||||
int slotID = slots[get];
|
||||
|
||||
if(stack.pathType != Path.HOME)
|
||||
{
|
||||
if(!sidedInventory.isItemValidForSlot(slotID, toInsert) && !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack inSlot = inv.getStackInSlot(slotID);
|
||||
|
||||
if(inSlot == null)
|
||||
{
|
||||
testInv[slotID] = toInsert;
|
||||
return;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
ItemStack toSet = toInsert.copy();
|
||||
toSet.stackSize += inSlot.stackSize;
|
||||
|
||||
testInv[slotID] = toSet;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize();
|
||||
|
||||
ItemStack toSet = toInsert.copy();
|
||||
toSet.stackSize = inSlot.getMaxStackSize();
|
||||
|
||||
ItemStack remains = toInsert.copy();
|
||||
remains.stackSize = rejects;
|
||||
|
||||
testInv[slotID] = toSet;
|
||||
|
||||
toInsert = remains;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean didEmit(ItemStack stack, ItemStack returned)
|
||||
{
|
||||
return returned == null || returned.stackSize < stack.stackSize;
|
||||
}
|
||||
|
||||
public static ItemStack getToUse(ItemStack stack, ItemStack returned)
|
||||
{
|
||||
if(returned == null || returned.stackSize == 0)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
return MekanismUtils.size(stack, stack.stackSize-returned.stackSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return rejects
|
||||
*/
|
||||
public static ItemStack getPredictedInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, int side)
|
||||
{
|
||||
if(!(tileEntity instanceof IInventory))
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if(tileEntity instanceof IConfigurable)
|
||||
{
|
||||
IConfigurable config = (IConfigurable)tileEntity;
|
||||
int tileSide = config.getOrientation();
|
||||
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());
|
||||
|
||||
if(config.getEjector().hasStrictInput() && configColor != null && configColor != color)
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
IInventory inventory = (IInventory)tileEntity;
|
||||
ItemStack[] testInv = copyInvFromSide(inventory, side);
|
||||
|
||||
List<TransporterStack> insertQueue = getStacksToDest(Object3D.get(tileEntity));
|
||||
|
||||
for(TransporterStack tStack : insertQueue)
|
||||
{
|
||||
testInsert(inventory, testInv, side, tStack);
|
||||
}
|
||||
|
||||
if(!(inventory instanceof ISidedInventory))
|
||||
{
|
||||
inventory = InventoryUtils.checkChestInv(inventory);
|
||||
|
||||
for(int i = 0; i <= inventory.getSizeInventory() - 1; i++)
|
||||
{
|
||||
if(!inventory.isItemValidForSlot(i, itemStack))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack inSlot = testInv[i];
|
||||
|
||||
if(inSlot == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize();
|
||||
|
||||
if(rejects < itemStack.stackSize)
|
||||
{
|
||||
return MekanismUtils.size(itemStack, rejects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ISidedInventory sidedInventory = (ISidedInventory)inventory;
|
||||
int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal());
|
||||
|
||||
if(slots != null && slots.length != 0)
|
||||
{
|
||||
if(sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0)
|
||||
{
|
||||
slots = sidedInventory.getAccessibleSlotsFromSide(1);
|
||||
}
|
||||
|
||||
for(int get = 0; get <= slots.length - 1; get++)
|
||||
{
|
||||
int slotID = slots[get];
|
||||
|
||||
if(!sidedInventory.isItemValidForSlot(slotID, itemStack) || !sidedInventory.canInsertItem(slotID, itemStack, ForgeDirection.getOrientation(side).getOpposite().ordinal()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack inSlot = testInv[slotID];
|
||||
|
||||
if(inSlot == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize();
|
||||
|
||||
if(rejects < itemStack.stackSize)
|
||||
{
|
||||
return MekanismUtils.size(itemStack, rejects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,8 @@ import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
|||
import mekanism.common.transporter.TransporterPathfinder.Pathfinder.DestChecker;
|
||||
import mekanism.common.transporter.TransporterStack.Path;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -70,7 +72,7 @@ public final class TransporterPathfinder
|
|||
|
||||
if(!found)
|
||||
{
|
||||
destinations.add(new Destination(currentPath, dist, true));
|
||||
destinations.add(new Destination(currentPath, dist, true, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,8 +106,9 @@ public final class TransporterPathfinder
|
|||
{
|
||||
public List<Object3D> path = new ArrayList<Object3D>();
|
||||
public double score;
|
||||
public ItemStack rejected;
|
||||
|
||||
public Destination(ArrayList<Object3D> list, double d, boolean inv)
|
||||
public Destination(ArrayList<Object3D> list, double d, boolean inv, ItemStack rejects)
|
||||
{
|
||||
path = (List<Object3D>)list.clone();
|
||||
|
||||
|
@ -115,6 +118,7 @@ public final class TransporterPathfinder
|
|||
}
|
||||
|
||||
score = d;
|
||||
rejected = rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,6 +161,8 @@ public final class TransporterPathfinder
|
|||
|
||||
public Set<Object3D> destsFound = new HashSet<Object3D>();
|
||||
|
||||
public Map<Object3D, ItemStack> rejects = new HashMap<Object3D, ItemStack>();
|
||||
|
||||
public Object3D start;
|
||||
|
||||
public TransporterStack transportStack;
|
||||
|
@ -212,9 +218,15 @@ public final class TransporterPathfinder
|
|||
continue;
|
||||
}
|
||||
|
||||
if(InventoryUtils.canInsert(tile, transportStack.color, transportStack.itemStack, side.ordinal(), false))
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
destsFound.add(Object3D.get(tile));
|
||||
ItemStack stack = TransporterManager.getPredictedInsert(tile, transportStack.color, transportStack.itemStack, side.ordinal());
|
||||
|
||||
if(TransporterManager.didEmit(transportStack.itemStack, stack))
|
||||
{
|
||||
destsFound.add(Object3D.get(tile));
|
||||
rejects.put(Object3D.get(tile), stack);
|
||||
}
|
||||
}
|
||||
else if(transportStack.canInsertToTransporter(tile) && !iterated.contains(Object3D.get(tile)))
|
||||
{
|
||||
|
@ -224,13 +236,13 @@ public final class TransporterPathfinder
|
|||
}
|
||||
}
|
||||
|
||||
public Set<Object3D> find()
|
||||
{
|
||||
loop(start);
|
||||
|
||||
return destsFound;
|
||||
public Set<Object3D> find()
|
||||
{
|
||||
loop(start);
|
||||
|
||||
return destsFound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Destination> getPaths(TileEntityLogisticalTransporter start, TransporterStack stack)
|
||||
{
|
||||
|
@ -253,7 +265,7 @@ public final class TransporterPathfinder
|
|||
|
||||
if(p.getPath().size() >= 2)
|
||||
{
|
||||
paths.add(new Destination(p.getPath(), p.finalScore, false));
|
||||
paths.add(new Destination(p.getPath(), p.finalScore, false, d.rejects.get(obj)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +274,7 @@ public final class TransporterPathfinder
|
|||
return paths;
|
||||
}
|
||||
|
||||
public static List<Object3D> getNewBasePath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
||||
public static Destination getNewBasePath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
||||
{
|
||||
List<Destination> paths = getPaths(start, stack);
|
||||
|
||||
|
@ -271,10 +283,10 @@ public final class TransporterPathfinder
|
|||
return null;
|
||||
}
|
||||
|
||||
return paths.get(0).path;
|
||||
return paths.get(0);
|
||||
}
|
||||
|
||||
public static List<Object3D> getNewRRPath(TileEntityLogisticalTransporter start, TransporterStack stack, TileEntityLogisticalSorter outputter)
|
||||
public static Destination getNewRRPath(TileEntityLogisticalTransporter start, TransporterStack stack, TileEntityLogisticalSorter outputter)
|
||||
{
|
||||
List<Destination> paths = getPaths(start, stack);
|
||||
|
||||
|
@ -321,7 +333,7 @@ public final class TransporterPathfinder
|
|||
return null;
|
||||
}
|
||||
|
||||
return closest.path;
|
||||
return closest;
|
||||
}
|
||||
|
||||
public static class Pathfinder
|
||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.api.EnumColor;
|
|||
import mekanism.api.Object3D;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalSorter;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||
import mekanism.common.transporter.TransporterPathfinder.Destination;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -147,38 +148,38 @@ public class TransporterStack
|
|||
return pathToTarget != null;
|
||||
}
|
||||
|
||||
public boolean recalculatePath(TileEntityLogisticalTransporter tileEntity)
|
||||
public ItemStack recalculatePath(TileEntityLogisticalTransporter tileEntity)
|
||||
{
|
||||
List<Object3D> newPath = TransporterPathfinder.getNewBasePath(tileEntity, this);
|
||||
Destination newPath = TransporterPathfinder.getNewBasePath(tileEntity, this);
|
||||
|
||||
if(newPath == null)
|
||||
{
|
||||
return false;
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
pathToTarget = newPath;
|
||||
pathToTarget = newPath.path;
|
||||
|
||||
pathType = Path.DEST;
|
||||
initiatedPath = true;
|
||||
|
||||
return true;
|
||||
return newPath.rejected;
|
||||
}
|
||||
|
||||
public boolean recalculateRRPath(TileEntityLogisticalSorter outputter, TileEntityLogisticalTransporter tileEntity)
|
||||
public ItemStack recalculateRRPath(TileEntityLogisticalSorter outputter, TileEntityLogisticalTransporter tileEntity)
|
||||
{
|
||||
List<Object3D> newPath = TransporterPathfinder.getNewRRPath(tileEntity, this, outputter);
|
||||
Destination newPath = TransporterPathfinder.getNewRRPath(tileEntity, this, outputter);
|
||||
|
||||
if(newPath == null)
|
||||
{
|
||||
return false;
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
pathToTarget = newPath;
|
||||
pathToTarget = newPath.path;
|
||||
|
||||
pathType = Path.DEST;
|
||||
initiatedPath = true;
|
||||
|
||||
return true;
|
||||
return newPath.rejected;
|
||||
}
|
||||
|
||||
public boolean calculateIdle(TileEntityLogisticalTransporter tileEntity)
|
||||
|
|
|
@ -4,17 +4,17 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.common.tileentity.TileEntityBin;
|
||||
import mekanism.common.tileentity.TileEntityDiversionTransporter;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalSorter;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
import mekanism.common.transporter.TransporterStack;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -190,14 +190,14 @@ public final class TransporterUtils
|
|||
return inventories;
|
||||
}
|
||||
|
||||
public static boolean insert(TileEntity outputter, TileEntityLogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color)
|
||||
public static ItemStack insert(TileEntity outputter, TileEntityLogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color, boolean doEmit)
|
||||
{
|
||||
return tileEntity.insert(Object3D.get(outputter), itemStack.copy(), color);
|
||||
return tileEntity.insert(Object3D.get(outputter), itemStack.copy(), color, doEmit);
|
||||
}
|
||||
|
||||
public static boolean insertRR(TileEntityLogisticalSorter outputter, TileEntityLogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color)
|
||||
public static ItemStack insertRR(TileEntityLogisticalSorter outputter, TileEntityLogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color, boolean doEmit)
|
||||
{
|
||||
return tileEntity.insertRR(outputter, itemStack.copy(), color);
|
||||
return tileEntity.insertRR(outputter, itemStack.copy(), color, doEmit);
|
||||
}
|
||||
|
||||
public static EnumColor increment(EnumColor color)
|
||||
|
@ -226,6 +226,8 @@ public final class TransporterUtils
|
|||
pos = new float[] {0, 0, 0};
|
||||
}
|
||||
|
||||
TransporterManager.remove(stack);
|
||||
|
||||
EntityItem entityItem = new EntityItem(tileEntity.worldObj, tileEntity.xCoord + pos[0], tileEntity.yCoord + pos[1], tileEntity.zCoord + pos[2], stack.itemStack);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
|
@ -242,7 +244,7 @@ public final class TransporterUtils
|
|||
|
||||
float itemFix = 0;
|
||||
|
||||
if(stack.itemStack.itemID >= 256)
|
||||
if(!(stack.itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
itemFix = 0.1F;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt
|
|||
}
|
||||
else {
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)));
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v");
|
||||
list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + (getVoltage(itemstack)*Mekanism.FROM_UE) + "v");
|
||||
|
||||
if(hasTank(itemstack))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue