Finished update of data classes
This commit is contained in:
parent
c8b21e9b5c
commit
0df194b33a
3 changed files with 214 additions and 237 deletions
|
@ -3,40 +3,20 @@ package cr0s.warpdrive.data;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLeashKnot;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.item.EntityBoat;
|
||||
import net.minecraft.entity.item.EntityEnderCrystal;
|
||||
import net.minecraft.entity.item.EntityEnderEye;
|
||||
import net.minecraft.entity.item.EntityEnderPearl;
|
||||
import net.minecraft.entity.item.EntityExpBottle;
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.item.EntityPainting;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.passive.IAnimals;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntityEgg;
|
||||
import net.minecraft.entity.projectile.EntityFireball;
|
||||
import net.minecraft.entity.projectile.EntityFishHook;
|
||||
import net.minecraft.entity.projectile.EntityPotion;
|
||||
import net.minecraft.entity.projectile.EntitySmallFireball;
|
||||
import net.minecraft.entity.projectile.EntitySnowball;
|
||||
import net.minecraft.entity.projectile.EntityWitherSkull;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.sun.media.jfxmedia.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cr0s.warpdrive.PacketHandler;
|
||||
|
||||
/**
|
||||
* Cloak manager stores cloaking devices covered areas
|
||||
*
|
||||
* @author Cr0s
|
||||
*
|
||||
*/
|
||||
|
@ -69,8 +49,8 @@ public class CloakManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( area.aabb.minX <= (chunkPosX << 4 + 15) && area.aabb.maxX >= (chunkPosX << 4)
|
||||
&& area.aabb.minZ <= (chunkPosZ << 4 + 15) && area.aabb.maxZ >= (chunkPosZ << 4) ) {
|
||||
if (area.aabb.minX <= (chunkPosX << 4 + 15) && area.aabb.maxX >= (chunkPosX << 4) && area.aabb.minZ <= (chunkPosZ << 4 + 15)
|
||||
&& area.aabb.maxZ >= (chunkPosZ << 4)) {
|
||||
PacketHandler.sendCloakPacket(player, area.aabb, area.tier, false);
|
||||
}
|
||||
}
|
||||
|
@ -89,8 +69,14 @@ public class CloakManager {
|
|||
public void removeCloakedArea(World worldObj, int x, int y, int z) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < this.cloaks.size(); i++) {
|
||||
if (this.cloaks.get(i).coreX == x && this.cloaks.get(i).coreY == y && this.cloaks.get(i).coreZ == z && this.cloaks.get(i).dimensionId == worldObj.provider.dimensionId) {
|
||||
this.cloaks.get(i).sendCloakPacketToPlayersEx(true); // send info about collapsing cloaking field
|
||||
if (this.cloaks.get(i).coreX == x && this.cloaks.get(i).coreY == y && this.cloaks.get(i).coreZ == z
|
||||
&& this.cloaks.get(i).dimensionId == worldObj.provider.dimensionId) {
|
||||
this.cloaks.get(i).sendCloakPacketToPlayersEx(true); // send
|
||||
// info
|
||||
// about
|
||||
// collapsing
|
||||
// cloaking
|
||||
// field
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
@ -116,7 +102,7 @@ public class CloakManager {
|
|||
|
||||
public static Packet getPacketForThisEntity(Entity e) {
|
||||
if (e.isDead) {
|
||||
e.worldObj.getWorldLogAgent().logWarning("Fetching addPacket for removed entity");
|
||||
Logger.logMsg(Logger.WARNING, "Fetching addPacket for removed entity");
|
||||
}
|
||||
|
||||
Packet pkt = FMLNetworkHandler.getEntitySpawningPacket(e);
|
||||
|
@ -124,91 +110,81 @@ public class CloakManager {
|
|||
return pkt;
|
||||
}
|
||||
|
||||
if (e instanceof EntityItem) {
|
||||
return new Packet23VehicleSpawn(e, 2, 1);
|
||||
} else if (e instanceof EntityPlayerMP) {
|
||||
return new Packet20NamedEntitySpawn((EntityPlayer)e);
|
||||
} else if (e instanceof EntityMinecart) {
|
||||
EntityMinecart entityminecart = (EntityMinecart)e;
|
||||
return new Packet23VehicleSpawn(e, 10, entityminecart.getMinecartType());
|
||||
} else if (e instanceof EntityBoat) {
|
||||
return new Packet23VehicleSpawn(e, 1);
|
||||
} else if (!(e instanceof IAnimals) && !(e instanceof EntityDragon)) {
|
||||
if (e instanceof EntityFishHook) {
|
||||
EntityPlayer entityplayer = ((EntityFishHook)e).angler;
|
||||
return new Packet23VehicleSpawn(e, 90, entityplayer != null ? entityplayer.entityId : e.entityId);
|
||||
} else if (e instanceof EntityArrow) {
|
||||
Entity entity = ((EntityArrow)e).shootingEntity;
|
||||
return new Packet23VehicleSpawn(e, 60, entity != null ? entity.entityId : e.entityId);
|
||||
} else if (e instanceof EntitySnowball) {
|
||||
return new Packet23VehicleSpawn(e, 61);
|
||||
} else if (e instanceof EntityPotion) {
|
||||
return new Packet23VehicleSpawn(e, 73, ((EntityPotion)e).getPotionDamage());
|
||||
} else if (e instanceof EntityExpBottle) {
|
||||
return new Packet23VehicleSpawn(e, 75);
|
||||
} else if (e instanceof EntityEnderPearl) {
|
||||
return new Packet23VehicleSpawn(e, 65);
|
||||
} else if (e instanceof EntityEnderEye) {
|
||||
return new Packet23VehicleSpawn(e, 72);
|
||||
} else if (e instanceof EntityFireworkRocket) {
|
||||
return new Packet23VehicleSpawn(e, 76);
|
||||
} else {
|
||||
Packet23VehicleSpawn packet23vehiclespawn;
|
||||
return null;
|
||||
|
||||
if (e instanceof EntityFireball) {
|
||||
EntityFireball entityfireball = (EntityFireball)e;
|
||||
packet23vehiclespawn = null;
|
||||
byte b0 = 63;
|
||||
|
||||
if (e instanceof EntitySmallFireball) {
|
||||
b0 = 64;
|
||||
} else if (e instanceof EntityWitherSkull) {
|
||||
b0 = 66;
|
||||
}
|
||||
|
||||
if (entityfireball.shootingEntity != null) {
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, ((EntityFireball)e).shootingEntity.entityId);
|
||||
} else {
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, 0);
|
||||
}
|
||||
|
||||
packet23vehiclespawn.speedX = (int)(entityfireball.accelerationX * 8000.0D);
|
||||
packet23vehiclespawn.speedY = (int)(entityfireball.accelerationY * 8000.0D);
|
||||
packet23vehiclespawn.speedZ = (int)(entityfireball.accelerationZ * 8000.0D);
|
||||
return packet23vehiclespawn;
|
||||
} else if (e instanceof EntityEgg) {
|
||||
return new Packet23VehicleSpawn(e, 62);
|
||||
} else if (e instanceof EntityTNTPrimed) {
|
||||
return new Packet23VehicleSpawn(e, 50);
|
||||
} else if (e instanceof EntityEnderCrystal) {
|
||||
return new Packet23VehicleSpawn(e, 51);
|
||||
} else if (e instanceof EntityFallingSand) {
|
||||
EntityFallingSand entityfallingsand = (EntityFallingSand)e;
|
||||
return new Packet23VehicleSpawn(e, 70, entityfallingsand.blockID | entityfallingsand.metadata << 16);
|
||||
} else if (e instanceof EntityPainting) {
|
||||
return new Packet25EntityPainting((EntityPainting)e);
|
||||
} else if (e instanceof EntityItemFrame) {
|
||||
EntityItemFrame entityitemframe = (EntityItemFrame)e;
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, 71, entityitemframe.hangingDirection);
|
||||
packet23vehiclespawn.xPosition = MathHelper.floor_float(entityitemframe.xPosition * 32);
|
||||
packet23vehiclespawn.yPosition = MathHelper.floor_float(entityitemframe.yPosition * 32);
|
||||
packet23vehiclespawn.zPosition = MathHelper.floor_float(entityitemframe.zPosition * 32);
|
||||
return packet23vehiclespawn;
|
||||
} else if (e instanceof EntityLeashKnot) {
|
||||
EntityLeashKnot entityleashknot = (EntityLeashKnot)e;
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, 77);
|
||||
packet23vehiclespawn.xPosition = MathHelper.floor_float(entityleashknot.xPosition * 32);
|
||||
packet23vehiclespawn.yPosition = MathHelper.floor_float(entityleashknot.yPosition * 32);
|
||||
packet23vehiclespawn.zPosition = MathHelper.floor_float(entityleashknot.zPosition * 32);
|
||||
return packet23vehiclespawn;
|
||||
} else if (e instanceof EntityXPOrb) {
|
||||
return new Packet26EntityExpOrb((EntityXPOrb)e);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don\'t know how to add " + e.getClass() + "!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return new Packet24MobSpawn((EntityLivingBase)e);
|
||||
}
|
||||
// TODO: Major, redo networking
|
||||
/*
|
||||
* if (e instanceof EntityItem) { return new Packet23VehicleSpawn(e, 2,
|
||||
* 1); } else if (e instanceof EntityPlayerMP) { return new
|
||||
* Packet20NamedEntitySpawn((EntityPlayer) e); } else if (e instanceof
|
||||
* EntityMinecart) { EntityMinecart entityminecart = (EntityMinecart) e;
|
||||
* return new Packet23VehicleSpawn(e, 10,
|
||||
* entityminecart.getMinecartType()); } else if (e instanceof
|
||||
* EntityBoat) { return new Packet23VehicleSpawn(e, 1); } else if (!(e
|
||||
* instanceof IAnimals) && !(e instanceof EntityDragon)) { if (e
|
||||
* instanceof EntityFishHook) { EntityPlayer entityplayer =
|
||||
* ((EntityFishHook) e).angler; return new Packet23VehicleSpawn(e, 90,
|
||||
* entityplayer != null ? entityplayer.entityId : e.entityId); } else if
|
||||
* (e instanceof EntityArrow) { Entity entity = ((EntityArrow)
|
||||
* e).shootingEntity; return new Packet23VehicleSpawn(e, 60, entity !=
|
||||
* null ? entity.entityId : e.entityId); } else if (e instanceof
|
||||
* EntitySnowball) { return new Packet23VehicleSpawn(e, 61); } else if
|
||||
* (e instanceof EntityPotion) { return new Packet23VehicleSpawn(e, 73,
|
||||
* ((EntityPotion) e).getPotionDamage()); } else if (e instanceof
|
||||
* EntityExpBottle) { return new Packet23VehicleSpawn(e, 75); } else if
|
||||
* (e instanceof EntityEnderPearl) { return new Packet23VehicleSpawn(e,
|
||||
* 65); } else if (e instanceof EntityEnderEye) { return new
|
||||
* Packet23VehicleSpawn(e, 72); } else if (e instanceof
|
||||
* EntityFireworkRocket) { return new Packet23VehicleSpawn(e, 76); }
|
||||
* else { Packet23VehicleSpawn packet23vehiclespawn;
|
||||
*
|
||||
* if (e instanceof EntityFireball) { EntityFireball entityfireball =
|
||||
* (EntityFireball) e; packet23vehiclespawn = null; byte b0 = 63;
|
||||
*
|
||||
* if (e instanceof EntitySmallFireball) { b0 = 64; } else if (e
|
||||
* instanceof EntityWitherSkull) { b0 = 66; }
|
||||
*
|
||||
* if (entityfireball.shootingEntity != null) { packet23vehiclespawn =
|
||||
* new Packet23VehicleSpawn(e, b0, ((EntityFireball)
|
||||
* e).shootingEntity.entityId); } else { packet23vehiclespawn = new
|
||||
* Packet23VehicleSpawn(e, b0, 0); }
|
||||
*
|
||||
* packet23vehiclespawn.speedX = (int) (entityfireball.accelerationX *
|
||||
* 8000.0D); packet23vehiclespawn.speedY = (int)
|
||||
* (entityfireball.accelerationY * 8000.0D); packet23vehiclespawn.speedZ
|
||||
* = (int) (entityfireball.accelerationZ * 8000.0D); return
|
||||
* packet23vehiclespawn; } else if (e instanceof EntityEgg) { return new
|
||||
* Packet23VehicleSpawn(e, 62); } else if (e instanceof EntityTNTPrimed)
|
||||
* { return new Packet23VehicleSpawn(e, 50); } else if (e instanceof
|
||||
* EntityEnderCrystal) { return new Packet23VehicleSpawn(e, 51); } else
|
||||
* if (e instanceof EntityFallingSand) { EntityFallingSand
|
||||
* entityfallingsand = (EntityFallingSand) e; return new
|
||||
* Packet23VehicleSpawn(e, 70, entityfallingsand.blockID |
|
||||
* entityfallingsand.metadata << 16); } else if (e instanceof
|
||||
* EntityPainting) { return new Packet25EntityPainting((EntityPainting)
|
||||
* e); } else if (e instanceof EntityItemFrame) { EntityItemFrame
|
||||
* entityitemframe = (EntityItemFrame) e; packet23vehiclespawn = new
|
||||
* Packet23VehicleSpawn(e, 71, entityitemframe.hangingDirection);
|
||||
* packet23vehiclespawn.xPosition =
|
||||
* MathHelper.floor_float(entityitemframe.xPosition * 32);
|
||||
* packet23vehiclespawn.yPosition =
|
||||
* MathHelper.floor_float(entityitemframe.yPosition * 32);
|
||||
* packet23vehiclespawn.zPosition =
|
||||
* MathHelper.floor_float(entityitemframe.zPosition * 32); return
|
||||
* packet23vehiclespawn; } else if (e instanceof EntityLeashKnot) {
|
||||
* EntityLeashKnot entityleashknot = (EntityLeashKnot) e;
|
||||
* packet23vehiclespawn = new Packet23VehicleSpawn(e, 77);
|
||||
* packet23vehiclespawn.xPosition =
|
||||
* MathHelper.floor_float(entityleashknot.xPosition * 32);
|
||||
* packet23vehiclespawn.yPosition =
|
||||
* MathHelper.floor_float(entityleashknot.yPosition * 32);
|
||||
* packet23vehiclespawn.zPosition =
|
||||
* MathHelper.floor_float(entityleashknot.zPosition * 32); return
|
||||
* packet23vehiclespawn; } else if (e instanceof EntityXPOrb) { return
|
||||
* new Packet26EntityExpOrb((EntityXPOrb) e); } else { throw new
|
||||
* IllegalArgumentException("Don\'t know how to add " + e.getClass() +
|
||||
* "!"); } } } else { return new Packet24MobSpawn((EntityLivingBase) e);
|
||||
* }
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -21,7 +22,9 @@ public class CloakedArea {
|
|||
|
||||
public boolean isPlayerListedInArea(String username) {
|
||||
for (String playerInArea : playersInArea) {
|
||||
// WarpDrive.debugPrint("" + this + " Checking player: " + p.username + "(" + p.entityId + ")" + " =? " + player.username + " (" + p.entityId + ")");
|
||||
// WarpDrive.debugPrint("" + this + " Checking player: " +
|
||||
// p.username + "(" + p.entityId + ")" + " =? " + player.username +
|
||||
// " (" + p.entityId + ")");
|
||||
if (playerInArea.equals(username)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -46,8 +49,7 @@ public class CloakedArea {
|
|||
}
|
||||
|
||||
public boolean isEntityWithinArea(EntityLivingBase entity) {
|
||||
return (aabb.minX <= entity.posX && (aabb.maxX + 1) > entity.posX
|
||||
&& aabb.minY <= (entity.posY + entity.height) && (aabb.maxY + 1) > entity.posY
|
||||
return (aabb.minX <= entity.posX && (aabb.maxX + 1) > entity.posX && aabb.minY <= (entity.posY + entity.height) && (aabb.maxY + 1) > entity.posY
|
||||
&& aabb.minZ <= entity.posZ && (aabb.maxZ + 1) > entity.posZ);
|
||||
}
|
||||
|
||||
|
@ -70,7 +72,7 @@ public class CloakedArea {
|
|||
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, this.aabb);
|
||||
for (Entity e : list) {
|
||||
if (e instanceof EntityPlayer) {
|
||||
addPlayer(((EntityPlayer)e).username);
|
||||
addPlayer(((EntityPlayer) e).getDisplayName());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -87,7 +89,7 @@ public class CloakedArea {
|
|||
double midZ = this.aabb.minZ + (Math.abs(this.aabb.maxZ - this.aabb.minZ) / 2);
|
||||
|
||||
for (int j = 0; j < MinecraftServer.getServer().getConfigurationManager().playerEntityList.size(); j++) {
|
||||
EntityPlayerMP entityPlayerMP = (EntityPlayerMP)MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(j);
|
||||
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(j);
|
||||
|
||||
if (entityPlayerMP.dimension == dimensionId) {
|
||||
double d4 = midX - entityPlayerMP.posX;
|
||||
|
@ -112,48 +114,57 @@ public class CloakedArea {
|
|||
|
||||
public void updatePlayer(EntityPlayer player) {
|
||||
if (isEntityWithinArea(player)) {
|
||||
if (!isPlayerListedInArea(player.username)) {
|
||||
// WarpDrive.debugPrint("" + this + " Player " + player.username + " has entered");
|
||||
addPlayer(player.username);
|
||||
if (!isPlayerListedInArea(player.getDisplayName())) {
|
||||
// WarpDrive.debugPrint("" + this + " Player " + player.username
|
||||
// + " has entered");
|
||||
addPlayer(player.getDisplayName());
|
||||
revealChunksToPlayer(player);
|
||||
revealEntityToPlayer(player);
|
||||
PacketHandler.sendCloakPacket(player, aabb, tier, false);
|
||||
}
|
||||
} else {
|
||||
if (isPlayerListedInArea(player.username)) {
|
||||
// WarpDrive.debugPrint("" + this + " Player " + player.username + " has left");
|
||||
removePlayer(player.username);
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNearExcept(player, player.posX, player.posY, player.posZ, 100, player.worldObj.provider.dimensionId, CloakManager.getPacketForThisEntity(player));
|
||||
if (isPlayerListedInArea(player.getDisplayName())) {
|
||||
// WarpDrive.debugPrint("" + this + " Player " + player.username
|
||||
// + " has left");
|
||||
removePlayer(player.getDisplayName());
|
||||
MinecraftServer
|
||||
.getServer()
|
||||
.getConfigurationManager()
|
||||
.sendToAllNearExcept(player, player.posX, player.posY, player.posZ, 100, player.worldObj.provider.dimensionId,
|
||||
CloakManager.getPacketForThisEntity(player));
|
||||
PacketHandler.sendCloakPacket(player, aabb, tier, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void revealChunksToPlayer(EntityPlayer p) {
|
||||
// WarpDrive.debugPrint("" + this + " Revealing cloaked blocks to player " + p.username);
|
||||
int minY = (int) Math.max( 0, aabb.minY);
|
||||
// WarpDrive.debugPrint("" + this +
|
||||
// " Revealing cloaked blocks to player " + p.username);
|
||||
int minY = (int) Math.max(0, aabb.minY);
|
||||
int maxY = (int) Math.min(255, aabb.maxY);
|
||||
for (int x = (int)aabb.minX; x <= (int)aabb.maxX; x++) {
|
||||
for (int z = (int)aabb.minZ; z <= (int)aabb.maxZ; z++) {
|
||||
for (int x = (int) aabb.minX; x <= (int) aabb.maxX; x++) {
|
||||
for (int z = (int) aabb.minZ; z <= (int) aabb.maxZ; z++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
if (p.worldObj.getBlockId(x, y, z) != 0) {
|
||||
if (!p.worldObj.getBlock(x, y, z).isAssociatedBlock(Blocks.air)) {
|
||||
p.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*ArrayList<Chunk> chunksToSend = new ArrayList<Chunk>();
|
||||
|
||||
for (int x = (int)aabb.minX >> 4; x <= (int)aabb.maxX >> 4; x++)
|
||||
for (int z = (int)aabb.minZ >> 4; z <= (int)aabb.maxZ >> 4; z++) {
|
||||
chunksToSend.add(p.worldObj.getChunkFromChunkCoords(x, z));
|
||||
}
|
||||
|
||||
//System.outprintln("[Cloak] Sending " + chunksToSend.size() + " chunks to player " + p.username);
|
||||
((EntityPlayerMP)p).playerNetServerHandler.sendPacketToPlayer(new Packet56MapChunks(chunksToSend));
|
||||
|
||||
//System.outprintln("[Cloak] Sending decloak packet to player " + p.username);
|
||||
area.sendCloakPacketToPlayer(p, true); // decloak = true
|
||||
/*
|
||||
* ArrayList<Chunk> chunksToSend = new ArrayList<Chunk>();
|
||||
*
|
||||
* for (int x = (int)aabb.minX >> 4; x <= (int)aabb.maxX >> 4; x++) for
|
||||
* (int z = (int)aabb.minZ >> 4; z <= (int)aabb.maxZ >> 4; z++) {
|
||||
* chunksToSend.add(p.worldObj.getChunkFromChunkCoords(x, z)); }
|
||||
*
|
||||
* //System.outprintln("[Cloak] Sending " + chunksToSend.size() +
|
||||
* " chunks to player " + p.username);
|
||||
* ((EntityPlayerMP)p).playerNetServerHandler.sendPacketToPlayer(new
|
||||
* Packet56MapChunks(chunksToSend));
|
||||
*
|
||||
* //System.outprintln("[Cloak] Sending decloak packet to player " +
|
||||
* p.username); area.sendCloakPacketToPlayer(p, true); // decloak = true
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -161,16 +172,13 @@ public class CloakedArea {
|
|||
List<Entity> list = p.worldObj.getEntitiesWithinAABBExcludingEntity(p, aabb);
|
||||
|
||||
for (Entity e : list) {
|
||||
((EntityPlayerMP)p).playerNetServerHandler.sendPacketToPlayer(CloakManager.getPacketForThisEntity(e));
|
||||
((EntityPlayerMP) p).playerNetServerHandler.sendPacket(CloakManager.getPacketForThisEntity(e));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s @ DIM%d %d, %d, %d %s", new Object[] {
|
||||
getClass().getSimpleName(),
|
||||
Integer.valueOf(dimensionId),
|
||||
Integer.valueOf(coreX), Integer.valueOf(coreY), Integer.valueOf(coreZ),
|
||||
aabb.toString()});
|
||||
return String.format("%s @ DIM%d %d, %d, %d %s", new Object[] { getClass().getSimpleName(), Integer.valueOf(dimensionId), Integer.valueOf(coreX),
|
||||
Integer.valueOf(coreY), Integer.valueOf(coreZ), aabb.toString() });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ import cr0s.warpdrive.WarpDriveConfig;
|
|||
import cr0s.warpdrive.machines.TileEntityReactor;
|
||||
import cr0s.warpdrive.machines.TileEntityReactor.ReactorMode;
|
||||
|
||||
/** Registry of active Warp Cores in world
|
||||
/**
|
||||
* Registry of active Warp Cores in world
|
||||
*
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class WarpCoresRegistry {
|
||||
|
@ -69,7 +71,7 @@ public class WarpCoresRegistry {
|
|||
double dZ = core.zCoord - z;
|
||||
double distance2 = dX * dX + dY * dY + dZ * dZ;
|
||||
|
||||
if (distance2 <= radius2 && ! core.isHidden()) {
|
||||
if (distance2 <= radius2 && !core.isHidden()) {
|
||||
res.add(core);
|
||||
}
|
||||
}
|
||||
|
@ -82,8 +84,8 @@ public class WarpCoresRegistry {
|
|||
removeDeadCores();
|
||||
|
||||
for (TileEntityReactor core : registry) {
|
||||
WarpDrive.print("- Frequency '" + core.coreFrequency + "' @ '" + core.worldObj.provider.getDimensionName() + "' " + core.xCoord + ", " + core.yCoord + ", " + core.zCoord
|
||||
+ " with " + core.isolationBlocksCount + " isolation blocks");
|
||||
WarpDrive.print("- Frequency '" + core.coreFrequency + "' @ '" + core.getWorldObj().provider.getDimensionName() + "' " + core.xCoord + ", "
|
||||
+ core.yCoord + ", " + core.zCoord + " with " + core.isolationBlocksCount + " isolation blocks");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +99,7 @@ public class WarpCoresRegistry {
|
|||
|
||||
for (TileEntityReactor c : registry) {
|
||||
// Skip cores in other worlds
|
||||
if (c.worldObj != core.worldObj) {
|
||||
if (c.getWorldObj() != core.getWorldObj()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -135,8 +137,11 @@ public class WarpCoresRegistry {
|
|||
TileEntityReactor c;
|
||||
for (int i = registry.size() - 1; i >= 0; i--) {
|
||||
c = registry.get(i);
|
||||
if (c == null || c.worldObj == null || c.worldObj.getBlockId(c.xCoord, c.yCoord, c.zCoord) != WarpDriveConfig.coreID || c.worldObj.getBlockTileEntity(c.xCoord, c.yCoord, c.zCoord) != c || c.worldObj.getBlockTileEntity(c.xCoord, c.yCoord, c.zCoord).isInvalid()) {
|
||||
WarpDrive.debugPrint("Removing 'dead' core at " + ((c != null)? c.xCoord : "?") + ", " + ((c != null)? c.yCoord : "?") + ", " + ((c != null)? c.zCoord : "?"));
|
||||
if (c == null || c.getWorldObj() == null || c.getWorldObj().getBlock(c.xCoord, c.yCoord, c.zCoord) != WarpDrive.warpCore
|
||||
|| c.getWorldObj().getTileEntity(c.xCoord, c.yCoord, c.zCoord) != c
|
||||
|| c.getWorldObj().getTileEntity(c.xCoord, c.yCoord, c.zCoord).isInvalid()) {
|
||||
WarpDrive.debugPrint("Removing 'dead' core at " + ((c != null) ? c.xCoord : "?") + ", " + ((c != null) ? c.yCoord : "?") + ", "
|
||||
+ ((c != null) ? c.zCoord : "?"));
|
||||
registry.remove(i);
|
||||
}
|
||||
}
|
||||
|
@ -145,39 +150,27 @@ public class WarpCoresRegistry {
|
|||
}
|
||||
|
||||
// TODO: fix it to normal work in client
|
||||
/*public boolean isEntityInsideAnyWarpField(Entity e) {
|
||||
AxisAlignedBB aabb1, aabb2;
|
||||
|
||||
double x = e.posX;
|
||||
double y = e.posY;
|
||||
double z = e.posZ;
|
||||
|
||||
for (TileEntityReactor c : registry) {
|
||||
// Skip offline or disassembled warp cores
|
||||
if (c.controller == null || !c.prepareToJump()) {
|
||||
System.out.println("Skipping " + c);
|
||||
if (c.controller == null) {
|
||||
System.out.println("Controller is null!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c.controller.getMode() == 0) {
|
||||
System.out.println("Mode is zero!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!c.prepareToJump()) {
|
||||
System.out.println("prepareToJump() returns false!");
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c.minX <= x && c.maxX >= x && c.minY <= y && c.maxY >= y && c.minZ <= z && c.maxZ >= z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}*/
|
||||
/*
|
||||
* public boolean isEntityInsideAnyWarpField(Entity e) { AxisAlignedBB
|
||||
* aabb1, aabb2;
|
||||
*
|
||||
* double x = e.posX; double y = e.posY; double z = e.posZ;
|
||||
*
|
||||
* for (TileEntityReactor c : registry) { // Skip offline or disassembled
|
||||
* warp cores if (c.controller == null || !c.prepareToJump()) {
|
||||
* System.out.println("Skipping " + c); if (c.controller == null) {
|
||||
* System.out.println("Controller is null!"); continue; }
|
||||
*
|
||||
* if (c.controller.getMode() == 0) { System.out.println("Mode is zero!");
|
||||
* continue; }
|
||||
*
|
||||
* if (!c.prepareToJump()) {
|
||||
* System.out.println("prepareToJump() returns false!"); continue; }
|
||||
* continue; }
|
||||
*
|
||||
* if (c.minX <= x && c.maxX >= x && c.minY <= y && c.maxY >= y && c.minZ <=
|
||||
* z && c.maxZ >= z) { return true; } }
|
||||
*
|
||||
* return false; }
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue