Compare commits

...

3 Commits

Author SHA1 Message Date
Timo Ley 18365c9c85 feat: add vibes
continuous-integration/drone/push Build is passing Details
2023-06-02 14:01:30 +02:00
Timo Ley d5e9580367 fix: add balanced shard crystal color 2023-05-28 22:45:18 +02:00
Timo Ley 61cd161d8e feat: add IWandableBlock 2023-05-28 22:45:01 +02:00
6 changed files with 121 additions and 5 deletions

View File

@ -47,6 +47,17 @@ public class EventHandler {
}
}
nodeNBT.setTag("flux", flux);
NBTTagList stasis = new NBTTagList();
if (node.stasis.size() > 0) {
for (Aspect tag : node.stasis.getAspects()) {
if (tag == null) continue;
NBTTagCompound f = new NBTTagCompound();
f.setString("id", tag.getTag());
f.setInteger("amount", node.stasis.getAmount(tag));
stasis.appendTag(f);
}
}
nodeNBT.setTag("stasis", stasis);
nodelist.appendTag(nodeNBT);
}
}
@ -83,6 +94,15 @@ public class EventHandler {
if (!flux.hasKey("id") || !flux.hasKey("amount")) continue;
node.flux.add(Aspect.getAspect(flux.getString("id")), flux.getInteger("amount"));
}
node.stasis = new AspectList();
if (nodeData.hasKey("stasis")) {
NBTTagList stasisTags = nodeData.getTagList("stasis", 10);
for (int j = 0; j < stasisTags.tagCount(); ++j) {
NBTTagCompound stasis = stasisTags.getCompoundTagAt(j);
if (!stasis.hasKey("id") || !stasis.hasKey("amount")) continue;
node.stasis.add(Aspect.getAspect(stasis.getString("id")), stasis.getInteger("amount"));
}
}
AuraManager.auraNodes.put(node.key, node);
AuraManager.addToAuraUpdateList(node);
AuraManager.generateNodeNeighbours(node);

View File

@ -10,6 +10,7 @@ public class AuraNode implements Serializable {
public short baseLevel;
public short taint;
public AspectList flux = new AspectList();
public AspectList stasis = new AspectList();
public EnumNodeType type;
public int dimension;
public double xPos;

View File

@ -5,7 +5,7 @@ public class CrystalColors {
public static final int[] colors = new int[]{16777215, 16777086, 16727041, 37119, 40960, 15650047, 5592439, 11154172, 0xB0B0BC, 0x800080};
public static int getColorForShard(int meta) {
if (meta > 9 || meta < 0) {
if (meta > 9 || meta < 0 || meta == 6) {
return 0xFFFFFF;
} else if (meta > 6) {
return colors[meta];

View File

@ -0,0 +1,25 @@
package dev.tilera.auracore.api;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IWandableBlock {
/**
* Called by wands when interacting with the block
* @param world The World of the block
* @param stack The ItemStack of the wand
* @param impl The IWand implementation for the wand
* @param player The player
* @param x xCoord of the block
* @param y yCoord of the block
* @param z zCoord of the block
* @param side The side, which was activated
* @param md The metadata of the block
* @return true, if block was successfully wanded
*/
boolean onWandRightClick(World world, ItemStack stack, IWand impl, EntityPlayer player, int x, int y, int z, ForgeDirection side, int md);
}

View File

@ -826,12 +826,17 @@ public class AuraManager {
}
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, 0, toggleLock, flx, x, y, z);
NodeChanges nc = new NodeChanges(key, levelMod, baseMod, 0, toggleLock, flx, null, x, y, z);
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);
NodeChanges nc = new NodeChanges(key, levelMod, baseMod, taint, toggleLock, flx, null, x, y, z);
auraUpdateQueue.add(nc);
}
public static void queueNodeChanges(int key, int levelMod, int baseMod, int taint, boolean toggleLock, AspectList flx, AspectList stasis, float x, float y, float z) {
NodeChanges nc = new NodeChanges(key, levelMod, baseMod, taint, toggleLock, flx, stasis, x, y, z);
auraUpdateQueue.add(nc);
}
@ -843,6 +848,31 @@ public class AuraManager {
queueNodeChanges(key, 0, 0, taint, false, null, 0, 0, 0);
}
public static void addGoodVibes(World world, int x, int y, int z, int amount) {
int key = getClosestAuraWithinRange(world, x, y, z, 64);
if (key < 0) return;
queueNodeChanges(key, 0, 0, 0, false, null, new AspectList().add(Aspect.MAGIC, amount), 0, 0, 0);
}
public static void addBadVibes(World world, int x, int y, int z, int amount) {
int key = getClosestAuraWithinRange(world, x, y, z, 64);
if (key < 0) return;
queueNodeChanges(key, 0, 0, 0, false, new AspectList().add(Aspect.TAINT, amount), null, 0, 0, 0);
}
public static void addBoost(World world, int x, int y, int z, int amount) {
int key = getClosestAuraWithinRange(world, x, y, z, 64);
if (key < 0) return;
queueNodeChanges(key, 0, 0, 0, false, null, new AspectList().add(Aspects.TIME, amount), 0, 0, 0);
}
public static int getBoost(World world, int x, int y, int z) {
int key = getClosestAuraWithinRange(world, x, y, z, 64);
if (key < 0) return 0;
AuraNode node = getNode(key);
return node.stasis.getAmount(Aspects.TIME);
}
public static AuraNode copyNode(AuraNode in) {
try {
AuraNode out = new AuraNode();
@ -856,6 +886,11 @@ public class AuraManager {
outflux.add(tag, in.flux.getAmount(tag));
}
out.flux = outflux;
AspectList outstasis = new AspectList();
for (Aspect tag : in.stasis.getAspects()) {
outstasis.add(tag, in.stasis.getAmount(tag));
}
out.stasis = outstasis;
out.dimension = in.dimension;
out.xPos = in.xPos;
out.yPos = in.yPos;
@ -876,6 +911,7 @@ public class AuraManager {
out.taint = in.taint;
out.type = in.type;
out.flux = in.flux;
out.stasis = in.stasis;
out.dimension = in.dimension;
out.xPos = in.xPos;
out.yPos = in.yPos;
@ -891,17 +927,19 @@ public class AuraManager {
int taintMod = 0;
boolean lock = false;
AspectList flux = null;
AspectList stasis = null;
float motionX;
float motionY;
float motionZ;
NodeChanges(int k, int l, int b, int t, boolean lo, AspectList ot, float x, float y, float z) {
NodeChanges(int k, int l, int b, int t, boolean lo, AspectList flux, AspectList stasis, float x, float y, float z) {
this.key = k;
this.levelMod = l;
this.baseMod = b;
this.taintMod = t;
this.lock = lo;
this.flux = ot;
this.flux = flux;
this.stasis = stasis;
this.motionX = x;
this.motionY = y;
this.motionZ = z;

View File

@ -74,6 +74,38 @@ public class AuraUpdateThread
}
}
}
if (nc.stasis != null) {
for (Aspect tag : nc.stasis.getAspects()) {
if (nc.stasis.getAmount(tag) > 0) {
node.stasis.add(tag, nc.stasis.getAmount(tag));
continue;
}
node.stasis.reduce(tag, -nc.stasis.getAmount(tag)); // TODO:WTF
}
}
if (node.stasis.size() > 0) {
ArrayList<Aspect> dt = new ArrayList<>();
ArrayList<Aspect> red = new ArrayList<>();
for (Aspect tag : node.stasis.getAspects()) {
if (node.stasis.getAmount(tag) <= 0) {
dt.add(tag);
continue;
}
if (node.stasis.getAmount(tag) <= 100)
continue;
red.add(tag);
}
if (red.size() > 0) {
for (Aspect tag : red) {
node.stasis.reduce(tag, node.stasis.getAmount(tag) - 100);
}
}
if (dt.size() > 0) {
for (Aspect tag : dt) {
node.stasis.remove(tag);
}
}
}
if (nc.motionX != 0.0f || nc.motionY != 0.0f || nc.motionZ != 0.0f) {
int cx = MathHelper.floor_double((double) node.xPos) / 16;
cz = MathHelper.floor_double((double) node.zPos) / 16;