commit
8aa3fe71e1
9 changed files with 153 additions and 180 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -161,4 +161,4 @@ pip-log.txt
|
|||
|
||||
# Mac crap
|
||||
.DS_Store
|
||||
src/cr0s/WarpDrive/client/ClientProxy.java
|
||||
|
||||
|
|
|
@ -9,20 +9,11 @@ import net.minecraftforge.event.world.ChunkWatchEvent;
|
|||
|
||||
public class CloakChunkWatcher {
|
||||
@ForgeSubscribe
|
||||
public void chunkLoaded(ChunkWatchEvent event)
|
||||
{
|
||||
EntityPlayerMP p = event.player;
|
||||
public void chunkLoaded(ChunkWatchEvent event) {
|
||||
ChunkCoordIntPair chunk = event.chunk;
|
||||
|
||||
// Check chunk for locating in cloaked areas
|
||||
ArrayList<CloakedArea> cloaks = WarpDrive.cloaks.getCloaksForPoint(p.worldObj.provider.dimensionId, chunk.getCenterXPos(), 0, chunk.getCenterZPosition(), true);
|
||||
if (cloaks.size() == 0)
|
||||
return;
|
||||
|
||||
//Chunk c = p.worldObj.getChunkFromChunkCoords(chunk.chunkXPos, chunk.chunkZPos);
|
||||
for (CloakedArea area : cloaks) {
|
||||
area.sendCloakPacketToPlayer(p, false);
|
||||
}
|
||||
WarpDrive.cloaks.checkChunkLoaded(event.player, chunk.chunkXPos, chunk.chunkZPos);
|
||||
|
||||
/*List<Chunk> list = new ArrayList<Chunk>();
|
||||
list.add(c);
|
||||
|
|
|
@ -570,59 +570,65 @@ public class EntityJump extends Entity
|
|||
*/
|
||||
private void saveShip(int shipSize) {
|
||||
LocalProfiler.start("EntityJump.saveShip");
|
||||
ship = new JumpBlock[shipSize];
|
||||
|
||||
if (ship == null) {
|
||||
killEntity("Unable to allocate memory (ship is null!)");
|
||||
LocalProfiler.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
int xc1 = minX >> 4;
|
||||
int xc2 = maxX >> 4;
|
||||
int zc1 = minZ >> 4;
|
||||
int zc2 = maxZ >> 4;
|
||||
|
||||
for (int xc = xc1; xc <= xc2; xc++)
|
||||
{
|
||||
int x1 = Math.max(minX, xc << 4);
|
||||
int x2 = Math.min(maxX, (xc << 4) + 15);
|
||||
|
||||
for (int zc = zc1; zc <= zc2; zc++)
|
||||
{
|
||||
int z1 = Math.max(minZ, zc << 4);
|
||||
int z2 = Math.min(maxZ, (zc << 4) + 15);
|
||||
|
||||
for (int y = minY; y <= maxY; y++)
|
||||
{
|
||||
for (int x = x1; x <= x2; x++)
|
||||
{
|
||||
for (int z = z1; z <= z2; z++)
|
||||
{
|
||||
int blockID = worldObj.getBlockId(x, y, z);
|
||||
|
||||
// Skip air blocks
|
||||
if (worldObj.isAirBlock(x, y, z) && (blockID != WarpDriveConfig.airID))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int blockMeta = worldObj.getBlockMetadata(x, y, z);
|
||||
TileEntity tileentity = worldObj.getBlockTileEntity(x, y, z);
|
||||
ship[index] = new JumpBlock(blockID, blockMeta, tileentity, x, y, z);
|
||||
if (ship[index] == null)
|
||||
{
|
||||
WarpDrive.debugPrint("" + this + " Unable to allocate memory (ship[" + index + "] is null!)");
|
||||
}
|
||||
try {
|
||||
int reactorChamber = WarpDriveConfig.isICLoaded ? WarpDriveConfig.getIC2Item("reactorChamber").itemID : 0;
|
||||
|
||||
ship = new JumpBlock[shipSize];
|
||||
JumpBlock placeAfter[] = new JumpBlock[shipSize]; // blocks and tile entities to be placed at the end, and removed first
|
||||
|
||||
int indexPlaceNormal = 0;
|
||||
int indexPlaceAfter = 0;
|
||||
int xc1 = minX >> 4;
|
||||
int xc2 = maxX >> 4;
|
||||
int zc1 = minZ >> 4;
|
||||
int zc2 = maxZ >> 4;
|
||||
|
||||
for (int xc = xc1; xc <= xc2; xc++) {
|
||||
int x1 = Math.max(minX, xc << 4);
|
||||
int x2 = Math.min(maxX, (xc << 4) + 15);
|
||||
|
||||
for (int zc = zc1; zc <= zc2; zc++) {
|
||||
int z1 = Math.max(minZ, zc << 4);
|
||||
int z2 = Math.min(maxZ, (zc << 4) + 15);
|
||||
|
||||
index++;
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
int blockID = worldObj.getBlockId(x, y, z);
|
||||
|
||||
// Skip air blocks
|
||||
if (worldObj.isAirBlock(x, y, z) && (blockID != WarpDriveConfig.airID)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int blockMeta = worldObj.getBlockMetadata(x, y, z);
|
||||
TileEntity tileEntity = worldObj.getBlockTileEntity(x, y, z);
|
||||
JumpBlock jumpBlock = new JumpBlock(blockID, blockMeta, tileEntity, x, y, z);
|
||||
|
||||
if (tileEntity == null || blockID != reactorChamber) {
|
||||
ship[indexPlaceNormal] = jumpBlock;
|
||||
indexPlaceNormal++;
|
||||
} else {
|
||||
placeAfter[indexPlaceAfter] = jumpBlock;
|
||||
indexPlaceAfter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = 0; index < indexPlaceAfter; index++) {
|
||||
ship[indexPlaceNormal] = placeAfter[index];
|
||||
indexPlaceNormal++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
killEntity("Exception during jump preparation (saveShip)!");
|
||||
LocalProfiler.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WarpDrive.debugPrint("" + this + " Ship saved as " + ship.length + " blocks");
|
||||
LocalProfiler.stop();
|
||||
}
|
||||
|
@ -1126,9 +1132,7 @@ public class EntityJump extends Entity
|
|||
}
|
||||
|
||||
NBTTagCompound oldnbt = new NBTTagCompound();
|
||||
// 145 Anvil, 146 Trapped chest, 149 inactive redstone comparator, 156 Quartz stair, 159 Stained clay
|
||||
if (shipBlock.blockTileEntity != null && blockID != 159 && blockID != 149 && blockID != 156 && blockID != 146 && blockID != 145)
|
||||
{
|
||||
if (shipBlock.blockTileEntity != null) {
|
||||
shipBlock.blockTileEntity.writeToNBT(oldnbt);
|
||||
oldnbt.setInteger("x", newX);
|
||||
oldnbt.setInteger("y", newY);
|
||||
|
|
|
@ -62,8 +62,9 @@ public class PacketHandler implements IPacketHandler
|
|||
|
||||
//WarpDrive.debugPrint("[Cloak Packet] Received " + ((decloak) ? "DEcloaked" : "cloaked") + "area: (" + minX + "; " + minY + "; " + minZ + ") -> (" + maxX + "; " + maxY + "; " + maxZ + ")");
|
||||
|
||||
if (minX <= player.posX && maxX >= player.posY && minY <= player.posZ && maxY >= player.posX && minZ <= player.posY && maxZ >= player.posZ)
|
||||
if (minX <= player.posX && (maxX + 1) > player.posY && minY <= player.posZ && (maxY + 1) > player.posX && minZ <= player.posY && (maxZ + 1) > player.posZ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide the area
|
||||
if (!decloak) {
|
||||
|
@ -73,7 +74,9 @@ public class PacketHandler implements IPacketHandler
|
|||
World worldObj = player.worldObj;
|
||||
int cloakBlockID = (tier == 1) ? WarpDriveConfig.gasID : 0;
|
||||
int cloakBlockMetadata = (tier == 1) ? 5 : 0;
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
int minYmap = Math.max( 0, minY);
|
||||
int maxYmap = Math.min(255, maxY);
|
||||
for (int y = minYmap; y <= maxYmap; y++) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for(int z = minZ; z <= maxZ; z++) {
|
||||
if (worldObj.getBlockId(x, y, z) != 0) {
|
||||
|
@ -85,14 +88,14 @@ public class PacketHandler implements IPacketHandler
|
|||
|
||||
//WarpDrive.debugPrint("[Cloak Packet] Removing entity...");
|
||||
// Hide any entities inside area
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1);
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(player, aabb);
|
||||
for (Entity e : list) {
|
||||
worldObj.removeEntity(e);
|
||||
((WorldClient)worldObj).removeEntityFromWorld(e.entityId);
|
||||
}
|
||||
} else { // reveal the area
|
||||
player.worldObj.markBlockRangeForRenderUpdate(minX + 1, minY + 1, minZ + 1, maxX + 1, maxY + 1, maxZ + 1);
|
||||
player.worldObj.markBlockRangeForRenderUpdate(minX - 1, Math.max(0, minY - 1), minZ - 1, maxX + 1, Math.min(255, maxY + 1), maxZ + 1);
|
||||
|
||||
// Make some graphics
|
||||
int numLasers = 80 + player.worldObj.rand.nextInt(50);
|
||||
|
|
|
@ -191,19 +191,7 @@ public class SpaceEventHandler {
|
|||
if (cloakTicks >= CLOAK_CHECK_TIMEOUT_TICKS) {
|
||||
player_cloakTicks.put(player.username, 0);
|
||||
|
||||
List<CloakedArea> cloaks = WarpDrive.cloaks.getCloaksForPoint(player.worldObj.provider.dimensionId, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), false);
|
||||
if (cloaks.size() != 0) {
|
||||
//WarpDrive.debugPrint("[Cloak] Player inside " + cloaks.size() + " cloaked areas");
|
||||
for (CloakedArea area : cloaks) {
|
||||
//WarpDrive.debugPrint("[Cloak] Frequency: " + area.frequency + ". In: " + area.isPlayerInArea(p) + ", W: " + area.isPlayerWithinArea(p));
|
||||
if (!area.isPlayerInArea(player.username) && area.isEntityWithinArea(player)) {
|
||||
area.playerEnteringCloakedArea(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//WarpDrive.debugPrint("[Cloak] Player is not inside any cloak fields. Check, which field player may left...");
|
||||
WarpDrive.cloaks.checkPlayerLeftArea(player);
|
||||
}
|
||||
WarpDrive.cloaks.updatePlayer(player);
|
||||
} else {
|
||||
player_cloakTicks.put(player.username, cloakTicks + 1);
|
||||
}
|
||||
|
|
20
src/cr0s/WarpDrive/client/ClientProxy.java
Normal file
20
src/cr0s/WarpDrive/client/ClientProxy.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package cr0s.WarpDrive.client;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cr0s.WarpDrive.CommonProxy;
|
||||
import cr0s.WarpDrive.render.FXBeam;
|
||||
import cr0s.WarpDrive.data.Vector3;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void registerRenderers() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBeam(World world, Vector3 position, Vector3 target, float red, float green, float blue, int age, int energy) {
|
||||
// WarpDrive.debugPrint("Rendering beam...");
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXBeam(world, position, target, red, green, blue, age, energy));
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.data.CloakedArea;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLeashKnot;
|
||||
|
@ -64,14 +65,13 @@ public class CloakManager {
|
|||
this.cloaks = new LinkedList<CloakedArea>();
|
||||
}
|
||||
|
||||
public boolean isInCloak(int dimensionID, int x, int y, int z, boolean chunk) {
|
||||
for (int i = 0; i < this.cloaks.size(); i++) {
|
||||
if (this.cloaks.get(i).dimensionId != dimensionID)
|
||||
public boolean isCloaked(int dimensionID, int x, int y, int z) {
|
||||
for (CloakedArea area : this.cloaks) {
|
||||
if (area.dimensionId != dimensionID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AxisAlignedBB axisalignedbb = this.cloaks.get(i).aabb;
|
||||
|
||||
if (axisalignedbb.minX <= x && axisalignedbb.maxX >= x && (chunk || (axisalignedbb.minY <= y && axisalignedbb.maxY >= y)) && axisalignedbb.minZ <= z && axisalignedbb.maxZ >= z) {
|
||||
if (area.aabb.minX <= x && area.aabb.maxX >= x && area.aabb.minY <= y && area.aabb.maxY >= y && area.aabb.minZ <= z && area.aabb.maxZ >= z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -79,20 +79,19 @@ public class CloakManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public ArrayList<CloakedArea> getCloaksForPoint(int dimensionID, int x, int y, int z, boolean chunk) {
|
||||
ArrayList<CloakedArea> res = new ArrayList<CloakedArea>();
|
||||
|
||||
for (int i = 0; i < this.cloaks.size(); i++) {
|
||||
if (this.cloaks.get(i).dimensionId != dimensionID)
|
||||
public boolean checkChunkLoaded(EntityPlayerMP player, int chunkPosX, int chunkPosZ) {
|
||||
for (CloakedArea area : this.cloaks) {
|
||||
if (area.dimensionId != player.worldObj.provider.dimensionId) {
|
||||
continue;
|
||||
|
||||
AxisAlignedBB axisalignedbb = this.cloaks.get(i).aabb;
|
||||
if (axisalignedbb.minX <= x && axisalignedbb.maxX >= x && (chunk || (axisalignedbb.minY <= y && axisalignedbb.maxY >= y)) && axisalignedbb.minZ <= z && axisalignedbb.maxZ >= z) {
|
||||
res.add(cloaks.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
if ( area.aabb.minX <= (chunkPosX << 4 + 15) && area.aabb.maxX >= (chunkPosX << 4)
|
||||
&& area.aabb.minZ <= (chunkPosZ << 4 + 15) && area.aabb.maxZ >= (chunkPosZ << 4) ) {
|
||||
area.sendCloakPacketToPlayer(player, false);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAreaExists(World worldObj, int x, int y, int z) {
|
||||
|
@ -105,13 +104,13 @@ 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++){
|
||||
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
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cloaks.remove(index);
|
||||
}
|
||||
|
@ -125,14 +124,9 @@ public class CloakManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void checkPlayerLeftArea(EntityPlayer player) {
|
||||
public void updatePlayer(EntityPlayer player) {
|
||||
for (CloakedArea area : this.cloaks) {
|
||||
if (!area.isEntityWithinArea(player) && area.isPlayerInArea(player.username)) {
|
||||
area.removePlayer(player.username);
|
||||
//System.outprintln("[Cloak] Player " + p.username + " has leaved cloaked area " + area.frequency);
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNearExcept(player, player.posX, player.posY, player.posZ, 100, player.worldObj.provider.dimensionId, getPacketForThisEntity(player));
|
||||
area.sendCloakPacketToPlayer(player, false);
|
||||
}
|
||||
area.updatePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.util.List;
|
|||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
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.util.AxisAlignedBB;
|
||||
|
@ -24,17 +26,18 @@ public class CloakedArea {
|
|||
private LinkedList<String> playersInArea;
|
||||
public byte tier = 0;
|
||||
|
||||
public boolean isPlayerInArea(String username) {
|
||||
public boolean isPlayerListedInArea(String username) {
|
||||
for (String playerInArea : playersInArea) {
|
||||
//System.outprintln("[Cloak] Checking player: " + p.username + "(" + p.entityId + ")" + " =? " + player.username + " (" + p.entityId + ")");
|
||||
if (playerInArea.equals(username))
|
||||
//WarpDrive.debugPrint("" + this + " Checking player: " + p.username + "(" + p.entityId + ")" + " =? " + player.username + " (" + p.entityId + ")");
|
||||
if (playerInArea.equals(username)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removePlayer(String username) {
|
||||
private void removePlayer(String username) {
|
||||
for (int i = 0; i < playersInArea.size(); i++) {
|
||||
if (playersInArea.get(i).equals(username)) {
|
||||
playersInArea.remove(i);
|
||||
|
@ -43,14 +46,16 @@ public class CloakedArea {
|
|||
}
|
||||
}
|
||||
|
||||
public void addPlayer(String username) {
|
||||
if (!isPlayerInArea(username)) {
|
||||
private void addPlayer(String username) {
|
||||
if (!isPlayerListedInArea(username)) {
|
||||
playersInArea.add(username);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEntityWithinArea(Entity entity) {
|
||||
return (aabb.minX <= entity.posX && aabb.maxX >= entity.posX && aabb.minY <= entity.posY && aabb.maxY >= entity.posY && aabb.minZ <= entity.posZ && aabb.maxZ >= entity.posZ);
|
||||
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
|
||||
&& aabb.minZ <= entity.posZ && (aabb.maxZ + 1) > entity.posZ);
|
||||
}
|
||||
|
||||
public CloakedArea(World worldObj, int x, int y, int z, AxisAlignedBB aabb, byte tier) {
|
||||
|
@ -66,7 +71,7 @@ public class CloakedArea {
|
|||
}
|
||||
|
||||
this.dimensionId = worldObj.provider.dimensionId;
|
||||
|
||||
|
||||
try {
|
||||
// Add all players currently inside the field
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, this.aabb);
|
||||
|
@ -80,16 +85,6 @@ public class CloakedArea {
|
|||
}
|
||||
}
|
||||
|
||||
public Chunk obscureChunkBlocksWithinArea(Chunk chunk) {
|
||||
for (int x = (int)this.aabb.minX; x < (int)this.aabb.maxX; x++)
|
||||
for (int z = (int)this.aabb.minZ; z < (int)this.aabb.maxZ; z++)
|
||||
for (int y = (int)this.aabb.minY; y < (int)this.aabb.maxY; y++) {
|
||||
myChunkSBIDWMT(chunk, x & 15, y, z & 15, 0, 0);
|
||||
}
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
// Sending only if field changes: sets up or collapsing
|
||||
public void sendCloakPacketToPlayersEx(boolean decloak) {
|
||||
final int RADIUS = 250;
|
||||
|
@ -123,15 +118,14 @@ public class CloakedArea {
|
|||
}
|
||||
|
||||
public void sendCloakPacketToPlayer(EntityPlayer player, boolean decloak) {
|
||||
//System.outprintln("[Cloak] Sending cloak packet to player " + player.username);
|
||||
if (isPlayerInArea(player.username)) {
|
||||
//System.outprintln("[Cloak] Player " + player.username + " is inside cloaking field");
|
||||
if (isPlayerListedInArea(player.username)) {
|
||||
WarpDrive.debugPrint("" + this + " Player " + player.username + " is inside, no cloak packet to send");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
|
||||
try {
|
||||
outputStream.writeInt((int) this.aabb.minX);
|
||||
outputStream.writeInt((int) this.aabb.minY);
|
||||
|
@ -142,12 +136,13 @@ public class CloakedArea {
|
|||
outputStream.writeInt((int) this.aabb.maxZ);
|
||||
|
||||
outputStream.writeBoolean(decloak);
|
||||
|
||||
|
||||
outputStream.writeByte(this.tier);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// WarpDrive.debugPrint("" + this + " Sending cloak packet to player " + player.username);
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "WarpDriveCloaks";
|
||||
packet.data = bos.toByteArray();
|
||||
|
@ -156,63 +151,32 @@ public class CloakedArea {
|
|||
((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
|
||||
public boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, int blockId, int blockMeta)
|
||||
{
|
||||
int j1 = z << 4 | x;
|
||||
|
||||
if (y >= c.precipitationHeightMap[j1] - 1)
|
||||
{
|
||||
c.precipitationHeightMap[j1] = -999;
|
||||
}
|
||||
|
||||
int l1 = c.getBlockID(x, y, z);
|
||||
int i2 = c.getBlockMetadata(x, y, z);
|
||||
|
||||
if (l1 == blockId && i2 == blockMeta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray();
|
||||
ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4];
|
||||
|
||||
if (extendedblockstorage == null)
|
||||
{
|
||||
if (blockId == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
extendedblockstorage = storageArrays[y >> 4] = new ExtendedBlockStorage(y >> 4 << 4, !c.worldObj.provider.hasNoSky);
|
||||
public void updatePlayer(EntityPlayer player) {
|
||||
if (isEntityWithinArea(player)) {
|
||||
if (!isPlayerListedInArea(player.username)) {
|
||||
WarpDrive.debugPrint("" + this + " Player " + player.username + " has entered");
|
||||
addPlayer(player.username);
|
||||
revealChunksToPlayer(player);
|
||||
revealEntityToPlayer(player);
|
||||
sendCloakPacketToPlayer(player, false);
|
||||
}
|
||||
extendedblockstorage.setExtBlockID(x, y & 15, z, blockId);
|
||||
|
||||
if (extendedblockstorage.getExtBlockID(x, y & 15, z) != blockId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
extendedblockstorage.setExtBlockMetadata(x, y & 15, z, blockMeta);
|
||||
c.isModified = true;
|
||||
return true;
|
||||
} 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));
|
||||
sendCloakPacketToPlayer(player, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void playerEnteringCloakedArea(EntityPlayer player) {
|
||||
addPlayer(player.username);
|
||||
revealChunksToPlayer(player);
|
||||
revealEntityToPlayer(player);
|
||||
sendCloakPacketToPlayer(player, false);
|
||||
}
|
||||
|
||||
public void revealChunksToPlayer(EntityPlayer p) {
|
||||
//System.outprintln("[Cloak] Revealing cloaked chunks in area " + area.frequency + " to player " + p.username);
|
||||
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 y = (int)aabb.minY; y <= (int)aabb.maxY; y++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
if (p.worldObj.getBlockId(x, y, z) != 0) {
|
||||
p.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
@ -241,4 +205,13 @@ public class CloakedArea {
|
|||
((EntityPlayerMP)p).playerNetServerHandler.sendPacketToPlayer(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()});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
return;
|
||||
}
|
||||
|
||||
if (WarpDrive.cloaks.isInCloak(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, false)) {
|
||||
if (WarpDrive.cloaks.isCloaked(worldObj.provider.dimensionId, xCoord, yCoord, zCoord)) {
|
||||
controller.setJumpFlag(false);
|
||||
messageToAllPlayersOnShip("Core is inside a cloaking field. Aborting. Disable cloaking field to jump!");
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue