diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java b/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java index 3f883444c..a98436f23 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java @@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.items.base.ItemBase; import ellpeck.actuallyadditions.tile.IPhantomTile; +import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.WorldPos; @@ -48,6 +49,9 @@ public class ItemPhantomConnector extends ItemBase{ if(tile instanceof IPhantomTile){ if(this.checkHasConnection(stack, player, tile)){ ((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack)); + if(tile instanceof TileEntityBase){ + ((TileEntityBase)tile).sendUpdate(); + } clearStorage(stack); player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc"))); return true; diff --git a/src/main/java/ellpeck/actuallyadditions/misc/EntityColoredParticleFX.java b/src/main/java/ellpeck/actuallyadditions/misc/EntityColoredParticleFX.java new file mode 100644 index 000000000..b52c057c3 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/misc/EntityColoredParticleFX.java @@ -0,0 +1,27 @@ +/* + * This file ("EntityColoredParticleFX.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.misc; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.particle.EntityReddustFX; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityColoredParticleFX extends EntityReddustFX{ + + public EntityColoredParticleFX(World world, double x, double y, double z, float size, float r, float g, float b, int ageMulti){ + super(world, x, y, z, size, r, g, b); + //To work around Reddust particles resetting the color to red if it's 0 (which is really stupid to be honest) + this.particleRed = ((float)(Math.random()*0.20000000298023224D)+0.8F)*r*(float)Math.random()*0.4F+0.6F; + this.particleMaxAge = (int)(8.0D/(Math.random()*0.8D+0.2D))*ageMulti; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketParticle.java b/src/main/java/ellpeck/actuallyadditions/network/PacketParticle.java index b71dfb254..5b17c069d 100644 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketParticle.java +++ b/src/main/java/ellpeck/actuallyadditions/network/PacketParticle.java @@ -15,9 +15,9 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.misc.EntityColoredParticleFX; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.EntityReddustFX; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -88,22 +88,26 @@ public class PacketParticle implements IMessage{ @Override @SideOnly(Side.CLIENT) public IMessage onMessage(PacketParticle message, MessageContext ctx){ - World world = Minecraft.getMinecraft().theWorld; - - if(Minecraft.getMinecraft().thePlayer.getDistance(message.startX, message.startY, message.startZ) <= 64){ - int difX = message.startX-message.endX; - int difY = message.startY-message.endY; - int difZ = message.startZ-message.endZ; - double distance = Vec3.createVectorHelper(message.startX, message.startY, message.startZ).distanceTo(Vec3.createVectorHelper(message.endX, message.endY, message.endZ)); - - for(int times = 0; times < message.particleAmount/2; times++){ - for(double i = 0; i <= 1; i += 1/(distance*message.particleAmount)){ - Minecraft.getMinecraft().effectRenderer.addEffect(new EntityReddustFX(world, (difX*i)+message.endX+0.5, (difY*i)+message.endY+0.5, (difZ*i)+message.endZ+0.5, message.particleSize, message.color[0], message.color[1], message.color[2])); - } - } - } - + renderParticlesFromAToB(message.startX, message.startY, message.startZ, message.endX, message.endY, message.endZ, message.particleAmount, message.particleSize, message.color, 1); return null; } } + + public static void renderParticlesFromAToB(int startX, int startY, int startZ, int endX, int endY, int endZ, int particleAmount, float particleSize, float[] color, int ageMultiplier){ + World world = Minecraft.getMinecraft().theWorld; + + if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64){ + int difX = startX-endX; + int difY = startY-endY; + int difZ = startZ-endZ; + double distance = Vec3.createVectorHelper(startX, startY, startZ).distanceTo(Vec3.createVectorHelper(endX, endY, endZ)); + + for(int times = 0; times < particleAmount/2; times++){ + for(double i = 0; i <= 1; i += 1/(distance*particleAmount)){ + EntityColoredParticleFX fx = new EntityColoredParticleFX(world, (difX*i)+endX+0.5, (difY*i)+endY+0.5, (difZ*i)+endZ+0.5, particleSize, color[0], color[1], color[2], ageMultiplier); + Minecraft.getMinecraft().effectRenderer.addEffect(fx); + } + } + } + } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java index 3dc19e49c..a88eaeced 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java @@ -16,12 +16,11 @@ import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler; +import ellpeck.actuallyadditions.network.PacketParticle; import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldUtil; import io.netty.util.internal.ConcurrentSet; -import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.EntityReddustFX; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; @@ -32,6 +31,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{ public static final int MAX_DISTANCE = 15; + private static final float[] COLOR = new float[]{1F, 0F, 0F}; @Override public void updateEntity(){ @@ -49,16 +49,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei if(network != null){ for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){ if(aPair.contains(thisPos) && thisPos.isEqual(aPair.firstRelay)){ - 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() ? 1 : 5))){ - 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.75F, 0, 0, 0)); - } - } + PacketParticle.renderParticlesFromAToB(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ(), aPair.secondRelay.getX(), aPair.secondRelay.getY(), aPair.secondRelay.getZ(), ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 1 : 5, 0.75F, COLOR, 1); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java index 5615c3abe..9f0b71fae 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java @@ -13,6 +13,7 @@ package ellpeck.actuallyadditions.tile; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.network.PacketParticle; import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldUtil; @@ -20,8 +21,6 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; @@ -110,6 +109,10 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1); worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5); } + + if(this.ticksElapsed%80 == 0){ + PacketParticle.renderParticlesFromAToB(xCoord, yCoord, zCoord, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), 2, 0.35F, TileEntityPhantomface.COLORS, 3); + } } @Override @@ -152,8 +155,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements @Override public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ super.writeSyncableNBT(compound, sync); - compound.setInteger("Time", currentTime); - if(this.hasBoundPosition()){ + if(this.boundPosition != null){ compound.setInteger("XCoordOfTileStored", boundPosition.getX()); compound.setInteger("YCoordOfTileStored", boundPosition.getY()); compound.setInteger("ZCoordOfTileStored", boundPosition.getZ()); @@ -167,8 +169,8 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements int x = compound.getInteger("XCoordOfTileStored"); int y = compound.getInteger("YCoordOfTileStored"); int z = compound.getInteger("ZCoordOfTileStored"); - World world = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored")); - if(x != 0 && y != 0 && z != 0 && world != null){ + int world = compound.getInteger("WorldOfTileStored"); + if(!(x == 0 && y == 0 && z == 0)){ this.boundPosition = new WorldPos(world, x, y, z); this.markDirty(); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java index ccb0a55b7..dc024bc64 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java @@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.blocks.BlockPhantom; import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.network.PacketParticle; import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.WorldPos; import net.minecraft.block.Block; @@ -32,6 +33,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP private WorldPos boundPosBefore; private Block boundBlockBefore; + public static final float[] COLORS = new float[]{93F/255F, 43F/255F, 181F/255F}; + public TileEntityPhantomface(String name){ super(0, name); } @@ -131,6 +134,10 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1); worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5); } + + if(this.ticksElapsed%80 == 0){ + PacketParticle.renderParticlesFromAToB(xCoord, yCoord, zCoord, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), 2, 0.35F, COLORS, 3); + } } @Override