More tweaks to improve mobility of blocks

This commit is contained in:
CovertJaguar 2013-09-15 00:38:55 -07:00
parent 56d46de1be
commit 2d65129722
2 changed files with 27 additions and 13 deletions

View file

@ -54,7 +54,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
protected PowerHandler powerHandler;
public float currentOutput = 0;
public boolean isRedstonePowered = false;
public TileBuffer[] tileCache;
private TileBuffer[] tileCache;
public float progress;
public float energy;
public float heat = MIN_HEAT;
@ -74,7 +74,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
@Override
public void initialize() {
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, true);
powerHandler.configure(minEnergyReceived(), maxEnergyReceived(), 1, getMaxEnergy());
checkRedstonePower();
}
@ -173,7 +172,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
updateHeatLevel();
engineUpdate();
TileEntity tile = tileCache[orientation.ordinal()].getTile();
TileEntity tile = getTileBuffer(orientation).getTile();
if (progressPart != 0) {
progress += getPistonSpeed();
@ -206,14 +205,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
}
private float getPowerToExtract() {
TileEntity tile = tileCache[orientation.ordinal()].getTile();
TileEntity tile = getTileBuffer(orientation).getTile();
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
return extractEnergy(receptor.getMinEnergyReceived(), receptor.getMaxEnergyReceived(), false); // Comment out for constant power
// return extractEnergy(0, getActualOutput(), false); // Uncomment for constant power
}
private void sendPower() {
TileEntity tile = tileCache[orientation.ordinal()].getTile();
TileEntity tile = getTileBuffer(orientation).getTile();
if (isPoweredTile(tile, orientation)) {
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
@ -255,10 +254,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
}
public boolean isOrientationValid() {
Position pos = new Position(xCoord, yCoord, zCoord, orientation);
pos.moveForwards(1);
TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
TileEntity tile = getTileBuffer(orientation).getTile();
return isPoweredTile(tile, orientation);
}
@ -272,9 +268,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
for (int i = orientation.ordinal() + 1; i <= orientation.ordinal() + 6; ++i) {
ForgeDirection o = ForgeDirection.VALID_DIRECTIONS[i % 6];
Position pos = new Position(xCoord, yCoord, zCoord, o);
pos.moveForwards(1);
TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
TileEntity tile = getTileBuffer(o).getTile();
if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
orientation = o;
@ -287,6 +281,26 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
return false;
}
public TileBuffer getTileBuffer(ForgeDirection side) {
if (tileCache == null)
tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false);
return tileCache[side.ordinal()];
}
@Override
public void invalidate() {
super.invalidate();
tileCache = null;
}
@Override
public void validate() {
super.validate();
tileCache = null;
if (!isOrientationValid())
switchOrientation(true);
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);

View file

@ -35,7 +35,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.logging.Level;
import net.minecraft.block.Block;
@ -140,6 +139,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
@Override
public void validate() {
super.validate();
initialized = false;
tileBuffer = null;
bindPipe();
if (pipe != null)