diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java index a45ab3d43..4c2795d89 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLaserRelay.java @@ -11,9 +11,13 @@ package ellpeck.actuallyadditions.tile; import cofh.api.energy.IEnergyReceiver; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; 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; @@ -27,27 +31,32 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei @Override public void invalidate(){ super.invalidate(); - if(!worldObj.isRemote){ - LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord)); - } + LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord)); } @Override public void updateEntity(){ if(this.worldObj.isRemote){ - 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)){ + this.renderParticles(); + } + } + + @SideOnly(Side.CLIENT) + public void renderParticles(){ + 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)){ + 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 : 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); + 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)); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java index 3aad3319f..8bfab305a 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java @@ -10,6 +10,8 @@ package ellpeck.actuallyadditions.tile; +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.config.values.ConfigIntValues; @@ -19,7 +21,6 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; public class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{ @@ -55,21 +56,26 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP } else{ if(this.boundPosition != null){ - if(this.worldObj.rand.nextInt(2) == 0){ - double d1 = (double)((float)this.boundPosition.getY()+worldObj.rand.nextFloat()); - int i1 = worldObj.rand.nextInt(2)*2-1; - int j1 = worldObj.rand.nextInt(2)*2-1; - double d4 = ((double)worldObj.rand.nextFloat()-0.5D)*0.125D; - double d2 = (double)this.boundPosition.getZ()+0.5D+0.25D*(double)j1; - double d5 = (double)(worldObj.rand.nextFloat()*1.0F*(float)j1); - double d0 = (double)this.boundPosition.getX()+0.5D+0.25D*(double)i1; - double d3 = (double)(worldObj.rand.nextFloat()*1.0F*(float)i1); - worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5); - } + this.renderParticles(); } } } + @SideOnly(Side.CLIENT) + public void renderParticles(){ + if(this.worldObj.rand.nextInt(2) == 0){ + double d1 = (double)((float)this.boundPosition.getY()+worldObj.rand.nextFloat()); + int i1 = worldObj.rand.nextInt(2)*2-1; + int j1 = worldObj.rand.nextInt(2)*2-1; + double d4 = ((double)worldObj.rand.nextFloat()-0.5D)*0.125D; + double d2 = (double)this.boundPosition.getZ()+0.5D+0.25D*(double)j1; + double d5 = (double)(worldObj.rand.nextFloat()*1.0F*(float)j1); + double d0 = (double)this.boundPosition.getX()+0.5D+0.25D*(double)i1; + double d3 = (double)(worldObj.rand.nextFloat()*1.0F*(float)i1); + worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5); + } + } + public static int upgradeRange(int defaultRange, World world, int x, int y, int z){ int newRange = defaultRange; for(int i = 0; i < 3; i++){ @@ -137,7 +143,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP @Override public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ super.writeSyncableNBT(compound, sync); - if(this.hasBoundPosition()){ + if(this.boundPosition != null){ compound.setInteger("XCoordOfTileStored", boundPosition.getX()); compound.setInteger("YCoordOfTileStored", boundPosition.getY()); compound.setInteger("ZCoordOfTileStored", boundPosition.getZ()); @@ -151,8 +157,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP 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(); }