Fix Server again

This commit is contained in:
Ellpeck 2015-10-27 23:09:23 +01:00
parent 7671b408c8
commit 1549882d3a
2 changed files with 41 additions and 26 deletions

View file

@ -11,9 +11,13 @@
package ellpeck.actuallyadditions.tile; package ellpeck.actuallyadditions.tile;
import cofh.api.energy.IEnergyReceiver; 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.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler; import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldPos;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityReddustFX;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
@ -27,27 +31,32 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
@Override @Override
public void invalidate(){ public void invalidate(){
super.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 @Override
public void updateEntity(){ public void updateEntity(){
if(this.worldObj.isRemote){ if(this.worldObj.isRemote){
this.renderParticles();
}
}
@SideOnly(Side.CLIENT)
public void renderParticles(){
if(this.worldObj.rand.nextInt(2) == 0){ if(this.worldObj.rand.nextInt(2) == 0){
WorldPos thisPos = new WorldPos(this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord); WorldPos thisPos = new WorldPos(this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord);
ArrayList<LaserRelayConnectionHandler.ConnectionPair> network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos); ArrayList<LaserRelayConnectionHandler.ConnectionPair> network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos);
if(network != null){ if(network != null){
for(LaserRelayConnectionHandler.ConnectionPair aPair : network){ for(LaserRelayConnectionHandler.ConnectionPair aPair : network){
if(aPair.contains(thisPos) && thisPos.isEqual(aPair.firstRelay)){ 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 difX = aPair.firstRelay.getX()-aPair.secondRelay.getX();
int difY = aPair.firstRelay.getY()-aPair.secondRelay.getY(); int difY = aPair.firstRelay.getY()-aPair.secondRelay.getY();
int difZ = aPair.firstRelay.getZ()-aPair.secondRelay.getZ(); int difZ = aPair.firstRelay.getZ()-aPair.secondRelay.getZ();
double distance = aPair.firstRelay.toVec().distanceTo(aPair.secondRelay.toVec()); 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))){ for(double i = 0; i <= 1; i += 1/(distance*(ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 1 : 5))){
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); 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));
} }
} }
} }

View file

@ -10,6 +10,8 @@
package ellpeck.actuallyadditions.tile; 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.BlockPhantom;
import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues;
@ -19,7 +21,6 @@ import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
public class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{ public class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{
@ -55,6 +56,13 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
} }
else{ else{
if(this.boundPosition != null){ if(this.boundPosition != null){
this.renderParticles();
}
}
}
@SideOnly(Side.CLIENT)
public void renderParticles(){
if(this.worldObj.rand.nextInt(2) == 0){ if(this.worldObj.rand.nextInt(2) == 0){
double d1 = (double)((float)this.boundPosition.getY()+worldObj.rand.nextFloat()); double d1 = (double)((float)this.boundPosition.getY()+worldObj.rand.nextFloat());
int i1 = worldObj.rand.nextInt(2)*2-1; int i1 = worldObj.rand.nextInt(2)*2-1;
@ -67,8 +75,6 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5); worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
} }
} }
}
}
public static int upgradeRange(int defaultRange, World world, int x, int y, int z){ public static int upgradeRange(int defaultRange, World world, int x, int y, int z){
int newRange = defaultRange; int newRange = defaultRange;
@ -137,7 +143,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
if(this.hasBoundPosition()){ if(this.boundPosition != null){
compound.setInteger("XCoordOfTileStored", boundPosition.getX()); compound.setInteger("XCoordOfTileStored", boundPosition.getX());
compound.setInteger("YCoordOfTileStored", boundPosition.getY()); compound.setInteger("YCoordOfTileStored", boundPosition.getY());
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ()); compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
@ -151,8 +157,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
int x = compound.getInteger("XCoordOfTileStored"); int x = compound.getInteger("XCoordOfTileStored");
int y = compound.getInteger("YCoordOfTileStored"); int y = compound.getInteger("YCoordOfTileStored");
int z = compound.getInteger("ZCoordOfTileStored"); int z = compound.getInteger("ZCoordOfTileStored");
World world = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored")); int world = compound.getInteger("WorldOfTileStored");
if(x != 0 && y != 0 && z != 0 && world != null){ if(!(x == 0 && y == 0 && z == 0)){
this.boundPosition = new WorldPos(world, x, y, z); this.boundPosition = new WorldPos(world, x, y, z);
this.markDirty(); this.markDirty();
} }