From b8ba00ed839a7d40feb93a7a2c26367299f1a78e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 27 Oct 2015 20:28:48 +0100 Subject: [PATCH] Made Laser Particles render up to a range of 64 instead of the default 16 --- .../tile/TileEntityLaserRelay.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java index 0661d6f59..30c37cc2d 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java @@ -14,6 +14,8 @@ import cofh.api.energy.IEnergyReceiver; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler; import ellpeck.actuallyadditions.util.WorldPos; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityReddustFX; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -35,19 +37,21 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei @Override public void updateEntity(){ if(this.worldObj.isRemote){ - if(this.worldObj.rand.nextInt(ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 8 : 4) == 0){ + if(this.worldObj.rand.nextInt(2) == 0){ WorldPos thisPos = new WorldPos(this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord); ArrayList network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos); if(network != null){ for(LaserRelayConnectionHandler.ConnectionPair aPair : network){ if(aPair.contains(thisPos) && thisPos.isEqual(aPair.firstRelay)){ - int difX = aPair.firstRelay.getX()-aPair.secondRelay.getX(); - int difY = aPair.firstRelay.getY()-aPair.secondRelay.getY(); - int difZ = aPair.firstRelay.getZ()-aPair.secondRelay.getZ(); + if(Minecraft.getMinecraft().thePlayer.getDistance(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ()) <= 64){ + int difX = aPair.firstRelay.getX()-aPair.secondRelay.getX(); + int difY = aPair.firstRelay.getY()-aPair.secondRelay.getY(); + int difZ = aPair.firstRelay.getZ()-aPair.secondRelay.getZ(); - double distance = aPair.firstRelay.toVec().distanceTo(aPair.secondRelay.toVec()); - for(double i = 0; i <= 1; i += 1/(distance*(ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 2 : 4))){ - this.worldObj.spawnParticle("reddust", (difX*i)+aPair.secondRelay.getX()+0.5, (difY*i)+aPair.secondRelay.getY()+0.5, (difZ*i)+aPair.secondRelay.getZ()+0.5, 0, 0, 0); + double distance = aPair.firstRelay.toVec().distanceTo(aPair.secondRelay.toVec()); + for(double i = 0; i <= 1; i += 1/(distance*(ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 1 : 4))){ + Minecraft.getMinecraft().effectRenderer.addEffect(new EntityReddustFX(this.worldObj, (difX*i)+aPair.secondRelay.getX()+0.5, (difY*i)+aPair.secondRelay.getY()+0.5, (difZ*i)+aPair.secondRelay.getZ()+0.5, 0, 0, 0)); + } } } }