generated from tilera/1710mod
feat: basic TC2 features
This commit is contained in:
parent
06262cb43e
commit
179eea1f32
|
@ -29,6 +29,7 @@ public class EventHandler {
|
||||||
nodeNBT.setInteger("key", node.key);
|
nodeNBT.setInteger("key", node.key);
|
||||||
nodeNBT.setShort("level", node.level);
|
nodeNBT.setShort("level", node.level);
|
||||||
nodeNBT.setShort("baseLevel", node.baseLevel);
|
nodeNBT.setShort("baseLevel", node.baseLevel);
|
||||||
|
nodeNBT.setShort("taint", node.taint);
|
||||||
nodeNBT.setByte("type", (byte)node.type.ordinal());
|
nodeNBT.setByte("type", (byte)node.type.ordinal());
|
||||||
nodeNBT.setDouble("xPos", node.xPos);
|
nodeNBT.setDouble("xPos", node.xPos);
|
||||||
nodeNBT.setDouble("yPos", node.yPos);
|
nodeNBT.setDouble("yPos", node.yPos);
|
||||||
|
@ -67,6 +68,8 @@ public class EventHandler {
|
||||||
node.level = nodeData.getShort("level");
|
node.level = nodeData.getShort("level");
|
||||||
node.baseLevel = nodeData.getShort("baseLevel");
|
node.baseLevel = nodeData.getShort("baseLevel");
|
||||||
node.locked = nodeData.getBoolean("locked");
|
node.locked = nodeData.getBoolean("locked");
|
||||||
|
if(nodeData.hasKey("taint"))
|
||||||
|
node.taint = nodeData.getShort("taint");
|
||||||
if(nodeData.hasKey("isVirtual"))
|
if(nodeData.hasKey("isVirtual"))
|
||||||
node.isVirtual = nodeData.getBoolean("isVirtual");
|
node.isVirtual = nodeData.getBoolean("isVirtual");
|
||||||
node.type = EnumNodeType.getType(nodeData.getByte("type"));
|
node.type = EnumNodeType.getType(nodeData.getByte("type"));
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class AuraNode implements Serializable {
|
||||||
public int key;
|
public int key;
|
||||||
public short level;
|
public short level;
|
||||||
public short baseLevel;
|
public short baseLevel;
|
||||||
|
public short taint;
|
||||||
public AspectList flux = new AspectList();
|
public AspectList flux = new AspectList();
|
||||||
public EnumNodeType type;
|
public EnumNodeType type;
|
||||||
public int dimension;
|
public int dimension;
|
||||||
|
@ -26,6 +27,7 @@ public class AuraNode implements Serializable {
|
||||||
this.xPos = (double)x + 0.5;
|
this.xPos = (double)x + 0.5;
|
||||||
this.yPos = (double)y + 0.5;
|
this.yPos = (double)y + 0.5;
|
||||||
this.zPos = (double)z + 0.5;
|
this.zPos = (double)z + 0.5;
|
||||||
|
this.taint = 0;
|
||||||
this.isVirtual = false;
|
this.isVirtual = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package dev.tilera.auracore.api.machine;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public interface IConnection
|
||||||
|
{
|
||||||
|
boolean getConnectable(ForgeDirection side);
|
||||||
|
|
||||||
|
boolean isVisSource();
|
||||||
|
|
||||||
|
boolean isVisConduit();
|
||||||
|
|
||||||
|
float[] subtractVis(float amount);
|
||||||
|
|
||||||
|
float getPureVis();
|
||||||
|
|
||||||
|
void setPureVis(float vis);
|
||||||
|
|
||||||
|
float getTaintedVis();
|
||||||
|
|
||||||
|
void setTaintedVis(float taint);
|
||||||
|
|
||||||
|
float getMaxVis();
|
||||||
|
|
||||||
|
int getVisSuction(int x, int y, int z);
|
||||||
|
|
||||||
|
void setVisSuction(int suction);
|
||||||
|
|
||||||
|
int getTaintSuction(int x, int y, int z);
|
||||||
|
|
||||||
|
void setTaintSuction(int suction);
|
||||||
|
|
||||||
|
void setSuction(int suction);
|
||||||
|
|
||||||
|
int getSuction(int x, int y, int z);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package dev.tilera.auracore.api.machine;
|
||||||
|
|
||||||
|
public interface IUpgradable
|
||||||
|
{
|
||||||
|
boolean canAcceptUpgrade(byte p0);
|
||||||
|
|
||||||
|
boolean hasUpgrade(byte p0);
|
||||||
|
|
||||||
|
int getUpgradeLimit();
|
||||||
|
|
||||||
|
byte[] getUpgrades();
|
||||||
|
|
||||||
|
boolean setUpgrade(byte p0);
|
||||||
|
|
||||||
|
boolean clearUpgrade(int p0);
|
||||||
|
}
|
178
src/main/java/dev/tilera/auracore/api/machine/TileVisUser.java
Normal file
178
src/main/java/dev/tilera/auracore/api/machine/TileVisUser.java
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
package dev.tilera.auracore.api.machine;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public class TileVisUser extends TileEntity implements IConnection
|
||||||
|
{
|
||||||
|
public int visSuction;
|
||||||
|
public int taintSuction;
|
||||||
|
|
||||||
|
public TileVisUser() {
|
||||||
|
this.visSuction = 0;
|
||||||
|
this.taintSuction = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
super.updateEntity();
|
||||||
|
this.setSuction(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getExactPureVis(float amount) {
|
||||||
|
this.setVisSuction(50);
|
||||||
|
int x = super.xCoord;
|
||||||
|
int y = super.yCoord;
|
||||||
|
int z = super.zCoord;
|
||||||
|
for (ForgeDirection side : ForgeDirection.values()) {
|
||||||
|
int offX = x + side.offsetX;
|
||||||
|
int offY = y + side.offsetY;
|
||||||
|
int offZ = z + side.offsetZ;
|
||||||
|
if (this.getConnectable(side)) {
|
||||||
|
TileEntity te = worldObj.getTileEntity(offX, offY, offZ);
|
||||||
|
IConnection ic = te instanceof IConnection ? (IConnection) te : null;
|
||||||
|
if (ic != null && (ic.isVisConduit() || ic.isVisSource()) && ic.getPureVis() >= amount) {
|
||||||
|
ic.setPureVis(ic.getPureVis() - amount);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getAvailablePureVis(float amount) {
|
||||||
|
this.setVisSuction(50);
|
||||||
|
int x = super.xCoord;
|
||||||
|
int y = super.yCoord;
|
||||||
|
int z = super.zCoord;
|
||||||
|
float gatheredVis = 0.0f;
|
||||||
|
for (ForgeDirection side : ForgeDirection.values()) {
|
||||||
|
int offX = x + side.offsetX;
|
||||||
|
int offY = y + side.offsetY;
|
||||||
|
int offZ = z + side.offsetZ;
|
||||||
|
if (this.getConnectable(side)) {
|
||||||
|
TileEntity te = worldObj.getTileEntity(offX, offY, offZ);
|
||||||
|
IConnection ic = te instanceof IConnection ? (IConnection) te : null;
|
||||||
|
if (ic != null && (ic.isVisConduit() || ic.isVisSource())) {
|
||||||
|
float sucked = Math.min(amount - gatheredVis, ic.getPureVis());
|
||||||
|
if (sucked < 0.001f) {
|
||||||
|
sucked = 0.0f;
|
||||||
|
}
|
||||||
|
gatheredVis += sucked;
|
||||||
|
ic.setPureVis(ic.getPureVis() - sucked);
|
||||||
|
}
|
||||||
|
if (gatheredVis >= amount) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Math.min(gatheredVis, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getAvailableTaintedVis(float amount) {
|
||||||
|
this.setTaintSuction(50);
|
||||||
|
int x = super.xCoord;
|
||||||
|
int y = super.yCoord;
|
||||||
|
int z = super.zCoord;
|
||||||
|
float gatheredVis = 0.0f;
|
||||||
|
for (ForgeDirection side : ForgeDirection.values()) {
|
||||||
|
int offX = x + side.offsetX;
|
||||||
|
int offY = y + side.offsetY;
|
||||||
|
int offZ = z + side.offsetZ;
|
||||||
|
if (this.getConnectable(side)) {
|
||||||
|
TileEntity te = worldObj.getTileEntity(offX, offY, offZ);
|
||||||
|
IConnection ic = te instanceof IConnection ? (IConnection) te : null;
|
||||||
|
if (ic != null && (ic.isVisConduit() || ic.isVisSource())) {
|
||||||
|
float sucked = Math.min(amount - gatheredVis, ic.getTaintedVis());
|
||||||
|
if (sucked < 0.001f) {
|
||||||
|
sucked = 0.0f;
|
||||||
|
}
|
||||||
|
gatheredVis += sucked;
|
||||||
|
ic.setTaintedVis(ic.getTaintedVis() - sucked);
|
||||||
|
}
|
||||||
|
if (gatheredVis >= amount) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Math.min(gatheredVis, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean gettingPower() {
|
||||||
|
return super.worldObj.isBlockIndirectlyGettingPowered(super.xCoord, super.yCoord, super.zCoord) || super.worldObj.isBlockIndirectlyGettingPowered(super.xCoord, super.yCoord + 1, super.zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getConnectable(ForgeDirection face) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisSource() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisConduit() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] subtractVis(float amount) {
|
||||||
|
return new float[] { 0.0f, 0.0f };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPureVis() {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPureVis(float amount) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getTaintedVis() {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getMaxVis() {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTaintedVis(float amount) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVisSuction(int x, int y, int z) {
|
||||||
|
return this.visSuction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVisSuction(int suction) {
|
||||||
|
this.visSuction = suction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTaintSuction(int x, int y, int z) {
|
||||||
|
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(int x, int y, int z) {
|
||||||
|
return Math.max(this.visSuction, this.taintSuction);
|
||||||
|
}
|
||||||
|
}
|
|
@ -779,16 +779,30 @@ public class AuraManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void queueNodeChanges(int key, int levelMod, int baseMod, boolean toggleLock, AspectList flx, float x, float y, float z) {
|
public static void queueNodeChanges(int key, int levelMod, int baseMod, boolean toggleLock, AspectList flx, float x, float y, float z) {
|
||||||
NodeChanges nc = new NodeChanges(key, levelMod, baseMod, toggleLock, flx, x, y, z);
|
NodeChanges nc = new NodeChanges(key, levelMod, baseMod, 0, toggleLock, flx, x, y, z);
|
||||||
auraUpdateQueue.add(nc);
|
auraUpdateQueue.add(nc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void queueNodeChanges(int key, int levelMod, int baseMod, int taint, boolean toggleLock, AspectList flx, float x, float y, float z) {
|
||||||
|
NodeChanges nc = new NodeChanges(key, levelMod, baseMod, taint, toggleLock, flx, x, y, z);
|
||||||
|
auraUpdateQueue.add(nc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addTaintToClosest(World world, int x, int y, int z, int taint) {
|
||||||
|
int key = getClosestAuraWithinRange(world, x, y, z, 64);
|
||||||
|
if (key < 0) {
|
||||||
|
key = registerAuraNode(world, (short)(world.rand.nextInt(50) + 50), EnumNodeType.DARK, world.provider.dimensionId, x, y, z);
|
||||||
|
}
|
||||||
|
queueNodeChanges(key, 0, 0, taint, false, null, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
public static AuraNode copyNode(AuraNode in) {
|
public static AuraNode copyNode(AuraNode in) {
|
||||||
try {
|
try {
|
||||||
AuraNode out = new AuraNode();
|
AuraNode out = new AuraNode();
|
||||||
out.key = in.key;
|
out.key = in.key;
|
||||||
out.level = in.level;
|
out.level = in.level;
|
||||||
out.baseLevel = in.baseLevel;
|
out.baseLevel = in.baseLevel;
|
||||||
|
out.taint = in.taint;
|
||||||
out.type = in.type;
|
out.type = in.type;
|
||||||
AspectList outflux = new AspectList();
|
AspectList outflux = new AspectList();
|
||||||
for (Aspect tag : in.flux.getAspects()) {
|
for (Aspect tag : in.flux.getAspects()) {
|
||||||
|
@ -812,6 +826,7 @@ public class AuraManager {
|
||||||
out.key = in.key;
|
out.key = in.key;
|
||||||
out.level = in.level;
|
out.level = in.level;
|
||||||
out.baseLevel = in.baseLevel;
|
out.baseLevel = in.baseLevel;
|
||||||
|
out.taint = in.taint;
|
||||||
out.type = in.type;
|
out.type = in.type;
|
||||||
out.flux = in.flux;
|
out.flux = in.flux;
|
||||||
out.dimension = in.dimension;
|
out.dimension = in.dimension;
|
||||||
|
@ -826,16 +841,18 @@ public class AuraManager {
|
||||||
int key = 0;
|
int key = 0;
|
||||||
int levelMod = 0;
|
int levelMod = 0;
|
||||||
int baseMod = 0;
|
int baseMod = 0;
|
||||||
|
int taintMod = 0;
|
||||||
boolean lock = false;
|
boolean lock = false;
|
||||||
AspectList flux = null;
|
AspectList flux = null;
|
||||||
float motionX;
|
float motionX;
|
||||||
float motionY;
|
float motionY;
|
||||||
float motionZ;
|
float motionZ;
|
||||||
|
|
||||||
NodeChanges(int k, int l, int b, boolean lo, AspectList ot, float x, float y, float z) {
|
NodeChanges(int k, int l, int b, int t, boolean lo, AspectList ot, float x, float y, float z) {
|
||||||
this.key = k;
|
this.key = k;
|
||||||
this.levelMod = l;
|
this.levelMod = l;
|
||||||
this.baseMod = b;
|
this.baseMod = b;
|
||||||
|
this.taintMod = t;
|
||||||
this.lock = lo;
|
this.lock = lo;
|
||||||
this.flux = ot;
|
this.flux = ot;
|
||||||
this.motionX = x;
|
this.motionX = x;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class AuraUpdateThread
|
||||||
continue;
|
continue;
|
||||||
node.level = (short) (node.level + nc.levelMod);
|
node.level = (short) (node.level + nc.levelMod);
|
||||||
node.baseLevel = (short) (node.baseLevel + nc.baseMod);
|
node.baseLevel = (short) (node.baseLevel + nc.baseMod);
|
||||||
|
node.taint = (short) (node.taint + nc.taintMod);
|
||||||
if (nc.lock) {
|
if (nc.lock) {
|
||||||
node.locked = !node.locked;
|
node.locked = !node.locked;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +39,9 @@ public class AuraUpdateThread
|
||||||
if (node.baseLevel < 0) {
|
if (node.baseLevel < 0) {
|
||||||
node.baseLevel = 0;
|
node.baseLevel = 0;
|
||||||
}
|
}
|
||||||
|
if (node.taint < 0) {
|
||||||
|
node.taint = 0;
|
||||||
|
}
|
||||||
if (nc.flux != null) {
|
if (nc.flux != null) {
|
||||||
for (Aspect tag : nc.flux.getAspects()) {
|
for (Aspect tag : nc.flux.getAspects()) {
|
||||||
if (nc.flux.getAmount(tag) > 0) {
|
if (nc.flux.getAmount(tag) > 0) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class AuraManagerClient {
|
||||||
public double z;
|
public double z;
|
||||||
public short level;
|
public short level;
|
||||||
public short base;
|
public short base;
|
||||||
|
public short taint;
|
||||||
public int flux;
|
public int flux;
|
||||||
public boolean lock;
|
public boolean lock;
|
||||||
public byte type;
|
public byte type;
|
||||||
|
@ -40,6 +41,7 @@ public class AuraManagerClient {
|
||||||
z = packet.z;
|
z = packet.z;
|
||||||
level = packet.level;
|
level = packet.level;
|
||||||
base = packet.base;
|
base = packet.base;
|
||||||
|
taint = packet.taint;
|
||||||
flux = packet.flux;
|
flux = packet.flux;
|
||||||
lock = packet.lock;
|
lock = packet.lock;
|
||||||
type = packet.type;
|
type = packet.type;
|
||||||
|
@ -51,17 +53,20 @@ public class AuraManagerClient {
|
||||||
public static class NodeHistoryStats {
|
public static class NodeHistoryStats {
|
||||||
|
|
||||||
public short level;
|
public short level;
|
||||||
|
public short taint;
|
||||||
public int flux;
|
public int flux;
|
||||||
|
|
||||||
public NodeHistoryStats(short level, int flux) {
|
public NodeHistoryStats(short level, int flux, short taint) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.flux = flux;
|
this.flux = flux;
|
||||||
|
this.taint = taint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeHistoryStats(NodeStats stats) {
|
public NodeHistoryStats(NodeStats stats) {
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
this.level = stats.level;
|
this.level = stats.level;
|
||||||
this.flux = stats.flux;
|
this.flux = stats.flux;
|
||||||
|
this.taint = stats.taint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class AuraPacket implements IMessage {
|
||||||
public double z;
|
public double z;
|
||||||
public short level;
|
public short level;
|
||||||
public short base;
|
public short base;
|
||||||
|
public short taint;
|
||||||
public int flux;
|
public int flux;
|
||||||
public boolean lock;
|
public boolean lock;
|
||||||
public byte type;
|
public byte type;
|
||||||
|
@ -25,6 +26,7 @@ public class AuraPacket implements IMessage {
|
||||||
this.z = node.zPos;
|
this.z = node.zPos;
|
||||||
this.level = node.level;
|
this.level = node.level;
|
||||||
this.base = node.baseLevel;
|
this.base = node.baseLevel;
|
||||||
|
this.taint = node.taint;
|
||||||
this.flux = node.flux.visSize();
|
this.flux = node.flux.visSize();
|
||||||
this.lock = node.locked;
|
this.lock = node.locked;
|
||||||
this.type = (byte) node.type.ordinal();
|
this.type = (byte) node.type.ordinal();
|
||||||
|
@ -38,6 +40,7 @@ public class AuraPacket implements IMessage {
|
||||||
this.z = buf.readDouble();
|
this.z = buf.readDouble();
|
||||||
this.level = buf.readShort();
|
this.level = buf.readShort();
|
||||||
this.base = buf.readShort();
|
this.base = buf.readShort();
|
||||||
|
this.taint = buf.readShort();
|
||||||
this.flux = buf.readInt();
|
this.flux = buf.readInt();
|
||||||
this.lock = buf.readBoolean();
|
this.lock = buf.readBoolean();
|
||||||
this.type = buf.readByte();
|
this.type = buf.readByte();
|
||||||
|
@ -51,6 +54,7 @@ public class AuraPacket implements IMessage {
|
||||||
buf.writeDouble(z);
|
buf.writeDouble(z);
|
||||||
buf.writeShort(level);
|
buf.writeShort(level);
|
||||||
buf.writeShort(base);
|
buf.writeShort(base);
|
||||||
|
buf.writeShort(taint);
|
||||||
buf.writeInt(flux);
|
buf.writeInt(flux);
|
||||||
buf.writeBoolean(lock);
|
buf.writeBoolean(lock);
|
||||||
buf.writeByte(type);
|
buf.writeByte(type);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class AuraPacketHandler implements IMessageHandler<AuraPacket, IMessage>
|
||||||
}
|
}
|
||||||
AuraManagerClient.auraClientList.put(message.key, new NodeStats(message, world.provider.dimensionId));
|
AuraManagerClient.auraClientList.put(message.key, new NodeStats(message, world.provider.dimensionId));
|
||||||
if (AuraManagerClient.auraClientHistory.get(message.key) == null) {
|
if (AuraManagerClient.auraClientHistory.get(message.key) == null) {
|
||||||
AuraManagerClient.auraClientHistory.put(message.key, new NodeHistoryStats(message.level, message.flux));
|
AuraManagerClient.auraClientHistory.put(message.key, new NodeHistoryStats(message.level, message.flux, message.taint));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue