generated from tilera/1710mod
feat: initial tile implementation
This commit is contained in:
parent
0ef0e02cf8
commit
6a6dbb0261
|
@ -2,3 +2,4 @@
|
||||||
.idea
|
.idea
|
||||||
build
|
build
|
||||||
run
|
run
|
||||||
|
bin
|
|
@ -0,0 +1,28 @@
|
||||||
|
package net.anvilcraft.thaummach;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class AuraUtils {
|
||||||
|
|
||||||
|
public static void taintExplosion(World w, int x, int y, int z) {
|
||||||
|
w.createExplosion(null, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), 1.0F, false);
|
||||||
|
|
||||||
|
int xx;
|
||||||
|
for(xx = x - 2; xx <= x + 2; ++xx) {
|
||||||
|
for(int yy = y - 2; yy <= y + 2; ++yy) {
|
||||||
|
for(int zz = z - 2; zz <= z + 2; ++zz) {
|
||||||
|
//increaseTaintedPlants(w, xx, yy, zz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*for(xx = 0; xx < 100; ++xx) {
|
||||||
|
FXWisp ef = new FXWisp(w, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), (double)((float)x + 0.5F + (w.rand.nextFloat() - w.rand.nextFloat()) * 2.0F), (double)((float)y + 0.5F + (w.rand.nextFloat() - w.rand.nextFloat()) * 2.0F), (double)((float)z + 0.5F + (w.rand.nextFloat() - w.rand.nextFloat()) * 2.0F), 1.0F, 5);
|
||||||
|
ef.setGravity(0.02F);
|
||||||
|
ef.shrink = true;
|
||||||
|
ModLoader.getMinecraftInstance().effectRenderer.addEffect(ef);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package net.anvilcraft.thaummach;
|
||||||
|
|
||||||
|
public class ThaumicMachinery {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,252 @@
|
||||||
|
package net.anvilcraft.thaummach.tiles;
|
||||||
|
|
||||||
|
import dev.tilera.auracore.api.HelperLocation;
|
||||||
|
import dev.tilera.auracore.api.machine.IConnection;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public class TileConduit extends TileEntity implements IConnection {
|
||||||
|
public float pureVis = 0.0F;
|
||||||
|
public float taintedVis = 0.0F;
|
||||||
|
public float maxVis = 4.0F;
|
||||||
|
float fillAmount = 4.0F;
|
||||||
|
public float displayPure;
|
||||||
|
public float displayTaint;
|
||||||
|
public float prevdisplayPure;
|
||||||
|
public float prevdisplayTaint;
|
||||||
|
public int visSuction = 0;
|
||||||
|
public int taintSuction = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
if (!super.worldObj.isRemote) {
|
||||||
|
if (this.prevdisplayPure != this.displayPure || this.prevdisplayTaint != this.displayTaint) {
|
||||||
|
super.worldObj.markBlockForUpdate(super.xCoord, super.yCoord, super.zCoord);
|
||||||
|
this.prevdisplayPure = this.displayPure;
|
||||||
|
this.prevdisplayTaint = this.displayTaint;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.calculateSuction();
|
||||||
|
if (this.getSuction((HelperLocation)null) > 0) {
|
||||||
|
this.equalizeWithNeighbours();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.displayTaint = Math.max(this.displayTaint, MathHelper.clamp_float(this.taintedVis, 0.0F, this.maxVis));
|
||||||
|
this.displayPure = Math.max(this.displayPure, MathHelper.clamp_float(this.pureVis, 0.0F, this.maxVis));
|
||||||
|
if (this.displayTaint + this.displayPure < 0.1F) {
|
||||||
|
this.displayTaint = 0.0F;
|
||||||
|
this.displayPure = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void calculateSuction() {
|
||||||
|
this.setSuction(0);
|
||||||
|
|
||||||
|
for(int dir = 0; dir < 6; ++dir) {
|
||||||
|
HelperLocation loc = new HelperLocation(this);
|
||||||
|
switch (dir) {
|
||||||
|
case 0:
|
||||||
|
loc.facing = ForgeDirection.UP;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
loc.facing = ForgeDirection.DOWN;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
loc.facing = ForgeDirection.SOUTH;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
loc.facing = ForgeDirection.NORTH;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
loc.facing = ForgeDirection.EAST;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
loc.facing = ForgeDirection.WEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getConnectable(loc.facing)) {
|
||||||
|
TileEntity te = loc.getConnectableTile(super.worldObj);
|
||||||
|
if (te != null && te instanceof IConnection) {
|
||||||
|
IConnection ic = (IConnection)te;
|
||||||
|
if (this.getVisSuction((HelperLocation)null) < ic.getVisSuction(new HelperLocation(this)) - 1) {
|
||||||
|
this.setVisSuction(ic.getVisSuction(new HelperLocation(this)) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getTaintSuction((HelperLocation)null) < ic.getTaintSuction(new HelperLocation(this)) - 1) {
|
||||||
|
this.setTaintSuction(ic.getTaintSuction(new HelperLocation(this)) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void equalizeWithNeighbours() {
|
||||||
|
for(int dir = 0; dir < 6; ++dir) {
|
||||||
|
HelperLocation loc = new HelperLocation(this);
|
||||||
|
switch (dir) {
|
||||||
|
case 0:
|
||||||
|
loc.facing = ForgeDirection.UP;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
loc.facing = ForgeDirection.DOWN;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
loc.facing = ForgeDirection.SOUTH;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
loc.facing = ForgeDirection.NORTH;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
loc.facing = ForgeDirection.EAST;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
loc.facing = ForgeDirection.WEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getConnectable(loc.facing)) {
|
||||||
|
TileEntity te = loc.getConnectableTile(super.worldObj);
|
||||||
|
if (te != null && te instanceof IConnection) {
|
||||||
|
IConnection ent = (IConnection)te;
|
||||||
|
if (this.pureVis + this.taintedVis < this.maxVis && (this.getVisSuction((HelperLocation)null) > ent.getVisSuction(new HelperLocation(this)) || this.getTaintSuction((HelperLocation)null) > ent.getTaintSuction(new HelperLocation(this)))) {
|
||||||
|
float qq = Math.min((ent.getPureVis() + ent.getTaintedVis()) / 4.0F, this.fillAmount);
|
||||||
|
float[] results = ent.subtractVis(Math.min(qq, this.maxVis - (this.pureVis + this.taintedVis)));
|
||||||
|
if (this.getVisSuction((HelperLocation)null) > ent.getVisSuction(new HelperLocation(this))) {
|
||||||
|
this.pureVis += results[0];
|
||||||
|
} else {
|
||||||
|
ent.setPureVis(results[0] + ent.getPureVis());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getTaintSuction((HelperLocation)null) > ent.getTaintSuction(new HelperLocation(this))) {
|
||||||
|
this.taintedVis += results[1];
|
||||||
|
} else {
|
||||||
|
ent.setTaintedVis(results[1] + ent.getTaintedVis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pureVis = MathHelper.clamp_float(this.pureVis, 0.0F, this.maxVis);
|
||||||
|
this.taintedVis = MathHelper.clamp_float(this.taintedVis, 0.0F, this.maxVis);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.readFromNBT(nbttagcompound);
|
||||||
|
this.pureVis = nbttagcompound.getFloat("pureVis");
|
||||||
|
this.taintedVis = nbttagcompound.getFloat("taintedVis");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.writeToNBT(nbttagcompound);
|
||||||
|
nbttagcompound.setFloat("pureVis", this.pureVis);
|
||||||
|
nbttagcompound.setFloat("taintedVis", this.taintedVis);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getConnectable(ForgeDirection face) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisSource() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisConduit() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPureVis() {
|
||||||
|
return this.pureVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPureVis(float amount) {
|
||||||
|
this.pureVis = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getTaintedVis() {
|
||||||
|
return this.taintedVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTaintedVis(float amount) {
|
||||||
|
this.taintedVis = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getMaxVis() {
|
||||||
|
return this.maxVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] subtractVis(float amount) {
|
||||||
|
float pureAmount = amount / 2.0F;
|
||||||
|
float taintAmount = amount / 2.0F;
|
||||||
|
float[] result = new float[]{0.0F, 0.0F};
|
||||||
|
if (amount < 0.001F) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
if (this.pureVis < pureAmount) {
|
||||||
|
pureAmount = this.pureVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.taintedVis < taintAmount) {
|
||||||
|
taintAmount = this.taintedVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pureAmount < amount / 2.0F && taintAmount == amount / 2.0F) {
|
||||||
|
taintAmount = Math.min(amount - pureAmount, this.taintedVis);
|
||||||
|
} else if (taintAmount < amount / 2.0F && pureAmount == amount / 2.0F) {
|
||||||
|
pureAmount = Math.min(amount - taintAmount, this.pureVis);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pureVis -= pureAmount;
|
||||||
|
this.taintedVis -= taintAmount;
|
||||||
|
result[0] = pureAmount;
|
||||||
|
result[1] = taintAmount;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVisSuction(HelperLocation loc) {
|
||||||
|
return this.visSuction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVisSuction(int suction) {
|
||||||
|
this.visSuction = suction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTaintSuction(HelperLocation loc) {
|
||||||
|
return this.taintSuction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTaintSuction(int suction) {
|
||||||
|
this.taintSuction = suction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSuction(int suction) {
|
||||||
|
this.visSuction = suction;
|
||||||
|
this.taintSuction = suction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSuction(HelperLocation loc) {
|
||||||
|
return Math.max(this.visSuction, this.taintSuction);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,255 @@
|
||||||
|
package net.anvilcraft.thaummach.tiles;
|
||||||
|
|
||||||
|
import dev.tilera.auracore.api.HelperLocation;
|
||||||
|
import dev.tilera.auracore.api.machine.IConnection;
|
||||||
|
import net.anvilcraft.thaummach.AuraUtils;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import thaumcraft.common.tiles.TileBellows;
|
||||||
|
|
||||||
|
public class TileConduitTank extends TileEntity implements IConnection {
|
||||||
|
public float pureVis = 0.0F;
|
||||||
|
public float taintedVis = 0.0F;
|
||||||
|
float fillAmount = 1.0F;
|
||||||
|
int wait;
|
||||||
|
public float displayPure;
|
||||||
|
public float displayTaint;
|
||||||
|
public float prevdisplayPure;
|
||||||
|
public float prevdisplayTaint;
|
||||||
|
public int visSuction = 10;
|
||||||
|
public int taintSuction = 10;
|
||||||
|
|
||||||
|
public void updateEntity() {
|
||||||
|
if (!super.worldObj.isRemote) {
|
||||||
|
--this.wait;
|
||||||
|
if (this.wait <= 0) {
|
||||||
|
if (this.prevdisplayPure != this.displayPure || this.prevdisplayTaint != this.displayTaint) {
|
||||||
|
super.worldObj.markBlockForUpdate(super.xCoord, super.yCoord, super.zCoord);
|
||||||
|
this.prevdisplayPure = this.displayPure;
|
||||||
|
this.prevdisplayTaint = this.displayTaint;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wait = 10;
|
||||||
|
this.calculateSuction();
|
||||||
|
int breakchance = 999;
|
||||||
|
if (this.getBlockMetadata() != 3) {
|
||||||
|
breakchance = 3333;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.taintedVis > this.getMaxVis() * 0.9F) {
|
||||||
|
if (this.getBlockMetadata() == 3 && super.worldObj.rand.nextInt(breakchance) == 123) {
|
||||||
|
AuraUtils.taintExplosion(super.worldObj, super.xCoord, super.yCoord, super.zCoord);
|
||||||
|
super.worldObj.setBlock(super.xCoord, super.yCoord, super.zCoord, Blocks.air, 0, 3);
|
||||||
|
} else if (super.worldObj.rand.nextInt(breakchance / 8) == 42) {
|
||||||
|
super.worldObj.playSoundEffect((double)((float)super.xCoord + 0.5F), (double)((float)super.yCoord + 0.5F), (double)((float)super.zCoord + 0.5F), "thaumcraft.creaking", 0.75F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.equalizeWithNeighbours();
|
||||||
|
this.displayTaint = Math.max(this.displayTaint, MathHelper.clamp_float(this.taintedVis, 0.0F, this.getMaxVis()));
|
||||||
|
this.displayPure = Math.max(this.displayPure, MathHelper.clamp_float(this.pureVis, 0.0F, this.getMaxVis()));
|
||||||
|
if (this.displayTaint + this.displayPure < 0.1F) {
|
||||||
|
this.displayTaint = 0.0F;
|
||||||
|
this.displayPure = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calculateSuction() {
|
||||||
|
this.setSuction(10);
|
||||||
|
|
||||||
|
int bellows = TileBellows.getBellows(this.worldObj, this.xCoord, this.yCoord, this.zCoord, new ForgeDirection[] {ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST});
|
||||||
|
if (bellows > 0)
|
||||||
|
this.setSuction(this.getSuction((HelperLocation)null) + (10 * bellows));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void equalizeWithNeighbours() {
|
||||||
|
float stackpureVis = this.pureVis;
|
||||||
|
float stacktaintedVis = this.taintedVis;
|
||||||
|
float stackmaxVis = this.getMaxVis();
|
||||||
|
|
||||||
|
TileEntity ts;
|
||||||
|
int count;
|
||||||
|
for(count = 1; (ts = super.worldObj.getTileEntity(super.xCoord, super.yCoord + count, super.zCoord)) instanceof TileConduitTank; ++count) {
|
||||||
|
stackpureVis += ((TileConduitTank)ts).pureVis;
|
||||||
|
stacktaintedVis += ((TileConduitTank)ts).taintedVis;
|
||||||
|
stackmaxVis += ((TileConduitTank)ts).getMaxVis();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int dir = 0; dir < 6; ++dir) {
|
||||||
|
HelperLocation loc = new HelperLocation(this);
|
||||||
|
switch (dir) {
|
||||||
|
case 0:
|
||||||
|
loc.facing = ForgeDirection.UP;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
loc.facing = ForgeDirection.DOWN;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
loc.facing = ForgeDirection.SOUTH;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
loc.facing = ForgeDirection.NORTH;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
loc.facing = ForgeDirection.EAST;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
loc.facing = ForgeDirection.WEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getConnectable(loc.facing)) {
|
||||||
|
TileEntity te = loc.getConnectableTile(super.worldObj);
|
||||||
|
if (te != null && te instanceof IConnection) {
|
||||||
|
IConnection ent = (IConnection)te;
|
||||||
|
if (!(te instanceof TileConduitTank) && stackpureVis + stacktaintedVis < stackmaxVis && (this.getVisSuction((HelperLocation)null) > ent.getVisSuction(new HelperLocation(this)) || this.getTaintSuction((HelperLocation)null) > ent.getTaintSuction(new HelperLocation(this)))) {
|
||||||
|
float[] results = ent.subtractVis(Math.min(this.fillAmount, stackmaxVis - (stackpureVis + stacktaintedVis)));
|
||||||
|
if (this.getVisSuction((HelperLocation)null) > ent.getVisSuction(new HelperLocation(this))) {
|
||||||
|
stackpureVis += results[0];
|
||||||
|
} else {
|
||||||
|
ent.setPureVis(results[0] + ent.getPureVis());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getTaintSuction((HelperLocation)null) > ent.getTaintSuction(new HelperLocation(this))) {
|
||||||
|
stacktaintedVis += results[1];
|
||||||
|
} else {
|
||||||
|
ent.setTaintedVis(results[1] + ent.getTaintedVis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float total = stackpureVis + stacktaintedVis;
|
||||||
|
if ((float)Math.round(total) >= stackmaxVis) {
|
||||||
|
this.setSuction(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
float pratio = stackpureVis / total;
|
||||||
|
float tratio = stacktaintedVis / total;
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
for(boolean clearrest = false; (ts = super.worldObj.getTileEntity(super.xCoord, super.yCoord + count, super.zCoord)) instanceof TileConduitTank; ++count) {
|
||||||
|
if (clearrest) {
|
||||||
|
((TileConduitTank)ts).pureVis = 0.0F;
|
||||||
|
((TileConduitTank)ts).taintedVis = 0.0F;
|
||||||
|
} else if (total <= ((TileConduitTank)ts).getMaxVis()) {
|
||||||
|
((TileConduitTank)ts).pureVis = stackpureVis;
|
||||||
|
((TileConduitTank)ts).taintedVis = stacktaintedVis;
|
||||||
|
clearrest = true;
|
||||||
|
} else {
|
||||||
|
((TileConduitTank)ts).pureVis = ((TileConduitTank)ts).getMaxVis() * pratio;
|
||||||
|
((TileConduitTank)ts).taintedVis = ((TileConduitTank)ts).getMaxVis() * tratio;
|
||||||
|
stackpureVis -= ((TileConduitTank)ts).pureVis;
|
||||||
|
stacktaintedVis -= ((TileConduitTank)ts).taintedVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
total = stackpureVis + stacktaintedVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.readFromNBT(nbttagcompound);
|
||||||
|
this.pureVis = nbttagcompound.getFloat("pureVis");
|
||||||
|
this.taintedVis = nbttagcompound.getFloat("taintedVis");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.writeToNBT(nbttagcompound);
|
||||||
|
nbttagcompound.setFloat("pureVis", this.pureVis);
|
||||||
|
nbttagcompound.setFloat("taintedVis", this.taintedVis);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getConnectable(ForgeDirection face) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisSource() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisConduit() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPureVis() {
|
||||||
|
return this.pureVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPureVis(float amount) {
|
||||||
|
this.pureVis = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTaintedVis() {
|
||||||
|
return this.taintedVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaintedVis(float amount) {
|
||||||
|
this.taintedVis = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getMaxVis() {
|
||||||
|
return this.getBlockMetadata() != 3 ? 1000.0F : 500.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[] subtractVis(float amount) {
|
||||||
|
float pureAmount = amount / 2.0F;
|
||||||
|
float taintAmount = amount / 2.0F;
|
||||||
|
float[] result = new float[]{0.0F, 0.0F};
|
||||||
|
if (amount < 0.001F) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
if (this.pureVis < pureAmount) {
|
||||||
|
pureAmount = this.pureVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.taintedVis < taintAmount) {
|
||||||
|
taintAmount = this.taintedVis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pureAmount < amount / 2.0F && taintAmount == amount / 2.0F) {
|
||||||
|
taintAmount = Math.min(amount - pureAmount, this.taintedVis);
|
||||||
|
} else if (taintAmount < amount / 2.0F && pureAmount == amount / 2.0F) {
|
||||||
|
pureAmount = Math.min(amount - taintAmount, this.pureVis);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pureVis -= pureAmount;
|
||||||
|
this.taintedVis -= taintAmount;
|
||||||
|
result[0] = pureAmount;
|
||||||
|
result[1] = taintAmount;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVisSuction(HelperLocation loc) {
|
||||||
|
return this.visSuction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisSuction(int suction) {
|
||||||
|
this.visSuction = suction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTaintSuction(HelperLocation loc) {
|
||||||
|
return this.taintSuction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaintSuction(int suction) {
|
||||||
|
this.taintSuction = suction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuction(int suction) {
|
||||||
|
this.visSuction = suction;
|
||||||
|
this.taintSuction = suction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSuction(HelperLocation loc) {
|
||||||
|
return Math.max(this.visSuction, this.taintSuction);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
package net.anvilcraft.thaummach.tiles;
|
||||||
|
|
||||||
|
import dev.tilera.auracore.api.HelperLocation;
|
||||||
|
import dev.tilera.auracore.api.machine.IConnection;
|
||||||
|
import dev.tilera.auracore.aura.AuraManager;
|
||||||
|
import net.anvilcraft.thaummach.blocks.BlockApparatusFragile;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import thaumcraft.client.fx.particles.FXWisp;
|
||||||
|
|
||||||
|
public class TileFilter extends TileConduit implements IConnection {
|
||||||
|
public short taintedStore;
|
||||||
|
public short stack;
|
||||||
|
|
||||||
|
public void updateEntity() {
|
||||||
|
if (!super.worldObj.isRemote) {
|
||||||
|
if (Math.round(super.prevdisplayPure) != Math.round(super.displayPure) || Math.round(super.prevdisplayTaint) != Math.round(super.displayTaint)) {
|
||||||
|
super.worldObj.markBlockForUpdate(super.xCoord, super.yCoord, super.zCoord);
|
||||||
|
super.prevdisplayPure = super.displayPure;
|
||||||
|
super.prevdisplayTaint = super.displayTaint;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.calculateSuction();
|
||||||
|
if (super.taintSuction < 15) {
|
||||||
|
this.setTaintSuction(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getSuction((HelperLocation)null) > 0) {
|
||||||
|
this.equalizeWithNeighbours();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.displayTaint = Math.max(super.displayTaint, MathHelper.clamp_float(super.taintedVis, 0.0F, super.maxVis));
|
||||||
|
super.displayPure = Math.max(super.displayPure, MathHelper.clamp_float(super.pureVis, 0.0F, super.maxVis));
|
||||||
|
if (super.displayTaint + super.displayPure < 0.1F) {
|
||||||
|
super.displayTaint = 0.0F;
|
||||||
|
super.displayPure = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.taintedStore < 40 + this.stack * 4 && super.taintedVis >= 0.025F) {
|
||||||
|
++this.taintedStore;
|
||||||
|
super.taintedVis -= 0.025F;
|
||||||
|
this.stack = 0;
|
||||||
|
|
||||||
|
for(TileEntity te = super.worldObj.getTileEntity(super.xCoord, super.yCoord + 1, super.zCoord); te != null && te instanceof TileFilter && super.yCoord + 1 + this.stack < super.worldObj.getHeight(); te = super.worldObj.getTileEntity(super.xCoord, super.yCoord + 1 + this.stack, super.zCoord)) {
|
||||||
|
++this.stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.taintedStore % 16 == 0) {
|
||||||
|
FXWisp ef = new FXWisp(super.worldObj, (double)((float)super.xCoord + 0.5F), (double)((float)super.yCoord + 0.8F + (float)this.stack), (double)((float)super.zCoord + 0.5F), (double)((float)super.xCoord + 0.5F + (super.worldObj.rand.nextFloat() - super.worldObj.rand.nextFloat())), (double)((float)super.yCoord + 3.0F + (float)this.stack + super.worldObj.rand.nextFloat()), (double)((float)super.zCoord + 0.5F + (super.worldObj.rand.nextFloat() - super.worldObj.rand.nextFloat())), 0.5F, 5);
|
||||||
|
Minecraft.getMinecraft().effectRenderer.addEffect(ef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.taintedStore >= 40 + this.stack * 4) {
|
||||||
|
int auraX = super.xCoord >> 4;
|
||||||
|
int auraZ = super.zCoord >> 4;
|
||||||
|
AuraManager.addTaintToClosest(this.worldObj, this.xCoord, this.yCoord, this.zCoord, 1);
|
||||||
|
this.taintedStore = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.readFromNBT(nbttagcompound);
|
||||||
|
this.taintedStore = nbttagcompound.getShort("taintedStore");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.writeToNBT(nbttagcompound);
|
||||||
|
nbttagcompound.setShort("taintedStore", this.taintedStore);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getConnectable(ForgeDirection face) { //TODO: BLOCK
|
||||||
|
if (super.worldObj.getBlock(super.xCoord, super.yCoord - 1, super.zCoord) == new BlockApparatusFragile() && super.worldObj.getBlockMetadata(super.xCoord, super.yCoord - 1, super.zCoord) == this.getBlockMetadata()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
switch (face) {
|
||||||
|
case UP:
|
||||||
|
case UNKNOWN:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue