Hoist some particle data decls, eliminates some allocations

This commit is contained in:
Vincent Lee committed 2019-10-09 21:06:11 -05:00
1 parent 6c1a9af6ca
commit 589fe30964
3 files changed
+7 -8

No files matched your search

@@ -106,11 +106,11 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan
float mul = 0.5F;
float mulPer = 0.4F;
float maxMul = 2;
WispParticleData data = WispParticleData.wisp(0.1F, 0.4F, 0.4F, 1F, 1);
for(int i = start; i < start + count; i++) {
mul = Math.min(maxMul, mul + mulPer);
double rad = radPer * (i + ticksElapsed * 0.4);
Vector3 vecRot = vecMag.crossProduct(Vector3.ONE).multiply(mul).rotate(rad, vecMag).add(vecTip);
WispParticleData data = WispParticleData.wisp(0.1F, 0.4F, 0.4F, 1F, 1);
world.addParticle(data, vecRot.x, vecRot.y, vecRot.z, (float) -vecMag.x, (float) -vecMag.y, (float) -vecMag.z);
vecTip = vecTip.add(vecMag);
}
@@ -60,10 +60,10 @@ public class ItemSkyDirtRod extends ItemDirtRod {
if(stackToPlace.isEmpty()) {
ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true);
SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.35F, 0.2F, 0.05F, 5);
for(int i = 0; i < 6; i++) {
SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.35F, 0.2F, 0.05F, 5);
world.addParticle(data, x + Math.random(), y + Math.random(), z + Math.random(), 0, 0, 0);
}
world.addParticle(data, x + Math.random(), y + Math.random(), z + Math.random(), 0, 0, 0);
}
}
}
}
@@ -114,14 +114,13 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
decremented = false;
}
WispParticleData data1 = WispParticleData.wisp(0.5F, 1F, 0.2F, 0.2F, 1);
for(int i = 0; i < 25; i++) {
double x = pos.getPos().getX() + Math.random();
double y = pos.getPos().getY() + Math.random();
double z = pos.getPos().getZ() + Math.random();
WispParticleData data1 = WispParticleData.wisp(0.5F, 1F, 0.2F, 0.2F, 1);
p.world.addParticle(data1, x, y, z, 0, (float) -Math.random() / 10F, 0);
}
p.world.addParticle(data1, x, y, z, 0, (float) -Math.random() / 10F, 0);
}
}
}
}