aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/tileentities/general
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
commitcbe0e497be8e466c380a5b4fa781b314ede9ada3 (patch)
treeb85848b432adf458e3abda466ee46d9dfc3e454b /src/Java/gtPlusPlus/core/tileentities/general
parentc40416b036c0e89451e1558253ccf07bbee028d0 (diff)
downloadGT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.gz
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.bz2
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.zip
Revert "$ Cleaned up the entire project."
This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747. # Conflicts: # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java Revert "% Cleaned up Imports." This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966.
Diffstat (limited to 'src/Java/gtPlusPlus/core/tileentities/general')
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java469
1 files changed, 244 insertions, 225 deletions
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java
index 535af68200..8767b6607c 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java
@@ -1,96 +1,90 @@
package gtPlusPlus.core.tileentities.general;
+import gtPlusPlus.core.block.ModBlocks;
+
import java.util.Random;
-import gtPlusPlus.core.block.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
-public class TileEntityReverter extends TileEntity {
- private static final int REVERT_CHANCE = 10;
- public int radius = 16;
- public int diameter = 8 * this.radius + 4;
- public double requiredPlayerRange = 64.0D;
- public Random rand = new Random();
- private int tickCount;
- private boolean slowScan;
- private int ticksSinceChange;
- private Block[] blockData;
- private byte[] metaData;
- public boolean anyPlayerInRange() {
- return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D,
- this.requiredPlayerRange) != null;
- }
- @Override
- public boolean canUpdate() {
+public class TileEntityReverter extends TileEntity
+{
+ private static final int REVERT_CHANCE = 10;
+ public int radius = 16;
+ public int diameter = 8 * this.radius + 4;
+ public double requiredPlayerRange = 64.0D;
+ public Random rand = new Random();
+ private int tickCount;
+ private boolean slowScan;
+ private int ticksSinceChange;
+ private Block[] blockData;
+ private byte[] metaData;
+
+ public boolean canUpdate(){
return true;
}
- private void captureBlockData() {
- this.blockData = new Block[this.diameter * this.diameter * this.diameter];
- this.metaData = new byte[this.diameter * this.diameter * this.diameter];
-
- int index = 0;
- for (int x = -this.radius; x <= this.radius; x++) {
- for (int y = -this.radius; y <= this.radius; y++) {
- for (int z = -this.radius; z <= this.radius; z++) {
- final Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z);
- final int meta = this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z);
-
- this.blockData[index] = blockID;
- this.metaData[index] = (byte) meta;
+ public void updateEntity()
+ {
+ if (anyPlayerInRange())
+ {
+ this.tickCount += 1;
+ if (this.worldObj.isRemote)
+ {
+ double var1 = this.xCoord + this.worldObj.rand.nextFloat();
+ double var3 = this.yCoord + this.worldObj.rand.nextFloat();
+ double var5 = this.zCoord + this.worldObj.rand.nextFloat();
- index++;
+ this.worldObj.spawnParticle("enchantmenttable", var1, var3, var5, 0.0D, 0.0D, 0.0D);
+ if (this.rand.nextInt(5) == 0)
+ {
+ makeRandomOutline();
+ makeRandomOutline();
+ makeRandomOutline();
+ }
+ }
+ else
+ {
+ if ((this.blockData == null) || (this.metaData == null))
+ {
+ captureBlockData();
+ this.slowScan = true;
+ }
+ if ((!this.slowScan) || (this.tickCount % 20 == 0)) {
+ if (scanAndRevertChanges())
+ {
+ this.slowScan = false;
+ this.ticksSinceChange = 0;
+ }
+ else
+ {
+ this.ticksSinceChange += 1;
+ if (this.ticksSinceChange > 20) {
+ this.slowScan = true;
+ }
+ }
}
}
}
- }
-
- protected void drawParticleLine(final double srcX, final double srcY, final double srcZ, final double destX,
- final double destY, final double destZ) {
- final int particles = 16;
- for (int i = 0; i < particles; i++) {
- final double trailFactor = i / (particles - 1.0D);
+ else
+ {
+ this.blockData = null;
+ this.metaData = null;
- final double tx = srcX + (destX - srcX) * trailFactor + this.rand.nextFloat() * 0.005D;
- final double ty = srcY + (destY - srcY) * trailFactor + this.rand.nextFloat() * 0.005D;
- final double tz = srcZ + (destZ - srcZ) * trailFactor + this.rand.nextFloat() * 0.005D;
- this.worldObj.spawnParticle("portal", tx, ty, tz, 0.0D, 0.0D, 0.0D);
+ this.tickCount = 0;
}
}
- private boolean isUnrevertable(final Block thereBlockID, final byte thereMeta, final Block replaceBlockID,
- final byte replaceMeta) {
- if (thereBlockID == ModBlocks.blockGriefSaver || replaceBlockID == ModBlocks.blockGriefSaver) {
- return true;
- }
- /*
- * if (((thereBlockID == towerTranslucent) && (thereMeta != 4)) ||
- * ((replaceBlockID == towerTranslucent) && (replaceMeta != 4))) {
- * return true; }
- */
- if (thereBlockID == Blocks.redstone_lamp && replaceBlockID == Blocks.lit_redstone_lamp) {
- return true;
- }
- if (thereBlockID == Blocks.lit_redstone_lamp && replaceBlockID == Blocks.redstone_lamp) {
- return true;
- }
- /*
- * if ((thereBlockID == Blocks.water) || (replaceBlockID ==
- * Blocks.flowing_water)) { return true; } if ((thereBlockID ==
- * Blocks.flowing_water) || (replaceBlockID == Blocks.water)) { return
- * true; }
- */
- if (replaceBlockID == Blocks.tnt) {
- return true;
- }
- return false;
+ private void makeRandomOutline()
+ {
+ makeOutline(this.rand.nextInt(12));
}
- private void makeOutline(final int outline) {
+ private void makeOutline(int outline)
+ {
double sx = this.xCoord;
double sy = this.yCoord;
double sz = this.zCoord;
@@ -98,143 +92,126 @@ public class TileEntityReverter extends TileEntity {
double dx = this.xCoord;
double dy = this.yCoord;
double dz = this.zCoord;
- switch (outline) {
- case 0:
- sx -= this.radius;
- dx -= this.radius;
- sz -= this.radius;
- dz += this.radius + 1;
- case 8:
- sx -= this.radius;
- dx += this.radius + 1;
- sz -= this.radius;
- dz -= this.radius;
- break;
- case 1:
- case 9:
- sx -= this.radius;
- dx -= this.radius;
- sz -= this.radius;
- dz += this.radius + 1;
- break;
- case 2:
- case 10:
- sx -= this.radius;
- dx += this.radius + 1;
- sz += this.radius + 1;
- dz += this.radius + 1;
- break;
- case 3:
- case 11:
- sx += this.radius + 1;
- dx += this.radius + 1;
- sz -= this.radius;
- dz += this.radius + 1;
- break;
- case 4:
- sx -= this.radius;
- dx -= this.radius;
- sz -= this.radius;
- dz -= this.radius;
- break;
- case 5:
- sx += this.radius + 1;
- dx += this.radius + 1;
- sz -= this.radius;
- dz -= this.radius;
- break;
- case 6:
- sx += this.radius + 1;
- dx += this.radius + 1;
- sz += this.radius + 1;
- dz += this.radius + 1;
- break;
- case 7:
- sx -= this.radius;
- dx -= this.radius;
- sz += this.radius + 1;
- dz += this.radius + 1;
+ switch (outline)
+ {
+ case 0:
+ sx -= this.radius;
+ dx -= this.radius;
+ sz -= this.radius;
+ dz += this.radius + 1;
+ case 8:
+ sx -= this.radius;
+ dx += this.radius + 1;
+ sz -= this.radius;
+ dz -= this.radius;
+ break;
+ case 1:
+ case 9:
+ sx -= this.radius;
+ dx -= this.radius;
+ sz -= this.radius;
+ dz += this.radius + 1;
+ break;
+ case 2:
+ case 10:
+ sx -= this.radius;
+ dx += this.radius + 1;
+ sz += this.radius + 1;
+ dz += this.radius + 1;
+ break;
+ case 3:
+ case 11:
+ sx += this.radius + 1;
+ dx += this.radius + 1;
+ sz -= this.radius;
+ dz += this.radius + 1;
+ break;
+ case 4:
+ sx -= this.radius;
+ dx -= this.radius;
+ sz -= this.radius;
+ dz -= this.radius;
+ break;
+ case 5:
+ sx += this.radius + 1;
+ dx += this.radius + 1;
+ sz -= this.radius;
+ dz -= this.radius;
+ break;
+ case 6:
+ sx += this.radius + 1;
+ dx += this.radius + 1;
+ sz += this.radius + 1;
+ dz += this.radius + 1;
+ break;
+ case 7:
+ sx -= this.radius;
+ dx -= this.radius;
+ sz += this.radius + 1;
+ dz += this.radius + 1;
}
- switch (outline) {
- case 0:
- case 1:
- case 2:
- case 3:
- sy += this.radius + 1;
- dy += this.radius + 1;
- break;
- case 4:
- case 5:
- case 6:
- case 7:
- sy -= this.radius;
- dy += this.radius + 1;
- break;
- case 8:
- case 9:
- case 10:
- case 11:
- sy -= this.radius;
- dy -= this.radius;
+ switch (outline)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ sy += this.radius + 1;
+ dy += this.radius + 1;
+ break;
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ sy -= this.radius;
+ dy += this.radius + 1;
+ break;
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ sy -= this.radius;
+ dy -= this.radius;
}
if (this.rand.nextBoolean()) {
- this.drawParticleLine(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, dx, dy, dz);
+ drawParticleLine(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, dx, dy, dz);
+ } else {
+ drawParticleLine(sx, sy, sz, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D);
}
- else {
- this.drawParticleLine(sx, sy, sz, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D);
- }
- this.drawParticleLine(sx, sy, sz, dx, dy, dz);
+ drawParticleLine(sx, sy, sz, dx, dy, dz);
}
- private void makeRandomOutline() {
- this.makeOutline(this.rand.nextInt(12));
- }
+ protected void drawParticleLine(double srcX, double srcY, double srcZ, double destX, double destY, double destZ)
+ {
+ int particles = 16;
+ for (int i = 0; i < particles; i++)
+ {
+ double trailFactor = i / (particles - 1.0D);
- private boolean revertBlock(final int x, final int y, final int z, final Block thereBlockID, final byte thereMeta,
- final Block replaceBlockID, byte replaceMeta) {
- /*
- * if ((thereBlockID == Blocks.air) &&
- * (!replaceBlockID.getMaterial().blocksMovement())) {
- * System.out.println("Not replacing block " + replaceBlockID +
- * " because it doesn't block movement");
- *
- * return false; }
- */
- if (this.isUnrevertable(thereBlockID, thereMeta, replaceBlockID, replaceMeta)) {
- return false;
- }
- if (this.rand.nextInt(5) == 0) {
- if (replaceBlockID != Blocks.air) {
- // replaceBlockID = null;
- replaceMeta = 4;
- }
- this.worldObj.setBlock(x, y, z, replaceBlockID, replaceMeta, 2);
- if (thereBlockID == Blocks.air) {
- this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(replaceBlockID) + (replaceMeta << 12));
- }
- else if (replaceBlockID == Blocks.air) {
- this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(thereBlockID) + (thereMeta << 12));
- thereBlockID.dropBlockAsItem(this.worldObj, x, y, z, thereMeta, 0);
- }
+ double tx = srcX + (destX - srcX) * trailFactor + this.rand.nextFloat() * 0.005D;
+ double ty = srcY + (destY - srcY) * trailFactor + this.rand.nextFloat() * 0.005D;
+ double tz = srcZ + (destZ - srcZ) * trailFactor + this.rand.nextFloat() * 0.005D;
+ this.worldObj.spawnParticle("portal", tx, ty, tz, 0.0D, 0.0D, 0.0D);
}
- return true;
}
- private boolean scanAndRevertChanges() {
+ private boolean scanAndRevertChanges()
+ {
int index = 0;
boolean reverted = false;
for (int x = -this.radius; x <= this.radius; x++) {
for (int y = -this.radius; y <= this.radius; y++) {
- for (int z = -this.radius; z <= this.radius; z++) {
- final Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z);
- final byte meta = (byte) this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y,
- this.zCoord + z);
+ for (int z = -this.radius; z <= this.radius; z++)
+ {
+ Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z);
+ byte meta = (byte)this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z);
if (this.blockData[index] != blockID) {
- if (this.revertBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z, blockID, meta,
- this.blockData[index], this.metaData[index])) {
+ if (revertBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z, blockID, meta, this.blockData[index], this.metaData[index]))
+ {
reverted = true;
}
- else {
+ else
+ {
this.blockData[index] = blockID;
this.metaData[index] = meta;
}
@@ -246,46 +223,88 @@ public class TileEntityReverter extends TileEntity {
return reverted;
}
- @Override
- public void updateEntity() {
- if (this.anyPlayerInRange()) {
- this.tickCount += 1;
- if (this.worldObj.isRemote) {
- final double var1 = this.xCoord + this.worldObj.rand.nextFloat();
- final double var3 = this.yCoord + this.worldObj.rand.nextFloat();
- final double var5 = this.zCoord + this.worldObj.rand.nextFloat();
+ private boolean revertBlock(int x, int y, int z, Block thereBlockID, byte thereMeta, Block replaceBlockID, byte replaceMeta)
+ {
+ /*if ((thereBlockID == Blocks.air) && (!replaceBlockID.getMaterial().blocksMovement()))
+ {
+ System.out.println("Not replacing block " + replaceBlockID + " because it doesn't block movement");
- this.worldObj.spawnParticle("enchantmenttable", var1, var3, var5, 0.0D, 0.0D, 0.0D);
- if (this.rand.nextInt(5) == 0) {
- this.makeRandomOutline();
- this.makeRandomOutline();
- this.makeRandomOutline();
- }
+ return false;
+ }*/
+ if (isUnrevertable(thereBlockID, thereMeta, replaceBlockID, replaceMeta)) {
+ return false;
+ }
+ if (this.rand.nextInt(5) == 0)
+ {
+ if (replaceBlockID != Blocks.air)
+ {
+ //replaceBlockID = null;
+ replaceMeta = 4;
}
- else {
- if (this.blockData == null || this.metaData == null) {
- this.captureBlockData();
- this.slowScan = true;
- }
- if (!this.slowScan || this.tickCount % 20 == 0) {
- if (this.scanAndRevertChanges()) {
- this.slowScan = false;
- this.ticksSinceChange = 0;
- }
- else {
- this.ticksSinceChange += 1;
- if (this.ticksSinceChange > 20) {
- this.slowScan = true;
- }
- }
- }
+ this.worldObj.setBlock(x, y, z, replaceBlockID, replaceMeta, 2);
+ if (thereBlockID == Blocks.air)
+ {
+ this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(replaceBlockID) + (replaceMeta << 12));
+ }
+ else if (replaceBlockID == Blocks.air)
+ {
+ this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(thereBlockID) + (thereMeta << 12));
+ thereBlockID.dropBlockAsItem(this.worldObj, x, y, z, thereMeta, 0);
}
}
- else {
- this.blockData = null;
- this.metaData = null;
+ return true;
+ }
- this.tickCount = 0;
+ private boolean isUnrevertable(Block thereBlockID, byte thereMeta, Block replaceBlockID, byte replaceMeta)
+ {
+ if ((thereBlockID == ModBlocks.blockGriefSaver) || (replaceBlockID == ModBlocks.blockGriefSaver)) {
+ return true;
}
+ /*if (((thereBlockID == towerTranslucent) && (thereMeta != 4)) || ((replaceBlockID == towerTranslucent) && (replaceMeta != 4))) {
+ return true;
+ }*/
+ if ((thereBlockID == Blocks.redstone_lamp) && (replaceBlockID == Blocks.lit_redstone_lamp)) {
+ return true;
+ }
+ if ((thereBlockID == Blocks.lit_redstone_lamp) && (replaceBlockID == Blocks.redstone_lamp)) {
+ return true;
+ }
+ /*if ((thereBlockID == Blocks.water) || (replaceBlockID == Blocks.flowing_water)) {
+ return true;
+ }
+ if ((thereBlockID == Blocks.flowing_water) || (replaceBlockID == Blocks.water)) {
+ return true;
+ }*/
+ if (replaceBlockID == Blocks.tnt) {
+ return true;
+ }
+ return false;
+ }
+
+ private void captureBlockData()
+ {
+ this.blockData = new Block[this.diameter * this.diameter * this.diameter];
+ this.metaData = new byte[this.diameter * this.diameter * this.diameter];
+
+ int index = 0;
+ for (int x = -this.radius; x <= this.radius; x++) {
+ for (int y = -this.radius; y <= this.radius; y++) {
+ for (int z = -this.radius; z <= this.radius; z++)
+ {
+ Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z);
+ int meta = this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z);
+
+ this.blockData[index] = blockID;
+ this.metaData[index] = ((byte)meta);
+
+ index++;
+ }
+ }
+ }
+ }
+
+ public boolean anyPlayerInRange()
+ {
+ return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, this.requiredPlayerRange) != null;
}
}