mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 07:55:41 +00:00
Merge branch 'master' into 1.7 (v 1.0.1)
This commit is contained in:
commit
d36a11e591
11 files changed
+200
-24
No files matched your search
@@ -2,6 +2,7 @@ package crazypants.enderio.conduit;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import crazypants.enderio.EnderIO;
|
||||
|
||||
public enum ConduitDisplayMode {
|
||||
ALL,
|
||||
@@ -27,7 +28,7 @@ public enum ConduitDisplayMode {
|
||||
}
|
||||
|
||||
public static ConduitDisplayMode getDisplayMode(ItemStack equipped) {
|
||||
if(equipped == null) {
|
||||
if(equipped == null || equipped.getItem() != EnderIO.itemYetaWench) {
|
||||
return ALL;
|
||||
}
|
||||
int index = equipped.getItemDamage();
|
||||
|
||||
@@ -80,10 +80,12 @@ public class BlockConduitFacade extends Block {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
if(blockOverride != null) {
|
||||
return blockOverride.colorMultiplier(par1IBlockAccess, par2, par3, par4);
|
||||
} else {
|
||||
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
|
||||
try { //work around for Issue #589
|
||||
return blockOverride.colorMultiplier(par1IBlockAccess, par2, par3, par4);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
|
||||
public Block getIconOverrideBlock() {
|
||||
|
||||
@@ -37,6 +37,8 @@ public class NetworkPowerManager {
|
||||
|
||||
private final List<ReceptorEntry> storageReceptors = new ArrayList<ReceptorEntry>();
|
||||
|
||||
private boolean receptorsDirty = true;
|
||||
|
||||
private boolean lastActiveValue = false;
|
||||
private int ticksWithNoPower = 0;
|
||||
|
||||
@@ -124,6 +126,8 @@ public class NetworkPowerManager {
|
||||
|
||||
trackerStartTick();
|
||||
|
||||
checkReceptors();
|
||||
|
||||
// Update our energy stored based on what's in our conduits
|
||||
updateNetorkStorage();
|
||||
networkPowerTracker.tickStart(energyStored);
|
||||
@@ -365,16 +369,25 @@ public class NetworkPowerManager {
|
||||
}
|
||||
|
||||
public void receptorsChanged() {
|
||||
receptorsDirty = true;
|
||||
}
|
||||
|
||||
private void checkReceptors() {
|
||||
if(!receptorsDirty) {
|
||||
return;
|
||||
}
|
||||
receptors.clear();
|
||||
storageReceptors.clear();
|
||||
for (ReceptorEntry rec : network.getPowerReceptors()) {
|
||||
if(rec.powerInterface.getDelegate() instanceof TileCapacitorBank) {
|
||||
if(rec.powerInterface.getDelegate() != null && rec.powerInterface.getDelegate().getClass() == TileCapacitorBank.class) {
|
||||
storageReceptors.add(rec);
|
||||
} else {
|
||||
receptors.add(rec);
|
||||
}
|
||||
}
|
||||
receptorIterator = receptors.listIterator();
|
||||
|
||||
receptorsDirty = false;
|
||||
}
|
||||
|
||||
void onNetworkDestroyed() {
|
||||
@@ -426,6 +439,7 @@ public class NetworkPowerManager {
|
||||
maxCap = 0;
|
||||
for (ReceptorEntry rec : storageReceptors) {
|
||||
TileCapacitorBank cb = (TileCapacitorBank) rec.powerInterface.getDelegate();
|
||||
cb = cb.getController();
|
||||
|
||||
boolean processed = capBanks.contains(cb);
|
||||
|
||||
|
||||
@@ -101,6 +101,8 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
protected final EnumMap<ForgeDirection, RedstoneControlMode> rsModes = new EnumMap<ForgeDirection, RedstoneControlMode>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, DyeColor> rsColors = new EnumMap<ForgeDirection, DyeColor>(ForgeDirection.class);
|
||||
|
||||
protected EnumMap<ForgeDirection, Long> recievedTicks;
|
||||
|
||||
private final Map<ForgeDirection, Integer> externalRedstoneSignals = new HashMap<ForgeDirection, Integer>();
|
||||
|
||||
private boolean redstoneStateDirty = true;
|
||||
@@ -281,15 +283,6 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
return powerHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxEnergyExtracted(ForgeDirection dir) {
|
||||
ConnectionMode mode = getConectionMode(dir);
|
||||
if(mode == ConnectionMode.INPUT || mode == ConnectionMode.DISABLED || !isRedstoneEnabled(dir)) {
|
||||
return 0;
|
||||
}
|
||||
return getCapacitor().getMaxEnergyExtracted();
|
||||
}
|
||||
|
||||
private boolean isRedstoneEnabled(ForgeDirection dir) {
|
||||
boolean result;
|
||||
RedstoneControlMode mode = getExtractionRedstoneMode(dir);
|
||||
@@ -342,7 +335,35 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
return getCapacitor().getMaxEnergyReceived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxEnergyExtracted(ForgeDirection dir) {
|
||||
ConnectionMode mode = getConectionMode(dir);
|
||||
if(mode == ConnectionMode.INPUT || mode == ConnectionMode.DISABLED || !isRedstoneEnabled(dir)) {
|
||||
return 0;
|
||||
}
|
||||
if(recievedRfThisTick(dir)) {
|
||||
return 0;
|
||||
}
|
||||
return getCapacitor().getMaxEnergyExtracted();
|
||||
}
|
||||
|
||||
private boolean recievedRfThisTick(ForgeDirection dir) {
|
||||
if(recievedTicks == null || dir == null || recievedTicks.get(dir) == null || getBundle() == null || getBundle().getWorld() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
long curTick = getBundle().getWorld().getTotalWorldTime();
|
||||
long recT = recievedTicks.get(dir);
|
||||
if(curTick >= (recT - 5)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerHandler getPowerHandler() {
|
||||
return powerHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
@@ -364,13 +385,21 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
if(getMaxEnergyRecieved(from) == 0) {
|
||||
if(getMaxEnergyRecieved(from) == 0 || maxReceive <= 0) {
|
||||
return 0;
|
||||
}
|
||||
float freeSpace = getCapacitor().getMaxEnergyStored() - energyStored;
|
||||
int result = (int) Math.min(maxReceive / 10, freeSpace);
|
||||
if(!simulate) {
|
||||
if(!simulate && result > 0) {
|
||||
energyStored += result;
|
||||
|
||||
if(getBundle() != null) {
|
||||
if(recievedTicks == null) {
|
||||
recievedTicks = new EnumMap<ForgeDirection, Long>(ForgeDirection.class);
|
||||
}
|
||||
recievedTicks.put(from, getBundle().getWorld().getTotalWorldTime());
|
||||
}
|
||||
|
||||
}
|
||||
return result * 10;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ public class TileHyperCube extends TileEntityEio implements IInternalPowerRecept
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
if(getModeForChannel(SubChannel.POWER).isSendEnabled()) {
|
||||
if(getModeForChannel(SubChannel.POWER) != IoMode.RECIEVE) {
|
||||
return PowerHandlerUtil.recieveRedstoneFlux(from, powerHandler, maxReceive, simulate);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -823,7 +823,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
render = true;
|
||||
}
|
||||
|
||||
TileCapacitorBank getController() {
|
||||
public TileCapacitorBank getController() {
|
||||
if(isMaster() || !isMultiblock()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -20,10 +20,14 @@ public class OreDictionaryRecipeInput extends RecipeInput {
|
||||
|
||||
@Override
|
||||
public boolean isInput(ItemStack test) {
|
||||
if(test == null) {
|
||||
if(test == null || oreId < 0) {
|
||||
return false;
|
||||
}
|
||||
try { //work around for issue #591
|
||||
return OreDictionary.getOreID(test) == oreId;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return OreDictionary.getOreID(test) == oreId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,9 +42,12 @@ public class ItemUtil {
|
||||
inventorySide = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
int[] slots = sidedInv.getAccessibleSlotsFromSide(inventorySide.ordinal());
|
||||
if(slots == null) {
|
||||
return 0;
|
||||
}
|
||||
int numInserted = 0;
|
||||
int numToInsert = item.stackSize;
|
||||
int[] slots = sidedInv.getAccessibleSlotsFromSide(inventorySide.ordinal());
|
||||
for (int i = 0; i < slots.length && numToInsert > 0; i++) {
|
||||
int slot = slots[i];
|
||||
if(sidedInv.canInsertItem(slot, item, inventorySide.ordinal())) {
|
||||
|
||||
Reference in new issue
Block a user