Tidying
Moved the sendLaserPacket function into its own abstract class (had to extend WarpChunkTE for mining laser and things) Made beamFX debug messages much more concise. Tidied up cloaking field callMethods to use new toInt functions. Made laser lift try to move stuff every 8 ticks rather than every 40 to eliminate the slow feeling. Made a custom laser calling function in laserLift since source and dest are the same in nearly every call. Made BeamFX only use the grey texture since it can just colorise it. Changed a few System.out.printlns to WarpDrive.debugPrints.
This commit is contained in:
parent
2ce9e1cdae
commit
cd9386998e
9 changed files with 194 additions and 300 deletions
|
@ -103,7 +103,7 @@ public class EntityJump extends Entity
|
|||
{
|
||||
super(world);
|
||||
targetWorld = worldObj;
|
||||
System.out.println("[JE@" + this + "] Entity created (empty)");
|
||||
WarpDrive.debugPrint("[JE@" + this + "] Entity created (empty)");
|
||||
}
|
||||
|
||||
public EntityJump(World world, int x, int y, int z, int _dist, int _direction, int _dx, int _dz, TileEntityReactor parReactor)
|
||||
|
@ -122,7 +122,7 @@ public class EntityJump extends Entity
|
|||
this.dz = _dz;
|
||||
maxX = maxZ = maxY = minX = minZ = minY = 0;
|
||||
targetWorld = worldObj;
|
||||
System.out.println("[JE@" + this + "] Entity created");
|
||||
WarpDrive.debugPrint("[JE@" + this + "] Entity created");
|
||||
this.reactor = parReactor;
|
||||
}
|
||||
|
||||
|
@ -134,11 +134,11 @@ public class EntityJump extends Entity
|
|||
}
|
||||
|
||||
on = false;
|
||||
System.out.println("[JE@" + this + "] Killing jump entity...");
|
||||
WarpDrive.debugPrint("[JE@" + this + "] Killing jump entity...");
|
||||
|
||||
if (!reason.isEmpty())
|
||||
{
|
||||
System.out.println("[JUMP] Killed: " + reason);
|
||||
WarpDrive.debugPrint("[JUMP] Killed: " + reason);
|
||||
}
|
||||
|
||||
unlockWorlds();
|
||||
|
@ -168,7 +168,7 @@ public class EntityJump extends Entity
|
|||
|
||||
if (state == STATE_IDLE)
|
||||
{
|
||||
System.out.println("[JE] Preparing to jump...");
|
||||
WarpDrive.debugPrint("[JE] Preparing to jump...");
|
||||
prepareToJump();
|
||||
state = STATE_JUMPING;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ public class EntityJump extends Entity
|
|||
|
||||
private void forceChunks()
|
||||
{
|
||||
System.out.println("[JE@" + this + "] Forcing chunks");
|
||||
WarpDrive.debugPrint("[JE@" + this + "] Forcing chunks");
|
||||
sourceWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, worldObj, Type.ENTITY);
|
||||
targetWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, targetWorld, Type.NORMAL);
|
||||
sourceWorldTicket.bindEntity(this);
|
||||
|
@ -235,7 +235,7 @@ public class EntityJump extends Entity
|
|||
|
||||
private void unforceChunks()
|
||||
{
|
||||
System.out.println("[JE@" + this + "] Unforcing chunks");
|
||||
WarpDrive.debugPrint("[JE@" + this + "] Unforcing chunks");
|
||||
|
||||
if (sourceWorldTicket == null || targetWorldTicket == null)
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ public class EntityJump extends Entity
|
|||
|
||||
public void lockWorlds()
|
||||
{
|
||||
System.out.println("[JE@" + this + "] Locking worlds...");
|
||||
WarpDrive.debugPrint("[JE@" + this + "] Locking worlds...");
|
||||
targetWorld.isRemote = true;
|
||||
|
||||
// When warping between dimensions is need to lock both worlds
|
||||
|
@ -288,7 +288,7 @@ public class EntityJump extends Entity
|
|||
|
||||
public void unlockWorlds()
|
||||
{
|
||||
System.out.println("[JE@" + this + "] Unlocking worlds..");
|
||||
WarpDrive.debugPrint("[JE@" + this + "] Unlocking worlds..");
|
||||
targetWorld.isRemote = false;
|
||||
|
||||
if (targetWorld.provider.dimensionId != worldObj.provider.dimensionId)
|
||||
|
@ -399,13 +399,13 @@ public class EntityJump extends Entity
|
|||
|
||||
if (betweenWorlds)
|
||||
{
|
||||
System.out.println("[JE] Worlds: " + worldObj.provider.getDimensionName() + " -> " + targetWorld.provider.getDimensionName());
|
||||
WarpDrive.debugPrint("[JE] Worlds: " + worldObj.provider.getDimensionName() + " -> " + targetWorld.provider.getDimensionName());
|
||||
}
|
||||
|
||||
forceChunks();
|
||||
lockWorlds();
|
||||
saveEntities(axisalignedbb);
|
||||
System.out.println("[JE] Saved " + entitiesOnShip.size() + " entities from ship");
|
||||
WarpDrive.debugPrint("[JE] Saved " + entitiesOnShip.size() + " entities from ship");
|
||||
|
||||
if (!isCoordJump && !(toHyperSpace || fromHyperSpace))
|
||||
{
|
||||
|
@ -450,7 +450,7 @@ public class EntityJump extends Entity
|
|||
this.currentIndexInShip = 0;
|
||||
msCounter = System.currentTimeMillis();
|
||||
LocalProfiler.stop();
|
||||
System.out.println("Removing TE duplicates. Size before jump: " + targetWorld.loadedTileEntityList.size());
|
||||
WarpDrive.debugPrint("Removing TE duplicates. Size before jump: " + targetWorld.loadedTileEntityList.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -458,9 +458,9 @@ public class EntityJump extends Entity
|
|||
*/
|
||||
public void finishJump()
|
||||
{
|
||||
System.out.println("[JE] Finished. Jump took " + ((System.currentTimeMillis() - msCounter) / 1000F) + " seconds");
|
||||
WarpDrive.debugPrint("[JE] Finished. Jump took " + ((System.currentTimeMillis() - msCounter) / 1000F) + " seconds");
|
||||
//FIXME TileEntity duplication workaround
|
||||
System.out.println("Removing TE duplicates. Size before: " + targetWorld.loadedTileEntityList.size());
|
||||
WarpDrive.debugPrint("Removing TE duplicates. Size before: " + targetWorld.loadedTileEntityList.size());
|
||||
LocalProfiler.start("EntityJump.removeDuplicates()");
|
||||
|
||||
try
|
||||
|
@ -469,11 +469,11 @@ public class EntityJump extends Entity
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("TE Duplicates removing exception: " + e.getMessage());
|
||||
WarpDrive.debugPrint("TE Duplicates removing exception: " + e.getMessage());
|
||||
}
|
||||
|
||||
LocalProfiler.stop();
|
||||
System.out.println("Removing TE duplicates. Size after: " + targetWorld.loadedTileEntityList.size());
|
||||
WarpDrive.debugPrint("Removing TE duplicates. Size after: " + targetWorld.loadedTileEntityList.size());
|
||||
killEntity("");
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ public class EntityJump extends Entity
|
|||
{
|
||||
LocalProfiler.start("EntityJump.removeShip");
|
||||
int blocksToMove = Math.min(BLOCKS_PER_TICK, ship.length - currentIndexInShip);
|
||||
System.out.println("[JE] Removing ship part: " + currentIndexInShip + "/" + ship.length + " [btm: " + blocksToMove + "]");
|
||||
WarpDrive.debugPrint("[JE] Removing ship part: " + currentIndexInShip + "/" + ship.length + " [btm: " + blocksToMove + "]");
|
||||
TileEntity te;
|
||||
Class<?> c;
|
||||
for (int index = 0; index < blocksToMove; index++)
|
||||
|
@ -592,7 +592,7 @@ public class EntityJump extends Entity
|
|||
}
|
||||
}
|
||||
|
||||
System.out.println((new StringBuilder()).append("[JUMP] Ship saved: ").append((new StringBuilder()).append(ship.length).append(" blocks")).toString());
|
||||
WarpDrive.debugPrint((new StringBuilder()).append("[JUMP] Ship saved: ").append((new StringBuilder()).append(ship.length).append(" blocks")).toString());
|
||||
LocalProfiler.stop();
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ public class EntityJump extends Entity
|
|||
{
|
||||
LocalProfiler.start("EntityJump.moveShip");
|
||||
int blocksToMove = Math.min(BLOCKS_PER_TICK, ship.length - currentIndexInShip);
|
||||
System.out.println("[JE] Moving ship part: " + currentIndexInShip + "/" + ship.length + " [btm: " + blocksToMove + "]");
|
||||
WarpDrive.debugPrint("[JE] Moving ship part: " + currentIndexInShip + "/" + ship.length + " [btm: " + blocksToMove + "]");
|
||||
|
||||
for (int index = 0; index < blocksToMove; index++)
|
||||
{
|
||||
|
@ -626,7 +626,7 @@ public class EntityJump extends Entity
|
|||
*/
|
||||
public int getPossibleJumpDistance()
|
||||
{
|
||||
System.out.println("[JUMP] Calculating possible jump distance...");
|
||||
WarpDrive.debugPrint("[JUMP] Calculating possible jump distance...");
|
||||
int testDistance = this.distance;
|
||||
int blowPoints = 0;
|
||||
|
||||
|
@ -709,7 +709,7 @@ public class EntityJump extends Entity
|
|||
|
||||
public boolean moveEntities(boolean restorePositions)
|
||||
{
|
||||
System.out.println("[JE] Moving entities");
|
||||
WarpDrive.debugPrint("[JE] Moving entities");
|
||||
|
||||
if (entitiesOnShip != null)
|
||||
{
|
||||
|
@ -742,7 +742,7 @@ public class EntityJump extends Entity
|
|||
newEntityZ = oldEntityZ + moveZ;
|
||||
}
|
||||
|
||||
//System.out.println("Entity moving: old (" + oldEntityX + " " + oldEntityY + " " + oldEntityZ + ") -> new (" + newEntityX + " " + newEntityY + " " + newEntityZ);
|
||||
//WarpDrive.debugPrint("Entity moving: old (" + oldEntityX + " " + oldEntityY + " " + oldEntityZ + ") -> new (" + newEntityX + " " + newEntityY + " " + newEntityZ);
|
||||
|
||||
// Travel to another dimension if needed
|
||||
if (betweenWorlds && !restorePositions)
|
||||
|
@ -839,7 +839,7 @@ public class EntityJump extends Entity
|
|||
{
|
||||
if ((dir == -1 && maxY + testDistance > 255) && !toSpace)
|
||||
{
|
||||
System.out.println("[JUMP] Reactor will blow due +high limit");
|
||||
WarpDrive.debugPrint("[JUMP] Reactor will blow due +high limit");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -848,7 +848,7 @@ public class EntityJump extends Entity
|
|||
blowY = minY - testDistance;
|
||||
blowX = xCoord;
|
||||
blowZ = zCoord;
|
||||
System.out.println("[JUMP] Reactor will blow due -low limit");
|
||||
WarpDrive.debugPrint("[JUMP] Reactor will blow due -low limit");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -886,7 +886,7 @@ public class EntityJump extends Entity
|
|||
blowX = x;
|
||||
blowY = y;
|
||||
blowZ = z;
|
||||
System.out.println((new StringBuilder()).append("[JUMP] Reactor will blow due BlockID ").append((new StringBuilder()).append(blockID).append(" at (").append(newX).append(";").append(newY).append(";").append(newZ).append(")").toString()).toString());
|
||||
WarpDrive.debugPrint((new StringBuilder()).append("[JUMP] Reactor will blow due BlockID ").append((new StringBuilder()).append(blockID).append(" at (").append(newX).append(";").append(newY).append(";").append(newZ).append(")").toString()).toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1048,19 +1048,19 @@ public class EntityJump extends Entity
|
|||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
//System.out.println("[JE@"+this+"] readEntityFromNBT()");
|
||||
//WarpDrive.debugPrint("[JE@"+this+"] readEntityFromNBT()");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
//System.out.println("[JE@"+this+"] entityInit()");
|
||||
//WarpDrive.debugPrint("[JE@"+this+"] entityInit()");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound var1)
|
||||
{
|
||||
//System.out.println("[JE@"+this+"] writeEntityToNBT()");
|
||||
//WarpDrive.debugPrint("[JE@"+this+"] writeEntityToNBT()");
|
||||
}
|
||||
|
||||
// Own implementation of setting blocks without light recalculation in optimization purposes
|
||||
|
|
|
@ -43,6 +43,7 @@ public class FXBeam extends EntityFX
|
|||
public FXBeam(World par1World, Vector3 position, float yaw, float pitch, float red, float green, float blue, int age, int energy)
|
||||
{
|
||||
super(par1World, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D);
|
||||
WarpDrive.debugPrint("creating new FXBeam");
|
||||
a = true;
|
||||
this.setRGB(red, green, blue);
|
||||
this.setSize(0.02F, 0.02F);
|
||||
|
@ -57,35 +58,8 @@ public class FXBeam extends EntityFX
|
|||
this.prevPitch = this.rotPitch;
|
||||
this.particleMaxAge = age;
|
||||
this.energy = energy;
|
||||
|
||||
if (red == 1 && green == 0 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_red.png");
|
||||
}
|
||||
else if (red == 0 && green == 1 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_green.png");
|
||||
}
|
||||
else if (red == 0 && green == 0 && blue == 1)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy.png");
|
||||
}
|
||||
else if (red == 1 && green == 1 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_yellow.png");
|
||||
}
|
||||
else if (red == 1 && green == 0.5 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_orange.png");
|
||||
}
|
||||
else if (red == 0.5 && green == 0 && blue == 0.5)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_violet.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_grey.png");
|
||||
}
|
||||
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_grey.png");
|
||||
|
||||
/**
|
||||
* Sets the particle age based on distance.
|
||||
|
@ -107,6 +81,7 @@ public class FXBeam extends EntityFX
|
|||
public FXBeam(World par1World, Vector3 position, Vector3 target, float red, float green, float blue, int age, int energy)
|
||||
{
|
||||
super(par1World, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D);
|
||||
WarpDrive.debugPrint("attempting to render!");
|
||||
this.setRGB(red, green, blue);
|
||||
this.setSize(0.02F, 0.02F);
|
||||
this.noClip = true;
|
||||
|
@ -126,34 +101,7 @@ public class FXBeam extends EntityFX
|
|||
this.particleMaxAge = age;
|
||||
this.energy = energy;
|
||||
|
||||
if (red == 1 && green == 0 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_red.png");
|
||||
}
|
||||
else if (red == 0 && green == 1 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_green.png");
|
||||
}
|
||||
else if (red == 0 && green == 0 && blue == 1)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy.png");
|
||||
}
|
||||
else if (red == 1 && green == 1 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_yellow.png");
|
||||
}
|
||||
else if (red == 1 && green == 0.5 && blue == 0)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_orange.png");
|
||||
}
|
||||
else if (red == 0.5 && green == 0 && blue == 0.5)
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_violet.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_grey.png");
|
||||
}
|
||||
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_grey.png");
|
||||
|
||||
/**
|
||||
* Sets the particle age based on distance.
|
||||
|
@ -173,7 +121,7 @@ public class FXBeam extends EntityFX
|
|||
|
||||
//this.pulse = (energy == 0);
|
||||
//if (TEXTURE != null) {
|
||||
// System.out.println("BeamFX created. Texture: " + TEXTURE);
|
||||
WarpDrive.debugPrint("BeamFX created. Texture: " + TEXTURE);
|
||||
//}
|
||||
}
|
||||
|
||||
|
|
|
@ -255,16 +255,9 @@ public class PacketHandler implements IPacketHandler
|
|||
energy = inputStream.readInt();
|
||||
|
||||
// Render beam
|
||||
WarpDrive.debugPrint("sx: " + sx + " sy: " + sy + " sz: " + sz);
|
||||
WarpDrive.debugPrint("tx: " + sx + " ty: " + sy + " tz: " + sz);
|
||||
|
||||
WarpDrive.debugPrint("source: " + source);
|
||||
WarpDrive.debugPrint("target: " + target);
|
||||
WarpDrive.debugPrint("r: " + r);
|
||||
WarpDrive.debugPrint("g: " + g);
|
||||
WarpDrive.debugPrint("b " + b);
|
||||
WarpDrive.debugPrint("age: " + age);
|
||||
WarpDrive.debugPrint("energy: " + energy);
|
||||
WarpDrive.debugPrint("r: " + r + " g: " + g + " b:" + b + " age: " + age +" en: " + energy);
|
||||
|
||||
// To avoid NPE at logging in
|
||||
if (worldObj == null)
|
||||
|
|
63
src/cr0s/WarpDrive/machines/TileEntityAbstractLaser.java
Normal file
63
src/cr0s/WarpDrive/machines/TileEntityAbstractLaser.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package cr0s.WarpDrive.machines;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cr0s.WarpDrive.Vector3;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
|
||||
public abstract class TileEntityAbstractLaser extends WarpChunkTE
|
||||
{
|
||||
|
||||
protected void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (side == Side.SERVER)
|
||||
{
|
||||
WarpDrive.debugPrint("laser:" + source + ":" + dest + ":" + r + ":" + g + ":" + b + ":" + age);
|
||||
if (source == null || dest == null || worldObj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
// Write source vector
|
||||
outputStream.writeDouble(source.x);
|
||||
outputStream.writeDouble(source.y);
|
||||
outputStream.writeDouble(source.z);
|
||||
// Write target vector
|
||||
outputStream.writeDouble(dest.x);
|
||||
outputStream.writeDouble(dest.y);
|
||||
outputStream.writeDouble(dest.z);
|
||||
// Write r, g, b of laser
|
||||
outputStream.writeFloat(r);
|
||||
outputStream.writeFloat(g);
|
||||
outputStream.writeFloat(b);
|
||||
// Write age
|
||||
outputStream.writeByte(age);
|
||||
// Write energy value
|
||||
outputStream.writeInt(0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "WarpDriveBeam";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(source.intX(), source.intY(), source.intZ(), radius, worldObj.provider.dimensionId, packet);
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(dest.intX(), dest.intY(), dest.intZ(), radius, worldObj.provider.dimensionId, packet);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ import cr0s.WarpDrive.Vector3;
|
|||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.WarpDriveConfig;
|
||||
|
||||
public abstract class TileEntityAbstractMiner extends WarpChunkTE implements IGridMachine, ITileCable
|
||||
public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser implements IGridMachine, ITileCable
|
||||
{
|
||||
|
||||
//FOR STORAGE
|
||||
|
@ -213,54 +213,6 @@ public abstract class TileEntityAbstractMiner extends WarpChunkTE implements IGr
|
|||
|
||||
//MINING FUNCTIONS
|
||||
|
||||
protected void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (side == Side.SERVER)
|
||||
{
|
||||
WarpDrive.debugPrint("trying to fire laser!");
|
||||
if (source == null || dest == null || worldObj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
// Write source vector
|
||||
outputStream.writeDouble(source.x);
|
||||
outputStream.writeDouble(source.y);
|
||||
outputStream.writeDouble(source.z);
|
||||
// Write target vector
|
||||
outputStream.writeDouble(dest.x);
|
||||
outputStream.writeDouble(dest.y);
|
||||
outputStream.writeDouble(dest.z);
|
||||
// Write r, g, b of laser
|
||||
outputStream.writeFloat(r);
|
||||
outputStream.writeFloat(g);
|
||||
outputStream.writeFloat(b);
|
||||
// Write age
|
||||
outputStream.writeByte(age);
|
||||
// Write energy value
|
||||
outputStream.writeInt(0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "WarpDriveBeam";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(source.intX(), source.intY(), source.intZ(), radius, worldObj.provider.dimensionId, packet);
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(dest.intX(), dest.intY(), dest.intZ(), radius, worldObj.provider.dimensionId, packet);
|
||||
}
|
||||
}
|
||||
|
||||
protected void laserBlock(Vector3 valuable)
|
||||
{
|
||||
fixMinerVector();
|
||||
|
|
|
@ -46,7 +46,7 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergySink,
|
||||
public class TileEntityCloakingDeviceCore extends TileEntityAbstractLaser implements IEnergySink,
|
||||
IPeripheral {
|
||||
public boolean addedToEnergyNet = false;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS
|
|||
"getEnergyLevel", // 2
|
||||
"enableCloakingField", // 3 enables field if assembled right
|
||||
"disableCloakingField", // 4 disables cloaking field
|
||||
"setFieldFrequency" // 5 setFieldFrequency(int)
|
||||
"fieldFrequency" // 5 fieldFrequency(int)
|
||||
};
|
||||
|
||||
public boolean isEnabled = false;
|
||||
|
@ -169,7 +169,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS
|
|||
|
||||
for (int i = START_LENGTH + 1; i < WarpDriveConfig.i.CD_MAX_CLOAKING_FIELD_SIDE; i++) {
|
||||
if (worldObj.getBlockId(xCoord + i * dx, yCoord + i * dy, zCoord + i * dz) == WarpDriveConfig.i.cloakCoilID)
|
||||
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord + i * dx, yCoord + i * dy, zCoord + i * dz).add(0.5), r, g, b, 110, 0, 100);
|
||||
sendLaserPacket(new Vector3(this).translate(0.5), new Vector3(xCoord + i * dx, yCoord + i * dy, zCoord + i * dz).translate(0.5), r, g, b, 110, 0, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS
|
|||
g = 0f;
|
||||
}
|
||||
|
||||
sendLaserPacket(new Vector3(xCoord + START_LENGTH * dx[i], yCoord + START_LENGTH * dy[i], zCoord + START_LENGTH * dz[i]).add(0.5), new Vector3(xCoord + START_LENGTH * dx[j], yCoord + START_LENGTH * dy[j], zCoord + START_LENGTH * dz[j]).add(0.5), r, g, b, 110, 0, 100);
|
||||
sendLaserPacket(new Vector3(xCoord + START_LENGTH * dx[i], yCoord + START_LENGTH * dy[i], zCoord + START_LENGTH * dz[i]).translate(0.5), new Vector3(xCoord + START_LENGTH * dx[j], yCoord + START_LENGTH * dy[j], zCoord + START_LENGTH * dz[j]).translate(0.5), r, g, b, 110, 0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,47 +250,10 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS
|
|||
this.currentEnergyValue -= energyToConsume;
|
||||
}
|
||||
|
||||
public void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius) {
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (side == Side.SERVER) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try {
|
||||
// Write source vector
|
||||
outputStream.writeDouble(source.x);
|
||||
outputStream.writeDouble(source.y);
|
||||
outputStream.writeDouble(source.z);
|
||||
// Write target vector
|
||||
outputStream.writeDouble(dest.x);
|
||||
outputStream.writeDouble(dest.y);
|
||||
outputStream.writeDouble(dest.z);
|
||||
// Write r, g, b of laser
|
||||
outputStream.writeFloat(r);
|
||||
outputStream.writeFloat(g);
|
||||
outputStream.writeFloat(b);
|
||||
// Write age
|
||||
outputStream.writeByte(age);
|
||||
// Write energy value
|
||||
outputStream.writeInt(energy);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "WarpDriveBeam";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
// Send packet to all players within cloaked area
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
for (Entity e : list) {
|
||||
if (e != null && e instanceof EntityPlayer) {
|
||||
((EntityPlayerMP)e).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean shouldChunkLoad()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -392,14 +355,18 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS
|
|||
int method, Object[] arguments) throws Exception {
|
||||
switch (method) {
|
||||
case 0: // setFieldTier(1 or 2)
|
||||
if (arguments.length == 1) {
|
||||
if (((Double)arguments[0]).byteValue() != 1 && ((Double)arguments[0]).byteValue() != 2) {
|
||||
this.tier = 1;
|
||||
} else
|
||||
this.tier = ((Double)arguments[0]).byteValue();
|
||||
try
|
||||
{
|
||||
if (arguments.length >= 1)
|
||||
{
|
||||
tier = (byte) clamp(toInt(arguments[0]),1,2);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
tier = 1;
|
||||
}
|
||||
return new Object[] { tier };
|
||||
case 1: // isAssemblyValid()
|
||||
return new Object[] { (boolean)validateAssembly() };
|
||||
|
||||
|
@ -408,25 +375,33 @@ public class TileEntityCloakingDeviceCore extends TileEntity implements IEnergyS
|
|||
|
||||
case 3: // enableCloakingField()
|
||||
this.isEnabled = true;
|
||||
break;
|
||||
return new Object[] { true };
|
||||
|
||||
case 4: // disableCloakingField()
|
||||
disableCloakingField();
|
||||
setCoilsState(false);
|
||||
break;
|
||||
return new Object[] { false };
|
||||
|
||||
case 5: // setFieldFrequency(int)
|
||||
if (arguments.length == 1) {
|
||||
if (isEnabled)
|
||||
disableCloakingField();
|
||||
|
||||
if (WarpDrive.instance.cloaks.isAreaExists(((Double)arguments[0]).intValue()))
|
||||
return new Object[] { (Boolean)false };
|
||||
|
||||
this.frequency = ((Double)arguments[0]).intValue();
|
||||
return new Object[] { (Boolean)true };
|
||||
if (arguments.length == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isEnabled)
|
||||
disableCloakingField();
|
||||
|
||||
if (WarpDrive.instance.cloaks.isAreaExists(toInt(arguments[0])))
|
||||
return new Object[] { this.frequency };
|
||||
|
||||
this.frequency = toInt(arguments[0]);
|
||||
return new Object[] { this.frequency };
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
return new Object[] { false };
|
||||
}
|
||||
}
|
||||
break;
|
||||
return new Object[] { this.frequency };
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -36,7 +36,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class TileEntityLaser extends TileEntity implements IPeripheral
|
||||
public class TileEntityLaser extends TileEntityAbstractLaser implements IPeripheral
|
||||
{
|
||||
private int dx, dz, dy;
|
||||
public float yaw, pitch; // laser direction
|
||||
|
@ -103,11 +103,11 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
if (isEmitting)
|
||||
{
|
||||
energyFromOtherBeams += amount;
|
||||
System.out.println("[LE] Added energy: " + amount);
|
||||
WarpDrive.debugPrint("[LE] Added energy: " + amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("[LE] Ignored energy: " + amount);
|
||||
WarpDrive.debugPrint("[LE] Ignored energy: " + amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
{
|
||||
// Beam power calculations
|
||||
int beamLengthBlocks = energy / WarpDriveConfig.i.LE_BEAM_LENGTH_PER_ENERGY_DIVIDER;
|
||||
System.out.println("Energy: " + energy + " | beamLengthBlocks: " + beamLengthBlocks);
|
||||
WarpDrive.debugPrint("Energy: " + energy + " | beamLengthBlocks: " + beamLengthBlocks);
|
||||
|
||||
if (energy == 0 || beamLengthBlocks < 1)
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
}
|
||||
|
||||
Vector3 beamVector = new Vector3(this).add(0.5);
|
||||
System.out.println("beamVector: " + beamVector);
|
||||
WarpDrive.debugPrint("beamVector: " + beamVector);
|
||||
float yawz = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float yawx = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float pitchhorizontal = -MathHelper.cos(-pitch * 0.017453292F);
|
||||
|
@ -161,9 +161,9 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
Vector3 lookVector = new Vector3((double) directionx, (double) pitchvertical, (double) directionz);
|
||||
Vector3.translate(beamVector, lookVector);
|
||||
Vector3 reachPoint = beamVector.clone().translate(beamVector.clone(), beamVector.clone().scale(lookVector.clone(), beamLengthBlocks));
|
||||
System.out.println("Look vector: " + lookVector);
|
||||
System.out.println("reachPoint: " + reachPoint);
|
||||
System.out.println("translatedBeamVector: " + beamVector);
|
||||
WarpDrive.debugPrint("Look vector: " + lookVector);
|
||||
WarpDrive.debugPrint("reachPoint: " + reachPoint);
|
||||
WarpDrive.debugPrint("translatedBeamVector: " + beamVector);
|
||||
Vector3 endPoint = reachPoint.clone();
|
||||
playSoundCorrespondsEnergy(energy);
|
||||
|
||||
|
@ -189,11 +189,11 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
|
||||
if (entityHit == null)
|
||||
{
|
||||
System.out.println("Entity hit is null.");
|
||||
WarpDrive.debugPrint("Entity hit is null.");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Entity hit: " + entityHit);
|
||||
WarpDrive.debugPrint("Entity hit: " + entityHit);
|
||||
}
|
||||
|
||||
if (entityHit != null && entityHit.entityHit instanceof EntityLivingBase)
|
||||
|
@ -425,7 +425,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
public void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
@ -497,7 +497,7 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
packet.length = bos.size();
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(dest.intX(), dest.intY(), dest.intZ(), radius, worldObj.provider.dimensionId, packet);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
private void playSoundCorrespondsEnergy(int energy)
|
||||
{
|
||||
|
@ -701,6 +701,12 @@ public class TileEntityLaser extends TileEntity implements IPeripheral
|
|||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(xCoord, yCoord, zCoord, 100, worldObj.provider.dimensionId, packet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldChunkLoad()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttachToSide(int side)
|
||||
|
|
|
@ -27,7 +27,7 @@ import net.minecraft.util.AxisAlignedBB;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class TileEntityLift extends TileEntity implements IEnergySink
|
||||
public class TileEntityLift extends TileEntityAbstractLaser implements IEnergySink
|
||||
{
|
||||
public boolean addedToEnergyNet = false;
|
||||
|
||||
|
@ -36,11 +36,23 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
|
||||
private int mode = 0; // 0 - inactive, 1 - up, 2 - down
|
||||
private int firstUncoveredY;
|
||||
private Vector3 firstUncoveredYVec;
|
||||
private Vector3 myVector;
|
||||
|
||||
private boolean isEnabled = false;
|
||||
|
||||
int ticks = 0;
|
||||
|
||||
public TileEntityLift()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
private void sendLaser(float r,float g,float b, int age, int energy, int rad)
|
||||
{
|
||||
sendLaserPacket(myVector,firstUncoveredYVec,r,g,b,age,energy,rad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
@ -54,6 +66,9 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
addedToEnergyNet = true;
|
||||
}
|
||||
if(ticks % 8 == 0)
|
||||
if(isEnabled)
|
||||
liftEntity();
|
||||
|
||||
if (++ticks > 40)
|
||||
{
|
||||
|
@ -89,6 +104,8 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
if (!worldObj.isAirBlock(xCoord, ny, zCoord))
|
||||
{
|
||||
firstUncoveredY = ny;
|
||||
myVector = new Vector3(this).translate(0.5);
|
||||
firstUncoveredYVec = new Vector3(xCoord,ny,zCoord).translate(0.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -96,11 +113,13 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
if (yCoord - firstUncoveredY > 0)
|
||||
if (mode == 1)
|
||||
{
|
||||
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).add(0.5), 0f, 1f, 0f, 40, 0, 100);
|
||||
sendLaser(0f,1f,0f,40,0,100);
|
||||
//sendLaserPacket(new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5), 0f, 1f, 0f, 40, 0, 100);
|
||||
}
|
||||
else if (mode == 2)
|
||||
{
|
||||
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).add(0.5), 0f, 0f, 1f, 40, 0, 100);
|
||||
sendLaser(0f,0f,1f,40,0,100);
|
||||
sendLaserPacket(new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5), 0f, 0f, 1f, 40, 0, 100);
|
||||
}
|
||||
|
||||
liftEntity();
|
||||
|
@ -140,11 +159,11 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
zmin = z2;
|
||||
zmax = z1;
|
||||
}
|
||||
|
||||
double errorMargin = 0.1;
|
||||
// Lift up
|
||||
if (mode == 1)
|
||||
{
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin + 0.3, firstUncoveredY, zmin + 0.3, xmax - 0.3, yCoord, zmax - 0.3);
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin + errorMargin, firstUncoveredY, zmin + errorMargin, xmax - errorMargin, yCoord, zmax - errorMargin);
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb);
|
||||
|
||||
if (list != null) // up
|
||||
|
@ -154,7 +173,8 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
if (o != null && o instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, yCoord + 1, zCoord + 0.5f);
|
||||
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).add(0.5), 1, 1, 0, 40, 0, 100);
|
||||
sendLaser(1f,1f,0f,40,0,100);
|
||||
//sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).add(0.5), 1, 1, 0, 40, 0, 100);
|
||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
|
||||
currentEnergyValue = 0;
|
||||
return;
|
||||
|
@ -164,7 +184,7 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
}
|
||||
else if (mode == 2) // down
|
||||
{
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin + 0.3, yCoord, zmin + 0.3, xmax - 0.3, yCoord + 2, zmax - 0.3);
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin + errorMargin, yCoord, zmin + errorMargin, xmax - errorMargin, yCoord + 2, zmax - errorMargin);
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb);
|
||||
|
||||
if (list != null)
|
||||
|
@ -174,7 +194,8 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
if (o != null && o instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, firstUncoveredY + 1, zCoord + 0.5f);
|
||||
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY + 1, zCoord).add(0.5), 1, 1, 0, 40, 0, 100);
|
||||
//sendLaserPacket(new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY + 1, zCoord).translate(0.5), 1, 1, 0, 40, 0, 100);
|
||||
sendLaser(1f,1f,0f,40,0,100);
|
||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
|
||||
currentEnergyValue = 0;
|
||||
return;
|
||||
|
@ -183,78 +204,11 @@ public class TileEntityLift extends TileEntity implements IEnergySink
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius)
|
||||
|
||||
@Override
|
||||
public boolean shouldChunkLoad()
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (side == Side.SERVER)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
// Write source vector
|
||||
outputStream.writeDouble(source.x);
|
||||
outputStream.writeDouble(source.y);
|
||||
outputStream.writeDouble(source.z);
|
||||
// Write target vector
|
||||
outputStream.writeDouble(dest.x);
|
||||
outputStream.writeDouble(dest.y);
|
||||
outputStream.writeDouble(dest.z);
|
||||
// Write r, g, b of laser
|
||||
outputStream.writeFloat(r);
|
||||
outputStream.writeFloat(g);
|
||||
outputStream.writeFloat(b);
|
||||
// Write age
|
||||
outputStream.writeByte(age);
|
||||
// Write energy value
|
||||
outputStream.writeInt(energy);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "WarpDriveBeam";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(source.intX(), source.intY(), source.intZ(), radius, worldObj.provider.dimensionId, packet);
|
||||
ByteArrayOutputStream bos2 = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream2 = new DataOutputStream(bos2);
|
||||
|
||||
try
|
||||
{
|
||||
// Write source vector
|
||||
outputStream2.writeDouble(source.x);
|
||||
outputStream2.writeDouble(source.y);
|
||||
outputStream2.writeDouble(source.z);
|
||||
// Write target vector
|
||||
outputStream2.writeDouble(dest.x);
|
||||
outputStream2.writeDouble(dest.y);
|
||||
outputStream2.writeDouble(dest.z);
|
||||
// Write r, g, b of laser
|
||||
outputStream2.writeFloat(r);
|
||||
outputStream2.writeFloat(g);
|
||||
outputStream2.writeFloat(b);
|
||||
// Write age
|
||||
outputStream2.writeByte(age);
|
||||
// Write energy value
|
||||
outputStream2.writeInt(energy);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet2 = new Packet250CustomPayload();
|
||||
packet.channel = "WarpDriveBeam";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(dest.intX(), dest.intY(), dest.intZ(), radius, worldObj.provider.dimensionId, packet);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -115,14 +115,17 @@ public abstract class WarpChunkTE extends WarpTE
|
|||
|
||||
public ArrayList<ChunkCoordIntPair> getChunksFromCentre(ChunkCoordIntPair chunkA,ChunkCoordIntPair chunkB)
|
||||
{
|
||||
if(!shouldChunkLoad())
|
||||
return null;
|
||||
int minX = Math.min(chunkA.chunkXPos, chunkB.chunkXPos);
|
||||
int maxX = Math.max(chunkA.chunkXPos, chunkB.chunkXPos);
|
||||
int minZ = Math.min(chunkA.chunkZPos, chunkB.chunkZPos);
|
||||
int maxZ = Math.max(chunkA.chunkZPos, chunkB.chunkZPos);
|
||||
WarpDrive.debugPrint("From " + minX + "," + minZ + " to " + maxX + "," + maxZ);
|
||||
|
||||
int deltaX = 2 * ((maxX - minX + 1) / 2) + 1;
|
||||
int deltaZ = 2 * ((maxZ - minZ + 1) / 2) + 1;
|
||||
//REMOVE ODD SIZES
|
||||
int deltaX = (maxX - minX + 1);
|
||||
int deltaZ = (maxZ - minZ + 1);
|
||||
WarpDrive.debugPrint("Allocating Block: " + deltaX + "," + deltaZ);
|
||||
|
||||
maxX = minX + deltaX - 1;
|
||||
|
|
Loading…
Reference in a new issue