use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.
the class TileEntityScreen method joinLeft.
private void joinLeft() {
int meta = this.getBlockMetadata();
int side = this.getLeft(meta);
BlockVec3 vec = new BlockVec3(this);
for (int z = -this.connectionsUp; z <= this.connectionsDown; z++) {
TileEntity tile;
BlockVec3 newVec = vec.clone().modifyPositionFromSide(EnumFacing.DOWN, z);
if (z == 0) {
tile = this;
} else {
tile = newVec.getTileEntity(this.worldObj);
}
if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
TileEntityScreen screenTile = (TileEntityScreen) tile;
// screenTile.connectedLeft = true;
screenTile.setConnectedLeft(true);
TileEntity te2 = newVec.getTileEntityOnSide(this.worldObj, side);
if (te2 instanceof TileEntityScreen && te2.getBlockMetadata() == meta && !te2.isInvalid()) {
screenTile.tryConnectLeft((TileEntityScreen) te2);
}
}
}
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.
the class TileEntityScreen method checkWholeScreen.
/**
* After figuring out the screen edges (overall screen dimensions)
* check that the screen is a whole A x B rectangle with no tiles missing
* <p>
* If it is whole, set all tiles in the screen to match this screen type
*
* @param up Number of blocks the screen edge is away from this in the up direction
* @param down Number of blocks the screen edge is away from this in the down direction
* @param left Number of blocks the screen edge is away from this in the left direction
* @param right Number of blocks the screen edge is away from this in the right direction
* @return True if the screen was whole
*/
private boolean checkWholeScreen(int up, int down, int left, int right) {
if (up + down + left + right == 0 || up < 0 || down < 0 || left < 0 || right < 0) {
this.doneClientUpdate = true;
this.resetToSingle();
return true;
}
// System.out.println("Checking screen size at "+this.getPos().getX()+","+this.getPos().getZ()+": Up "+up+" Dn "+down+" Lf "+left+" Rg "+right);
boolean screenWhole = true;
boolean existingScreen = false;
int barrierUp = up;
int barrierDown = down;
int barrierLeft = left;
int barrierRight = right;
int meta = this.getBlockMetadata() & 7;
BlockVec3 vec = new BlockVec3(this);
ArrayList<TileEntityScreen> screenList = new ArrayList<TileEntityScreen>();
// int side = this.getRight(meta);
EnumFacing side = getFront().rotateY();
for (int x = -left; x <= right; x++) {
for (int z = -up; z <= down; z++) {
BlockVec3 newVec = vec.clone().modifyPositionFromSide(side, x).modifyPositionFromSide(EnumFacing.DOWN, z);
TileEntity tile = newVec.getTileEntity(this.worldObj);
if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
TileEntityScreen screenTile = (TileEntityScreen) tile;
screenList.add(screenTile);
if (screenTile.isMultiscreen) {
if (screenTile.connectionsUp > z + up) {
barrierUp = -z - 1;
existingScreen = true;
}
if (screenTile.connectionsDown > down - z) {
barrierDown = z - 1;
existingScreen = true;
}
if (screenTile.connectionsLeft > x + left) {
barrierLeft = -x - 1;
existingScreen = true;
}
if (screenTile.connectionsRight > right - x) {
barrierRight = x - 1;
existingScreen = true;
}
}
} else {
screenWhole = false;
}
}
}
if (!screenWhole) {
for (TileEntityScreen scr : screenList) {
scr.resetToSingle();
}
return false;
}
if (existingScreen) {
return this.checkWholeScreen(barrierUp, barrierDown, barrierLeft, barrierRight);
}
DrawGameScreen newScreen = null;
boolean serverside = true;
TileEntity bottomLeft = vec.clone().modifyPositionFromSide(side, -left).modifyPositionFromSide(EnumFacing.DOWN, down).getTileEntity(this.worldObj);
if (this.worldObj.isRemote) {
if (// It always will be if reached this far
bottomLeft instanceof TileEntityScreen) {
newScreen = ((TileEntityScreen) bottomLeft).screen;
if (!newScreen.check(1.0F + left + right, 1.0F + up + down)) {
newScreen = new DrawGameScreen(1.0F + left + right, 1.0F + up + down, bottomLeft);
}
}
serverside = false;
}
Iterator<TileEntityScreen> it = screenList.iterator();
for (int x = -left; x <= right; x++) {
for (int z = -up; z <= down; z++) {
TileEntityScreen screenTile = it.next();
screenTile.screenOffsetx = x + left;
screenTile.screenOffsetz = z + up;
screenTile.screen = newScreen;
screenTile.connectionsLeft = x + left;
screenTile.connectionsRight = right - x;
screenTile.connectionsUp = z + up;
screenTile.connectionsDown = down - z;
screenTile.isMultiscreen = true;
screenTile.refreshOnUpdate = false;
if (serverside) {
screenTile.imageType = this.imageType;
screenTile.markDirty();
screenTile.updateAllInDimension();
}
screenTile.refreshConnections(false);
}
}
this.connectionsUp = up;
this.connectionsDown = down;
this.connectionsLeft = left;
this.connectionsRight = right;
return true;
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.
the class TileEntityScreen method canJoinLeft.
private boolean canJoinLeft() {
int meta = this.getBlockMetadata();
TileEntity te = new BlockVec3(this).getTileEntityOnSide(this.worldObj, this.getLeft(meta));
if (!(te instanceof TileEntityScreen)) {
return false;
}
TileEntityScreen screenTile = (TileEntityScreen) te;
if (screenTile.getBlockMetadata() != meta) {
return false;
}
if (screenTile.connectionsUp != this.connectionsUp) {
return false;
}
if (screenTile.connectionsDown != this.connectionsDown) {
return false;
}
if (this.connectionsUp + this.connectionsDown > 0) {
return true;
}
if (this.connectionsRight > 0) {
return false;
}
if (screenTile.connectionsLeft > 0) {
return false;
}
return true;
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.
the class TileEntityScreen method canJoinDown.
private boolean canJoinDown() {
int meta = this.getBlockMetadata();
TileEntity te = new BlockVec3(this).getTileEntityOnSide(this.worldObj, 0);
if (!(te instanceof TileEntityScreen)) {
return false;
}
TileEntityScreen screenTile = (TileEntityScreen) te;
if (screenTile.getBlockMetadata() != meta) {
return false;
}
if (screenTile.connectionsLeft != this.connectionsLeft) {
return false;
}
if (screenTile.connectionsRight != this.connectionsRight) {
return false;
}
if (this.connectionsLeft + this.connectionsRight > 0) {
return true;
}
if (this.connectionsUp > 0) {
return false;
}
if (screenTile.connectionsDown > 0) {
return false;
}
return true;
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.
the class TileEntityScreen method joinUp.
private void joinUp() {
int meta = this.getBlockMetadata();
// EnumFacing side = EnumFacing.getFront(this.getRight(meta));
EnumFacing side = getFront().rotateY();
BlockVec3 vec = new BlockVec3(this);
for (int x = -this.connectionsLeft; x <= this.connectionsRight; x++) {
TileEntity tile;
BlockVec3 newVec = vec.clone().modifyPositionFromSide(side, x);
if (x == 0) {
tile = this;
} else {
tile = newVec.getTileEntity(this.worldObj);
}
if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
TileEntityScreen screenTile = (TileEntityScreen) tile;
// screenTile.connectedUp = true;
screenTile.setConnectedUp(true);
TileEntity te2 = newVec.getTileEntityOnSide(this.worldObj, 1);
if (te2 instanceof TileEntityScreen && te2.getBlockMetadata() == meta && !te2.isInvalid()) {
screenTile.tryConnectUp((TileEntityScreen) te2);
}
}
}
}
Aggregations