improve engine mechanics and fix orientation bugs
This commit is contained in:
parent
582ebb9887
commit
5a4635876c
2 changed files with 23 additions and 18 deletions
|
@ -262,7 +262,7 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
||||||
TileEntity tile = world.getTileEntity(x, y, z);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tile instanceof TileEngine) {
|
if (tile instanceof TileEngine) {
|
||||||
((TileEngine) tile).checkRedstonePower();
|
((TileEngine) tile).onNeighborUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
protected boolean lastPower = false;
|
protected boolean lastPower = false;
|
||||||
protected PowerHandler powerHandler;
|
protected PowerHandler powerHandler;
|
||||||
|
|
||||||
private boolean checkOrienation = false;
|
private boolean checkOrientation = false;
|
||||||
private TileBuffer[] tileCache;
|
private TileBuffer[] tileCache;
|
||||||
|
|
||||||
@NetworkData
|
@NetworkData
|
||||||
|
@ -203,6 +203,16 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refreshPowerMode(TileEntity tile, ForgeDirection orientation) {
|
||||||
|
if (isPoweredTile(tile, orientation)) {
|
||||||
|
if ((tile instanceof IPipeTile) && (((IPipeTile) tile).getPipeType() != PipeType.POWER)) {
|
||||||
|
constantPower = false;
|
||||||
|
} else {
|
||||||
|
constantPower = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
@ -223,21 +233,15 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkOrienation) {
|
if (checkOrientation) {
|
||||||
checkOrienation = false;
|
checkOrientation = false;
|
||||||
|
|
||||||
if (!isOrientationValid()) {
|
if (!isOrientationValid()) {
|
||||||
switchOrientation(true);
|
switchOrientation(true);
|
||||||
} else {
|
} else {
|
||||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||||
|
|
||||||
if (isPoweredTile(tile, orientation)) {
|
refreshPowerMode(tile, orientation);
|
||||||
if ((tile instanceof IPipeTile) && (((IPipeTile) tile).getPipeType() != PipeType.POWER)) {
|
|
||||||
constantPower = false;
|
|
||||||
} else {
|
|
||||||
constantPower = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,11 +397,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
TileEntity tile = getTileBuffer(o).getTile();
|
TileEntity tile = getTileBuffer(o).getTile();
|
||||||
|
|
||||||
if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
|
if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
|
||||||
if ((tile instanceof IPipeTile) && (((IPipeTile) tile).getPipeType() != PipeType.POWER)) {
|
refreshPowerMode(tile, o);
|
||||||
constantPower = false;
|
|
||||||
} else {
|
|
||||||
constantPower = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
orientation = o;
|
orientation = o;
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
@ -422,14 +422,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
tileCache = null;
|
tileCache = null;
|
||||||
checkOrienation = true;
|
checkOrientation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() {
|
public void validate() {
|
||||||
super.validate();
|
super.validate();
|
||||||
tileCache = null;
|
tileCache = null;
|
||||||
checkOrienation = true;
|
checkOrientation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -598,6 +598,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
isRedstonePowered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
isRedstonePowered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onNeighborUpdate() {
|
||||||
|
checkRedstonePower();
|
||||||
|
checkOrientation = true;
|
||||||
|
tileCache = null;
|
||||||
|
}
|
||||||
// RF support
|
// RF support
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue