Skip to content
Permalink
Browse files

Arcs are now more responsive and have been fixed for servers.

  • Loading branch information...
Ri5ux Ri5ux
Ri5ux authored and Ri5ux committed Jul 15, 2019
1 parent 83dcaaf commit 997342377bb7760301277645a0eec581632f9c9f
Showing with 21 additions and 9 deletions.
  1. +21 −9 src/main/java/org/avp/tile/TileEntityPowerline.java
@@ -19,6 +19,9 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class TileEntityPowerline extends TileEntityElectrical implements IVoltageProvider, IVoltageReceiver
{
@@ -66,7 +69,7 @@ public void update()
}

boolean canArc = connections <= 1;

if (canArc)
{
Random rand = new Random();
@@ -85,7 +88,7 @@ public void update()
{
t = new Pos(target.getPosition()).add(target.width / 2, 0, target.width / 2);
m = 8F;
dist = target.getDistanceSq(x, y, z);
dist = target.getDistance(x, y, z);

if (dist <= maxArcDist)
{
@@ -96,18 +99,27 @@ public void update()

if (dist <= maxArcDist)
{
float targetX = (float) (t.x + (rand.nextFloat() / m) - (rand.nextFloat() / m));
float targetY = (float) (t.y + 1);
float targetZ = (float) (t.z + (rand.nextFloat() / m) - (rand.nextFloat() / m));
int age = 4;
int color = 0xFF8866CC;
EntityFXElectricArc arc = new EntityFXElectricArc(world, x, y, z, targetX, targetY, targetZ, age, 0.24F * dist, 0.1F, (float) arcWidth, color);
Game.minecraft().effectRenderer.addEffect(arc);
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
{
this.spawnArc(t, m, rand, dist, x, y, z, arcWidth);
}
}
}
}
}

@SideOnly(Side.CLIENT)
public void spawnArc(Pos t, float m, Random rand, double dist, double x, double y, double z, double arcWidth)
{
float targetX = (float) (t.x + (rand.nextFloat() / m) - (rand.nextFloat() / m));
float targetY = (float) (t.y + 1);
float targetZ = (float) (t.z + (rand.nextFloat() / m) - (rand.nextFloat() / m));
int age = 4;
int color = 0xFF8866CC;
EntityFXElectricArc arc = new EntityFXElectricArc(world, x, y, z, targetX, targetY, targetZ, age, 0.24F * dist, 0.1F, (float) arcWidth, color);
Game.minecraft().effectRenderer.addEffect(arc);
}

public static Pos getNextGroundingPoint(Pos pos, World world)
{
for (int y = (int) pos.y; y > 0; y--)

0 comments on commit 9973423

Please sign in to comment.
You can’t perform that action at this time.