mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Merge branch 'master' into 1.7: Release 0.11.4
Note: Issue #545 Crash with Conduit Probe not fixed, need to create a new packet for this.
This commit is contained in:
commit
c6287436cb
14 files changed
+222
-151
No files matched your search
@@ -34,6 +34,8 @@ public class GuiExternalConnectionSelector extends GuiScreen {
|
||||
ForgeDirection dir = ForgeDirection.values()[b.id];
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
BlockCoord loc = cb.getBlockCoord();
|
||||
//TODO:1.7
|
||||
//PacketDispatcher.sendPacketToServer(MJReaderPacketHandler.createOpenConduitGuiPacket(cb, dir));
|
||||
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + dir.ordinal(), player.worldObj, loc.x, loc.y, loc.z);
|
||||
}
|
||||
|
||||
|
||||
@@ -225,10 +225,9 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
|
||||
int tickDeficit;
|
||||
|
||||
//work around for a vanilla chest changing into a double chest without doing unnedded checks all the time
|
||||
//work around for a vanilla chest changing into a double chest without doing unneeded checks all the time
|
||||
boolean recheckInv = false;
|
||||
private int delay = 0;
|
||||
IInventory origInv;
|
||||
World world;
|
||||
|
||||
NetworkedInventory(IInventory inv, IItemConduit con, ForgeDirection conDir, BlockCoord location) {
|
||||
|
||||
@@ -237,16 +236,15 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
this.con = con;
|
||||
this.conDir = conDir;
|
||||
this.location = location;
|
||||
world = con.getBundle().getWorld();
|
||||
|
||||
if(inv instanceof ISidedInventory) {
|
||||
this.inv = (ISidedInventory) inv;
|
||||
} else {
|
||||
if(inv instanceof TileEntityChest) {
|
||||
recheckInv = true;
|
||||
}
|
||||
this.inv = new InventoryWrapper(inv);
|
||||
TileEntity te = world.getBlockTileEntity(location.x, location.y, location.z);
|
||||
if(te.getClass().getName().contains("cpw.mods.ironchest")) {
|
||||
recheckInv = true;
|
||||
} else if(te instanceof TileEntityChest) {
|
||||
recheckInv = true;
|
||||
}
|
||||
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
public boolean hasTarget(IItemConduit conduit, ForgeDirection dir) {
|
||||
@@ -310,12 +308,7 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
private boolean transferItems() {
|
||||
|
||||
if(recheckInv) {
|
||||
//Re-check vanilla chests twice a second to make sure they haven't become double chests
|
||||
delay++;
|
||||
if(delay % 10 == 0) {
|
||||
inv = new InventoryWrapper(((InventoryWrapper) inv).getWrappedInv());
|
||||
delay = 0;
|
||||
}
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
int[] slotIndices = inv.getAccessibleSlotsFromSide(inventorySide);
|
||||
@@ -400,6 +393,9 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
matchedStickyInput = of.isValid() && of.doesItemPassFilter(toExtract);
|
||||
}
|
||||
if(target.stickyInput || !matchedStickyInput) {
|
||||
if(target.inv.recheckInv) {
|
||||
target.inv.updateInventory();
|
||||
}
|
||||
int inserted = target.inv.insertItem(toExtract);
|
||||
if(inserted > 0) {
|
||||
toExtract.stackSize -= inserted;
|
||||
@@ -413,6 +409,16 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
return totalToInsert - leftToInsert;
|
||||
}
|
||||
|
||||
private void updateInventory() {
|
||||
|
||||
TileEntity te = world.getBlockTileEntity(location.x, location.y, location.z);
|
||||
if(te instanceof ISidedInventory) {
|
||||
this.inv = (ISidedInventory) te;
|
||||
} else if(te instanceof IInventory) {
|
||||
inv = new InventoryWrapper((IInventory) te);
|
||||
}
|
||||
}
|
||||
|
||||
private int insertItem(ItemStack item) {
|
||||
if(!canInsert() || item == null) {
|
||||
return 0;
|
||||
@@ -431,8 +437,6 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
if(!canExtract()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Map<BlockCoord, Target> result = new HashMap<BlockCoord, Target>();
|
||||
List<Target> result = new ArrayList<ItemConduitNetwork.NetworkedInventory.Target>();
|
||||
|
||||
for (NetworkedInventory other : inventories) {
|
||||
@@ -443,7 +447,6 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
if(Config.itemConduitUsePhyscialDistance) {
|
||||
sendPriority.add(new Target(other, distanceTo(other), other.isSticky()));
|
||||
} else {
|
||||
//result.put(other.location, new Target(other, 9999999, other.isSticky()));
|
||||
result.add(new Target(other, 9999999, other.isSticky()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,10 +135,14 @@ public abstract class AbstractLiquidConduit extends AbstractConduit implements I
|
||||
|
||||
DyeColor col = getExtractionSignalColor(dir);
|
||||
int signal = ConduitUtil.getInternalSignalForColor(getBundle(), col);
|
||||
if(mode.isConditionMet(mode, signal)) {
|
||||
if(mode.isConditionMet(mode, signal) && mode != RedstoneControlMode.OFF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isConditionMetByExternalSignal(dir, mode, col);
|
||||
}
|
||||
|
||||
private boolean isConditionMetByExternalSignal(ForgeDirection dir, RedstoneControlMode mode, DyeColor col) {
|
||||
int externalSignal = 0;
|
||||
if(col == DyeColor.RED) {
|
||||
Integer val = externalRedstoneSignals.get(dir);
|
||||
|
||||
@@ -13,6 +13,7 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
|
||||
import crazypants.enderio.conduit.power.PowerConduitNetwork.ReceptorEntry;
|
||||
@@ -587,6 +588,11 @@ public class NetworkPowerManager {
|
||||
@Override
|
||||
public void tickEnd(ServerTickEvent evt) {
|
||||
doApplyRecievedPower();
|
||||
try {
|
||||
doApplyRecievedPower();
|
||||
} catch (Exception e) {
|
||||
Log.warn("NetworkPowerManager: Exception thrown when updating power network " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
@Override
|
||||
public boolean onNeighborBlockChange(Block blockId) {
|
||||
redstoneStateDirty = true;
|
||||
if(network != null) {
|
||||
if(network != null && network.powerManager != null) {
|
||||
network.powerManager.receptorsChanged();
|
||||
}
|
||||
return super.onNeighborBlockChange(blockId);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CompositeInventory implements ISidedInventory {
|
||||
return;
|
||||
}
|
||||
inventories.add(new InvEntry(inv, size, side));
|
||||
size += inv.getSizeInventory();
|
||||
updateSize();
|
||||
}
|
||||
|
||||
public void removeInventory(IInventory inv) {
|
||||
|
||||
@@ -741,6 +741,9 @@ public class TileHyperCube extends TileEntityEio implements IInternalPowerRecept
|
||||
}
|
||||
for (TileHyperCube cube : cubes) {
|
||||
if(cube != this && cube != null && cube.canRecieveItems()) {
|
||||
if(cube.inventoriesDirty) {
|
||||
cube.updateInventories();
|
||||
}
|
||||
res.addInventory(cube.localInventory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ItemConduitProbe extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8,
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8,
|
||||
float par9, float par10) {
|
||||
|
||||
if(player.isSneaking()) {
|
||||
|
||||
@@ -513,7 +513,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
float freeSpace = maxStoredEnergy - storedEnergy;
|
||||
int result = (int) Math.min(maxReceive / 10, freeSpace);
|
||||
if(!simulate) {
|
||||
storedEnergy += result;
|
||||
doAddEnergy(result);
|
||||
}
|
||||
return result * 10;
|
||||
}
|
||||
@@ -630,7 +630,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
}
|
||||
|
||||
void doAddEnergy(float add) {
|
||||
storedEnergy = Math.min(maxStoredEnergy, storedEnergy + add);
|
||||
storedEnergy = Math.max(0, Math.min(maxStoredEnergy, storedEnergy + add));
|
||||
}
|
||||
|
||||
void doSetMaxInput(int in) {
|
||||
@@ -679,6 +679,8 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
private void updatePowerHandler() {
|
||||
if(storedEnergy > maxStoredEnergy) {
|
||||
storedEnergy = maxStoredEnergy;
|
||||
} else if(storedEnergy < 0) {
|
||||
storedEnergy = 0;
|
||||
}
|
||||
powerHandler = null;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,9 @@ public class InventoryWrapper implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack itemStack) {
|
||||
inv.setInventorySlotContents(slot, itemStack);
|
||||
if(slot >= 0 && slot < inv.getSizeInventory()) {
|
||||
inv.setInventorySlotContents(slot, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,7 +89,7 @@ public class InventoryWrapper implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
|
||||
return inv.isItemValidForSlot(slot, itemStack);
|
||||
return slot >= 0 && slot < getSizeInventory() && inv.isItemValidForSlot(slot, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +108,7 @@ public class InventoryWrapper implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
||||
return true;
|
||||
return slot >= 0 && slot < getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user