Bug fixing and cleanup after massive merge
- Fixed air generation & rendering - Merged translation support and other changes since initial merging - Improved performances (linkedlist vs arraylist, etc.) - Fixed memory leaks (cloaking notably) - Fixed cloaking coils remaining visible, etc. - Fixed oxygen not required in space - Fixed entity respiration corrupting world blocks - Fixed ship 'deleted' when jumping too high in space or hyperspace - Fixed /space command from command blocks and console - Fixed no collision when jumping below bedrock or above sky limit - Fixed controller lua script to get size after jump - Fixed insane collision damages - Improved logs spam & readability (partial) - Improved performance on Moon/gaz world generation, gaz/air rendering, cloaked players, etc. - Improved uncloaking special effect - Updated moons to be more frequent - Updated collision damages to be done at target on multiple points - Updated asteroid fields to be more frequent, use more height and have a spheric shape - Updated asteroids to be twice more corrupted - Updated ship and cloaking size limit from 100 to 127 - Added overworld world border, initial TransitionPlane support and more...
This commit is contained in:
parent
0a1ab5d9a1
commit
3eaad47212
50 changed files with 1571 additions and 1216 deletions
src/cr0s/WarpDrive
BlockAir.javaBlockGas.javaBlockIridium.javaCamRegistry.javaCloakManager.javaEntityJump.javaEntitySphereGen.javaGenerateCommand.javaJumpGatesRegistry.javaPacketHandler.javaSpaceEventHandler.javaSpaceTpCommand.javaSpaceWorldGenerator.javaTransitionPlane.javaWarpCoresRegistry.javaWarpDrive.javaWarpDriveConfig.javaWarpDriveCreativeTab.javaWarpDrivePeripheralHandler.javaWorldGenSmallShip.java
item
machines
BlockAirGenerator.javaBlockCamera.javaBlockCloakingCoil.javaBlockCloakingDeviceCore.javaBlockLaser.javaBlockLaserCam.javaBlockLaserReactorMonitor.javaBlockLaserTreeFarm.javaBlockLift.javaBlockMiningLaser.javaBlockMonitor.javaBlockParticleBooster.javaBlockPowerLaser.javaBlockPowerReactor.javaBlockProtocol.javaBlockRadar.javaBlockReactor.javaBlockShipScanner.javaBlockTransporter.javaBlockWarpIsolation.javaTileEntityCloakingDeviceCore.javaTileEntityLaserTreeFarm.javaTileEntityMiningLaser.javaTileEntityPowerReactor.javaTileEntityProtocol.javaTileEntityReactor.javaTileEntityShipScanner.javaTileEntityTransporter.java
|
@ -20,7 +20,7 @@ public class BlockAir extends Block
|
|||
public BlockAir(int par1) {
|
||||
super(par1, Material.air);
|
||||
setHardness(0.0F);
|
||||
setUnlocalizedName("Air block");
|
||||
setUnlocalizedName("warpdrive.blocks.Air");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,8 +84,7 @@ public class BlockAir extends Block
|
|||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int side, int metadata)
|
||||
{
|
||||
public Icon getIcon(int side, int metadata) {
|
||||
if (AIR_DEBUG) {
|
||||
return iconBuffer[metadata];
|
||||
} else {
|
||||
|
@ -139,39 +138,16 @@ public class BlockAir extends Block
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
|
||||
if (AIR_DEBUG) {
|
||||
return true;
|
||||
return side == 0;
|
||||
}
|
||||
|
||||
if (par1IBlockAccess.getBlockId(par2, par3, par4) == this.blockID) {
|
||||
return false;
|
||||
} else {
|
||||
final int i = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
boolean var6 = false;
|
||||
|
||||
if (Block.blocksList[i] != null) {
|
||||
var6 = !Block.blocksList[i].isOpaqueCube();
|
||||
}
|
||||
|
||||
final boolean var7 = i == 0;
|
||||
|
||||
if ((var6 || var7) && par5 == 3 && !var6) {
|
||||
return true;
|
||||
} else if ((var6 || var7) && par5 == 4 && !var6) {
|
||||
return true;
|
||||
} else if ((var6 || var7) && par5 == 5 && !var6) {
|
||||
return true;
|
||||
} else if ((var6 || var7) && par5 == 2 && !var6) {
|
||||
return true;
|
||||
} else if ((var6 || var7) && par5 == 0 && !var6) {
|
||||
return true;
|
||||
} else if ((var6 || var7) && par5 == 1 && !var6) {
|
||||
return true;
|
||||
} else {
|
||||
int sideBlockID = world.getBlockId(x, y, z);
|
||||
if (sideBlockID == this.blockID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return world.isAirBlock(x, y, z);
|
||||
}
|
||||
|
||||
private void spreadAirBlock(World worldObj, int x, int y, int z, int concentration) {
|
||||
|
@ -268,7 +244,7 @@ public class BlockAir extends Block
|
|||
if ( (xp_blockId != WarpDriveConfig.airgenID) && (xn_blockId != WarpDriveConfig.airgenID)
|
||||
&& (yp_blockId != WarpDriveConfig.airgenID) && (yn_blockId != WarpDriveConfig.airgenID)
|
||||
&& (zp_blockId != WarpDriveConfig.airgenID) && (zn_blockId != WarpDriveConfig.airgenID) ) {
|
||||
WarpDrive.debugPrint("AirGenerator not found, removing air block at " + x + ", " + y + ", " + z);
|
||||
// WarpDrive.debugPrint("AirGenerator not found, removing air block at " + x + ", " + y + ", " + z);
|
||||
worldObj.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
} else {
|
||||
// keep the block as a source
|
|
@ -10,62 +10,52 @@ import net.minecraft.util.Icon;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockGas extends Block
|
||||
{
|
||||
public class BlockGas extends Block {
|
||||
private Icon[] gasIcons;
|
||||
|
||||
public BlockGas(int par1)
|
||||
{
|
||||
public BlockGas(int par1) {
|
||||
super(par1, Material.air);
|
||||
setHardness(0.0F);
|
||||
setUnlocalizedName("Gas block");
|
||||
setUnlocalizedName("warpdrive.blocks.Gas");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAirBlock(World var1, int var2, int var3, int var4)
|
||||
{
|
||||
public boolean isAirBlock(World var1, int var2, int var3, int var4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World var1, int var2, int var3, int var4)
|
||||
{
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World var1, int var2, int var3, int var4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockReplaceable(World var1, int var2, int var3, int var4)
|
||||
{
|
||||
public boolean isBlockReplaceable(World var1, int var2, int var3, int var4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World var1, int var2, int var3, int var4)
|
||||
{
|
||||
public boolean canPlaceBlockAt(World var1, int var2, int var3, int var4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck(int var1, boolean var2)
|
||||
{
|
||||
public boolean canCollideCheck(int var1, boolean var2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
public int getRenderBlockPass() {
|
||||
return 1; // transparency enabled
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
gasIcons = new Icon[12];
|
||||
gasIcons[0] = par1IconRegister.registerIcon("warpdrive:gasBlockBlue");
|
||||
gasIcons[1] = par1IconRegister.registerIcon("warpdrive:gasBlockRed");
|
||||
|
@ -82,20 +72,17 @@ public class BlockGas extends Block
|
|||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int side, int metadata)
|
||||
{
|
||||
public Icon getIcon(int side, int metadata) {
|
||||
return gasIcons[metadata % gasIcons.length]; // Lem
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMobilityFlag()
|
||||
{
|
||||
public int getMobilityFlag() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped(int var1, Random var2, int var3)
|
||||
{
|
||||
public int idDropped(int var1, Random var2, int var3) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -103,59 +90,17 @@ public class BlockGas extends Block
|
|||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (par1IBlockAccess.getBlockId(par2, par3, par4) == this.blockID)
|
||||
{
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int sideBlockID = world.getBlockId(x, y, z);
|
||||
if (sideBlockID == this.blockID) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
final int i = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
boolean var6 = false;
|
||||
|
||||
if (Block.blocksList[i] != null)
|
||||
{
|
||||
var6 = !Block.blocksList[i].isOpaqueCube();
|
||||
}
|
||||
|
||||
final boolean var7 = i == 0;
|
||||
|
||||
if ((var6 || var7) && par5 == 3 && !var6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((var6 || var7) && par5 == 4 && !var6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((var6 || var7) && par5 == 5 && !var6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((var6 || var7) && par5 == 2 && !var6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((var6 || var7) && par5 == 0 && !var6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((var6 || var7) && par5 == 1 && !var6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return world.isAirBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -168,17 +113,14 @@ public class BlockGas extends Block
|
|||
* Returns if this block is collidable. Args: x, y, z
|
||||
*/
|
||||
@Override
|
||||
public boolean isCollidable()
|
||||
{
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4) {
|
||||
// Gas blocks allow only in space
|
||||
if (par1World.provider.dimensionId != WarpDriveConfig.G_SPACE_DIMENSION_ID)
|
||||
{
|
||||
if (par1World.provider.dimensionId != WarpDriveConfig.G_SPACE_DIMENSION_ID) {
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ public class BlockIridium extends Block
|
|||
setResistance(150 * 4);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Block of Iridium");
|
||||
setUnlocalizedName("warpdrive.blocks.IridiumBlock");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package cr0s.WarpDrive;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cr0s.WarpDrive.machines.TileEntityReactor;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CamRegistry {
|
||||
private ArrayList<CamRegistryItem> registry;
|
||||
private LinkedList<CamRegistryItem> registry;
|
||||
|
||||
public CamRegistry() {
|
||||
registry = new ArrayList<CamRegistryItem>();
|
||||
registry = new LinkedList<CamRegistryItem>();
|
||||
}
|
||||
|
||||
public CamRegistryItem getCamByFrequency(World worldObj, int frequency) {
|
||||
|
|
|
@ -57,10 +57,10 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||
|
||||
public class CloakManager {
|
||||
|
||||
private ArrayList<CloakedArea> cloaks;
|
||||
private LinkedList<CloakedArea> cloaks;
|
||||
|
||||
public CloakManager() {
|
||||
this.cloaks = new ArrayList<CloakedArea>();
|
||||
this.cloaks = new LinkedList<CloakedArea>();
|
||||
}
|
||||
|
||||
public boolean isInCloak(int dimensionID, int x, int y, int z, boolean chunk) {
|
||||
|
@ -81,17 +81,14 @@ public class CloakManager {
|
|||
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++){
|
||||
for (int i = 0; i < this.cloaks.size(); i++) {
|
||||
if (this.cloaks.get(i).dimensionId != dimensionID)
|
||||
continue;
|
||||
|
||||
AxisAlignedBB axisalignedbb = this.cloaks.get(i).aabb;
|
||||
//System.outprint("[Cloak] checking (" + x + "; " + y + "; " + z + ") -> " + this.cloaks.get(i).aabb);
|
||||
if (axisalignedbb.minX <= (double) x && axisalignedbb.maxX >= (double) x && (chunk || (axisalignedbb.minY <= (double) y && axisalignedbb.maxY >= (double) y)) && axisalignedbb.minZ <= (double) z && axisalignedbb.maxZ >= (double) z) {
|
||||
res.add(cloaks.get(i));
|
||||
//System.outprintln(": YES");
|
||||
}// else
|
||||
//System.outprintln(": NO");
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -128,7 +125,7 @@ public class CloakManager {
|
|||
}
|
||||
|
||||
public void playerEnteringCloakedArea(CloakedArea area, EntityPlayer player) {
|
||||
area.playersInArea.add(player);
|
||||
area.addPlayer(player.username);
|
||||
revealChunksToPlayer(area, player);
|
||||
revealEntityToPlayer(area, player);
|
||||
area.sendCloakPacketToPlayer(player, false);
|
||||
|
@ -142,25 +139,28 @@ public class CloakManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void checkPlayerLeavedArea(EntityPlayer p) {
|
||||
public void checkPlayerLeftArea(EntityPlayer player) {
|
||||
for (CloakedArea area : this.cloaks) {
|
||||
if (!area.isPlayerWithinArea(p) && area.isPlayerInArea(p)) {
|
||||
area.removePlayerFromArea(p);
|
||||
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(p, p.posX, p.posY, p.posZ, 100, p.worldObj.provider.dimensionId, getPacketForThisEntity(p));
|
||||
area.sendCloakPacketToPlayer(p, false);
|
||||
MinecraftServer.getServer().getConfigurationManager().sendToAllNearExcept(player, player.posX, player.posY, player.posZ, 100, player.worldObj.provider.dimensionId, getPacketForThisEntity(player));
|
||||
area.sendCloakPacketToPlayer(player, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void revealChunksToPlayer(CloakedArea area, EntityPlayer p) {
|
||||
//System.outprintln("[Cloak] Revealing cloaked chunks in area " + area.frequency + " to player " + p.username);
|
||||
for (int x = (int)area.aabb.minX; x < (int)area.aabb.maxX; x++)
|
||||
for (int z = (int)area.aabb.minZ; z < (int)area.aabb.maxZ; z++)
|
||||
for (int y = (int)area.aabb.minY; y < (int)area.aabb.maxY; y++) {
|
||||
if (p.worldObj.getBlockId(x, y, z) != 0)
|
||||
for (int x = (int)area.aabb.minX; x <= (int)area.aabb.maxX; x++) {
|
||||
for (int z = (int)area.aabb.minZ; z <= (int)area.aabb.maxZ; z++) {
|
||||
for (int y = (int)area.aabb.minY; y <= (int)area.aabb.maxY; y++) {
|
||||
if (p.worldObj.getBlockId(x, y, z) != 0) {
|
||||
p.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*ArrayList<Chunk> chunksToSend = new ArrayList<Chunk>();
|
||||
|
||||
for (int x = (int)area.aabb.minX >> 4; x <= (int)area.aabb.maxX >> 4; x++)
|
||||
|
@ -177,34 +177,39 @@ public class CloakManager {
|
|||
}
|
||||
|
||||
public class CloakedArea {
|
||||
// public int frequency;
|
||||
public int x, y, z;
|
||||
public AxisAlignedBB aabb;
|
||||
public LinkedList<EntityPlayer> playersInArea;
|
||||
private LinkedList<String> playersInArea;
|
||||
public byte tier = 0;
|
||||
public int dimensionId = -666;
|
||||
|
||||
public boolean isPlayerInArea(EntityPlayer player) {
|
||||
for (EntityPlayer p : this.playersInArea) {
|
||||
public boolean isPlayerInArea(String username) {
|
||||
for (String playerInArea : playersInArea) {
|
||||
//System.outprintln("[Cloak] Checking player: " + p.username + "(" + p.entityId + ")" + " =? " + player.username + " (" + p.entityId + ")");
|
||||
if (p.username.equals(player.username))
|
||||
if (playerInArea.equals(username))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removePlayerFromArea(EntityPlayer p) {
|
||||
for (int i = 0; i < this.playersInArea.size(); i++) {
|
||||
if (this.playersInArea.get(i).username.equals(p.username)) {
|
||||
this.playersInArea.remove(i);
|
||||
public void removePlayer(String username) {
|
||||
for (int i = 0; i < playersInArea.size(); i++) {
|
||||
if (playersInArea.get(i).equals(username)) {
|
||||
playersInArea.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayerWithinArea(EntityPlayer player) {
|
||||
return (aabb.minX <= player.posX && aabb.maxX >= player.posX && aabb.minY <= player.posY && aabb.maxY >= player.posY && aabb.minZ <= player.posZ && aabb.maxZ >= player.posZ);
|
||||
public void addPlayer(String username) {
|
||||
if (!isPlayerInArea(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 CloakedArea(World worldObj, int x, int y, int z, AxisAlignedBB aabb, byte tier) {
|
||||
|
@ -213,19 +218,21 @@ public class CloakManager {
|
|||
this.z = z;
|
||||
this.aabb = aabb;
|
||||
this.tier = tier;
|
||||
this.playersInArea = new LinkedList<EntityPlayer>();
|
||||
this.playersInArea = new LinkedList<String>();
|
||||
|
||||
if (worldObj == null || aabb == null)
|
||||
if (worldObj == null || aabb == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dimensionId = worldObj.provider.dimensionId;
|
||||
|
||||
try {
|
||||
// Added all players, who inside the field
|
||||
// Add all players currently inside the field
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, this.aabb);
|
||||
for (Entity e : list) {
|
||||
if (e instanceof EntityPlayer)
|
||||
this.playersInArea.add((EntityPlayer)e);
|
||||
if (e instanceof EntityPlayer) {
|
||||
addPlayer(((EntityPlayer)e).username);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -250,27 +257,24 @@ public class CloakManager {
|
|||
double midY = this.aabb.minY + (Math.abs(this.aabb.maxY - this.aabb.minY) / 2);
|
||||
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);
|
||||
for (int j = 0; j < MinecraftServer.getServer().getConfigurationManager().playerEntityList.size(); j++) {
|
||||
EntityPlayerMP entityPlayerMP = (EntityPlayerMP)MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(j);
|
||||
|
||||
if (entityplayermp.dimension == this.dimensionId)
|
||||
{
|
||||
double d4 = midX - entityplayermp.posX;
|
||||
double d5 = midY - entityplayermp.posY;
|
||||
double d6 = midZ - entityplayermp.posZ;
|
||||
if (entityPlayerMP.dimension == dimensionId) {
|
||||
double d4 = midX - entityPlayerMP.posX;
|
||||
double d5 = midY - entityPlayerMP.posY;
|
||||
double d6 = midZ - entityPlayerMP.posZ;
|
||||
|
||||
if (d4 * d4 + d5 * d5 + d6 * d6 < RADIUS * RADIUS)
|
||||
{
|
||||
if (Math.abs(d4) < RADIUS && Math.abs(d5) < RADIUS && Math.abs(d6) < RADIUS) {
|
||||
if (decloak) {
|
||||
revealChunksToPlayer(this, (EntityPlayer)entityplayermp);
|
||||
revealEntityToPlayer(this, (EntityPlayer)entityplayermp);
|
||||
revealChunksToPlayer(this, entityPlayerMP);
|
||||
revealEntityToPlayer(this, entityPlayerMP);
|
||||
}
|
||||
|
||||
if (!isPlayerWithinArea((EntityPlayer)entityplayermp) && !decloak)
|
||||
sendCloakPacketToPlayer((EntityPlayer)entityplayermp, false);
|
||||
else if (decloak) {
|
||||
sendCloakPacketToPlayer((EntityPlayer)entityplayermp, true);
|
||||
if (!isEntityWithinArea(entityPlayerMP) && !decloak) {
|
||||
sendCloakPacketToPlayer(entityPlayerMP, false);
|
||||
} else if (decloak) {
|
||||
sendCloakPacketToPlayer(entityPlayerMP, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +283,7 @@ public class CloakManager {
|
|||
|
||||
public void sendCloakPacketToPlayer(EntityPlayer player, boolean decloak) {
|
||||
//System.outprintln("[Cloak] Sending cloak packet to player " + player.username);
|
||||
if (isPlayerInArea(player)) {
|
||||
if (isPlayerInArea(player.username)) {
|
||||
//System.outprintln("[Cloak] Player " + player.username + " is inside cloaking field");
|
||||
return;
|
||||
}
|
||||
|
@ -287,8 +291,7 @@ public class CloakManager {
|
|||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
outputStream.writeInt((int) this.aabb.minX);
|
||||
outputStream.writeInt((int) this.aabb.minY);
|
||||
outputStream.writeInt((int) this.aabb.minZ);
|
||||
|
@ -300,9 +303,7 @@ public class CloakManager {
|
|||
outputStream.writeBoolean(decloak);
|
||||
|
||||
outputStream.writeByte(this.tier);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -360,98 +361,61 @@ public class CloakManager {
|
|||
}
|
||||
}
|
||||
|
||||
private Packet getPacketForThisEntity(Entity e)
|
||||
{
|
||||
if (e.isDead)
|
||||
{
|
||||
private Packet getPacketForThisEntity(Entity e) {
|
||||
if (e.isDead) {
|
||||
e.worldObj.getWorldLogAgent().logWarning("Fetching addPacket for removed entity");
|
||||
}
|
||||
|
||||
Packet pkt = FMLNetworkHandler.getEntitySpawningPacket(e);
|
||||
|
||||
if (pkt != null)
|
||||
{
|
||||
if (pkt != null) {
|
||||
return pkt;
|
||||
}
|
||||
|
||||
if (e instanceof EntityItem)
|
||||
{
|
||||
if (e instanceof EntityItem) {
|
||||
return new Packet23VehicleSpawn(e, 2, 1);
|
||||
}
|
||||
else if (e instanceof EntityPlayerMP)
|
||||
{
|
||||
} else if (e instanceof EntityPlayerMP) {
|
||||
return new Packet20NamedEntitySpawn((EntityPlayer)e);
|
||||
}
|
||||
else if (e instanceof EntityMinecart)
|
||||
{
|
||||
} else if (e instanceof EntityMinecart) {
|
||||
EntityMinecart entityminecart = (EntityMinecart)e;
|
||||
return new Packet23VehicleSpawn(e, 10, entityminecart.getMinecartType());
|
||||
}
|
||||
else if (e instanceof EntityBoat)
|
||||
{
|
||||
} else if (e instanceof EntityBoat) {
|
||||
return new Packet23VehicleSpawn(e, 1);
|
||||
}
|
||||
else if (!(e instanceof IAnimals) && !(e instanceof EntityDragon))
|
||||
{
|
||||
if (e instanceof EntityFishHook)
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
} else if (e instanceof EntitySnowball) {
|
||||
return new Packet23VehicleSpawn(e, 61);
|
||||
}
|
||||
else if (e instanceof EntityPotion)
|
||||
{
|
||||
} else if (e instanceof EntityPotion) {
|
||||
return new Packet23VehicleSpawn(e, 73, ((EntityPotion)e).getPotionDamage());
|
||||
}
|
||||
else if (e instanceof EntityExpBottle)
|
||||
{
|
||||
} else if (e instanceof EntityExpBottle) {
|
||||
return new Packet23VehicleSpawn(e, 75);
|
||||
}
|
||||
else if (e instanceof EntityEnderPearl)
|
||||
{
|
||||
} else if (e instanceof EntityEnderPearl) {
|
||||
return new Packet23VehicleSpawn(e, 65);
|
||||
}
|
||||
else if (e instanceof EntityEnderEye)
|
||||
{
|
||||
} else if (e instanceof EntityEnderEye) {
|
||||
return new Packet23VehicleSpawn(e, 72);
|
||||
}
|
||||
else if (e instanceof EntityFireworkRocket)
|
||||
{
|
||||
} else if (e instanceof EntityFireworkRocket) {
|
||||
return new Packet23VehicleSpawn(e, 76);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Packet23VehicleSpawn packet23vehiclespawn;
|
||||
|
||||
if (e instanceof EntityFireball)
|
||||
{
|
||||
if (e instanceof EntityFireball) {
|
||||
EntityFireball entityfireball = (EntityFireball)e;
|
||||
packet23vehiclespawn = null;
|
||||
byte b0 = 63;
|
||||
|
||||
if (e instanceof EntitySmallFireball)
|
||||
{
|
||||
if (e instanceof EntitySmallFireball) {
|
||||
b0 = 64;
|
||||
}
|
||||
else if (e instanceof EntityWitherSkull)
|
||||
{
|
||||
} else if (e instanceof EntityWitherSkull) {
|
||||
b0 = 66;
|
||||
}
|
||||
|
||||
if (entityfireball.shootingEntity != null)
|
||||
{
|
||||
if (entityfireball.shootingEntity != null) {
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, ((EntityFireball)e).shootingEntity.entityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, b0, 0);
|
||||
}
|
||||
|
||||
|
@ -459,58 +423,38 @@ public class CloakManager {
|
|||
packet23vehiclespawn.speedY = (int)(entityfireball.accelerationY * 8000.0D);
|
||||
packet23vehiclespawn.speedZ = (int)(entityfireball.accelerationZ * 8000.0D);
|
||||
return packet23vehiclespawn;
|
||||
}
|
||||
else if (e instanceof EntityEgg)
|
||||
{
|
||||
} else if (e instanceof EntityEgg) {
|
||||
return new Packet23VehicleSpawn(e, 62);
|
||||
}
|
||||
else if (e instanceof EntityTNTPrimed)
|
||||
{
|
||||
} else if (e instanceof EntityTNTPrimed) {
|
||||
return new Packet23VehicleSpawn(e, 50);
|
||||
}
|
||||
else if (e instanceof EntityEnderCrystal)
|
||||
{
|
||||
} else if (e instanceof EntityEnderCrystal) {
|
||||
return new Packet23VehicleSpawn(e, 51);
|
||||
}
|
||||
else if (e instanceof EntityFallingSand)
|
||||
{
|
||||
} else if (e instanceof EntityFallingSand) {
|
||||
EntityFallingSand entityfallingsand = (EntityFallingSand)e;
|
||||
return new Packet23VehicleSpawn(e, 70, entityfallingsand.blockID | entityfallingsand.metadata << 16);
|
||||
}
|
||||
else if (e instanceof EntityPainting)
|
||||
{
|
||||
} else if (e instanceof EntityPainting) {
|
||||
return new Packet25EntityPainting((EntityPainting)e);
|
||||
}
|
||||
else if (e instanceof EntityItemFrame)
|
||||
{
|
||||
} else if (e instanceof EntityItemFrame) {
|
||||
EntityItemFrame entityitemframe = (EntityItemFrame)e;
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, 71, entityitemframe.hangingDirection);
|
||||
packet23vehiclespawn.xPosition = MathHelper.floor_float((float)(entityitemframe.xPosition * 32));
|
||||
packet23vehiclespawn.yPosition = MathHelper.floor_float((float)(entityitemframe.yPosition * 32));
|
||||
packet23vehiclespawn.zPosition = MathHelper.floor_float((float)(entityitemframe.zPosition * 32));
|
||||
return packet23vehiclespawn;
|
||||
}
|
||||
else if (e instanceof EntityLeashKnot)
|
||||
{
|
||||
} else if (e instanceof EntityLeashKnot) {
|
||||
EntityLeashKnot entityleashknot = (EntityLeashKnot)e;
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(e, 77);
|
||||
packet23vehiclespawn.xPosition = MathHelper.floor_float((float)(entityleashknot.xPosition * 32));
|
||||
packet23vehiclespawn.yPosition = MathHelper.floor_float((float)(entityleashknot.yPosition * 32));
|
||||
packet23vehiclespawn.zPosition = MathHelper.floor_float((float)(entityleashknot.zPosition * 32));
|
||||
return packet23vehiclespawn;
|
||||
}
|
||||
else if (e instanceof EntityXPOrb)
|
||||
{
|
||||
} else if (e instanceof EntityXPOrb) {
|
||||
return new Packet26EntityExpOrb((EntityXPOrb)e);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don\'t know how to add " + e.getClass() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new Packet24MobSpawn((EntityLivingBase)e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
@ -63,6 +64,11 @@ public class EntityJump extends Entity
|
|||
private Ticket sourceWorldTicket;
|
||||
private Ticket targetWorldTicket;
|
||||
|
||||
private boolean collisionDetected = false;
|
||||
private ArrayList<Vector3> collisionAtSource;
|
||||
private ArrayList<Vector3> collisionAtTarget;
|
||||
private float collisionStrength = 0;
|
||||
|
||||
public boolean on = false;
|
||||
private JumpBlock ship[];
|
||||
private TileEntityReactor reactor;
|
||||
|
@ -78,14 +84,13 @@ public class EntityJump extends Entity
|
|||
private List<MovingEntity> entitiesOnShip;
|
||||
private List<TileEntity> ASTurbines;
|
||||
|
||||
AxisAlignedBB axisalignedbb;
|
||||
|
||||
private boolean fromSpace, toSpace, betweenWorlds;
|
||||
private boolean betweenWorlds;
|
||||
|
||||
private int destX, destY, destZ;
|
||||
private boolean isCoordJump;
|
||||
|
||||
private long msCounter = 0;
|
||||
private int ticks = 0;
|
||||
|
||||
public EntityJump(World world)
|
||||
{
|
||||
|
@ -96,8 +101,7 @@ public class EntityJump extends Entity
|
|||
}
|
||||
|
||||
public EntityJump(World world, int x, int y, int z, int _dx, int _dz, TileEntityReactor _reactor,
|
||||
boolean _isHyperspaceJump, int _distance, int _direction, boolean _isCoordJump, int _destX, int _destY, int _destZ)
|
||||
{
|
||||
boolean _isHyperspaceJump, int _distance, int _direction, boolean _isCoordJump, int _destX, int _destY, int _destZ) {
|
||||
super(world);
|
||||
this.posX = x + 0.5D;
|
||||
this.posY = y + 0.5D;
|
||||
|
@ -168,6 +172,7 @@ public class EntityJump extends Entity
|
|||
return;
|
||||
}
|
||||
|
||||
ticks++;
|
||||
if (state == STATE_IDLE) {
|
||||
WarpDrive.debugPrint("" + this + " Preparing to jump...");
|
||||
prepareToJump();
|
||||
|
@ -189,7 +194,6 @@ public class EntityJump extends Entity
|
|||
|
||||
if (currentIndexInShip >= ship.length - 1) {
|
||||
finishJump();
|
||||
FixASTurbines();
|
||||
state = STATE_IDLE;
|
||||
}
|
||||
} else {
|
||||
|
@ -203,7 +207,7 @@ public class EntityJump extends Entity
|
|||
private boolean forceChunks(StringBuilder reason)
|
||||
{
|
||||
LocalProfiler.start("EntityJump.forceChunks");
|
||||
WarpDrive.debugPrint("" + this + " Forcing chunks in " + worldObj.provider.getDimensionName() + " and " + worldObj.provider.getDimensionName());
|
||||
WarpDrive.debugPrint("" + this + " Forcing chunks in " + worldObj.provider.getDimensionName() + " and " + targetWorld.provider.getDimensionName());
|
||||
sourceWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, worldObj, Type.NORMAL); // Type.ENTITY);
|
||||
if (sourceWorldTicket == null) {
|
||||
reason.append("Chunkloading rejected in S:" + worldObj.getWorldInfo().getWorldName() + ". Aborting.");
|
||||
|
@ -291,44 +295,80 @@ public class EntityJump extends Entity
|
|||
LocalProfiler.stop();
|
||||
}
|
||||
|
||||
public void messageToAllPlayersOnShip(String msg)
|
||||
{
|
||||
private void messageToAllPlayersOnShip(String msg) {
|
||||
if (entitiesOnShip == null) {
|
||||
this.reactor.messageToAllPlayersOnShip(msg);
|
||||
reactor.messageToAllPlayersOnShip(msg);
|
||||
} else {
|
||||
System.out.println("" + this + " messageToAllPlayersOnShip: " + msg);
|
||||
for (MovingEntity me : entitiesOnShip) {
|
||||
if (me.entity instanceof EntityPlayer) {
|
||||
((EntityPlayer)me.entity).addChatMessage("[WarpCore] " + msg);
|
||||
((EntityPlayer)me.entity).addChatMessage("[" + ((reactor != null && reactor.coreFrequency.length() > 0) ? reactor.coreFrequency : "WarpCore") + "] " + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void prepareToJump()
|
||||
{
|
||||
public String getDirectionLabel(int direction) {
|
||||
switch (direction) {
|
||||
case -1: return "UP";
|
||||
case -2: return "DOWN";
|
||||
case 0: return "FRONT";
|
||||
case 180: return "BACK";
|
||||
case 90: return "LEFT";
|
||||
case 255: return "RIGHT";
|
||||
default: return direction + " degrees";
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareToJump() {
|
||||
StringBuilder reason = new StringBuilder();
|
||||
|
||||
LocalProfiler.start("EntityJump.prepareToJump");
|
||||
boolean isInSpace = (worldObj.provider.dimensionId == WarpDriveConfig.G_SPACE_DIMENSION_ID);
|
||||
boolean isInHyperSpace = (worldObj.provider.dimensionId == WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID);
|
||||
|
||||
toSpace = (direction == -1 && (maxY + distance > 255) && (!isInSpace) && (!isInHyperSpace));
|
||||
fromSpace = (direction == -2 && (minY - distance < 0) && isInSpace);
|
||||
boolean toSpace = (direction == -1) && (maxY + distance > 255) && (!isInSpace) && (!isInHyperSpace);
|
||||
boolean fromSpace = (direction == -2) && (minY - distance < 0) && isInSpace;
|
||||
betweenWorlds = fromSpace || toSpace || isHyperspaceJump;
|
||||
moveX = moveY = moveZ = 0;
|
||||
|
||||
if (toSpace || (isHyperspaceJump && isInHyperSpace)) {
|
||||
TransitionPlane overworld = new TransitionPlane(0, 0, 0, 5000, 5000, 0, 0);
|
||||
Vector3 exit;
|
||||
if (toSpace) {
|
||||
if (worldObj.provider.dimensionId == overworld.dimensionId) {
|
||||
if (!overworld.isValidToSpace(new Vector3(this))) {// invalid transition, cancel transition
|
||||
LocalProfiler.stop();
|
||||
String msg = "Ship is outside worldborder, unable to transition to space!";
|
||||
messageToAllPlayersOnShip(msg);
|
||||
killEntity(msg);
|
||||
return;
|
||||
}
|
||||
moveX = overworld.spaceCenterX - overworld.dimensionCenterX;
|
||||
moveZ = overworld.spaceCenterZ - overworld.dimensionCenterZ;
|
||||
} else {
|
||||
moveX = 0;
|
||||
moveZ = 0;
|
||||
}
|
||||
targetWorld = DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID);
|
||||
} else if (fromSpace) {
|
||||
if (!overworld.isValidFromSpace(new Vector3(this))) {// invalid transition, cancel transition
|
||||
LocalProfiler.stop();
|
||||
String msg = "Ship is outside worldborder, unable to transition from space!";
|
||||
messageToAllPlayersOnShip(msg);
|
||||
killEntity(msg);
|
||||
return;
|
||||
}
|
||||
moveX = overworld.dimensionCenterX - overworld.spaceCenterX;
|
||||
moveZ = overworld.dimensionCenterZ - overworld.spaceCenterZ;
|
||||
targetWorld = DimensionManager.getWorld(0);
|
||||
} else if (isHyperspaceJump && isInHyperSpace) {
|
||||
targetWorld = DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID);
|
||||
} else if (isHyperspaceJump && isInSpace) {
|
||||
targetWorld = DimensionManager.getWorld(WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID);
|
||||
} else {
|
||||
targetWorld = this.worldObj;
|
||||
targetWorld = worldObj;
|
||||
}
|
||||
|
||||
axisalignedbb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
|
||||
// FIXME
|
||||
//turnOffModems();
|
||||
|
||||
|
@ -339,34 +379,20 @@ public class EntityJump extends Entity
|
|||
moveY = destY - yCoord;
|
||||
distance = 0; // FIXME: check collision in straight path, starting with getPossibleJumpDistance() ?
|
||||
} else if (isHyperspaceJump) {
|
||||
moveX = moveY = moveZ = 0;
|
||||
distance = 0;
|
||||
} else {
|
||||
if (betweenWorlds) {
|
||||
moveX = moveZ = 0;
|
||||
|
||||
if (fromSpace) {
|
||||
if (toSpace) {
|
||||
// enter space at current altitude
|
||||
moveY = 0;
|
||||
} else if (fromSpace) {
|
||||
// re-enter atmosphere at max altitude
|
||||
moveY = 245 - maxY;
|
||||
}
|
||||
|
||||
if (toSpace) {
|
||||
moveY = 0;
|
||||
}
|
||||
} else {
|
||||
// Do not check in long jumps
|
||||
if (distance < 256) {
|
||||
distance = getPossibleJumpDistance();
|
||||
}
|
||||
|
||||
if (distance <= shipLength) {
|
||||
LocalProfiler.stop();
|
||||
String msg = "Not enough space for jump!";
|
||||
messageToAllPlayersOnShip(msg);
|
||||
killEntity(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
int movementVector[] = getVector(direction);
|
||||
moveX = movementVector[0] * distance;
|
||||
moveY = movementVector[1] * distance;
|
||||
|
@ -386,6 +412,21 @@ public class EntityJump extends Entity
|
|||
WarpDrive.debugPrint("" + this + " Worlds: " + worldObj.provider.getDimensionName() + " -> " + targetWorld.provider.getDimensionName());
|
||||
}
|
||||
|
||||
// Validate positions aren't overlapping
|
||||
if (!betweenWorlds) {
|
||||
if ( Math.abs(moveX) <= (maxX - minX + 1) && Math.abs(moveY) <= (maxY - minY + 1) && Math.abs(moveZ) <= (maxZ - minZ + 1) ) {
|
||||
// render fake explosions
|
||||
doCollisionDamage(false);
|
||||
|
||||
// cancel jump
|
||||
LocalProfiler.stop();
|
||||
String msg = "Not enough space for jump!";
|
||||
messageToAllPlayersOnShip(msg);
|
||||
killEntity(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!forceChunks(reason)) {
|
||||
String msg = reason.toString();
|
||||
killEntity(msg);
|
||||
|
@ -394,7 +435,7 @@ public class EntityJump extends Entity
|
|||
return;
|
||||
}
|
||||
// lockWorlds();
|
||||
saveEntities(axisalignedbb);
|
||||
saveEntities();
|
||||
WarpDrive.debugPrint("" + this + " Saved " + entitiesOnShip.size() + " entities from ship");
|
||||
|
||||
if (isHyperspaceJump && isInSpace) {
|
||||
|
@ -402,15 +443,9 @@ public class EntityJump extends Entity
|
|||
} else if (isHyperspaceJump && isInHyperSpace) {
|
||||
messageToAllPlayersOnShip("Leaving HYPERSPACE..");
|
||||
} else if (isCoordJump) {
|
||||
messageToAllPlayersOnShip("Jumping by coordinates to (" + destX + "; " + yCoord + "; " + destZ + ")!");
|
||||
messageToAllPlayersOnShip("Jumping to coordinates (" + destX + "; " + yCoord + "; " + destZ + ")!");
|
||||
} else {
|
||||
if (direction != -2 && direction != -1) {
|
||||
messageToAllPlayersOnShip("Jumping in direction " + direction + " degrees to distance " + distance + " blocks ");
|
||||
} else if (direction == -1) {
|
||||
messageToAllPlayersOnShip("Jumping UP to distance " + distance + " blocks ");
|
||||
} else if (direction == -2) {
|
||||
messageToAllPlayersOnShip("Jumping DOWN to distance " + distance + " blocks ");
|
||||
}
|
||||
messageToAllPlayersOnShip("Jumping " + getDirectionLabel(direction) + " by " + distance + " blocks");
|
||||
}
|
||||
|
||||
// validate ship content
|
||||
|
@ -433,21 +468,19 @@ public class EntityJump extends Entity
|
|||
/**
|
||||
* Finish jump: move entities, unlock worlds and delete self
|
||||
*/
|
||||
public void finishJump()
|
||||
{
|
||||
WarpDrive.debugPrint("" + this + " Jump done in " + ((System.currentTimeMillis() - msCounter) / 1000F) + " seconds");
|
||||
private void finishJump() {
|
||||
WarpDrive.debugPrint("" + this + " Jump done in " + ((System.currentTimeMillis() - msCounter) / 1000F) + " seconds and " + ticks + " ticks");
|
||||
//FIXME TileEntity duplication workaround
|
||||
WarpDrive.debugPrint("Removing TE duplicates: tileEntities in target world after jump, before cleanup: " + targetWorld.loadedTileEntityList.size());
|
||||
LocalProfiler.start("EntityJump.removeDuplicates()");
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
targetWorld.loadedTileEntityList = this.removeDuplicates(targetWorld.loadedTileEntityList);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
WarpDrive.debugPrint("TE Duplicates removing exception: " + e.getMessage());
|
||||
}
|
||||
FixASTurbines();
|
||||
doCollisionDamage(true);
|
||||
|
||||
LocalProfiler.stop();
|
||||
WarpDrive.debugPrint("Removing TE duplicates: tileEntities in target world after jump, after cleanup: " + targetWorld.loadedTileEntityList.size());
|
||||
|
@ -458,11 +491,10 @@ public class EntityJump extends Entity
|
|||
* Removing ship from world
|
||||
*
|
||||
*/
|
||||
public void removeShip()
|
||||
{
|
||||
private void removeShip() {
|
||||
LocalProfiler.start("EntityJump.removeShip");
|
||||
int blocksToMove = Math.min(BLOCKS_PER_TICK, ship.length - currentIndexInShip);
|
||||
WarpDrive.debugPrint("" + (FMLCommonHandler.instance().getEffectiveSide().isClient() ? "Client":"Server") + " " + this + " Removing ship part: " + currentIndexInShip + " to " + (currentIndexInShip + blocksToMove - 1) + " / " + (ship.length + 1));
|
||||
WarpDrive.debugPrint("" + this + " Removing ship blocks " + currentIndexInShip + " to " + (currentIndexInShip + blocksToMove - 1) + " / " + (ship.length - 1));
|
||||
TileEntity te;
|
||||
Class<?> c;
|
||||
for (int index = 0; index < blocksToMove; index++) {
|
||||
|
@ -535,13 +567,11 @@ public class EntityJump extends Entity
|
|||
*
|
||||
* @param shipSize
|
||||
*/
|
||||
public void saveShip(int shipSize)
|
||||
{
|
||||
private void saveShip(int shipSize) {
|
||||
LocalProfiler.start("EntityJump.saveShip");
|
||||
ship = new JumpBlock[shipSize];
|
||||
|
||||
if (ship == null)
|
||||
{
|
||||
if (ship == null) {
|
||||
killEntity("Unable to allocate memory (ship is null!)");
|
||||
LocalProfiler.stop();
|
||||
return;
|
||||
|
@ -599,8 +629,7 @@ public class EntityJump extends Entity
|
|||
/**
|
||||
*Ship moving
|
||||
*/
|
||||
private void moveShip()
|
||||
{
|
||||
private void moveShip() {
|
||||
LocalProfiler.start("EntityJump.moveShip");
|
||||
int blocksToMove = Math.min(BLOCKS_PER_TICK, ship.length - currentIndexInShip);
|
||||
WarpDrive.debugPrint("" + this + " Moving ship blocks " + currentIndexInShip + " to " + (currentIndexInShip + blocksToMove - 1) + " / " + (ship.length - 1));
|
||||
|
@ -622,62 +651,126 @@ public class EntityJump extends Entity
|
|||
*
|
||||
* @return possible jump distance or -1
|
||||
*/
|
||||
private int getPossibleJumpDistance()
|
||||
{
|
||||
private int getPossibleJumpDistance() {
|
||||
WarpDrive.debugPrint("" + this + " Calculating possible jump distance...");
|
||||
int testDistance = this.distance;
|
||||
int blowPoints = 0;
|
||||
collisionDetected = false;
|
||||
|
||||
CollisionResult finalResult = null, result = null;
|
||||
while (testDistance >= 0)
|
||||
{
|
||||
CheckMovementResult result = null;
|
||||
while (testDistance >= 0) {
|
||||
// Is there enough space in destination point?
|
||||
result = checkMovement(testDistance);
|
||||
result = checkMovement(testDistance, false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
if (result == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.isCollision)
|
||||
{
|
||||
if (result.isCollision) {
|
||||
blowPoints++;
|
||||
}
|
||||
finalResult = result;
|
||||
testDistance--;
|
||||
}
|
||||
|
||||
if (distance != testDistance)
|
||||
{
|
||||
WarpDrive.debugPrint("" + this + " Jump distance adjusted to " + testDistance + " and " + blowPoints + " collisions");
|
||||
if (distance != testDistance) {
|
||||
WarpDrive.debugPrint("" + this + " Jump distance adjusted to " + testDistance + " after " + blowPoints + " collisions");
|
||||
}
|
||||
|
||||
// Make an explosion in collision point
|
||||
if (blowPoints > WarpDriveConfig.WC_COLLISION_TOLERANCE_BLOCKS)
|
||||
{
|
||||
messageToAllPlayersOnShip("Ship collision detected at " + finalResult.x + ", " + finalResult.y + ", " + finalResult.z + ". Damage report pending...");
|
||||
worldObj.createExplosion((Entity) null, finalResult.x, finalResult.y, finalResult.z, Math.min(4F * 30, 4F * (distance / 2)), true);
|
||||
// Register explosion(s) at collision point
|
||||
if (blowPoints > WarpDriveConfig.WC_COLLISION_TOLERANCE_BLOCKS) {
|
||||
result = checkMovement(Math.max(1, testDistance + 1), true);
|
||||
if (result != null) {
|
||||
/*
|
||||
* Strength scaling:
|
||||
* Creeper = 3 or 6
|
||||
* Wither skull = 1
|
||||
* Wither boom = 5
|
||||
* Endercrystal = 6
|
||||
* TNTcart = 4 to 11.5
|
||||
* TNT = 4
|
||||
*/
|
||||
float massCorrection = 0.5F + (float)Math.sqrt(
|
||||
Math.min(1.0D, Math.max(0.0D, reactor.shipVolume - WarpDriveConfig.WC_MAX_SHIP_VOLUME_ON_SURFACE) / WarpDriveConfig.WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE));
|
||||
collisionDetected = true;
|
||||
collisionStrength = (4.0F + blowPoints - WarpDriveConfig.WC_COLLISION_TOLERANCE_BLOCKS) * massCorrection;
|
||||
collisionAtSource = result.atSource;
|
||||
collisionAtTarget = result.atTarget;
|
||||
WarpDrive.debugPrint("" + this + " Reporting " + collisionAtTarget.size() + " collisions coordinates "
|
||||
+ blowPoints + " blowPoints with massCorrection of " + String.format("%.2f", massCorrection) + " => strength " + String.format("%.2f", collisionStrength) );
|
||||
} else {
|
||||
System.out.println("WarpDrive error: unable to compute collision points, ignoring...");
|
||||
}
|
||||
}
|
||||
|
||||
return testDistance;
|
||||
}
|
||||
|
||||
private int getRealShipVolume_checkBedrock(StringBuilder reason)
|
||||
{
|
||||
private void doCollisionDamage(boolean atTarget) {
|
||||
if (!collisionDetected) {
|
||||
WarpDrive.debugPrint("" + this + " doCollisionDamage No collision detected...");
|
||||
return;
|
||||
}
|
||||
ArrayList<Vector3> collisionPoints = atTarget ? collisionAtTarget : collisionAtSource;
|
||||
Vector3 min = collisionPoints.get(0);
|
||||
Vector3 max = collisionPoints.get(0);
|
||||
for (Vector3 v : collisionPoints) {
|
||||
if (min.x > v.x) {
|
||||
min.x = v.x;
|
||||
} else if (max.x < v.x) {
|
||||
max.x = v.x;
|
||||
}
|
||||
if (min.y > v.y) {
|
||||
min.y = v.y;
|
||||
} else if (max.y < v.y) {
|
||||
max.y = v.y;
|
||||
}
|
||||
if (min.z > v.z) {
|
||||
min.z = v.z;
|
||||
} else if (max.z < v.z) {
|
||||
max.z = v.z;
|
||||
}
|
||||
}
|
||||
|
||||
// inform players on board
|
||||
double rx = Math.round(min.x + worldObj.rand.nextInt( Math.max(1, (int) (max.x - min.x)) ));
|
||||
double ry = Math.round(min.y + worldObj.rand.nextInt( Math.max(1, (int) (max.y - min.y)) ));
|
||||
double rz = Math.round(min.z + worldObj.rand.nextInt( Math.max(1, (int) (max.z - min.z)) ));
|
||||
// WarpDrive.debugPrint("doCollisionDamage msg " + rx + ", " + ry + ", " + rz + " atTarget " + atTarget + " min " + min + " max " + max);
|
||||
messageToAllPlayersOnShip("Ship collision detected around " + (int)rx + ", " + (int)ry + ", " + (int)rz + ". Damage report pending...");
|
||||
|
||||
// randomize if too many collision points
|
||||
int nbExplosions = Math.min(5, collisionPoints.size());
|
||||
WarpDrive.debugPrint("doCollisionDamage nbExplosions " + nbExplosions + "/" + collisionPoints.size());
|
||||
for (int i = 0; i < nbExplosions; i++) {
|
||||
// get location
|
||||
Vector3 current;
|
||||
if (nbExplosions < collisionPoints.size()) {
|
||||
WarpDrive.debugPrint("doCollisionDamage random #" + i);
|
||||
current = collisionPoints.get(worldObj.rand.nextInt(collisionPoints.size()));
|
||||
} else {
|
||||
WarpDrive.debugPrint("doCollisionDamage get " + i);
|
||||
current = collisionPoints.get(i);
|
||||
}
|
||||
|
||||
// compute explosion strength with a jitter, at least 1 TNT
|
||||
float strength = Math.max(4.0F, collisionStrength / nbExplosions - 2.0F + 2.0F * worldObj.rand.nextFloat());
|
||||
|
||||
(atTarget ? targetWorld : worldObj).newExplosion((Entity) null, current.x, current.y, current.z, strength, atTarget, atTarget);
|
||||
WarpDrive.debugPrint("doCollisionDamage explosion at " + current.x + ", " + current.y + ", " + current.z + " with strength " + strength);
|
||||
}
|
||||
}
|
||||
|
||||
private int getRealShipVolume_checkBedrock(StringBuilder reason) {
|
||||
LocalProfiler.start("EntityJump.getRealShipVolume_checkBedrock");
|
||||
int shipVolume = 0;
|
||||
|
||||
for (int x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (int z = minZ; z <= maxZ; z++)
|
||||
{
|
||||
for (int y = minY; y <= maxY; y++)
|
||||
{
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
int blockID = worldObj.getBlockId(x, y, z);
|
||||
|
||||
// Skipping vanilla air & WarpDrive gas blocks, keep WarpDrive air block
|
||||
if (worldObj.isAirBlock(x, y, z) && (blockID != WarpDriveConfig.airID))
|
||||
{
|
||||
if (worldObj.isAirBlock(x, y, z) && (blockID != WarpDriveConfig.airID)) {// whitelist
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -691,8 +784,7 @@ public class EntityJump extends Entity
|
|||
WarpDrive.debugPrint("Block(" + x + ", " + y + ", " + z + ") is " + item.getUnlocalizedName() + ":" + worldObj.getBlockMetadata(x, y, z));
|
||||
/**/
|
||||
|
||||
if ((blockID == Block.bedrock.blockID) || (blockID == 2702)) // Lem
|
||||
{
|
||||
if ((blockID == Block.bedrock.blockID) || (blockID == 2702)) {// Blacklist
|
||||
reason.append("Bedrock detected onboard at " + x + ", " + y + ", " + z + ". Aborting.");
|
||||
LocalProfiler.stop();
|
||||
return -1;
|
||||
|
@ -701,15 +793,12 @@ public class EntityJump extends Entity
|
|||
}
|
||||
}
|
||||
|
||||
// Lem: abort jump if blocks are connecting to the ship (avoid crash when splitting multi-blocks)
|
||||
for (int x = minX - 1; x <= maxX + 1; x++)
|
||||
{
|
||||
// Lem: abort jump if blocks with TE are connecting to the ship (avoid crash when splitting multi-blocks)
|
||||
for (int x = minX - 1; x <= maxX + 1; x++) {
|
||||
boolean xBorder = (x == minX - 1) || (x == maxX + 1);
|
||||
for (int z = minZ - 1; z <= maxZ + 1; z++)
|
||||
{
|
||||
for (int z = minZ - 1; z <= maxZ + 1; z++) {
|
||||
boolean zBorder = (z == minZ - 1) || (z == maxZ + 1);
|
||||
for (int y = minY - 1; y <= maxY + 1; y++)
|
||||
{
|
||||
for (int y = minY - 1; y <= maxY + 1; y++) {
|
||||
boolean yBorder = (y == minY - 1) || (y == maxY + 1);
|
||||
if ((y < 0) || (y > 255))
|
||||
continue;
|
||||
|
@ -719,16 +808,19 @@ public class EntityJump extends Entity
|
|||
int blockID = worldObj.getBlockId(x, y, z);
|
||||
|
||||
// Skipping air blocks
|
||||
if (worldObj.isAirBlock(x, y, z))
|
||||
if (worldObj.isAirBlock(x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skipping unmovable blocks
|
||||
if ((blockID == Block.bedrock.blockID) || (blockID == 2702))
|
||||
if ((blockID == Block.bedrock.blockID) || (blockID == 2702)) {// Blacklist
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity te = worldObj.getBlockTileEntity(x, y, z);
|
||||
if (te == null)
|
||||
if (te == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
reason.append("Ship snagged at " + x + ", " + y + ", " + z + ". Damage report pending...");
|
||||
worldObj.createExplosion((Entity) null, x, y, z, Math.min(4F * 30, 4F * (shipVolume / 50)), false);
|
||||
|
@ -742,15 +834,16 @@ public class EntityJump extends Entity
|
|||
return shipVolume;
|
||||
}
|
||||
|
||||
private void saveEntities(AxisAlignedBB axisalignedbb)
|
||||
{
|
||||
|
||||
private void saveEntities() {
|
||||
entitiesOnShip = new ArrayList<MovingEntity>();
|
||||
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX + 0.99D, maxY + 0.99D, maxZ + 0.99D);
|
||||
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, axisalignedbb);
|
||||
|
||||
for (Object o : list)
|
||||
{
|
||||
if (o == null || !(o instanceof Entity) || (o instanceof EntityJump))
|
||||
{
|
||||
for (Object o : list) {
|
||||
if (o == null || !(o instanceof Entity) || (o instanceof EntityJump)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -760,9 +853,10 @@ public class EntityJump extends Entity
|
|||
}
|
||||
}
|
||||
|
||||
private boolean moveEntities(boolean restorePositions)
|
||||
{
|
||||
|
||||
private boolean moveEntities(boolean restorePositions) {
|
||||
WarpDrive.debugPrint("" + this + " Moving entities");
|
||||
LocalProfiler.start("EntityJump.moveEntities");
|
||||
|
||||
if (entitiesOnShip != null) {
|
||||
for (MovingEntity me : entitiesOnShip) {
|
||||
|
@ -812,7 +906,10 @@ public class EntityJump extends Entity
|
|||
|
||||
ChunkCoordinates bedLocation = player.getBedLocation(player.worldObj.provider.dimensionId);
|
||||
|
||||
if (bedLocation != null && testBB(axisalignedbb, bedLocation.posX, bedLocation.posY, bedLocation.posZ)) {
|
||||
if (bedLocation != null
|
||||
&& minX <= bedLocation.posX && maxX >= bedLocation.posX
|
||||
&& minY <= bedLocation.posY && maxY >= bedLocation.posY
|
||||
&& minZ <= bedLocation.posZ && maxZ >= bedLocation.posZ) {
|
||||
bedLocation.posX = bedLocation.posX + moveX;
|
||||
bedLocation.posY = bedLocation.posY + moveY;
|
||||
bedLocation.posZ = bedLocation.posZ + moveZ;
|
||||
|
@ -826,13 +923,11 @@ public class EntityJump extends Entity
|
|||
}
|
||||
}
|
||||
|
||||
LocalProfiler.stop();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean testBB(AxisAlignedBB axisalignedbb, int x, int y, int z)
|
||||
{
|
||||
return axisalignedbb.minX <= (double) x && axisalignedbb.maxX >= (double) x && axisalignedbb.minY <= (double) y && axisalignedbb.maxY >= (double) y && axisalignedbb.minZ <= (double) z && axisalignedbb.maxZ >= (double) z;
|
||||
}
|
||||
|
||||
|
||||
public int[] getVector(int i)
|
||||
{
|
||||
|
@ -874,36 +969,46 @@ public class EntityJump extends Entity
|
|||
return v;
|
||||
}
|
||||
|
||||
class CollisionResult {
|
||||
public int x = 0, y = 0, z = 0;
|
||||
class CheckMovementResult {
|
||||
public ArrayList<Vector3> atSource;
|
||||
public ArrayList<Vector3> atTarget;
|
||||
public boolean isCollision = false;
|
||||
public String reason = "";
|
||||
CollisionResult(int px, int py, int pz, boolean pisCollision, String preason)
|
||||
{
|
||||
this.x = px;
|
||||
this.y = py;
|
||||
this.z = pz;
|
||||
this.isCollision = pisCollision;
|
||||
this.reason = preason;
|
||||
}
|
||||
};
|
||||
public CollisionResult checkMovement(int testDistance)
|
||||
{
|
||||
if ((direction == -1 && maxY + testDistance > 255) && betweenWorlds) {
|
||||
return new CollisionResult(xCoord, maxY + testDistance, zCoord, false, "[JUMP] Reactor will blow due +high limit");
|
||||
|
||||
CheckMovementResult() {
|
||||
this.atSource = new ArrayList<Vector3>(1);
|
||||
this.atTarget = new ArrayList<Vector3>(1);
|
||||
this.isCollision = false;
|
||||
this.reason = "Unknown reason";
|
||||
}
|
||||
|
||||
if ((direction == -2 && minY - testDistance <= 8) && betweenWorlds) {
|
||||
return new CollisionResult(xCoord, minY - testDistance, zCoord, false, "[JUMP] Reactor will blow due -low limit");
|
||||
public void add(double sx, double sy, double sz, double tx, double ty, double tz, boolean pisCollision, String preason) {
|
||||
atSource.add(new Vector3(sx, sy, sz));
|
||||
atTarget.add(new Vector3(tx, ty, tz));
|
||||
isCollision = isCollision || pisCollision;
|
||||
reason = preason;
|
||||
WarpDrive.debugPrint("CheckMovementResult " + sx + ", " + sy + ", " + sz + " -> " + tx + ", " + ty + ", " + tz + " " + isCollision + " '" + reason + "'");
|
||||
}
|
||||
};
|
||||
private CheckMovementResult checkMovement(int testDistance, boolean fullCollisionDetails) {
|
||||
CheckMovementResult result = new CheckMovementResult();
|
||||
if ((direction == -1 && maxY + testDistance > 255) && !betweenWorlds) {
|
||||
result.add(xCoord, maxY + testDistance, zCoord, xCoord + 0.5D, maxY + testDistance + 1.0D, zCoord + 0.5D,
|
||||
false, "Reactor will blow due +high limit");
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((direction == -2 && minY - testDistance <= 8) && !betweenWorlds) {
|
||||
result.add(xCoord, minY - testDistance, zCoord, xCoord + 0.5D, maxY - testDistance, zCoord + 0.5D,
|
||||
false, "Reactor will blow due -low limit");
|
||||
return result;
|
||||
}
|
||||
|
||||
int movementVector[] = getVector(direction);
|
||||
// TODO: Disasm, plz fix it. Local variable hiding class global field
|
||||
int moveX = movementVector[0] * testDistance;
|
||||
int moveY = movementVector[1] * testDistance;
|
||||
int moveZ = movementVector[2] * testDistance;
|
||||
|
||||
|
||||
int x, y, z, newX, newY, newZ, blockOnShipID, blockID;
|
||||
for (y = minY; y <= maxY; y++) {
|
||||
newY = y + moveY;
|
||||
|
@ -913,20 +1018,38 @@ public class EntityJump extends Entity
|
|||
newZ = z + moveZ;
|
||||
|
||||
blockID = worldObj.getBlockId(newX, newY, newZ);
|
||||
if ((blockID == Block.bedrock.blockID) || (blockID == 2702)) {
|
||||
return new CollisionResult(x, y, z, true, "Unpassable block " + blockID + " detected at destination (" + newX + ";" + newY + ";" + newZ + ")");
|
||||
if ((blockID == Block.bedrock.blockID) || (blockID == 2702)) {// Blacklist
|
||||
result.add(x, y, z,
|
||||
newX + 0.5D - movementVector[0] * 1.0D,
|
||||
newY + 0.5D - movementVector[1] * 1.0D,
|
||||
newZ + 0.5D - movementVector[2] * 1.0D,
|
||||
true, "Unpassable block " + blockID + " detected at destination (" + newX + ";" + newY + ";" + newZ + ")");
|
||||
if (!fullCollisionDetails) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
blockOnShipID = worldObj.getBlockId(x, y, z);
|
||||
if (blockOnShipID != 0 && blockID != 0 && blockID != WarpDriveConfig.airID && blockID != WarpDriveConfig.gasID && blockID != 18) {
|
||||
return new CollisionResult(x, y, z, true, "Obstacle block " + blockID + " detected at (" + newX + ";" + newY + ";" + newZ + ")");
|
||||
result.add(x, y, z,
|
||||
newX + 0.5D + movementVector[0] * 0.1D,
|
||||
newY + 0.5D + movementVector[1] * 0.1D,
|
||||
newZ + 0.5D + movementVector[2] * 0.1D,
|
||||
true, "Obstacle block #" + blockID + " detected at (" + newX + ", " + newY + ", " + newZ + ")");
|
||||
if (!fullCollisionDetails) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fullCollisionDetails && result.isCollision) {
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOffModem(IPeripheral p)
|
||||
{
|
||||
|
@ -1074,7 +1197,7 @@ public class EntityJump extends Entity
|
|||
return true;
|
||||
}
|
||||
|
||||
public ArrayList<Object> removeDuplicates(List<TileEntity> l)
|
||||
private ArrayList<Object> removeDuplicates(List<TileEntity> l)
|
||||
{
|
||||
Set<TileEntity> s = new TreeSet<TileEntity>(new Comparator<TileEntity>()
|
||||
{
|
||||
|
@ -1275,4 +1398,14 @@ public class EntityJump extends Entity
|
|||
minZ = minZV;
|
||||
maxZ = maxZV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s/%d \'%s\' @ \'%s\' %.2f, %.2f, %.2f", new Object[] {
|
||||
getClass().getSimpleName(),
|
||||
Integer.valueOf(entityId),
|
||||
reactor == null ? "~NULL~" : reactor.coreFrequency,
|
||||
worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(),
|
||||
Double.valueOf(posX), Double.valueOf(posY), Double.valueOf(posZ)});
|
||||
}
|
||||
}
|
|
@ -60,18 +60,18 @@ public final class EntitySphereGen extends Entity
|
|||
private final int STATE_DELETE = 2;
|
||||
private final int STATE_STOP = 3;
|
||||
private int state = STATE_DELETE;
|
||||
private int ticksDelay = 0;
|
||||
|
||||
private int currentIndex = 0;
|
||||
private int pregenSize = 0;
|
||||
|
||||
private ArrayList<JumpBlock> blocks;
|
||||
|
||||
public EntitySphereGen(World world)
|
||||
{
|
||||
public EntitySphereGen(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntitySphereGen(World world, int x, int y, int z, int radius, int blockID, int blockMeta, boolean hollow, boolean fillingSphere, boolean generateOres)
|
||||
{
|
||||
public EntitySphereGen(World world, int x, int y, int z, int radius, int blockID, int blockMeta, boolean hollow, boolean fillingSphere, boolean generateOres) {
|
||||
super(world);
|
||||
this.xCoord = x;
|
||||
this.posX = (double) x;
|
||||
|
@ -85,26 +85,29 @@ public final class EntitySphereGen extends Entity
|
|||
this.generateOres = generateOres;
|
||||
this.gasColor = worldObj.rand.nextInt(12);
|
||||
this.state = STATE_SAVING;
|
||||
blocks = new ArrayList<JumpBlock>();
|
||||
this.pregenSize = (int)Math.ceil(Math.PI * 4.0F / 3.0F * Math.pow(radius + 1, 3));
|
||||
blocks = new ArrayList<JumpBlock>(this.pregenSize);
|
||||
this.defaultBlock = new int[] {blockID, blockMeta};
|
||||
this.ticksDelay = world.rand.nextInt(60);
|
||||
}
|
||||
|
||||
public void killEntity()
|
||||
{
|
||||
public void killEntity() {
|
||||
this.state = STATE_STOP;
|
||||
worldObj.removeEntity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
public void onUpdate() {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this.state)
|
||||
{
|
||||
if (ticksDelay > 0) {
|
||||
ticksDelay--;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this.state) {
|
||||
case STATE_SAVING:
|
||||
tickScheduleBlocks();
|
||||
this.state = STATE_SETUP;
|
||||
|
@ -122,14 +125,12 @@ public final class EntitySphereGen extends Entity
|
|||
}
|
||||
}
|
||||
|
||||
private void tickPlaceBlocks()
|
||||
{
|
||||
private void tickPlaceBlocks() {
|
||||
int blocksToMove = Math.min(BLOCKS_PER_TICK, blocks.size() - currentIndex);
|
||||
// LocalProfiler.start("[EntitySphereGen] Placing blocks: " + currentIndex + "/" + blocks.size());
|
||||
int notifyFlag;
|
||||
|
||||
for (int index = 0; index < blocksToMove; index++)
|
||||
{
|
||||
for (int index = 0; index < blocksToMove; index++) {
|
||||
if (currentIndex >= blocks.size())
|
||||
break;
|
||||
notifyFlag = (currentIndex % 1000 == 0 ? 2 : 0);
|
||||
|
@ -141,10 +142,8 @@ public final class EntitySphereGen extends Entity
|
|||
// LocalProfiler.stop();
|
||||
}
|
||||
|
||||
private void tickScheduleBlocks()
|
||||
{
|
||||
System.out.println("[EntitySphereGen] Scheduling blocks...");
|
||||
LocalProfiler.start("EntitySphereGen.tickScheduleBlocks");
|
||||
private void tickScheduleBlocks() {
|
||||
// LocalProfiler.start("EntitySphereGen.tickScheduleBlocks");
|
||||
radius += 0.5D; // Radius from center of block
|
||||
double radiusSq = radius * radius; // Optimization to avoid square roots
|
||||
double radius1Sq = (radius - 1.0D) * (radius - 1.0D); // for hollow sphere
|
||||
|
@ -152,14 +151,11 @@ public final class EntitySphereGen extends Entity
|
|||
|
||||
// Pass the cube and check points for sphere equation x^2 + y^2 + z^2 = r^2
|
||||
int[] block = defaultBlock;
|
||||
for (int x = 0; x <= ceilRadius; x++)
|
||||
{
|
||||
for (int x = 0; x <= ceilRadius; x++) {
|
||||
double x2 = (x + 0.5D) * (x + 0.5D);
|
||||
for (int y = 0; y <= ceilRadius; y++)
|
||||
{
|
||||
for (int y = 0; y <= ceilRadius; y++) {
|
||||
double y2 = (y + 0.5D) * (y + 0.5D);
|
||||
for (int z = 0; z <= ceilRadius; z++)
|
||||
{
|
||||
for (int z = 0; z <= ceilRadius; z++) {
|
||||
double z2 = (z + 0.5D) * (z + 0.5D);
|
||||
double dSq = x2 + y2 + z2; // Distance from current position to center
|
||||
|
||||
|
@ -198,13 +194,13 @@ public final class EntitySphereGen extends Entity
|
|||
}
|
||||
}
|
||||
}
|
||||
if (blocks != null)
|
||||
System.out.println("[EntitySphereGen] Saved " + blocks.size() + " blocks");
|
||||
LocalProfiler.stop();
|
||||
if (blocks != null) {
|
||||
WarpDrive.debugPrint("[EntitySphereGen] Saved " + blocks.size() + " blocks (estimated to " + pregenSize + ")");
|
||||
}
|
||||
// LocalProfiler.stop();
|
||||
}
|
||||
|
||||
private void addBlock(JumpBlock jb)
|
||||
{
|
||||
private void addBlock(JumpBlock jb) {
|
||||
if (blocks == null)
|
||||
return;
|
||||
// Replace water with random gas (ship in moon)
|
||||
|
@ -223,31 +219,25 @@ public final class EntitySphereGen extends Entity
|
|||
blocks.add(jb);
|
||||
}
|
||||
|
||||
private static double lengthSq(double x, double y, double z)
|
||||
{
|
||||
private static double lengthSq(double x, double y, double z) {
|
||||
return (x * x) + (y * y) + (z * z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
protected void readEntityFromNBT(NBTTagCompound tag) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
protected void entityInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound tag)
|
||||
{
|
||||
protected void writeEntityToNBT(NBTTagCompound tag) {
|
||||
}
|
||||
|
||||
// Own implementation of setting blocks without light recalculation in optimization purposes
|
||||
public boolean mySetBlock(World w, int x, int y, int z, int blockId, int blockMeta, int par6)
|
||||
{
|
||||
if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000)
|
||||
{
|
||||
public boolean mySetBlock(World w, int x, int y, int z, int blockId, int blockMeta, int par6) {
|
||||
if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000) {
|
||||
if (y < 0)
|
||||
return false;
|
||||
else if (y >= 256)
|
||||
|
@ -255,13 +245,12 @@ public final class EntitySphereGen extends Entity
|
|||
w.markBlockForUpdate(x, y, z);
|
||||
Chunk chunk = w.getChunkFromChunkCoords(x >> 4, z >> 4);
|
||||
return myChunkSBIDWMT(chunk, x & 15, y, z & 15, blockId, blockMeta);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, int blockId, int blockMeta)
|
||||
{
|
||||
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;
|
||||
|
@ -303,8 +292,7 @@ public final class EntitySphereGen extends Entity
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass)
|
||||
{
|
||||
public boolean shouldRenderInPass(int pass) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -51,63 +51,41 @@ public class GenerateCommand extends CommandBase
|
|||
int y = MathHelper.floor_double(player.posY);
|
||||
int z = MathHelper.floor_double(player.posZ);
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
|
||||
{
|
||||
if (struct.equals("moon"))
|
||||
{
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
if (struct.equals("moon")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating moon at " + x + ", " + (y - 16) + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateMoon(player.worldObj, x, y - 16, z);
|
||||
}
|
||||
else if (struct.equals("ship"))
|
||||
{
|
||||
} else if (struct.equals("ship")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating NPC ship at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
new WorldGenSmallShip(false).generate(player.worldObj, player.worldObj.rand, x, y, z);
|
||||
}
|
||||
else if (struct.equals("asteroid"))
|
||||
{
|
||||
} else if (struct.equals("asteroid")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating asteroid at " + x + ", " + (y - 10) + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateAsteroid(player.worldObj, x, y - 10, z, 6, 11);
|
||||
}
|
||||
else if (struct.equals("astfield"))
|
||||
{
|
||||
WarpDrive.instance.spaceWorldGenerator.generateRandomAsteroid(player.worldObj, x, y - 10, z, 6, 11);
|
||||
} else if (struct.equals("astfield")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating asteroid field at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateAsteroidField(player.worldObj, x, y, z);
|
||||
}
|
||||
else if (struct.equals("gascloud"))
|
||||
{
|
||||
} else if (struct.equals("gascloud")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating gas cloud at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateGasCloudOfColor(player.worldObj, x, y, z, 15, 20, player.worldObj.rand.nextInt(12));
|
||||
}
|
||||
else if (struct.equals("star"))
|
||||
{
|
||||
} else if (struct.equals("star")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating star at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
Integer type = (params.length > 1) ? Integer.parseInt(params[1]) : -1; // Lem
|
||||
WarpDrive.instance.spaceWorldGenerator.generateStar(player.worldObj, x, y, z, type); // Lem
|
||||
}
|
||||
else if (struct.equals("jumpgate"))
|
||||
{
|
||||
if (params.length == 2)
|
||||
{
|
||||
} else if (struct.equals("jumpgate")) {
|
||||
if (params.length == 2) {
|
||||
notifyAdmins(icommandsender, "/generate: creating jumpgate at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
|
||||
if (WarpDrive.instance.jumpGates.addGate(params[1], x, y, z))
|
||||
{
|
||||
if (WarpDrive.instance.jumpGates.addGate(params[1], x, y, z)) {
|
||||
JumpGateGenerator.generate(player.worldObj, x, Math.min(y,255-JumpGateGenerator.GATE_SIZE_HALF - 1), z);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
notifyAdmins(icommandsender, "/generate: jumpgate '" + params[1] + "' already exists.", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
player.addChatMessage(getCommandUsage(icommandsender));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
player.addChatMessage(getCommandUsage(icommandsender));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ public final class JumpGatesRegistry
|
|||
private ArrayList<JumpGate> gates = new ArrayList<JumpGate>();
|
||||
|
||||
//@SideOnly(Side.CLIENT)
|
||||
public JumpGatesRegistry()
|
||||
{
|
||||
public JumpGatesRegistry() {
|
||||
db = new File("gates.txt");
|
||||
System.out.println("Gates.txt file: " + db);
|
||||
|
||||
|
@ -31,38 +30,31 @@ public final class JumpGatesRegistry
|
|||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
loadGates();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(JumpGatesRegistry.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveGates() throws IOException
|
||||
{
|
||||
public void saveGates() throws IOException {
|
||||
PrintWriter out = new PrintWriter(new FileWriter(db));
|
||||
|
||||
// Write each string in the array on a separate line
|
||||
for (JumpGate jg : gates)
|
||||
{
|
||||
for (JumpGate jg : gates) {
|
||||
out.println(jg);
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
public void loadGates() throws IOException
|
||||
{
|
||||
public void loadGates() throws IOException {
|
||||
System.out.println("[JUMP GATES] Loading jump gates from gates.txt...");
|
||||
BufferedReader bufferedreader;
|
||||
bufferedreader = new BufferedReader(new FileReader(db));
|
||||
String s1;
|
||||
|
||||
while ((s1 = bufferedreader.readLine()) != null)
|
||||
{
|
||||
while ((s1 = bufferedreader.readLine()) != null) {
|
||||
gates.add(new JumpGate(s1));
|
||||
}
|
||||
|
||||
|
@ -70,39 +62,31 @@ public final class JumpGatesRegistry
|
|||
System.out.println("[JUMP GATES] Loaded " + gates.size() + " jump gates.");
|
||||
}
|
||||
|
||||
public void addGate(JumpGate jg)
|
||||
{
|
||||
public void addGate(JumpGate jg) {
|
||||
gates.add(jg);
|
||||
}
|
||||
|
||||
public boolean addGate(String name, int x, int y, int z)
|
||||
{
|
||||
public boolean addGate(String name, int x, int y, int z) {
|
||||
// Gate already exists
|
||||
if (findGateByName(name) != null)
|
||||
{
|
||||
if (findGateByName(name) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
addGate(new JumpGate(name, x, y, z));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
saveGates();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(JumpGatesRegistry.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeGate(String name)
|
||||
{
|
||||
public void removeGate(String name) {
|
||||
JumpGate jg;
|
||||
|
||||
for (int i = 0; i < gates.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < gates.size(); i++) {
|
||||
jg = gates.get(i);
|
||||
|
||||
if (jg.name.equalsIgnoreCase(name))
|
||||
|
@ -112,22 +96,16 @@ public final class JumpGatesRegistry
|
|||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
saveGates();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(JumpGatesRegistry.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public JumpGate findGateByName(String name)
|
||||
{
|
||||
for (JumpGate jg : gates)
|
||||
{
|
||||
if (jg.name.equalsIgnoreCase(name))
|
||||
{
|
||||
public JumpGate findGateByName(String name) {
|
||||
for (JumpGate jg : gates) {
|
||||
if (jg.name.equalsIgnoreCase(name)) {
|
||||
return jg;
|
||||
}
|
||||
}
|
||||
|
@ -135,43 +113,36 @@ public final class JumpGatesRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public String jumpGatesList()
|
||||
{
|
||||
public String jumpGatesList() {
|
||||
String result = "";
|
||||
|
||||
for (JumpGate jg : gates)
|
||||
{
|
||||
for (JumpGate jg : gates) {
|
||||
result += jg.toNiceString() + "\n";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String commaList()
|
||||
{
|
||||
public String commaList() {
|
||||
String result = "";
|
||||
for (JumpGate jg : gates)
|
||||
{
|
||||
for (JumpGate jg : gates) {
|
||||
result += jg.toNiceString() + ",";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public JumpGate findNearestGate(int x, int y, int z)
|
||||
{
|
||||
public JumpGate findNearestGate(int x, int y, int z) {
|
||||
// WarpDrive.debugPrint(jumpGatesList());
|
||||
double minDistance2 = -1;
|
||||
JumpGate res = null;
|
||||
|
||||
for (JumpGate jg : gates)
|
||||
{
|
||||
for (JumpGate jg : gates) {
|
||||
double dX = jg.xCoord - x;
|
||||
double dY = jg.yCoord - y;
|
||||
double dZ = jg.zCoord - z;
|
||||
double distance2 = dX * dX + dY * dY + dZ * dZ;
|
||||
|
||||
if ((minDistance2 == -1) || (distance2 < minDistance2))
|
||||
{
|
||||
if ((minDistance2 == -1) || (distance2 < minDistance2)) {
|
||||
minDistance2 = distance2;
|
||||
res = jg;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ public class PacketHandler implements IPacketHandler
|
|||
public void handleCloak(Packet250CustomPayload packet, EntityPlayer player) {
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
// Read cloaked area parameters
|
||||
int minX = inputStream.readInt();
|
||||
int minY = inputStream.readInt();
|
||||
|
@ -72,11 +71,17 @@ public class PacketHandler implements IPacketHandler
|
|||
|
||||
// Now hide the blocks within area
|
||||
World worldObj = player.worldObj;
|
||||
for (int y = minY; y <= maxY; y++)
|
||||
for (int x = minX; x <= maxX; x++)
|
||||
for(int z = minZ; z <= maxZ; z++)
|
||||
if (worldObj.getBlockId(x, y, z) != 0)
|
||||
worldObj.setBlock(x, y, z, (tier == 1) ? WarpDriveConfig.gasID : 0, (tier == 1) ? 5 : 0, 4);
|
||||
int cloakBlockID = (tier == 1) ? WarpDriveConfig.gasID : 0;
|
||||
int cloakBlockMetadata = (tier == 1) ? 5 : 0;
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for(int z = minZ; z <= maxZ; z++) {
|
||||
if (worldObj.getBlockId(x, y, z) != 0) {
|
||||
worldObj.setBlock(x, y, z, cloakBlockID, cloakBlockMetadata, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//WarpDrive.debugPrint("[Cloak Packet] Removing entity...");
|
||||
// Hide any entities inside area
|
||||
|
@ -90,53 +95,30 @@ public class PacketHandler implements IPacketHandler
|
|||
player.worldObj.markBlockRangeForRenderUpdate(minX + 1, minY + 1, minZ + 1, maxX + 1, maxY + 1, maxZ + 1);
|
||||
|
||||
// Make some graphics
|
||||
int numLasers = 25 + player.worldObj.rand.nextInt(100);
|
||||
int numLasers = 80 + player.worldObj.rand.nextInt(50);
|
||||
|
||||
double centerX = (minX + maxX) / 2.0D;
|
||||
double centerY = (minY + maxY) / 2.0D;
|
||||
double centerZ = (minZ + maxZ) / 2.0D;
|
||||
double radiusX = (maxX - minX) / 2.0D + 5.0D;
|
||||
double radiusY = (maxY - minY) / 2.0D + 5.0D;
|
||||
double radiusZ = (maxZ - minZ) / 2.0D + 5.0D;
|
||||
|
||||
for (int i = 0; i < numLasers; i++) {
|
||||
int randX1 = minX + player.worldObj.rand.nextInt(maxX - minX);
|
||||
int randX2 = minX + player.worldObj.rand.nextInt(maxX - minX);
|
||||
|
||||
int randY1 = minY + player.worldObj.rand.nextInt(maxY - minY);
|
||||
int randY2 = minY + player.worldObj.rand.nextInt(maxY - minY);
|
||||
|
||||
int randZ1 = minZ + player.worldObj.rand.nextInt(maxZ - minZ);
|
||||
int randZ2 = minZ + player.worldObj.rand.nextInt(maxZ - minZ);
|
||||
|
||||
float r = 0, g = 0, b = 0;
|
||||
|
||||
switch (player.worldObj.rand.nextInt(6)) {
|
||||
case 0:
|
||||
r = 1.0f;
|
||||
g = b = 0;
|
||||
break;
|
||||
case 1:
|
||||
r = b = 0;
|
||||
g = 1.0f;
|
||||
break;
|
||||
case 2:
|
||||
r = g = 0;
|
||||
b = 1.0f;
|
||||
break;
|
||||
case 3:
|
||||
r = b = 0.5f;
|
||||
g = 0;
|
||||
break;
|
||||
case 4:
|
||||
r = g = 1.0f;
|
||||
b = 0;
|
||||
break;
|
||||
case 5:
|
||||
r = 1.0f;
|
||||
b = 0.5f;
|
||||
g = 0f;
|
||||
}
|
||||
|
||||
WarpDrive.proxy.renderBeam(player.worldObj, new Vector3(randX1, randY1, randZ1), new Vector3(randX2, randY2, randZ2), r, g, b, 60, 100);
|
||||
WarpDrive.proxy.renderBeam(player.worldObj,
|
||||
new Vector3(
|
||||
centerX + radiusX * player.worldObj.rand.nextGaussian(),
|
||||
centerY + radiusY * player.worldObj.rand.nextGaussian(),
|
||||
centerZ + radiusZ * player.worldObj.rand.nextGaussian()),
|
||||
new Vector3(
|
||||
centerX + radiusX * player.worldObj.rand.nextGaussian(),
|
||||
centerY + radiusY * player.worldObj.rand.nextGaussian(),
|
||||
centerZ + radiusZ * player.worldObj.rand.nextGaussian()),
|
||||
player.worldObj.rand.nextFloat(), player.worldObj.rand.nextFloat(), player.worldObj.rand.nextFloat(),
|
||||
60 + player.worldObj.rand.nextInt(60), 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,8 @@ public class SpaceEventHandler {
|
|||
private HashMap<Integer, Integer> entity_airBlock;
|
||||
private HashMap<String, Integer> player_airTank;
|
||||
private HashMap<String, Integer> player_cloakTicks;
|
||||
private long lastTimer = 0;
|
||||
|
||||
private final int CLOAK_CHECK_TIMEOUT_SEC = 5;
|
||||
private final int CLOAK_CHECK_TIMEOUT_TICKS = 100;
|
||||
private final int AIR_BLOCK_TICKS = 20;
|
||||
private final int AIR_TANK_TICKS = 300;
|
||||
|
||||
|
@ -38,7 +37,6 @@ public class SpaceEventHandler {
|
|||
entity_airBlock = new HashMap<Integer, Integer>();
|
||||
player_airTank = new HashMap<String, Integer>();
|
||||
player_cloakTicks = new HashMap<String, Integer>();
|
||||
this.lastTimer = 0;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
|
@ -67,27 +65,27 @@ public class SpaceEventHandler {
|
|||
// If player in vacuum, check and start consuming air cells
|
||||
if (entity.worldObj.provider.dimensionId == WarpDriveConfig.G_SPACE_DIMENSION_ID || entity.worldObj.provider.dimensionId == WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID) {
|
||||
int id1 = entity.worldObj.getBlockId(x, y, z);
|
||||
int id2 = entity.worldObj.getBlockId(x, y + 1, z);
|
||||
int id2 = entity.worldObj.getBlockId(x, y - 1, z);
|
||||
boolean inVacuum = (id1 != WarpDriveConfig.airID && id2 != WarpDriveConfig.airID);
|
||||
Integer air;
|
||||
if (!inVacuum) {// In space with air blocks
|
||||
air = entity_airBlock.get(entity.entityId);
|
||||
if (air == null) {
|
||||
entity_airBlock.put(entity.entityId, AIR_BLOCK_TICKS);
|
||||
} else if (air <= 0) {// time elapsed => consume air block
|
||||
} else if (air <= 1) {// time elapsed => consume air block
|
||||
entity_airBlock.put(entity.entityId, AIR_BLOCK_TICKS);
|
||||
|
||||
int metadata;
|
||||
if (id2 != WarpDriveConfig.airID) {
|
||||
metadata = entity.worldObj.getBlockMetadata(x, y + 1, z);
|
||||
if (metadata > 0 && metadata < 15) {
|
||||
entity.worldObj.setBlockMetadataWithNotify(x, y + 1, z, metadata - 1, 2);
|
||||
}
|
||||
} else {
|
||||
if (id1 == WarpDriveConfig.airID) {
|
||||
metadata = entity.worldObj.getBlockMetadata(x, y, z);
|
||||
if (metadata > 0 && metadata < 15) {
|
||||
entity.worldObj.setBlockMetadataWithNotify(x, y, z, metadata - 1, 2);
|
||||
}
|
||||
} else {
|
||||
metadata = entity.worldObj.getBlockMetadata(x, y - 1, z);
|
||||
if (metadata > 0 && metadata < 15) {
|
||||
entity.worldObj.setBlockMetadataWithNotify(x, y - 1, z, metadata - 1, 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
entity_airBlock.put(entity.entityId, air - 1);
|
||||
|
@ -99,9 +97,9 @@ public class SpaceEventHandler {
|
|||
|
||||
if ((player.getCurrentArmor(3) != null) && (WarpDriveConfig.SpaceHelmets.contains(player.getCurrentArmor(3).itemID))) {
|
||||
air = player_airTank.get(player.username);
|
||||
if (air == null) {
|
||||
player_airTank.put(player.username, AIR_TANK_TICKS);
|
||||
} else if (air <= 0) {
|
||||
if (air == null) {// new player in space => grace period
|
||||
player_airTank.put(player.username, AIR_TANK_TICKS / 2);
|
||||
} else if (air <= 1) {
|
||||
if (consumeO2(player.inventory.mainInventory, player)) {
|
||||
player_airTank.put(player.username, AIR_TANK_TICKS);
|
||||
} else {
|
||||
|
@ -130,13 +128,6 @@ public class SpaceEventHandler {
|
|||
}
|
||||
|
||||
private void updatePlayerCloakState(EntityLivingBase entity) {
|
||||
// Make sure for elapsed time is second after last update
|
||||
if (System.currentTimeMillis() - this.lastTimer > 1000) {
|
||||
lastTimer = System.currentTimeMillis();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
EntityPlayerMP player = (EntityPlayerMP)entity;
|
||||
Integer cloakTicks = player_cloakTicks.get(player.username);
|
||||
|
@ -146,7 +137,7 @@ public class SpaceEventHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
if (cloakTicks >= CLOAK_CHECK_TIMEOUT_SEC) {
|
||||
if (cloakTicks >= CLOAK_CHECK_TIMEOUT_TICKS) {
|
||||
player_cloakTicks.put(player.username, 0);
|
||||
|
||||
List<CloakedArea> cloaks = WarpDrive.instance.cloaks.getCloaksForPoint(player.worldObj.provider.dimensionId, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), false);
|
||||
|
@ -154,18 +145,20 @@ public class SpaceEventHandler {
|
|||
//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) && area.isPlayerWithinArea(player)) {
|
||||
if (!area.isPlayerInArea(player.username) && area.isEntityWithinArea(player)) {
|
||||
WarpDrive.instance.cloaks.playerEnteringCloakedArea(area, player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//WarpDrive.debugPrint("[Cloak] Player is not inside any cloak fields. Check, which field player may left...");
|
||||
WarpDrive.instance.cloaks.checkPlayerLeavedArea(player);
|
||||
WarpDrive.instance.cloaks.checkPlayerLeftArea(player);
|
||||
}
|
||||
} else {
|
||||
player_cloakTicks.put(player.username, cloakTicks + 1);
|
||||
}
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean consumeO2(ItemStack[] inventory, EntityPlayerMP entityPlayer) {
|
||||
|
@ -177,7 +170,7 @@ public class SpaceEventHandler {
|
|||
}
|
||||
|
||||
if (WarpDriveConfig.IC2_Empty.length != 0) {
|
||||
WarpDrive.debugPrint("giveEmptyCell");
|
||||
// WarpDrive.debugPrint("giveEmptyCell");
|
||||
ItemStack emptyCell = new ItemStack(WarpDriveConfig.IC2_Empty[0], 1, WarpDriveConfig.IC2_Empty[1]);
|
||||
if (!entityPlayer.inventory.addItemStackToInventory(emptyCell)) {
|
||||
World world = entityPlayer.worldObj;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cr0s.WarpDrive;
|
||||
|
||||
import cr0s.WarpDrive.machines.TileEntityReactor;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -7,27 +8,26 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class SpaceTpCommand extends CommandBase
|
||||
{
|
||||
public class SpaceTpCommand extends CommandBase {
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
public String getCommandName() {
|
||||
return "space";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring)
|
||||
{
|
||||
EntityPlayerMP player = (EntityPlayerMP)icommandsender;
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring) {
|
||||
EntityPlayerMP player = null;
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
int targetDim = WarpDriveConfig.G_SPACE_DIMENSION_ID;
|
||||
|
||||
if (icommandsender != null && icommandsender instanceof EntityPlayerMP) {
|
||||
player = (EntityPlayerMP)icommandsender;
|
||||
}
|
||||
if (astring.length >= 1) {
|
||||
if ("hyper".equals(astring[0])) {
|
||||
targetDim = WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID;
|
||||
|
@ -39,6 +39,7 @@ public class SpaceTpCommand extends CommandBase
|
|||
}
|
||||
|
||||
if (player == null) {
|
||||
notifyAdmins(icommandsender, "/space: undefined player");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,8 +50,7 @@ public class SpaceTpCommand extends CommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender)
|
||||
{
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "/space [hyper|overworld|<player>]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,11 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
return;
|
||||
int y = Y_LIMIT_DOWN + random.nextInt(Y_LIMIT - Y_LIMIT_DOWN);
|
||||
// Moon setup
|
||||
if (random.nextInt(900) == 1)
|
||||
if (random.nextInt(700) == 1)
|
||||
generateMoon(world, x, y, z);
|
||||
// Simple asteroids
|
||||
else if (random.nextInt(150) == 1) {
|
||||
generateAsteroid(world, x, y, z, 6, 11);
|
||||
generateAsteroidOfBlock(world, x, y, z, 6, 11, -1, 0);
|
||||
// Random asteroid of block
|
||||
} else if (random.nextInt(400) == 1) {
|
||||
generateRandomAsteroid(world, x, y, z, 6, 11);
|
||||
|
@ -60,7 +60,7 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
}
|
||||
} else if (random.nextInt(200) == 1) {// Ice asteroid
|
||||
generateAsteroidOfBlock(world, x, y, z, 6, 11, Block.ice.blockID, 0);
|
||||
} else if (random.nextInt(600) == 1) {// Asteroid field
|
||||
} else if (random.nextInt(500) == 1) {// Asteroid field
|
||||
generateAsteroidField(world, x, y, z);
|
||||
} else if (random.nextInt(1400) == 1) {// Diamond asteroid
|
||||
generateAsteroidOfBlock(world, x, y, z, 3, 2, Block.oreDiamond.blockID, 0);
|
||||
|
@ -87,16 +87,16 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
|
||||
// Generate moon's core
|
||||
if (block[0] == Block.netherrack.blockID) {
|
||||
generateSphere2(world, x, y2, z, coreRadius, false, Block.lavaStill.blockID, 0, false); // Lava core
|
||||
generateSphereDirect(world, x, y2, z, coreRadius, false, Block.lavaStill.blockID, 0, false); // Lava core
|
||||
world.setBlock(x, y2, z, Block.bedrock.blockID, 0, 0);
|
||||
} else if (block[0] != Block.whiteStone.blockID) {
|
||||
if (world.rand.nextInt(100) >= 10) {
|
||||
generateSphere2(world, x, y2, z, coreRadius, false, Block.lavaStill.blockID, 0, false); // Lava core
|
||||
generateSphereDirect(world, x, y2, z, coreRadius, false, Block.lavaStill.blockID, 0, false); // Lava core
|
||||
world.setBlock(x, y2, z, Block.bedrock.blockID, 0, 0);
|
||||
generateSphere2(world, x, y2, z, coreRadius + 1, false, Block.obsidian.blockID, 0, true); // Obsidian shell
|
||||
generateSphereDirect(world, x, y2, z, coreRadius + 1, false, Block.obsidian.blockID, 0, true); // Obsidian shell
|
||||
} else {
|
||||
coreRadius = Math.max(coreRadius, 7);
|
||||
generateSphere2(world, x, y2, z, coreRadius, false, Block.leaves.blockID, 0, false);
|
||||
generateSphereDirect(world, x, y2, z, coreRadius, false, Block.leaves.blockID, 0, false);
|
||||
world.setBlock(x, y2, z, Block.bedrock.blockID, 0, 0);
|
||||
generateSmallShip(world, x, y2, z, coreRadius - 6);
|
||||
}
|
||||
|
@ -170,28 +170,25 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
}
|
||||
}
|
||||
|
||||
private void generateSphereEntity(World world, int x, int y, int z, int radius, boolean hollow, int blockID, int blockMeta, boolean generateOres)
|
||||
{
|
||||
private void generateSphereEntity(World world, int x, int y, int z, int radius, boolean hollow, int blockID, int blockMeta, boolean generateOres) {
|
||||
EntitySphereGen esg = new EntitySphereGen(world, x, y, z, radius, blockID, blockMeta, hollow, true, generateOres);
|
||||
world.spawnEntityInWorld(esg);
|
||||
}
|
||||
|
||||
private void generateGasSphereEntity(World world, int x, int y, int z, int radius, boolean hollow, int color)
|
||||
{
|
||||
private void generateGasSphereEntity(World world, int x, int y, int z, int radius, boolean hollow, int color) {
|
||||
EntitySphereGen esg = new EntitySphereGen(world, x, y, z, radius, WarpDriveConfig.gasID, color, hollow, true, false);
|
||||
world.spawnEntityInWorld(esg);
|
||||
}
|
||||
|
||||
private void generateSmallShip(World world, int x, int y, int z, int jitter)
|
||||
{
|
||||
private void generateSmallShip(World world, int x, int y, int z, int jitter) {
|
||||
x = x + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(jitter));
|
||||
y = y + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(jitter));
|
||||
z = z + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(jitter));
|
||||
System.out.println("Generating small ship at " + x + " " + y + " " + z);
|
||||
System.out.println("Generating small ship at " + x + "," + y + "," + z);
|
||||
new WorldGenSmallShip(world.rand.nextBoolean()).generate(world, world.rand, x, y, z);
|
||||
}
|
||||
|
||||
private void generateRandomAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) {
|
||||
public void generateRandomAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) {
|
||||
if (world.rand.nextInt(30) == 1) {
|
||||
int[] t = new int[] {0, 0};
|
||||
if (world.rand.nextInt(25) == 1) {
|
||||
|
@ -209,58 +206,129 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
}
|
||||
generateAsteroidOfBlock(world, x, y, z, Math.min(3, asteroidSizeMax), Math.min(2, centerRadiusMax), t[0], t[1]);
|
||||
} else {
|
||||
generateAsteroid(world, x, y, z, asteroidSizeMax, centerRadiusMax);
|
||||
generateAsteroidOfBlock(world, x, y, z, asteroidSizeMax, centerRadiusMax, -1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateAsteroidField(World world, int x, int y, int z)
|
||||
{
|
||||
int numOfAsteroids = 50 + world.rand.nextInt(80);
|
||||
int numOfClouds = 5 + world.rand.nextInt(8);
|
||||
// Minimal distance between asteroids in field
|
||||
final int FIELD_ASTEROID_MIN_DISTANCE = 3;
|
||||
// Maximum distance
|
||||
// final int FIELD_ASTEROID_MAX_DISTANCE = 120;
|
||||
int maxDistance = 70 + world.rand.nextInt(80);
|
||||
int maxHeight = 40 + world.rand.nextInt(40);
|
||||
private float binomialRandom(World world) {
|
||||
float linear = world.rand.nextFloat();
|
||||
// ideal sphere repartition = linear ^ 0.5 (sqrt)
|
||||
// Dilution but slow to compute = 0.5 * ( x ^ 0.3 + 1 + (x - 1) ^ 3 )
|
||||
// Optimized form = 1.25 - 0.625 / (0.5 + 2 * x)
|
||||
// rectangular approach: return 0.5F * linear + 0.5F * linear * linear;
|
||||
return 1.25F - 0.625F / (0.5F + 2.0F * linear);
|
||||
}
|
||||
public void generateAsteroidField(World world, int x, int y, int z) {
|
||||
LocalProfiler.start("SpaceWorldGenerator.generateAsteroidField");
|
||||
// 6.0.1 au = 120 radius with 60 to 140 big + 60 to 140 small + 5 to 13 gaz
|
||||
// 45238 blocks surface with 120 to 280 asteroids => 161 to 376 blocks per asteroid (big & small)
|
||||
|
||||
// 6.0.2 av big = 80 to 180 radius with 40 to 90 big + 80 to 200 small + 5 to 13 gaz
|
||||
// 20106 to 101787 surface with 120 to 290 asteroids => 69 to 848 blocks per asteroid
|
||||
|
||||
// 6.0.2 av small = 30 to 80 radius with 2 to 22 big + 15 to 75 small + 0 to 3 gaz
|
||||
// 2827 to 20106 surface with 17 to 97 asteroids => 29 to 1182 blocks per asteroid
|
||||
|
||||
// random distanced one = 89727 surface 256 asteroids => 350 blocks per asteroid
|
||||
|
||||
/*
|
||||
boolean isBig = world.rand.nextInt(3) == 1;
|
||||
int numOfBigAsteroids, numOfSmallAsteroids, numOfClouds, maxDistance, maxHeight;
|
||||
if (isBig) {
|
||||
numOfBigAsteroids = 40 + world.rand.nextInt(50);
|
||||
numOfSmallAsteroids = 80 + world.rand.nextInt(120);
|
||||
numOfClouds = 5 + world.rand.nextInt(8);
|
||||
maxDistance = 80 + world.rand.nextInt(100);
|
||||
maxHeight = 40 + world.rand.nextInt(40);
|
||||
} else {
|
||||
numOfBigAsteroids = 2 + world.rand.nextInt(20);
|
||||
numOfSmallAsteroids = 15 + world.rand.nextInt(60);
|
||||
numOfClouds = 0 + world.rand.nextInt(3);
|
||||
maxDistance = 30 + world.rand.nextInt(50);
|
||||
maxHeight = 30 + world.rand.nextInt(30);
|
||||
}/**/
|
||||
|
||||
float surfacePerAsteroid = 80.0F + world.rand.nextFloat() * 300;
|
||||
int maxDistance = 30 + world.rand.nextInt(170);
|
||||
int maxDistanceBig = Math.round(maxDistance * (0.6F + 0.2F * world.rand.nextFloat()));
|
||||
int maxDistanceSmall = Math.round(maxDistance * 1.1F);
|
||||
float bigRatio = 0.3F + world.rand.nextFloat() * 0.3F;
|
||||
float surfaceBig = (float) (Math.PI * Math.pow(maxDistanceBig, 2));
|
||||
float surfaceSmall = (float) (Math.PI * Math.pow(maxDistanceSmall, 2));
|
||||
int numOfBigAsteroids = Math.round(bigRatio * surfaceBig / surfacePerAsteroid);
|
||||
int numOfSmallAsteroids = Math.round((1.0F - bigRatio) * surfaceSmall / surfacePerAsteroid);
|
||||
int numOfClouds = Math.round(numOfBigAsteroids * 1.0F / (10.0F + world.rand.nextInt(10)));
|
||||
int maxHeight = 70 + world.rand.nextInt(50);
|
||||
int y2 = Math.min(240 - maxHeight, Math.max(y, maxHeight));
|
||||
System.out.println("Generating asteroid field at " + x + "," + y + "," + z
|
||||
+ " qty " + numOfBigAsteroids + ", " + numOfSmallAsteroids + ", " + numOfClouds
|
||||
+ " over " + maxDistance + ", " + maxHeight + " surfacePerAsteroid " + String.format("%.1f", surfacePerAsteroid));
|
||||
|
||||
// Setting up of big asteroids
|
||||
for (int i = 1; i <= numOfAsteroids; i++) {
|
||||
int aX = x + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxDistance)));
|
||||
int aY = y + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxHeight)));
|
||||
int aZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxDistance)));
|
||||
for (int i = 1; i <= numOfBigAsteroids; i++) {
|
||||
float binomial = binomialRandom(world);
|
||||
double bearing = world.rand.nextFloat() * 2.0D * Math.PI;
|
||||
double yawn = world.rand.nextFloat() * Math.PI;
|
||||
float horizontalRange = Math.max(6.0F, binomial * maxDistanceBig);
|
||||
float verticalRange = Math.max(3.0F, binomial * maxHeight);
|
||||
|
||||
int aX = (int) (x + Math.round(horizontalRange * Math.cos(bearing)));
|
||||
int aY = (int) (y + Math.round(verticalRange * Math.cos(yawn)));
|
||||
int aZ = (int) (z + Math.round(horizontalRange * Math.sin(bearing)));
|
||||
/*System.out.println(String.format("Big asteroid: %.3f %.3f r %.3f r makes %3d, %3d, %3d", new Object[] {
|
||||
Double.valueOf(binomial),Double.valueOf(bearing), Double.valueOf(yawn),
|
||||
Integer.valueOf(aX), Integer.valueOf(aY), Integer.valueOf(aZ)}));/**/
|
||||
// Place an asteroid
|
||||
generateRandomAsteroid(world, aX, aY, aZ, 4, 6);
|
||||
}
|
||||
|
||||
// Setting up small asteroids
|
||||
for (int i = 1; i <= numOfAsteroids; i++) {
|
||||
int aX = x + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxDistance)));
|
||||
int aY = y + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxHeight)));
|
||||
int aZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxDistance)));
|
||||
for (int i = 1; i <= numOfSmallAsteroids; i++) {
|
||||
float binomial = binomialRandom(world);
|
||||
double bearing = world.rand.nextFloat() * 2.0D * Math.PI;
|
||||
double yawn = world.rand.nextFloat() * Math.PI;
|
||||
float horizontalRange = Math.max(6.0F, binomial * maxDistanceSmall);
|
||||
float verticalRange = Math.max(3.0F, binomial * maxHeight);
|
||||
|
||||
int aX = (int) (x + Math.round(horizontalRange * Math.cos(bearing)));
|
||||
int aY = (int) (y + Math.round(verticalRange * Math.cos(yawn)));
|
||||
int aZ = (int) (z + Math.round(horizontalRange * Math.sin(bearing)));
|
||||
|
||||
// Placing
|
||||
if (world.rand.nextInt(300) != 0) {
|
||||
generateRandomAsteroid(world, aX, aY, aZ, 2, 2);
|
||||
if (world.rand.nextInt(400) != 1) {
|
||||
generateRandomAsteroid(world, aX, aY, aZ, 3, 3);
|
||||
} else {
|
||||
generateSmallShip(world, aX, aY, aZ, 8);
|
||||
}
|
||||
}
|
||||
|
||||
// Setting up gas clouds
|
||||
for (int i = 1; i <= numOfClouds; i++) {
|
||||
int aX = x + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxDistance)));
|
||||
int aY = y + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxHeight)));
|
||||
int aZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(maxDistance)));
|
||||
float binomial = binomialRandom(world);
|
||||
double bearing = world.rand.nextFloat() * 2.0D * Math.PI;
|
||||
double yawn = world.rand.nextFloat() * Math.PI;
|
||||
float horizontalRange = Math.max(6.0F, binomial * maxDistanceBig);
|
||||
float verticalRange = Math.max(3.0F, binomial * maxHeight);
|
||||
|
||||
int aX = (int) (x + Math.round(horizontalRange * Math.cos(bearing)));
|
||||
int aY = (int) (y + Math.round(verticalRange * Math.cos(yawn)));
|
||||
int aZ = (int) (z + Math.round(horizontalRange * Math.sin(bearing)));
|
||||
|
||||
// Placing
|
||||
if (world.rand.nextBoolean()) {
|
||||
generateGasCloudOfColor(world, aX, aY, aZ, 12, 15, world.rand.nextInt(12));
|
||||
}
|
||||
}
|
||||
|
||||
LocalProfiler.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gas cloud generator
|
||||
*
|
||||
* @param x x-coord of center
|
||||
* @param y center
|
||||
* @param z center
|
||||
* @param x coordinate of center
|
||||
* @param y coordinate of center
|
||||
* @param z coordinate of center
|
||||
* @param cloudSizeMax maximum gas cloud size (by number of balls it consists)
|
||||
* @param centerRadiusMax maximum radius of central ball
|
||||
*/
|
||||
|
@ -289,62 +357,33 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
/**
|
||||
* Asteroid of block generator
|
||||
*
|
||||
* @param x x-coord of center
|
||||
* @param y center
|
||||
* @param z center
|
||||
* @param x coordinate of center
|
||||
* @param y coordinate of center
|
||||
* @param z coordinate of center
|
||||
* @param asteroidSizeMax maximum asteroid size (by number of balls it consists)
|
||||
* @param centerRadiusMax maximum radius of central ball
|
||||
*/
|
||||
private void generateAsteroidOfBlock(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax, int blockID, int meta)
|
||||
{
|
||||
private void generateAsteroidOfBlock(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax, int blockID, int meta) {
|
||||
// FIXME: get a proper range of random instead of capping it
|
||||
int asteroidSize = 1 + world.rand.nextInt(6);
|
||||
if (asteroidSizeMax != 0)
|
||||
if (asteroidSizeMax != 0) {
|
||||
asteroidSize = Math.min(asteroidSizeMax, asteroidSize);
|
||||
}
|
||||
int centerRadius = 1 + world.rand.nextInt(6);
|
||||
if (centerRadiusMax != 0)
|
||||
if (centerRadiusMax != 0) {
|
||||
centerRadius = Math.min(centerRadiusMax, centerRadius);
|
||||
}
|
||||
final int CENTER_SHIFT = 2; // Offset from center of central ball
|
||||
// Asteroid's center
|
||||
int[] t = WarpDriveConfig.getDefaultSurfaceBlock(world.rand, true, false);
|
||||
generateSphere2(world, x, y, z, centerRadius, true, blockID, meta, false, t);
|
||||
generateSphereDirect(world, x, y, z, centerRadius, true, blockID, meta, false, t);
|
||||
// Asteroids knolls
|
||||
for (int i = 1; i <= asteroidSize; i++)
|
||||
{
|
||||
int radius = 2 + world.rand.nextInt(centerRadius);
|
||||
for (int i = 1; i <= asteroidSize; i++) {
|
||||
int radius = 1 + world.rand.nextInt(centerRadius);
|
||||
int newX = x + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
|
||||
int newY = y + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
|
||||
int newZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
|
||||
generateSphere2(world, newX, newY, newZ, radius, true, blockID, meta, false, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asteroid generator
|
||||
*
|
||||
* @param x x-coord of center
|
||||
* @param y center
|
||||
* @param z center
|
||||
* @param asteroidSizeMax maximum asteroid size (by number of balls it consists)
|
||||
* @param centerRadiusMax maximum radius of central ball
|
||||
*/
|
||||
public void generateAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax)
|
||||
{
|
||||
int asteroidSize = 1 + world.rand.nextInt(6);
|
||||
if (asteroidSizeMax != 0)
|
||||
asteroidSize = Math.min(asteroidSizeMax, asteroidSize);
|
||||
int centerRadius = 1 + world.rand.nextInt(6);
|
||||
if (centerRadiusMax != 0)
|
||||
centerRadius = Math.min(centerRadiusMax, centerRadius);
|
||||
final int CENTER_SHIFT = 2;
|
||||
int[] t = WarpDriveConfig.getDefaultSurfaceBlock(world.rand, true, false);
|
||||
generateSphere2(world, x, y, z, centerRadius, true, -1, 0, false, t);
|
||||
for (int i = 1; i <= asteroidSize; i++)
|
||||
{
|
||||
int radius = 2 + world.rand.nextInt(centerRadius);
|
||||
int newX = x + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
|
||||
int newY = y + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
|
||||
int newZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
|
||||
generateSphere2(world, newX, newY, newZ, radius, true, -1, 0, false, t);
|
||||
generateSphereDirect(world, newX, newY, newZ, radius, true, blockID, meta, false, t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,37 +398,30 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
* @param forcedID sphere of specified blocks or random blocks if not specified
|
||||
* @return
|
||||
*/
|
||||
public void generateSphere2(World world, int xCoord, int yCoord, int zCoord, double radius, boolean corrupted, int forcedID, int meta, boolean hollow)
|
||||
{
|
||||
if (forcedID == -1)
|
||||
generateSphere2(world, xCoord, yCoord, zCoord, radius, corrupted, forcedID, meta, hollow, WarpDriveConfig.getDefaultSurfaceBlock(world.rand, corrupted, false));
|
||||
else
|
||||
generateSphere2(world, xCoord, yCoord, zCoord, radius, corrupted, forcedID, meta, hollow, new int[] {forcedID, meta});
|
||||
public void generateSphereDirect(World world, int xCoord, int yCoord, int zCoord, double radius, boolean corrupted, int forcedID, int meta, boolean hollow) {
|
||||
if (forcedID == -1) {
|
||||
generateSphereDirect(world, xCoord, yCoord, zCoord, radius, corrupted, forcedID, meta, hollow, WarpDriveConfig.getDefaultSurfaceBlock(world.rand, corrupted, false));
|
||||
} else {
|
||||
generateSphereDirect(world, xCoord, yCoord, zCoord, radius, corrupted, forcedID, meta, hollow, new int[] {forcedID, meta});
|
||||
}
|
||||
}
|
||||
|
||||
public void generateSphere2(World world, int xCoord, int yCoord, int zCoord, double radius, boolean corrupted, int forcedID, int meta, boolean hollow, int[] defaultBlock)
|
||||
{
|
||||
public void generateSphereDirect(World world, int xCoord, int yCoord, int zCoord, double radius, boolean corrupted, int forcedID, int meta, boolean hollow, int[] defaultBlock) {
|
||||
radius += 0.5D; // Radius from center of block
|
||||
double radiusSq = radius * radius; // Optimization to avoid sqrts...
|
||||
double radius1Sq = (radius - 1.0D) * (radius - 1.0D); // for hollow sphere
|
||||
int ceilRadius = (int) Math.ceil(radius);
|
||||
|
||||
int[] blockID;
|
||||
if (forcedID == 0)
|
||||
blockID = new int[] {0, 0};
|
||||
else if (forcedID == -1)
|
||||
blockID = new int[] {forcedID, meta};//SRANYA JABA might not have been initialized
|
||||
else
|
||||
int[] blockID = new int[] {0, 0};
|
||||
if (forcedID != -1) {
|
||||
blockID = new int[] {forcedID, meta};
|
||||
}
|
||||
// Pass the cube and check points for sphere equation x^2 + y^2 + z^2 = r^2
|
||||
for (int x = 0; x <= ceilRadius; x++)
|
||||
{
|
||||
for (int x = 0; x <= ceilRadius; x++) {
|
||||
double x2 = (x + 0.5D) * (x + 0.5D);
|
||||
for (int y = 0; y <= ceilRadius; y++)
|
||||
{
|
||||
for (int y = 0; y <= ceilRadius; y++) {
|
||||
double y2 = (y + 0.5D) * (y + 0.5D);
|
||||
for (int z = 0; z <= ceilRadius; z++)
|
||||
{
|
||||
for (int z = 0; z <= ceilRadius; z++) {
|
||||
double z2 = (z + 0.5D) * (z + 0.5D);
|
||||
double dSq = x2 + y2 + z2; // Distance from current position to center
|
||||
|
||||
|
@ -402,29 +434,25 @@ public class SpaceWorldGenerator implements IWorldGenerator
|
|||
continue;
|
||||
|
||||
// Place blocks
|
||||
if (!corrupted || world.rand.nextInt(10) != 1)
|
||||
{
|
||||
if (!corrupted || world.rand.nextInt(5) != 1) {
|
||||
if (forcedID == -1)
|
||||
blockID = WarpDriveConfig.getRandomSurfaceBlock(world.rand, defaultBlock[0], defaultBlock[1], false);
|
||||
world.setBlock(xCoord + x, yCoord + y, zCoord + z, blockID[0], blockID[1], 2);
|
||||
world.setBlock(xCoord - x, yCoord + y, zCoord + z, blockID[0], blockID[1], 2);
|
||||
}
|
||||
if (!corrupted || world.rand.nextInt(10) != 1)
|
||||
{
|
||||
if (!corrupted || world.rand.nextInt(5) != 1) {
|
||||
if (forcedID == -1)
|
||||
blockID = WarpDriveConfig.getRandomSurfaceBlock(world.rand, defaultBlock[0], defaultBlock[1], false);
|
||||
world.setBlock(xCoord + x, yCoord - y, zCoord + z, blockID[0], blockID[1], 2);
|
||||
world.setBlock(xCoord + x, yCoord + y, zCoord - z, blockID[0], blockID[1], 2);
|
||||
}
|
||||
if (!corrupted || world.rand.nextInt(10) != 1)
|
||||
{
|
||||
if (!corrupted || world.rand.nextInt(5) != 1) {
|
||||
if (forcedID == -1)
|
||||
blockID = WarpDriveConfig.getRandomSurfaceBlock(world.rand, defaultBlock[0], defaultBlock[1], false);
|
||||
world.setBlock(xCoord - x, yCoord - y, zCoord + z, blockID[0], blockID[1], 2);
|
||||
world.setBlock(xCoord + x, yCoord - y, zCoord - z, blockID[0], blockID[1], 2);
|
||||
}
|
||||
if (!corrupted || world.rand.nextInt(10) != 1)
|
||||
{
|
||||
if (!corrupted || world.rand.nextInt(5) != 1) {
|
||||
if (forcedID == -1)
|
||||
blockID = WarpDriveConfig.getRandomSurfaceBlock(world.rand, defaultBlock[0], defaultBlock[1], false);
|
||||
world.setBlock(xCoord - x, yCoord + y, zCoord - z, blockID[0], blockID[1], 2);
|
||||
|
|
106
src/cr0s/WarpDrive/TransitionPlane.java
Normal file
106
src/cr0s/WarpDrive/TransitionPlane.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package cr0s.WarpDrive;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cr0s.WarpDrive.Vector3;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* TransitionPlane Class is used for defining transition planes between dimensions.
|
||||
*
|
||||
* @author LemADEC
|
||||
*/
|
||||
|
||||
public class TransitionPlane implements Cloneable
|
||||
{
|
||||
public int dimensionId;
|
||||
public int dimensionCenterX, dimensionCenterZ;
|
||||
public int borderSizeX, borderSizeZ;
|
||||
public int spaceCenterX, spaceCenterZ;
|
||||
|
||||
public TransitionPlane() {
|
||||
this(0, 0, 0, 5000, 5000, 0, 0);
|
||||
}
|
||||
|
||||
public TransitionPlane(int parDimensionId, int parDimensionCenterX, int parDimensionCenterZ, int parBorderSizeX, int parBorderSizeZ, int parSpaceCenterX, int parSpaceCenterZ) {
|
||||
this.dimensionId = parDimensionId;
|
||||
this.spaceCenterX = parSpaceCenterX;
|
||||
this.spaceCenterZ = parSpaceCenterZ;
|
||||
this.dimensionCenterX = parDimensionCenterX;
|
||||
this.dimensionCenterZ = parDimensionCenterZ;
|
||||
this.borderSizeX = parBorderSizeX;
|
||||
this.borderSizeZ = parBorderSizeZ;
|
||||
}
|
||||
|
||||
public TransitionPlane(NBTTagCompound nbt) {
|
||||
readFromNBT(nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a new copy of this Vector. Prevents variable referencing problems.
|
||||
*/
|
||||
@Override
|
||||
public TransitionPlane clone() {
|
||||
return new TransitionPlane(dimensionId, dimensionCenterX, dimensionCenterZ, borderSizeX, borderSizeZ, spaceCenterX, spaceCenterZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute transition.
|
||||
*
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
|
||||
public boolean isValidToSpace(Vector3 currentPosition) {
|
||||
return ( (Math.abs(currentPosition.x - dimensionCenterX) <= borderSizeX) && (Math.abs(currentPosition.z - dimensionCenterZ) <= borderSizeZ) );
|
||||
}
|
||||
|
||||
public boolean isValidFromSpace(Vector3 currentPosition) {
|
||||
return ( (Math.abs(currentPosition.x - spaceCenterX) <= borderSizeX) && (Math.abs(currentPosition.z - spaceCenterX) <= borderSizeZ) );
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
this.dimensionId = tag.getInteger("dimensionId");
|
||||
this.dimensionCenterX = tag.getInteger("dimensionCenterX");
|
||||
this.dimensionCenterZ = tag.getInteger("dimensionCenterZ");
|
||||
this.borderSizeX = tag.getInteger("borderSizeX");
|
||||
this.borderSizeZ = tag.getInteger("borderSizeZ");
|
||||
this.spaceCenterX = tag.getInteger("spaceCenterX");
|
||||
this.spaceCenterZ = tag.getInteger("spaceCenterZ");
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
tag.setInteger("dimensionId", dimensionId);
|
||||
tag.setInteger("dimensionCenterX", dimensionCenterX);
|
||||
tag.setInteger("dimensionCenterZ", dimensionCenterZ);
|
||||
tag.setInteger("borderSizeX", borderSizeX);
|
||||
tag.setInteger("borderSizeZ", borderSizeZ);
|
||||
tag.setInteger("spaceCenterX", spaceCenterX);
|
||||
tag.setInteger("spaceCenterZ", spaceCenterZ);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ("dim:" + dimensionId + "(" + dimensionCenterX + "," + dimensionCenterZ + ")_Border(" + borderSizeX + "," + borderSizeZ + ")_Space(" + spaceCenterX + "," + spaceCenterZ).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof TransitionPlane) {
|
||||
TransitionPlane transitionPlane = (TransitionPlane) o;
|
||||
return this.dimensionId == transitionPlane.dimensionId
|
||||
&& this.dimensionCenterX == transitionPlane.dimensionCenterX && this.dimensionCenterZ == transitionPlane.dimensionCenterZ
|
||||
&& this.borderSizeX == transitionPlane.borderSizeX && this.borderSizeZ == transitionPlane.borderSizeZ
|
||||
&& this.spaceCenterX == transitionPlane.spaceCenterX && this.spaceCenterZ == transitionPlane.spaceCenterZ;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TransitionPlane [dim:" + dimensionId + "(" + dimensionCenterX + ", " + dimensionCenterZ + ") Border(" + borderSizeX + ", " + borderSizeZ + ") Space(" + spaceCenterX + ", " + spaceCenterZ + ")]";
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package cr0s.WarpDrive;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cr0s.WarpDrive.machines.TileEntityReactor;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
@ -12,10 +12,10 @@ import net.minecraft.util.MathHelper;
|
|||
* @author Cr0s
|
||||
*/
|
||||
public class WarpCoresRegistry {
|
||||
private ArrayList<TileEntityReactor> registry;
|
||||
private LinkedList<TileEntityReactor> registry;
|
||||
|
||||
public WarpCoresRegistry() {
|
||||
registry = new ArrayList<TileEntityReactor>();
|
||||
registry = new LinkedList<TileEntityReactor>();
|
||||
}
|
||||
|
||||
public int searchCoreInRegistry(TileEntityReactor core) {
|
||||
|
@ -56,7 +56,7 @@ public class WarpCoresRegistry {
|
|||
}
|
||||
|
||||
public ArrayList<TileEntityReactor> searchWarpCoresInRadius(int x, int y, int z, int radius) {
|
||||
ArrayList<TileEntityReactor> res = new ArrayList<TileEntityReactor>();
|
||||
ArrayList<TileEntityReactor> res = new ArrayList<TileEntityReactor>(registry.size());
|
||||
|
||||
for (TileEntityReactor c : registry) {
|
||||
double d3 = c.xCoord - x;
|
||||
|
|
|
@ -15,11 +15,12 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.item.ItemReactorLaserFocus;
|
||||
import cr0s.WarpDrive.item.*;
|
||||
import cr0s.WarpDrive.machines.*;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -38,8 +39,10 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
@Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.2.4.0", dependencies = "required-after:IC2; required-after:ComputerCraft; after:CCTurtle; after:gregtech_addon; required-after:AppliedEnergistics; after:AdvancedSolarPanel; after:AtomicScience; after:ICBM|Explosion; after:MFFS; after:GraviSuite; after:UndergroundBiomes; after:NetherOres")
|
||||
@Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.2.5.0",
|
||||
dependencies = "required-after:IC2; required-after:ComputerCraft; after:CCTurtle; after:gregtech_addon; required-after:AppliedEnergistics; after:AdvancedSolarPanel; after:AtomicScience; after:ICBM|Explosion; after:MFFS; after:GraviSuite; after:UndergroundBiomes; after:NetherOres")
|
||||
@NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = {
|
||||
"WarpDriveBeam",
|
||||
"WarpDriveFreq",
|
||||
|
@ -70,6 +73,8 @@ public class WarpDrive implements LoadingCallback {
|
|||
public static Block cloakCoilBlock;
|
||||
public static Block transporterBlock;
|
||||
public static Block reactorMonitorBlock;
|
||||
public static Block powerReactorBlock;
|
||||
public static Block powerLaserBlock;
|
||||
|
||||
public static Block airBlock;
|
||||
public static Block gasBlock;
|
||||
|
@ -78,6 +83,7 @@ public class WarpDrive implements LoadingCallback {
|
|||
public static Block transportBeaconBlock;
|
||||
|
||||
public static Item reactorLaserFocusItem;
|
||||
public static ItemWarpComponent componentItem;
|
||||
|
||||
public static BiomeGenBase spaceBiome;
|
||||
public World space;
|
||||
|
@ -108,7 +114,7 @@ public class WarpDrive implements LoadingCallback {
|
|||
|
||||
public static WarpDrivePeripheralHandler peripheralHandler = new WarpDrivePeripheralHandler();
|
||||
|
||||
private ArrayList<Ticket> warpTickets = new ArrayList<Ticket>();
|
||||
private LinkedList<Ticket> warpTickets = new LinkedList<Ticket>();
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
@ -148,74 +154,63 @@ public class WarpDrive implements LoadingCallback {
|
|||
// CORE CONTROLLER
|
||||
protocolBlock = new BlockProtocol(WarpDriveConfig.controllerID,0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(protocolBlock, "Warp Controller");
|
||||
GameRegistry.registerBlock(protocolBlock, "protocolBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityProtocol.class, "protocolBlock");
|
||||
|
||||
// WARP CORE
|
||||
warpCore = new BlockReactor(WarpDriveConfig.coreID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(warpCore, "Warp Core");
|
||||
GameRegistry.registerBlock(warpCore, "warpCore");
|
||||
GameRegistry.registerTileEntity(TileEntityReactor.class, "warpCore");
|
||||
|
||||
// WARP RADAR
|
||||
radarBlock = new BlockRadar(WarpDriveConfig.radarID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(radarBlock, "W-Radar");
|
||||
GameRegistry.registerBlock(radarBlock, "radarBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityRadar.class, "radarBlock");
|
||||
|
||||
// WARP ISOLATION
|
||||
isolationBlock = new BlockWarpIsolation( WarpDriveConfig.isolationID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(isolationBlock, "Warp-Field Isolation Block");
|
||||
GameRegistry.registerBlock(isolationBlock, "isolationBlock");
|
||||
|
||||
// AIR GENERATOR
|
||||
airgenBlock = new BlockAirGenerator(WarpDriveConfig.airgenID, 0,Material.rock);
|
||||
|
||||
LanguageRegistry.addName(airgenBlock, "Air Generator");
|
||||
GameRegistry.registerBlock(airgenBlock, "airgenBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityAirGenerator.class,"airgenBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityAirGenerator.class, "airgenBlock");
|
||||
|
||||
|
||||
// AIR BLOCK
|
||||
airBlock = (new BlockAir(WarpDriveConfig.airID));
|
||||
|
||||
LanguageRegistry.addName(airBlock, "Air block");
|
||||
GameRegistry.registerBlock(airBlock, "airBlock");
|
||||
|
||||
// GAS BLOCK
|
||||
gasBlock = (new BlockGas(WarpDriveConfig.gasID));
|
||||
|
||||
LanguageRegistry.addName(gasBlock, "Gas block");
|
||||
GameRegistry.registerBlock(gasBlock, "gasBlock");
|
||||
|
||||
// LASER EMITTER
|
||||
laserBlock = new BlockLaser(WarpDriveConfig.laserID, 0,Material.rock);
|
||||
|
||||
LanguageRegistry.addName(laserBlock, "Laser Emitter");
|
||||
GameRegistry.registerBlock(laserBlock, "laserBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityLaser.class, "laserBlock");
|
||||
|
||||
// LASER EMITTER WITH CAMERA
|
||||
laserCamBlock = new BlockLaserCam(WarpDriveConfig.laserCamID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(laserCamBlock, "Laser Emitter + Camera");
|
||||
GameRegistry.registerBlock(laserCamBlock, "laserCamBlock");
|
||||
|
||||
// CAMERA
|
||||
cameraBlock = new BlockCamera(WarpDriveConfig.camID, 0,Material.rock);
|
||||
|
||||
LanguageRegistry.addName(cameraBlock, "Camera");
|
||||
GameRegistry.registerBlock(cameraBlock, "cameraBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityCamera.class, "cameraBlock");
|
||||
|
||||
// MONITOR
|
||||
monitorBlock = new BlockMonitor(WarpDriveConfig.monitorID);
|
||||
|
||||
LanguageRegistry.addName(monitorBlock, "Monitor");
|
||||
GameRegistry.registerBlock(monitorBlock, "monitorBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityMonitor.class, "monitorBlock");
|
||||
|
||||
|
@ -223,86 +218,85 @@ public class WarpDrive implements LoadingCallback {
|
|||
// MINING LASER
|
||||
miningLaserBlock = new BlockMiningLaser(WarpDriveConfig.miningLaserID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(miningLaserBlock, "Mining Laser");
|
||||
GameRegistry.registerBlock(miningLaserBlock, "miningLaserBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityMiningLaser.class, "miningLaserBlock");
|
||||
|
||||
// LASER TREE FARM
|
||||
laserTreeFarmBlock = new BlockLaserTreeFarm(WarpDriveConfig.laserTreeFarmID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(laserTreeFarmBlock, "Laser Tree Farm");
|
||||
GameRegistry.registerBlock(laserTreeFarmBlock, "laserTreeFarmBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityLaserTreeFarm.class,"laserTreeFarmBlock");
|
||||
|
||||
// PARTICLE BOOSTER
|
||||
boosterBlock = new BlockParticleBooster(WarpDriveConfig.particleBoosterID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(boosterBlock, "Particle Booster");
|
||||
GameRegistry.registerBlock(boosterBlock, "boosterBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityParticleBooster.class, "boosterBlock");
|
||||
|
||||
// LASER LIFT
|
||||
liftBlock = new BlockLift(WarpDriveConfig.liftID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(liftBlock, "Laser lift");
|
||||
GameRegistry.registerBlock(liftBlock, "liftBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityLift.class, "liftBlock");
|
||||
|
||||
// IRIDIUM BLOCK
|
||||
iridiumBlock = new BlockIridium(WarpDriveConfig.iridiumID);
|
||||
|
||||
LanguageRegistry.addName(iridiumBlock, "Block of Iridium");
|
||||
GameRegistry.registerBlock(iridiumBlock, "iridiumBlock");
|
||||
|
||||
// SHIP SCANNER
|
||||
scannerBlock = new BlockShipScanner(WarpDriveConfig.shipScannerID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(scannerBlock, "Ship Scanner");
|
||||
GameRegistry.registerBlock(scannerBlock, "scannerBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityShipScanner.class, "scannerBlock");
|
||||
|
||||
// CLOAKING DEVICE CORE
|
||||
cloakBlock = new BlockCloakingDeviceCore(WarpDriveConfig.cloakCoreID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(cloakBlock, "Cloaking Device Core");
|
||||
GameRegistry.registerBlock(cloakBlock, "cloakBlock");
|
||||
GameRegistry.registerTileEntity(TileEntityCloakingDeviceCore.class, "cloakBlock");
|
||||
|
||||
// CLOAKING DEVICE COIL
|
||||
cloakCoilBlock = new BlockCloakingCoil(WarpDriveConfig.cloakCoilID, 0, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(cloakCoilBlock, "Cloaking Device Coil");
|
||||
GameRegistry.registerBlock(cloakCoilBlock, "cloakCoilBlock");
|
||||
|
||||
// TRANSPORTER
|
||||
transporterBlock = new BlockTransporter(WarpDriveConfig.transporterID,Material.rock);
|
||||
|
||||
LanguageRegistry.addName(transporterBlock, "Transporter");
|
||||
GameRegistry.registerBlock(transporterBlock, "transporter");
|
||||
GameRegistry.registerTileEntity(TileEntityTransporter.class,"transporter");
|
||||
|
||||
reactorMonitorBlock = new BlockLaserReactorMonitor(WarpDriveConfig.reactorMonitorID, Material.rock);
|
||||
|
||||
LanguageRegistry.addName(reactorMonitorBlock, "Laser Reactor Monitor");
|
||||
GameRegistry.registerBlock(reactorMonitorBlock, "reactorMonitor");
|
||||
GameRegistry.registerTileEntity(TileEntityLaserReactorMonitor.class,"reactorMonitor");
|
||||
|
||||
// REACTOR LASER FOCUS
|
||||
reactorLaserFocusItem = new ItemReactorLaserFocus(WarpDriveConfig.reactorLaserFocusID);
|
||||
|
||||
LanguageRegistry.addName(reactorLaserFocusItem, "Reactor Laser Focus");
|
||||
GameRegistry.registerItem(reactorLaserFocusItem, "reactorLaserFocus");
|
||||
|
||||
// TRANSPORT BEACON
|
||||
/*transportBeaconBlock = new BlockTransportBeacon(WarpDriveConfig.transportBeaconID)
|
||||
.setHardness(0.5F)
|
||||
.setStepSound(Block.soundMetalFootstep)
|
||||
.setCreativeTab(CreativeTabs.tabRedstone)
|
||||
.setUnlocalizedName("transporterBeacon");
|
||||
.setUnlocalizedName("warpdrive.blocks.TransporterBeacon");
|
||||
|
||||
LanguageRegistry.addName(transportBeaconBlock, "Test");
|
||||
GameRegistry.registerBlock(transportBeaconBlock, "transportBeacon");*/
|
||||
|
||||
// POWER STUFF
|
||||
powerReactorBlock = new BlockPowerReactor(WarpDriveConfig.powerReactorID);
|
||||
GameRegistry.registerBlock(powerReactorBlock,"powerReactor");
|
||||
GameRegistry.registerTileEntity(TileEntityPowerReactor.class, "powerReactor");
|
||||
powerLaserBlock = new BlockPowerLaser(WarpDriveConfig.powerLaserID);
|
||||
|
||||
// REACTOR LASER FOCUS
|
||||
reactorLaserFocusItem = new ItemReactorLaserFocus(WarpDriveConfig.reactorLaserFocusID);
|
||||
GameRegistry.registerItem(reactorLaserFocusItem, "reactorLaserFocus");
|
||||
|
||||
// COMPONENT ITEMS
|
||||
componentItem = new ItemWarpComponent(WarpDriveConfig.componentID);
|
||||
GameRegistry.registerItem(componentItem, "component");
|
||||
|
||||
|
||||
|
||||
proxy.registerEntities();
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance);
|
||||
|
||||
|
@ -329,18 +323,135 @@ public class WarpDrive implements LoadingCallback {
|
|||
space = DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID);
|
||||
hyperSpace = DimensionManager.getWorld(WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID);
|
||||
|
||||
if(WarpDriveConfig.isICLoaded && WarpDriveConfig.recipesIC2) {
|
||||
if (WarpDriveConfig.isICLoaded && WarpDriveConfig.recipesIC2) {
|
||||
initIC2Recipes();
|
||||
}
|
||||
if (WarpDriveConfig.isAELoaded && WarpDriveConfig.isThermalExpansionLoaded) {
|
||||
initAETERecipes();
|
||||
}
|
||||
if (!WarpDriveConfig.recipesIC2) {
|
||||
initVanillaRecipes();
|
||||
}
|
||||
|
||||
warpCores = new WarpCoresRegistry();
|
||||
jumpGates = new JumpGatesRegistry();
|
||||
cams = new CamRegistry();
|
||||
}
|
||||
|
||||
private void initVanillaRecipes() {
|
||||
componentItem.registerRecipes();
|
||||
//WarpCore
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(warpCore), false, "ipi", "ici", "idi",
|
||||
'i', Item.ingotIron,
|
||||
'p', componentItem.getIS(6),
|
||||
'c', componentItem.getIS(2),
|
||||
'd', Item.diamond));
|
||||
|
||||
//Controller
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(protocolBlock), false, "ici", "idi", "iii",
|
||||
'i', Item.ingotIron,
|
||||
'c', componentItem.getIS(5),
|
||||
'd', Item.diamond));
|
||||
|
||||
//Radar
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(radarBlock), false, "ggg", "pdc", "iii",
|
||||
'i', Item.ingotIron,
|
||||
'c', componentItem.getIS(5),
|
||||
'p', componentItem.getIS(6),
|
||||
'g', Block.glass,
|
||||
'd', Item.diamond));
|
||||
|
||||
//Isolation Block
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(isolationBlock), false, "igi", "geg", "igi",
|
||||
'i', Item.ingotIron,
|
||||
'g', Block.glass,
|
||||
'e', Item.enderPearl));
|
||||
|
||||
//Air generator
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(airgenBlock), false, "ibi", "i i", "ipi",
|
||||
'i', Item.ingotIron,
|
||||
'b', Block.fenceIron,
|
||||
'p', componentItem.getIS(6)));
|
||||
|
||||
//Laser
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(laserBlock), false, "ili", "iri", "ici",
|
||||
'i', Item.ingotIron,
|
||||
'r', Item.redstone,
|
||||
'c', componentItem.getIS(5),
|
||||
'l', componentItem.getIS(3),
|
||||
'p', componentItem.getIS(6)));
|
||||
|
||||
//Mining laser
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(miningLaserBlock), false, "ici", "iti", "ili",
|
||||
'i', Item.ingotIron,
|
||||
'r', Item.redstone,
|
||||
't', componentItem.getIS(1),
|
||||
'c', componentItem.getIS(5),
|
||||
'l', componentItem.getIS(3)));
|
||||
|
||||
//Tree farm laser
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(laserTreeFarmBlock), false, "ili", "sts", "ici",
|
||||
'i', Item.ingotIron,
|
||||
's', "treeSapling",
|
||||
't', componentItem.getIS(1),
|
||||
'c', componentItem.getIS(5),
|
||||
'l', componentItem.getIS(3)));
|
||||
|
||||
//Laser Lift
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(liftBlock), false, "ipi", "rtr", "ili",
|
||||
'i', Item.ingotIron,
|
||||
'r', Item.redstone,
|
||||
't', componentItem.getIS(1),
|
||||
'l', componentItem.getIS(3),
|
||||
'p', componentItem.getIS(6)));
|
||||
|
||||
//Transporter
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(transporterBlock), false, "iii", "ptc", "iii",
|
||||
'i', Item.ingotIron,
|
||||
't', componentItem.getIS(1),
|
||||
'c', componentItem.getIS(5),
|
||||
'p', componentItem.getIS(6)));
|
||||
|
||||
//Particle Booster
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(boosterBlock), false, "ipi", "rgr", "iii",
|
||||
'i', Item.ingotIron,
|
||||
'r', Item.redstone,
|
||||
'g', Block.glass,
|
||||
'p', componentItem.getIS(6)));
|
||||
|
||||
//Camera
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(cameraBlock), false, "ngn", "i i", "ici",
|
||||
'i', Item.ingotIron,
|
||||
'n', Item.goldNugget,
|
||||
'g', Block.glass,
|
||||
'c', componentItem.getIS(5)));
|
||||
|
||||
//LaserCamera
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(laserCamBlock), cameraBlock, laserBlock));
|
||||
|
||||
//Monitor
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(monitorBlock), false, "ggg", "iti", "ici",
|
||||
'i', Item.ingotIron,
|
||||
't', Block.torchWood,
|
||||
'g', Block.glass,
|
||||
'c', componentItem.getIS(5)));
|
||||
|
||||
//Cloaking device
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(cloakBlock), false, "ipi", "lrl", "ici",
|
||||
'i', Item.ingotIron,
|
||||
'r', Item.redstone,
|
||||
'l', componentItem.getIS(3),
|
||||
'c', componentItem.getIS(5),
|
||||
'p', componentItem.getIS(6)));
|
||||
|
||||
//Cloaking coil
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(cloakCoilBlock), false, "ini", "rdr", "ini",
|
||||
'i', Item.ingotIron,
|
||||
'd', Item.diamond,
|
||||
'r', Item.redstone,
|
||||
'n', Item.goldNugget));
|
||||
}
|
||||
|
||||
private void initAETERecipes() {
|
||||
ItemStack redstoneEnergycell = GameRegistry.findItemStack("ThermalExpansion", "cellReinforced", 1);
|
||||
ItemStack bucketEnder = GameRegistry.findItemStack("ThermalExpansion", "bucketEnder", 1);
|
||||
|
@ -505,17 +616,17 @@ public class WarpDrive implements LoadingCallback {
|
|||
event.registerServerCommand(new DebugCommand());
|
||||
}
|
||||
|
||||
private ArrayList<Ticket> worldTickets(World worldObj)
|
||||
{
|
||||
ArrayList<Ticket> ticks = new ArrayList<Ticket>();
|
||||
for(Ticket t: warpTickets)
|
||||
if(t.world.equals(worldObj))
|
||||
ticks.add(t);
|
||||
return ticks;
|
||||
private ArrayList<Ticket> worldTickets(World worldObj) {
|
||||
ArrayList<Ticket> worldTicks = new ArrayList<Ticket>(warpTickets.size());
|
||||
for(Ticket t: warpTickets) {
|
||||
if (t.world.equals(worldObj)) {
|
||||
worldTicks.add(t);
|
||||
}
|
||||
}
|
||||
return worldTicks;
|
||||
}
|
||||
|
||||
public Ticket registerChunkLoadTE(WarpChunkTE te,boolean refreshLoading)
|
||||
{
|
||||
public Ticket registerChunkLoadTE(WarpChunkTE te, boolean refreshLoading) {
|
||||
World worldObj = te.worldObj;
|
||||
ArrayList<Ticket> worldTicks = worldTickets(worldObj);
|
||||
boolean isWorldTicketed = worldTicks.size() != 0;
|
||||
|
|
|
@ -20,7 +20,7 @@ public class WarpDriveConfig
|
|||
{
|
||||
private static Configuration config;
|
||||
public static int coreID, controllerID, radarID, isolationID, airID, airgenID, gasID, laserID, miningLaserID, particleBoosterID, liftID, laserCamID, camID, monitorID, iridiumID, shipScannerID, cloakCoreID, cloakCoilID;
|
||||
public static int laserTreeFarmID, transporterID, transportBeaconID, reactorLaserFocusID, reactorMonitorID;
|
||||
public static int laserTreeFarmID, transporterID, transportBeaconID, reactorLaserFocusID, reactorMonitorID, powerReactorID, powerLaserID, componentID;
|
||||
//
|
||||
/*
|
||||
* The variables which store whether or not individual mods are loaded
|
||||
|
@ -82,11 +82,11 @@ public class WarpDriveConfig
|
|||
public static int WC_ENERGY_PER_DISTANCE_MODE2 = 1000; // eU
|
||||
public static int WC_ENERGY_PER_ENTITY_TO_SPACE = 1000000; // eU
|
||||
public static int WC_MAX_JUMP_DISTANCE = 128; // Maximum jump length value
|
||||
public static int WC_MAX_SHIP_VOLUME_ON_SURFACE = 15000; // Maximum ship mass to jump on earth (15k blocks)
|
||||
public static int WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = 500; // Minimum ship volume value for
|
||||
public static int WC_MAX_SHIP_SIDE = 100;
|
||||
public static int WC_MAX_SHIP_VOLUME_ON_SURFACE = 3000; // Maximum ship mass to jump on earth
|
||||
public static int WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = 1200; // Minimum ship volume value for hyperspace travel
|
||||
public static int WC_MAX_SHIP_SIDE = 127;
|
||||
public static int WC_COOLDOWN_INTERVAL_SECONDS = 4; // FIXME update me
|
||||
public static int WC_COLLISION_TOLERANCE_BLOCKS = 5;
|
||||
public static int WC_COLLISION_TOLERANCE_BLOCKS = 3;
|
||||
public static int WC_WARMUP_SHORTJUMP_SECONDS = 10;
|
||||
public static int WC_WARMUP_LONGJUMP_SECONDS = 30;
|
||||
public static int WC_WARMUP_RANDOM_TICKS = 60;
|
||||
|
@ -296,9 +296,8 @@ public class WarpDriveConfig
|
|||
recipesIC2 = config.get("Recipes", "ic2_recipes",true).getBoolean(true);
|
||||
}
|
||||
|
||||
public static void Init2()
|
||||
{
|
||||
CommonWorldGenOres = new ArrayList<int[]>();
|
||||
public static void Init2() {
|
||||
CommonWorldGenOres = new ArrayList<int[]>(30);
|
||||
CommonWorldGenOres.add(new int[] {Block.oreIron.blockID, 0});
|
||||
CommonWorldGenOres.add(new int[] {Block.oreGold.blockID, 0});
|
||||
CommonWorldGenOres.add(new int[] {Block.oreCoal.blockID, 0});
|
||||
|
@ -336,8 +335,11 @@ public class WarpDriveConfig
|
|||
transporterID = config.getBlock("transporter", 520).getInt();
|
||||
transportBeaconID = config.getBlock("transportBeacon", 521).getInt();
|
||||
reactorMonitorID = config.getBlock("reactorMonitor",522).getInt();
|
||||
powerLaserID = config.getBlock("powerLaser", 523).getInt();
|
||||
powerReactorID = config.getBlock("powerReactor",524).getInt();
|
||||
|
||||
reactorLaserFocusID = config.getItem("reactorLaserFocus", 8700).getInt();
|
||||
componentID = config.getItem("component", 8701).getInt();
|
||||
|
||||
isICLoaded = Loader.isModLoaded("IC2");
|
||||
if (isICLoaded)
|
||||
|
@ -421,35 +423,27 @@ public class WarpDriveConfig
|
|||
config.save();
|
||||
}
|
||||
|
||||
private static void LoadOreDict()
|
||||
{
|
||||
private static void LoadOreDict() {
|
||||
String[] oreNames = OreDictionary.getOreNames();
|
||||
for(String oreName: oreNames)
|
||||
{
|
||||
for(String oreName: oreNames) {
|
||||
String lowerOreName = oreName.toLowerCase();
|
||||
if(oreName.substring(0,3).equals("ore"))
|
||||
{
|
||||
if (oreName.substring(0,3).equals("ore")) {
|
||||
ArrayList<ItemStack> item = OreDictionary.getOres(oreName);
|
||||
for(ItemStack i: item)
|
||||
{
|
||||
for(ItemStack i: item) {
|
||||
MinerOres.add(i.itemID);
|
||||
WarpDrive.debugPrint("WD: Added ore ID: "+i.itemID);
|
||||
}
|
||||
}
|
||||
if(lowerOreName.contains("log"))
|
||||
{
|
||||
if (lowerOreName.contains("log")) {
|
||||
ArrayList<ItemStack> item = OreDictionary.getOres(oreName);
|
||||
for(ItemStack i: item)
|
||||
{
|
||||
for(ItemStack i: item) {
|
||||
MinerLogs.add(i.itemID);
|
||||
WarpDrive.debugPrint("WD: Added log ID: "+i.itemID);
|
||||
}
|
||||
}
|
||||
if(lowerOreName.contains("leave") || lowerOreName.contains("leaf"))
|
||||
{
|
||||
if (lowerOreName.contains("leave") || lowerOreName.contains("leaf")) {
|
||||
ArrayList<ItemStack> item = OreDictionary.getOres(oreName);
|
||||
for(ItemStack i: item)
|
||||
{
|
||||
for(ItemStack i: item) {
|
||||
MinerLeaves.add(i.itemID);
|
||||
WarpDrive.debugPrint("WD: Added leaf ID: "+i.itemID);
|
||||
}
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
package cr0s.WarpDrive;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class WarpDriveCreativeTab extends CreativeTabs
|
||||
{
|
||||
public class WarpDriveCreativeTab extends CreativeTabs {
|
||||
String topLabel;
|
||||
|
||||
public WarpDriveCreativeTab(int par1, String par2Str)
|
||||
{
|
||||
public WarpDriveCreativeTab(int par1, String par2Str) {
|
||||
super(par1, par2Str);
|
||||
}
|
||||
|
||||
public WarpDriveCreativeTab(String par1Str,String topLabelIn)
|
||||
{
|
||||
public WarpDriveCreativeTab(String par1Str,String topLabelIn) {
|
||||
super(par1Str);
|
||||
topLabel = topLabelIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return WarpDrive.reactorLaserFocusItem;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getTabIconItem() {
|
||||
return WarpDrive.componentItem;
|
||||
// return WarpDrive.reactorLaserFocusItem;
|
||||
}
|
||||
|
||||
public String getTranslatedTabLabel()
|
||||
{
|
||||
public String getTranslatedTabLabel() {
|
||||
return topLabel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,11 @@ import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
|||
public class WarpDrivePeripheralHandler implements IPeripheralProvider {
|
||||
@Override
|
||||
public IPeripheral getPeripheral(World world, int x, int y, int z, int side) {
|
||||
WarpDrive.debugPrint("Checking Peripheral at " + x + ", " + y + ", " + z);
|
||||
// WarpDrive.debugPrint("Checking Peripheral at " + x + ", " + y + ", " + z);
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if(te instanceof IPeripheral)
|
||||
if(te instanceof IPeripheral) {
|
||||
return (IPeripheral)te;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -16,8 +16,7 @@ public class WorldGenSmallShip extends WorldGenerator
|
|||
private boolean corrupted;
|
||||
private int solarType;
|
||||
|
||||
public WorldGenSmallShip(boolean corrupted)
|
||||
{
|
||||
public WorldGenSmallShip(boolean corrupted) {
|
||||
this.corrupted = corrupted;
|
||||
solarType = WarpDriveConfig.getIC2Item("solarPanel").getItemDamage();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ItemReactorLaserFocus extends Item implements IReactorComponent
|
|||
super(id);
|
||||
setMaxDamage(maxHeat);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Reactor Laser Focus");
|
||||
setUnlocalizedName("warpdrive.items.ReactorLaserFocus");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
125
src/cr0s/WarpDrive/item/ItemWarpComponent.java
Normal file
125
src/cr0s/WarpDrive/item/ItemWarpComponent.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package cr0s.WarpDrive.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class ItemWarpComponent extends Item {
|
||||
private Icon[] potentialIcons;
|
||||
private String[] potentialUnlocalized = new String[7];
|
||||
private ItemStack[] cachedIS;
|
||||
|
||||
private int id;
|
||||
|
||||
public ItemWarpComponent(int par1) {
|
||||
super(par1);
|
||||
id = par1;
|
||||
setHasSubtypes(true);
|
||||
//this.setMaxDamage(potentialUnlocalized.length);
|
||||
setUnlocalizedName("warpdrive.crafting.Malformed");
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
|
||||
potentialUnlocalized[0] = "EmptyCore";
|
||||
potentialUnlocalized[1] = "TeleCore";
|
||||
potentialUnlocalized[2] = "WarpCore";
|
||||
potentialUnlocalized[3] = "LaserCore";
|
||||
potentialUnlocalized[4] = "ReactorCore";
|
||||
potentialUnlocalized[5] = "InterfaceComputer";
|
||||
potentialUnlocalized[6] = "InterfacePower";
|
||||
|
||||
potentialIcons = new Icon[potentialUnlocalized.length];
|
||||
cachedIS = new ItemStack[potentialUnlocalized.length];
|
||||
}
|
||||
|
||||
public ItemStack getIS(int damage) {
|
||||
if (damage >=0 && damage < potentialUnlocalized.length) {
|
||||
if (cachedIS[damage] == null) {
|
||||
cachedIS[damage] = new ItemStack(WarpDrive.componentItem,1,damage);
|
||||
}
|
||||
return cachedIS[damage];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerRecipes() {
|
||||
WarpDrive.debugPrint("Registering empty recipe");
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(0),false,"nrn","r r","nrn",
|
||||
'r', Item.redstone,
|
||||
'n', Item.goldNugget));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(1),false,"g","e","c",
|
||||
'g', Block.glass,
|
||||
'e', Item.enderPearl,
|
||||
'c', getIS(0)));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(2),false," g ","ede"," c ",
|
||||
'g', Block.glass,
|
||||
'e', Item.enderPearl,
|
||||
'd', Item.diamond,
|
||||
'c', getIS(0)));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(3),false," g ","rtr"," c ",
|
||||
'g', Block.glass,
|
||||
'r', "dyeBlue",
|
||||
't', Block.torchWood,
|
||||
'c', getIS(0)));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(4),false," l ","rcr"," l ",
|
||||
'l', "dyeWhite",
|
||||
'r', Item.coal,
|
||||
'c', getIS(0)));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(5),false,"g ","gwr","rwr",
|
||||
'g', Item.goldNugget,
|
||||
'r', Item.redstone,
|
||||
'w', "plankWood"));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(6),false,"gig","iri","gig",
|
||||
'g', Item.goldNugget,
|
||||
'r', Item.redstone,
|
||||
'i', Item.ingotIron));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
for(int i = 0; i < potentialUnlocalized.length; i++) {
|
||||
potentialIcons[i] = par1IconRegister.registerIcon("warpdrive:component" + potentialUnlocalized[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemSt) {
|
||||
int damage = itemSt.getItemDamage();
|
||||
if (damage >= 0 && damage < potentialUnlocalized.length) {
|
||||
return "item.warpdrive.crafting." + potentialUnlocalized[damage];
|
||||
}
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int damage) {
|
||||
if (damage >= 0 && damage < potentialUnlocalized.length) {
|
||||
return potentialIcons[damage];
|
||||
}
|
||||
return potentialIcons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for(int i = 0; i < potentialUnlocalized.length; i++)
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ public class BlockAirGenerator extends BlockContainer
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Air Generator");
|
||||
setUnlocalizedName("warpdrive.machines.AirGenerator");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,7 @@ public class BlockCamera extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Camera block");
|
||||
setUnlocalizedName("warpdrive.machines.Camera");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,7 @@ public class BlockCloakingCoil extends Block {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Cloaking Device Coil");
|
||||
setUnlocalizedName("warpdrive.machines.CloakingCoil");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BlockCloakingDeviceCore extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Cloaking Device Core");
|
||||
setUnlocalizedName("warpdrive.machines.CloakingDeviceCore");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BlockLaser extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Laser Emitter");
|
||||
setUnlocalizedName("warpdrive.machines.Laser");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BlockLaserCam extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Laser Emitter + Camera");
|
||||
setUnlocalizedName("warpdrive.machines.LaserCamera");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class BlockLaserReactorMonitor extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Laser Reactor Monitor");
|
||||
setUnlocalizedName("warpdrive.machines.LaserReactorMonitor");
|
||||
}
|
||||
|
||||
public BlockLaserReactorMonitor(int id, Material material) {
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlockLaserTreeFarm extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Laser Tree Farm");
|
||||
setUnlocalizedName("warpdrive.machines.LaserTreeFarm");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,7 @@ public class BlockLift extends BlockContainer
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Laser lift");
|
||||
setUnlocalizedName("warpdrive.machines.LaserLift");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlockMiningLaser extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Mining Laser");
|
||||
setUnlocalizedName("warpdrive.machines.MiningLaser");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BlockMonitor extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Monitor");
|
||||
setUnlocalizedName("warpdrive.machines.Monitor");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BlockParticleBooster extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Particle Booster");
|
||||
setUnlocalizedName("warpdrive.machines.ParticleBooster");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
35
src/cr0s/WarpDrive/machines/BlockPowerLaser.java
Normal file
35
src/cr0s/WarpDrive/machines/BlockPowerLaser.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package cr0s.WarpDrive.machines;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockPowerLaser extends BlockContainer {
|
||||
Icon[] iconBuffer = new Icon[2];
|
||||
public BlockPowerLaser(int id) {
|
||||
super(id, Material.iron);
|
||||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("warpdrive.power.laser");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
return new TileEntityPowerReactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:powerLaserTopBottom");
|
||||
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:powerLaserSides");
|
||||
}
|
||||
}
|
35
src/cr0s/WarpDrive/machines/BlockPowerReactor.java
Normal file
35
src/cr0s/WarpDrive/machines/BlockPowerReactor.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package cr0s.WarpDrive.machines;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockPowerReactor extends BlockContainer {
|
||||
Icon[] iconBuffer = new Icon[2];
|
||||
public BlockPowerReactor(int id) {
|
||||
super(id, Material.iron);
|
||||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("warpdrive.power.Reactor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
return new TileEntityPowerReactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:powerReactorTopBottom");
|
||||
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:powerReactorSides");
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ public class BlockProtocol extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Warp Controller");
|
||||
setUnlocalizedName("warpdrive.machines.WarpProtocol");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BlockRadar extends BlockContainer
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("W-Radar");
|
||||
setUnlocalizedName("warpdrive.machines.WarpRadar");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,7 @@ public class BlockReactor extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Warp Core");
|
||||
setUnlocalizedName("warpdrive.machines.WarpCore");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BlockShipScanner extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Ship Scanner");
|
||||
setUnlocalizedName("warpdrive.machines.Scanner");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlockTransporter extends BlockContainer {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Transporter");
|
||||
setUnlocalizedName("warpdrive.machines.Transporter");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ public class BlockWarpIsolation extends Block {
|
|||
setHardness(0.5F);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setUnlocalizedName("Warp-Field Isolation Block");
|
||||
setUnlocalizedName("warpdrive.blocks.WarpIsolation");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -84,14 +84,14 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
|
|||
|
||||
updateTicks--;
|
||||
if (updateTicks <= 0) {
|
||||
//System.out.println("[CloakDev] Updating cloaking state...");
|
||||
//System.out.println("" + this + " Updating cloaking state...");
|
||||
updateTicks = ((tier == 1) ? 20 : (tier == 2) ? 10 : 20) * WarpDriveConfig.CD_FIELD_REFRESH_INTERVAL_SECONDS; // resetting timer
|
||||
|
||||
isValid = validateAssembly();
|
||||
isCloaking = WarpDrive.instance.cloaks.isAreaExists(worldObj, xCoord, yCoord, zCoord);
|
||||
if (!isEnabled) {// disabled
|
||||
if (isCloaking) {// disabled, cloaking => stop cloaking
|
||||
WarpDrive.debugPrint("[CloakDev] Disabled, cloak field going down...");
|
||||
WarpDrive.debugPrint("" + this + " Disabled, cloak field going down...");
|
||||
disableCloakingField();
|
||||
} else {// disabled, no cloaking
|
||||
// IDLE
|
||||
|
@ -100,13 +100,14 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
|
|||
boolean hasEnoughPower = countBlocksAndConsumeEnergy();
|
||||
if (!isCloaking) {// enabled, not cloaking
|
||||
if (hasEnoughPower && isValid) {// enabled, can cloak and able to
|
||||
setCoilsState(true);
|
||||
|
||||
// Register cloak
|
||||
WarpDrive.instance.cloaks.addCloakedAreaWorld(worldObj, minX, minY, minZ, maxX, maxY, maxZ, xCoord, yCoord, zCoord, tier);
|
||||
if (!soundPlayed) {
|
||||
soundPlayed = true;
|
||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, "warpdrive:cloak", 4F, 1F);
|
||||
}
|
||||
setCoilsState(true);
|
||||
|
||||
// Refresh the field
|
||||
CloakedArea area = WarpDrive.instance.cloaks.getCloakedArea(worldObj, xCoord, yCoord, zCoord);
|
||||
|
@ -118,14 +119,19 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
|
|||
}
|
||||
} else {// enabled & cloaked
|
||||
if (!isValid) {// enabled, cloaking but invalid
|
||||
WarpDrive.debugPrint("[CloakDev] Coil(s) lost, cloak field is collapsing...");
|
||||
WarpDrive.debugPrint("" + this + " Coil(s) lost, cloak field is collapsing...");
|
||||
consumeAllEnergy();
|
||||
disableCloakingField();
|
||||
} else {// enabled, cloaking and valid
|
||||
if (hasEnoughPower) {// enabled, cloaking and able to
|
||||
// IDLE
|
||||
// Refresh the field !!! LemTest 2014-07-12
|
||||
CloakedArea area = WarpDrive.instance.cloaks.getCloakedArea(worldObj, xCoord, yCoord, zCoord);
|
||||
if (area != null) {
|
||||
area.sendCloakPacketToPlayersEx(false); // recloak field
|
||||
}
|
||||
} else {// loosing power
|
||||
WarpDrive.debugPrint("[CloakDev] Low power, cloak field is collapsing...");
|
||||
WarpDrive.debugPrint("" + this + " Low power, cloak field is collapsing...");
|
||||
disableCloakingField();
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +284,7 @@ public class TileEntityCloakingDeviceCore extends WarpEnergyTE implements IPerip
|
|||
energyToConsume = volume * WarpDriveConfig.CD_ENERGY_PER_BLOCK_TIER2;
|
||||
}
|
||||
|
||||
//System.out.println("[CloakDev] Consuming " + energyToConsume + " eU for " + blocksCount + " blocks");
|
||||
//System.out.println("" + this + " Consuming " + energyToConsume + " eU for " + blocksCount + " blocks");
|
||||
return consumeEnergy(energyToConsume, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package cr0s.WarpDrive.machines;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -31,7 +31,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
private int xSize = defSize;
|
||||
private int zSize = defSize;
|
||||
|
||||
ArrayList<Vector3> logs;
|
||||
LinkedList<Vector3> logs;
|
||||
private int logIndex = 0;
|
||||
|
||||
private String[] methodsArray = {
|
||||
|
@ -45,36 +45,29 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
"state"
|
||||
};
|
||||
|
||||
public TileEntityLaserTreeFarm()
|
||||
{
|
||||
public TileEntityLaserTreeFarm() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (active) {
|
||||
if (mode == 0)
|
||||
{
|
||||
if(++scan >= scanWait)
|
||||
{
|
||||
scan++;
|
||||
if (mode == 0) {
|
||||
if (scan >= scanWait) {
|
||||
scan = 0;
|
||||
logs = scanTrees();
|
||||
if(logs.size() > 0)
|
||||
mode = treeTap ? 2 : 1;
|
||||
logIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (++scan >= mineWait * delayMul)
|
||||
{
|
||||
} else {
|
||||
if (scan >= mineWait * delayMul) {
|
||||
scan = 0;
|
||||
|
||||
if (logIndex >= logs.size())
|
||||
{
|
||||
if (logIndex >= logs.size()) {
|
||||
mode = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -84,7 +77,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
if (mode == 1) {
|
||||
int cost = calculateBlockCost(blockID);
|
||||
if (consumeEnergyFromBooster(cost, true)) {
|
||||
if(isLog(blockID) || (doLeaves && isLeaf(blockID))) {
|
||||
if (isLog(blockID) || (doLeaves && isLeaf(blockID))) {
|
||||
delayMul = 1;
|
||||
if (isRoomForHarvest()) {
|
||||
if (consumeEnergyFromBooster(cost, false)) {
|
||||
|
@ -104,9 +97,9 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
}
|
||||
} else if(mode == 2) {
|
||||
int cost = calculateBlockCost(blockID);
|
||||
if(consumeEnergyFromBooster(cost, true)) {
|
||||
if(isRoomForHarvest()) {
|
||||
if(blockID == WarpDriveConfig.IC2_RubberWood) {
|
||||
if (consumeEnergyFromBooster(cost, true)) {
|
||||
if (isRoomForHarvest()) {
|
||||
if (blockID == WarpDriveConfig.IC2_RubberWood) {
|
||||
int metadata = worldObj.getBlockMetadata(pos.intX(), pos.intY(), pos.intZ());
|
||||
if (metadata >= 2 && metadata <= 5) {
|
||||
WarpDrive.debugPrint("wetspot found");
|
||||
|
@ -125,8 +118,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
delayMul = 1;
|
||||
}
|
||||
} else if(isLog(blockID)) {
|
||||
if (consumeEnergyFromBooster(cost,false))
|
||||
{
|
||||
if (consumeEnergyFromBooster(cost, false)) {
|
||||
delayMul = 4;
|
||||
totalHarvested++;
|
||||
harvestBlock(pos);
|
||||
|
@ -152,24 +144,20 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isLog(int blockID)
|
||||
{
|
||||
private boolean isLog(int blockID) {
|
||||
return WarpDriveConfig.MinerLogs.contains(blockID);
|
||||
}
|
||||
|
||||
private boolean isLeaf(int blockID)
|
||||
{
|
||||
private boolean isLeaf(int blockID) {
|
||||
return WarpDriveConfig.MinerLeaves.contains(blockID);
|
||||
}
|
||||
|
||||
private void addTree(ArrayList<Vector3> list,Vector3 newTree)
|
||||
{
|
||||
private void addTree(LinkedList<Vector3> list, Vector3 newTree) {
|
||||
WarpDrive.debugPrint("Adding tree position:" + newTree.x + "," + newTree.y + "," + newTree.z);
|
||||
list.add(newTree);
|
||||
}
|
||||
|
||||
private ArrayList<Vector3> scanTrees()
|
||||
{
|
||||
private LinkedList<Vector3> scanTrees() {
|
||||
int xmax, zmax, x1, x2, z1, z2;
|
||||
int xmin, zmin;
|
||||
x1 = xCoord + xSize / 2;
|
||||
|
@ -182,41 +170,32 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
zmin = Math.min(z1, z2);
|
||||
zmax = Math.max(z1, z2);
|
||||
|
||||
ArrayList<Vector3> logPositions = new ArrayList<Vector3>();
|
||||
LinkedList<Vector3> logPositions = new LinkedList<Vector3>();
|
||||
|
||||
for(int x=xmin;x<=xmax;x++)
|
||||
{
|
||||
for(int z=zmin;z<=zmax;z++)
|
||||
{
|
||||
for(int x = xmin; x <= xmax; x++) {
|
||||
for(int z = zmin; z <= zmax; z++) {
|
||||
int blockID = worldObj.getBlockId(x, yCoord, z);
|
||||
if(isLog(blockID))
|
||||
{
|
||||
Vector3 pos = new Vector3(x,yCoord,z);
|
||||
if (isLog(blockID)) {
|
||||
Vector3 pos = new Vector3(x, yCoord, z);
|
||||
logPositions.add(pos);
|
||||
scanNearby(logPositions,x,yCoord,z,0);
|
||||
scanNearby(logPositions, x, yCoord, z, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return logPositions;
|
||||
}
|
||||
|
||||
private void scanNearby(ArrayList<Vector3> current,int x,int y,int z,int d)
|
||||
{
|
||||
int[] deltas = {0,-1,1};
|
||||
for(int dx : deltas)
|
||||
{
|
||||
for(int dy=1;dy>=0;dy--)
|
||||
{
|
||||
for(int dz : deltas)
|
||||
{
|
||||
private void scanNearby(LinkedList<Vector3> current, int x, int y, int z, int d) {
|
||||
int[] deltas = {0, -1, 1};
|
||||
for(int dx : deltas) {
|
||||
for(int dy = 1; dy >= 0; dy--) {
|
||||
for(int dz : deltas) {
|
||||
int blockID = worldObj.getBlockId(x+dx, y+dy, z+dz);
|
||||
if(isLog(blockID) || (doLeaves && isLeaf(blockID)))
|
||||
{
|
||||
Vector3 pos = new Vector3(x+dx,y+dy,z+dz);
|
||||
if(!current.contains(pos))
|
||||
{
|
||||
addTree(current,pos);
|
||||
if(d < 35)
|
||||
if (isLog(blockID) || (doLeaves && isLeaf(blockID))) {
|
||||
Vector3 pos = new Vector3(x + dx, y + dy, z + dz);
|
||||
if (!current.contains(pos)) {
|
||||
addTree(current, pos);
|
||||
if (d < 35) {
|
||||
scanNearby(current,x+dx,y+dy,z+dz,d+1);
|
||||
}
|
||||
}
|
||||
|
@ -224,10 +203,10 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tag.setInteger("xSize", xSize);
|
||||
tag.setInteger("zSize", zSize);
|
||||
|
@ -238,8 +217,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
xSize = tag.getInteger("xSize");
|
||||
zSize = tag.getInteger("zSize");
|
||||
|
@ -252,31 +230,25 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldChunkLoad()
|
||||
{
|
||||
public boolean shouldChunkLoad() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
public String getType() {
|
||||
return "treefarmLaser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
public String[] getMethodNames() {
|
||||
return methodsArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
|
||||
{
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
|
||||
String methodStr = methodsArray[method];
|
||||
if(methodStr == "start")
|
||||
{
|
||||
if(!active)
|
||||
{
|
||||
if (methodStr == "start") {
|
||||
if (!active) {
|
||||
mode = 0;
|
||||
totalHarvested = 0;
|
||||
active = true;
|
||||
|
@ -284,93 +256,70 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
return new Boolean[] { true };
|
||||
}
|
||||
|
||||
if(methodStr == "stop")
|
||||
{
|
||||
if (methodStr == "stop") {
|
||||
active = false;
|
||||
}
|
||||
|
||||
if(methodStr == "area")
|
||||
{
|
||||
try
|
||||
{
|
||||
if(arguments.length == 1)
|
||||
{
|
||||
if (methodStr == "area") {
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
xSize = clamp(toInt(arguments[0]),3,WarpDriveConfig.TF_MAX_SIZE);
|
||||
zSize = xSize;
|
||||
}
|
||||
else if(arguments.length == 2)
|
||||
{
|
||||
} else if(arguments.length == 2) {
|
||||
xSize = clamp(toInt(arguments[0]),3,WarpDriveConfig.TF_MAX_SIZE);
|
||||
zSize = clamp(toInt(arguments[1]),3,WarpDriveConfig.TF_MAX_SIZE);
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
} catch(NumberFormatException e) {
|
||||
xSize = defSize;
|
||||
zSize = defSize;
|
||||
}
|
||||
defineMiningArea(xSize,zSize);
|
||||
return new Integer[] { xSize , zSize };
|
||||
|
||||
}
|
||||
|
||||
if(methodStr == "leaves")
|
||||
{
|
||||
try
|
||||
{
|
||||
if(arguments.length > 0)
|
||||
if (methodStr == "leaves") {
|
||||
try {
|
||||
if (arguments.length > 0) {
|
||||
doLeaves = toBool(arguments[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
} catch(Exception e) {
|
||||
|
||||
}
|
||||
return new Boolean[] { doLeaves };
|
||||
}
|
||||
|
||||
if(methodStr == "silkTouch")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (methodStr == "silkTouch") {
|
||||
try {
|
||||
silkTouch(arguments[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
} catch(Exception e) {
|
||||
silkTouch(false);
|
||||
}
|
||||
return new Object[] { silkTouch() };
|
||||
}
|
||||
|
||||
if(methodStr == "silkTouchLeaves")
|
||||
{
|
||||
try
|
||||
{
|
||||
if(arguments.length >= 1)
|
||||
if (methodStr == "silkTouchLeaves") {
|
||||
try {
|
||||
if (arguments.length >= 1) {
|
||||
silkTouchLeaves = toBool(arguments[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
} catch(Exception e) {
|
||||
silkTouchLeaves = false;
|
||||
}
|
||||
return new Object[] { silkTouchLeaves };
|
||||
}
|
||||
|
||||
if(methodStr == "treetap")
|
||||
{
|
||||
try
|
||||
{
|
||||
if(arguments.length >= 1)
|
||||
if (methodStr == "treetap") {
|
||||
try {
|
||||
if (arguments.length >= 1) {
|
||||
treeTap = toBool(arguments[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
} catch(Exception e) {
|
||||
treeTap = false;
|
||||
}
|
||||
return new Object[] { treeTap };
|
||||
}
|
||||
|
||||
if(methodStr == "state")
|
||||
{
|
||||
if (methodStr == "state") {
|
||||
String state = active ? (mode==0?"scanning" : (mode == 1 ? "harvesting" : "tapping")) : "inactive";
|
||||
return new Object[] { state, xSize, zSize, energy(), totalHarvested };
|
||||
}
|
||||
|
@ -378,63 +327,54 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void attach(IComputerAccess computer)
|
||||
{
|
||||
public void attach(IComputerAccess computer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(IComputerAccess computer)
|
||||
{
|
||||
public void detach(IComputerAccess computer) {
|
||||
}
|
||||
|
||||
//ABSTRACT LASER IMPLEMENTATION
|
||||
@Override
|
||||
protected boolean silkTouch(int blockID)
|
||||
{
|
||||
if(isLeaf(blockID))
|
||||
protected boolean silkTouch(int blockID) {
|
||||
if (isLeaf(blockID)) {
|
||||
return silkTouchLeaves;
|
||||
}
|
||||
return silkTouch();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkTouch()
|
||||
{
|
||||
protected boolean canSilkTouch() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int minFortune()
|
||||
{
|
||||
protected int minFortune() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maxFortune()
|
||||
{
|
||||
protected int maxFortune() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double laserBelow()
|
||||
{
|
||||
protected double laserBelow() {
|
||||
return -0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getColorR()
|
||||
{
|
||||
protected float getColorR() {
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getColorG()
|
||||
{
|
||||
protected float getColorG() {
|
||||
return 0.7f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getColorB()
|
||||
{
|
||||
protected float getColorB() {
|
||||
return 0.4f;
|
||||
}
|
||||
|
||||
|
@ -443,5 +383,4 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner implements
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,8 +47,6 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
|
|||
Boolean powerStatus = false;
|
||||
private IGridInterface grid;
|
||||
|
||||
private final int MAX_BOOSTERS_NUMBER = 1;
|
||||
|
||||
private int dx, dz, dy;
|
||||
private boolean isMining = false;
|
||||
private boolean isQuarry = false;
|
||||
|
@ -127,7 +125,7 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
|
|||
}
|
||||
} else { // mining
|
||||
delayTicksMine++;
|
||||
if (delayTicksMine > WarpDriveConfig.ML_MINE_DELAY) {
|
||||
if (delayTicksMine > WarpDriveConfig.ML_MINE_DELAY && isMining) {
|
||||
delayTicksMine = 0;
|
||||
|
||||
if (valuableIndex < valuablesInLayer.size()) {
|
||||
|
@ -147,14 +145,15 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
|
|||
sendLaserPacket(minerVector, new Vector3(valuable.intX(), valuable.intY(), valuable.intZ()).add(0.5), 1, 1, 0, 2 * WarpDriveConfig.ML_MINE_DELAY, 0, 50);
|
||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);
|
||||
harvestBlock(valuable);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
currentMode = 0;
|
||||
currentLayer--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean canDig(int blockID) {
|
||||
|
@ -163,6 +162,7 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
|
|||
return false;
|
||||
}
|
||||
// check whitelist
|
||||
// WarpDriveConfig.i.MinerOres.contains(blockID) then true ?
|
||||
else if (blockID == WarpDriveConfig.GT_Granite || blockID == WarpDriveConfig.GT_Ores || blockID == WarpDriveConfig.iridiumID) {
|
||||
return true;
|
||||
}
|
||||
|
@ -276,8 +276,8 @@ public class TileEntityMiningLaser extends TileEntity implements IPeripheral, IG
|
|||
|
||||
public int putInChest(IInventory inventory, ItemStack itemStackSource)
|
||||
{
|
||||
if (inventory == null || itemStackSource == null)
|
||||
{
|
||||
if (inventory == null || itemStackSource == null) {
|
||||
isMining = false; //stopping operation
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
6
src/cr0s/WarpDrive/machines/TileEntityPowerReactor.java
Normal file
6
src/cr0s/WarpDrive/machines/TileEntityPowerReactor.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package cr0s.WarpDrive.machines;
|
||||
|
||||
public class TileEntityPowerReactor extends WarpTE
|
||||
{
|
||||
|
||||
}
|
|
@ -43,8 +43,7 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
|
||||
boolean ready = false; // Ready to operate (valid assembly)
|
||||
|
||||
public String[] methodsArray =
|
||||
{
|
||||
public String[] methodsArray = {
|
||||
"dim_getp", "dim_setp", // 0, 1
|
||||
"dim_getn", "dim_setn", // 2, 3
|
||||
"set_mode", "set_distance", "set_direction", // 4, 5, 6
|
||||
|
@ -54,12 +53,13 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
"set_beacon_frequency", "get_dx", "get_dz", // 16, 17, 18
|
||||
"set_core_frequency", "is_in_space", "is_in_hyperspace", // 19, 20, 21
|
||||
"set_target_jumpgate", // 22
|
||||
"isAttached" // 23
|
||||
};
|
||||
|
||||
private int ticks = 0;
|
||||
private final int BLOCK_UPDATE_INTERVAL = 20 * 3; // 3 seconds
|
||||
|
||||
private TileEntityReactor core;
|
||||
private TileEntityReactor core = null;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
@ -79,14 +79,12 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
}
|
||||
}
|
||||
|
||||
private void setJumpDistance(int distance)
|
||||
{
|
||||
private void setJumpDistance(int distance) {
|
||||
System.out.println("Setting jump distance: " + distance);
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
private void setMode(int mode)
|
||||
{
|
||||
private void setMode(int mode) {
|
||||
// System.out.println("Setting mode: " + mode);
|
||||
this.mode = mode;
|
||||
}
|
||||
|
@ -100,12 +98,11 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
dir = 270;
|
||||
}
|
||||
|
||||
WarpDrive.debugPrint("" + this + " Setting direction: " + dir);
|
||||
//WarpDrive.debugPrint("" + this + " Setting direction: " + dir);
|
||||
this.direction = dir;
|
||||
}
|
||||
|
||||
private void doJump()
|
||||
{
|
||||
private void doJump() {
|
||||
if (core != null) {
|
||||
// Adding random ticks to warmup
|
||||
core.randomWarmupAddition = worldObj.rand.nextInt(WarpDriveConfig.WC_WARMUP_RANDOM_TICKS);
|
||||
|
@ -117,8 +114,7 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
setMode(tag.getInteger("mode"));
|
||||
setFront(tag.getInteger("front"));
|
||||
|
@ -135,8 +131,7 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
updatePlayersString();
|
||||
tag.setString("players", playersString);
|
||||
|
@ -170,45 +165,37 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
entityPlayer.addChatMessage(getBlockType().getLocalizedName() + " Successfully attached.");
|
||||
}
|
||||
|
||||
public void updatePlayersString()
|
||||
{
|
||||
public void updatePlayersString() {
|
||||
String nick;
|
||||
this.playersString = "";
|
||||
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
nick = players.get(i);
|
||||
this.playersString += nick + "|";
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlayersList()
|
||||
{
|
||||
public void updatePlayersList() {
|
||||
String[] playersArray = playersString.split("\\|");
|
||||
|
||||
for (int i = 0; i < playersArray.length; i++)
|
||||
{
|
||||
for (int i = 0; i < playersArray.length; i++) {
|
||||
String nick = playersArray[i];
|
||||
|
||||
if (!nick.isEmpty())
|
||||
{
|
||||
if (!nick.isEmpty()) {
|
||||
players.add(nick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getAttachedPlayersList()
|
||||
{
|
||||
public String getAttachedPlayersList() {
|
||||
StringBuilder list = new StringBuilder("");
|
||||
|
||||
for (int i = 0; i < this.players.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < this.players.size(); i++) {
|
||||
String nick = this.players.get(i);
|
||||
list.append(nick + ((i == this.players.size() - 1) ? "" : ", "));
|
||||
}
|
||||
|
||||
if (players.isEmpty())
|
||||
{
|
||||
if (players.isEmpty()) {
|
||||
list = new StringBuilder("<nobody>");
|
||||
}
|
||||
|
||||
|
@ -218,16 +205,14 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
/**
|
||||
* @return the jumpFlag
|
||||
*/
|
||||
public boolean isJumpFlag()
|
||||
{
|
||||
public boolean isJumpFlag() {
|
||||
return jumpFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jumpFlag the jumpFlag to set
|
||||
*/
|
||||
public void setJumpFlag(boolean jumpFlag)
|
||||
{
|
||||
public void setJumpFlag(boolean jumpFlag) {
|
||||
WarpDrive.debugPrint("" + this + " setJumpFlag(" + jumpFlag + ")");
|
||||
this.jumpFlag = jumpFlag;
|
||||
}
|
||||
|
@ -235,101 +220,88 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
/**
|
||||
* @return the front
|
||||
*/
|
||||
public int getFront()
|
||||
{
|
||||
public int getFront() {
|
||||
return front;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param front the front to set
|
||||
*/
|
||||
public void setFront(int front)
|
||||
{
|
||||
public void setFront(int front) {
|
||||
this.front = front;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the right
|
||||
*/
|
||||
public int getRight()
|
||||
{
|
||||
public int getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param right the right to set
|
||||
*/
|
||||
public void setRight(int right)
|
||||
{
|
||||
public void setRight(int right) {
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the up
|
||||
*/
|
||||
public int getUp()
|
||||
{
|
||||
public int getUp() {
|
||||
return up;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param up the up to set
|
||||
*/
|
||||
public void setUp(int up)
|
||||
{
|
||||
public void setUp(int up) {
|
||||
this.up = up;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the back
|
||||
*/
|
||||
public int getBack()
|
||||
{
|
||||
public int getBack() {
|
||||
return back;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param back the back to set
|
||||
*/
|
||||
public void setBack(int back)
|
||||
{
|
||||
public void setBack(int back) {
|
||||
this.back = back;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the left
|
||||
*/
|
||||
public int getLeft()
|
||||
{
|
||||
public int getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param left the left to set
|
||||
*/
|
||||
public void setLeft(int left)
|
||||
{
|
||||
public void setLeft(int left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the down
|
||||
*/
|
||||
public int getDown()
|
||||
{
|
||||
public int getDown() {
|
||||
return down;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param down the down to set
|
||||
*/
|
||||
public void setDown(int down)
|
||||
{
|
||||
public void setDown(int down) {
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public void setDistance(int distance)
|
||||
{
|
||||
public void setDistance(int distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
|
@ -341,32 +313,28 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
/**
|
||||
* @return the mode
|
||||
*/
|
||||
public int getMode()
|
||||
{
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the direction
|
||||
*/
|
||||
public int getDirection()
|
||||
{
|
||||
public int getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the summonFlag
|
||||
*/
|
||||
public boolean isSummonAllFlag()
|
||||
{
|
||||
public boolean isSummonAllFlag() {
|
||||
return summonFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param summonFlag the summonFlag to set
|
||||
*/
|
||||
public void setSummonAllFlag(boolean summonFlag)
|
||||
{
|
||||
public void setSummonAllFlag(boolean summonFlag) {
|
||||
this.summonFlag = summonFlag;
|
||||
}
|
||||
|
||||
|
@ -407,17 +375,15 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
/**
|
||||
* @return the beaconFrequency
|
||||
*/
|
||||
public String getBeaconFrequency()
|
||||
{
|
||||
public String getBeaconFrequency() {
|
||||
return beaconFrequency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param beaconFrequency the beaconFrequency to set
|
||||
*/
|
||||
public void setBeaconFrequency(String beaconFrequency)
|
||||
{
|
||||
//System.out.println("Setting beacon freqency: " + beaconFrequency);
|
||||
public void setBeaconFrequency(String beaconFrequency) {
|
||||
//WarpDrive.debugPrint("Setting beacon frequency: " + beaconFrequency);
|
||||
this.beaconFrequency = beaconFrequency;
|
||||
}
|
||||
|
||||
|
@ -450,7 +416,7 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
@Override
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
|
||||
int argInt0, argInt1, argInt2;
|
||||
//System.out.println("[ProtoBlock] Method " + method + " " + methodsArray[method] + " called!");
|
||||
//WarpDrive.debugPrint("[ProtoBlock] Method " + method + " " + methodsArray[method] + " called!");
|
||||
switch (method) {
|
||||
case 0: // dim_getp ()
|
||||
return new Integer[] { getFront(), getRight(), getUp() };
|
||||
|
@ -612,6 +578,7 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
try {
|
||||
if (!core.validateShipSpatialParameters(reason)) {
|
||||
core.messageToAllPlayersOnShip(reason.toString());
|
||||
return null;
|
||||
}
|
||||
return new Object[] { (Integer)core.getRealShipVolume() };
|
||||
} catch(Exception e) {
|
||||
|
@ -660,6 +627,12 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
setTargetJumpgateName((String)arguments[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 23: // isAttached
|
||||
if (core != null) {
|
||||
return new Object[] { (boolean)(core.controller != null) };
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return new Integer[] { 0 };
|
||||
|
@ -686,4 +659,13 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s \'%s\' @ \'%s\' %d, %d, %d", new Object[] {
|
||||
getClass().getSimpleName(),
|
||||
core == null ? beaconFrequency : core.coreFrequency,
|
||||
worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(),
|
||||
Integer.valueOf(xCoord), Integer.valueOf(yCoord), Integer.valueOf(zCoord)});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
public int shipVolume;
|
||||
private int currentMode = 0;
|
||||
|
||||
private final byte MODE_TELEPORT = -1;
|
||||
private final byte MODE_TELEPORT = 3;
|
||||
// private final byte MODE_IDLE = 0;
|
||||
private final byte MODE_BASIC_JUMP = 1; // 0-128
|
||||
private final byte MODE_LONG_JUMP = 2; // 0-12800
|
||||
|
@ -99,7 +99,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
registryUpdateTicks = 0;
|
||||
WarpDrive.instance.warpCores.updateInRegistry(this);
|
||||
// WarpDrive.instance.registry.printRegistry();
|
||||
WarpDrive.debugPrint("" + this + " controller is " + controller + ", warmupTime " + warmupTime + ", currentMode " + currentMode + ", jumpFlag " + (controller == null ? "NA" : controller.isJumpFlag()) + ", cooldownTime " + cooldownTime);
|
||||
// WarpDrive.debugPrint("" + this + " controller is " + controller + ", warmupTime " + warmupTime + ", currentMode " + currentMode + ", jumpFlag " + (controller == null ? "NA" : controller.isJumpFlag()) + ", cooldownTime " + cooldownTime);
|
||||
|
||||
TileEntity c = findControllerBlock();
|
||||
if (c == null) {
|
||||
|
@ -269,7 +269,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
}
|
||||
|
||||
public void messageToAllPlayersOnShip(String msg) {
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ);
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(this.minX, this.minY, this.minZ, this.maxX + 0.99D, this.maxY + 0.99D, this.maxZ + 0.99D);
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, axisalignedbb);
|
||||
|
||||
System.out.println("" + (FMLCommonHandler.instance().getEffectiveSide().isClient() ? "Client":"Server") + this + " messageToAllPlayersOnShip: " + msg);
|
||||
|
@ -278,7 +278,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
continue;
|
||||
}
|
||||
|
||||
((EntityPlayer)o).addChatMessage("[WarpCore] " + msg);
|
||||
((EntityPlayer)o).addChatMessage("[" + (coreFrequency.length() > 0 ? coreFrequency : "WarpCore") + "] " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -804,11 +804,9 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
}
|
||||
}
|
||||
|
||||
private void teleportPlayersToSpace()
|
||||
{
|
||||
if (worldObj.provider.dimensionId != WarpDriveConfig.G_SPACE_DIMENSION_ID)
|
||||
{
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(xCoord - 5, yCoord - 5, zCoord - 5, xCoord + 5, yCoord + 5, zCoord + 5);
|
||||
private void teleportPlayersToSpace() {
|
||||
if (worldObj.provider.dimensionId != WarpDriveConfig.G_SPACE_DIMENSION_ID) {
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord - 1, zCoord - 2, xCoord + 2, yCoord + 4, zCoord + 2);
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, axisalignedbb);
|
||||
|
||||
WorldServer spaceWorld = DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID);
|
||||
|
@ -834,8 +832,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
newY = 254;
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayerMP)
|
||||
{
|
||||
if (entity instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) entity).mcServer.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) entity), WarpDriveConfig.G_SPACE_DIMENSION_ID, new SpaceTeleporter(DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID), 0, x, 256, z));
|
||||
|
||||
if (spaceWorld.isAirBlock(x, newY, z)) {
|
||||
|
@ -850,7 +847,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
spaceWorld.setBlock(x - 1, newY, z + 1, Block.stone.blockID, 0, 2);
|
||||
}
|
||||
|
||||
((EntityPlayerMP) entity).setPositionAndUpdate(x, newY + 2, z);
|
||||
((EntityPlayerMP) entity).setPositionAndUpdate(x + 0.5D, newY + 2.0D, z + 0.5D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -957,6 +954,7 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
public int getRealShipVolume() {
|
||||
int shipVolume = 0;
|
||||
|
||||
try {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
|
@ -970,6 +968,9 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return shipVolume;
|
||||
}
|
||||
|
@ -1075,4 +1076,13 @@ public class TileEntityReactor extends WarpEnergyTE
|
|||
WarpDrive.instance.warpCores.removeFromRegistry(this);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s \'%s\' @ \'%s\' %d, %d, %d", new Object[] {
|
||||
getClass().getSimpleName(),
|
||||
coreFrequency,
|
||||
worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(),
|
||||
Integer.valueOf(xCoord), Integer.valueOf(yCoord), Integer.valueOf(zCoord)});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -457,7 +457,7 @@ public class TileEntityShipScanner extends WarpEnergyTE implements IPeripheral {
|
|||
|
||||
// Returns result array for CC interface: [ code, "message" ]
|
||||
private Object[] deployShip(String fileName, int offsetX, int offsetY, int offsetZ) {
|
||||
NBTTagCompound schematic = readNBTFromFile(SCHEMATICS_DIR + fileName);
|
||||
NBTTagCompound schematic = readNBTFromFile(SCHEMATICS_DIR + "/" + fileName);
|
||||
|
||||
if (schematic == null) {
|
||||
System.out.println("[ShipScanner] Schematic is null!");
|
||||
|
@ -654,7 +654,7 @@ public class TileEntityShipScanner extends WarpEnergyTE implements IPeripheral {
|
|||
int y = ((Double)arguments[2]).intValue();
|
||||
int z = ((Double)arguments[3]).intValue();
|
||||
|
||||
if (!new File(SCHEMATICS_DIR + fileName).exists())
|
||||
if (!new File(SCHEMATICS_DIR + "/" + fileName).exists())
|
||||
return new Object[] { 0, "Specified .schematic file not found!" };
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2,13 +2,15 @@ package cr0s.WarpDrive.machines;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
import cr0s.WarpDrive.Vector3;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.WarpDriveConfig;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -48,6 +50,7 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
"energize",
|
||||
"energy",
|
||||
"powerBoost",
|
||||
"energyCost",
|
||||
"help" };
|
||||
|
||||
@Override
|
||||
|
@ -59,10 +62,14 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (isLocked && lockStrengthMul > 0) {
|
||||
if(isLocked) {
|
||||
if(lockStrengthMul > 0.8) {
|
||||
lockStrengthMul *= 0.995;
|
||||
} else {
|
||||
lockStrengthMul*= 0.98;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IPeripheral overrides
|
||||
@Override
|
||||
|
@ -70,6 +77,38 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
return "transporter";
|
||||
}
|
||||
|
||||
public String helpStr(Object[] function) {
|
||||
if (function != null && function.length > 0) {
|
||||
String fun = function[0].toString().toLowerCase();
|
||||
if(fun.equals("source")) {
|
||||
if(WarpDriveConfig.TR_RELATIVE_COORDS) {
|
||||
return "source(x,y,z): sets the coordinates (relative to the transporter) to teleport from\ndest(): returns the relative x,y,z coordinates of the source";
|
||||
} else {
|
||||
return "source(x,y,z): sets the absolute coordinates to teleport from\ndest(): returns the x,y,z coordinates of the source";
|
||||
}
|
||||
} else if(fun.equals("dest")) {
|
||||
if(WarpDriveConfig.TR_RELATIVE_COORDS) {
|
||||
return "dest(x,y,z): sets the coordinates (relative to the transporter) to teleport to\ndest(): returns the relative x,y,z coordinates of the destination";
|
||||
} else {
|
||||
return "dest(x,y,z): sets the absolute coordinates to teleport to\ndest(): returns the x,y,z coordinates of the destination";
|
||||
}
|
||||
} else if(fun.equals("lock")) {
|
||||
return "lock(): locks the source and dest coordinates in and returns the lock strength (float)";
|
||||
} else if(fun.equals("release")) {
|
||||
return "release(): releases the current lock";
|
||||
} else if(fun.equals("lockstrength")) {
|
||||
return "lockStrength(): returns the current lock strength (float)";
|
||||
} else if(fun.equals("energize")) {
|
||||
return "energize(): attempts to teleport all entities at source to dest. Returns the number of entities transported (-1 indicates a problem).";
|
||||
} else if(fun.equals("powerboost")) {
|
||||
return "powerBoost(boostAmount): sets the level of power to use (1 being default), returns the level of power\npowerBoost(): returns the level of power";
|
||||
} else if(fun.equals("energycost")) {
|
||||
return "energyCost(): returns the amount of energy it will take for a single entity to transport with the current settings";
|
||||
}
|
||||
}
|
||||
return "help(\"functionName\"): returns help for the function specified";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return methodArray;
|
||||
|
@ -79,20 +118,22 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
Vector3 vec = src ? sourceVec : destVec;
|
||||
|
||||
if (vec == null) {
|
||||
Vector3 sV = WarpDriveConfig.TR_RELATIVE_COORDS ? new Vector3(this) : new Vector3(0,0,0);
|
||||
if(src)
|
||||
sourceVec = new Vector3(0,0,0);
|
||||
sourceVec = sV;
|
||||
else
|
||||
destVec = new Vector3(0,0,0);
|
||||
destVec = sV;
|
||||
vec = src ? sourceVec : destVec;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (arguments.length >= 3) {
|
||||
unlock();
|
||||
vec.x = toDouble(arguments[0]);
|
||||
vec.y = toDouble(arguments[1]);
|
||||
vec.z = toDouble(arguments[2]);
|
||||
} else if(arguments.length == 1) {
|
||||
unlock();
|
||||
if(WarpDriveConfig.TR_RELATIVE_COORDS) {
|
||||
vec.x = centreOnMe.x;
|
||||
vec.y = centreOnMe.y;
|
||||
|
@ -103,49 +144,39 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
vec.z = zCoord + centreOnMe.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
} catch(NumberFormatException e) {
|
||||
return setVec3(src,"this");
|
||||
}
|
||||
return new Object[] { vec.x, vec.y, vec.z };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
|
||||
{
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
|
||||
String str = methodArray[method];
|
||||
if(str == "energy") {
|
||||
if (str == "energy") {
|
||||
return new Object[] { getEnergyStored(), getMaxEnergyStored() };
|
||||
}
|
||||
|
||||
if(str == "source")
|
||||
{
|
||||
if (str == "source") {
|
||||
return setVec3(true,arguments);
|
||||
}
|
||||
|
||||
if(str == "dest")
|
||||
{
|
||||
if (str == "dest") {
|
||||
return setVec3(false,arguments);
|
||||
}
|
||||
|
||||
if(str == "lock")
|
||||
{
|
||||
return new Object[] { lockStrength(sourceVec, destVec, true) };
|
||||
if (str == "lock") {
|
||||
return new Object[] { lock(sourceVec, destVec) };
|
||||
}
|
||||
|
||||
if(str == "release")
|
||||
{
|
||||
if (isLocked) {
|
||||
isLocked = false;
|
||||
return new Object[] { true };
|
||||
} else {
|
||||
return new Object[] { false };
|
||||
}
|
||||
unlock();
|
||||
return null;
|
||||
}
|
||||
|
||||
if(str == "lockStrength") {
|
||||
return new Object[] { lockStrength(sourceVec,destVec,false) };
|
||||
return new Object[] { getLockStrength() };
|
||||
}
|
||||
|
||||
if(str == "energize") {
|
||||
|
@ -156,7 +187,7 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
try
|
||||
{
|
||||
if(arguments.length >= 1)
|
||||
powerBoost = clamp(toInt(arguments[0]),1,WarpDriveConfig.TR_MAX_BOOST_MUL);
|
||||
powerBoost = clamp(toDouble(arguments[0]),1,WarpDriveConfig.TR_MAX_BOOST_MUL);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
|
@ -165,47 +196,83 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
return new Object[] { powerBoost };
|
||||
}
|
||||
|
||||
if (str == "energyCost") {
|
||||
return new Object[] { energyCost() };
|
||||
}
|
||||
|
||||
if (str == "help") {
|
||||
return new Object[] { helpStr(arguments) };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean energize()
|
||||
{
|
||||
double ls = lockStrength(sourceVec,destVec,false);
|
||||
ArrayList<EntityLivingBase> entitiesToTransport = findEntities(sourceVec,ls);
|
||||
int energyRequested = (int)Math.ceil(WarpDriveConfig.TR_EU_PER_METRE * sourceVec.distanceTo(destVec));
|
||||
for(EntityLivingBase ent : entitiesToTransport) {
|
||||
if (consumeEnergy(energyRequested, false)) {
|
||||
private Integer energyCost() {
|
||||
if (sourceVec != null && destVec != null) {
|
||||
return (int) Math.ceil(Math.pow(3, powerBoost - 1) * WarpDriveConfig.TR_EU_PER_METRE * sourceVec.distanceTo(destVec));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int energize() {
|
||||
if (isLocked) {
|
||||
int count = 0;
|
||||
double ls = getLockStrength();
|
||||
WarpDrive.debugPrint("LS:" + getLockStrength());
|
||||
ArrayList<Entity> entitiesToTransport = findEntities(sourceVec, ls);
|
||||
Integer energyReq = energyCost();
|
||||
if (energyReq == null) {
|
||||
return -1;
|
||||
}
|
||||
for(Entity ent : entitiesToTransport) {
|
||||
WarpDrive.debugPrint("" + this + " Handling entity " + ent.getEntityName());
|
||||
if (consumeEnergy(energyReq, false)) {
|
||||
WarpDrive.debugPrint("" + this + " Energy taken");
|
||||
inflictNegativeEffect(ent, ls);
|
||||
transportEnt(ent, destVec);
|
||||
transportEnt(ent,destVec);
|
||||
count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return count;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void transportEnt(EntityLivingBase ent, Vector3 dest)
|
||||
{
|
||||
if(WarpDriveConfig.TR_RELATIVE_COORDS)
|
||||
ent.setPositionAndUpdate(xCoord+dest.x, yCoord+dest.y, zCoord+dest.z);
|
||||
else
|
||||
ent.setPositionAndUpdate(dest.x, dest.y, dest.z);
|
||||
private void transportEnt(Entity ent, Vector3 dest) {
|
||||
if (ent instanceof EntityLivingBase) {
|
||||
EntityLivingBase livingEnt = (EntityLivingBase) ent;
|
||||
if (WarpDriveConfig.TR_RELATIVE_COORDS) {
|
||||
livingEnt.setPositionAndUpdate(xCoord+dest.x, yCoord+dest.y, zCoord+dest.z);
|
||||
} else {
|
||||
livingEnt.setPositionAndUpdate(dest.x, dest.y, dest.z);
|
||||
}
|
||||
} else {
|
||||
if (WarpDriveConfig.TR_RELATIVE_COORDS) {
|
||||
ent.setPosition(xCoord+dest.x, yCoord+dest.y, zCoord+dest.z);
|
||||
} else {
|
||||
ent.setPosition(dest.x, dest.y, dest.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void inflictNegativeEffect(EntityLivingBase ent,double lockStrength)
|
||||
{
|
||||
private void inflictNegativeEffect(Entity ent, double lockStrength) {
|
||||
double value = Math.random() + lockStrength;
|
||||
|
||||
WarpDrive.debugPrint("TELEPORT INFLICTION: " + value);
|
||||
if(value < 0.1)
|
||||
WarpDrive.debugPrint("TRANSPORTER INFLICTION: " + value);
|
||||
if (value < 0.1) {
|
||||
ent.attackEntityFrom(teleDam, 1000);
|
||||
}
|
||||
|
||||
if(value < 0.2)
|
||||
if (value < 0.2) {
|
||||
ent.attackEntityFrom(teleDam, 10);
|
||||
}
|
||||
|
||||
if(value < 0.5)
|
||||
if (value < 0.5) {
|
||||
ent.attackEntityFrom(teleDam, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private double beaconScan(int xV, int yV, int zV)
|
||||
{
|
||||
|
@ -257,55 +324,61 @@ public class TileEntityTransporter extends WarpEnergyTE implements IPeripheral
|
|||
return curMin;
|
||||
}
|
||||
|
||||
private double lockStrength(Vector3 source,Vector3 dest,boolean lock)
|
||||
{
|
||||
if(isLocked)
|
||||
{
|
||||
return Math.max(1, baseLockStrength * lockStrengthMul * Math.pow(2, powerBoost-1));
|
||||
private double getLockStrength() {
|
||||
if (isLocked) {
|
||||
return clamp(baseLockStrength * lockStrengthMul * Math.pow(2, powerBoost - 1), 0, 1);
|
||||
}
|
||||
else if(lock && source != null && dest != null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void unlock() {
|
||||
isLocked = false;
|
||||
baseLockStrength = 0;
|
||||
}
|
||||
|
||||
private double lock(Vector3 source,Vector3 dest) {
|
||||
if (source != null && dest != null) {
|
||||
double basePower = min(calculatePower(source),calculatePower(dest),calculatePower(source,dest));
|
||||
baseLockStrength = basePower;
|
||||
lockStrengthMul = 1;
|
||||
isLocked = true;
|
||||
return Math.max(1,baseLockStrength * powerBoost);
|
||||
}
|
||||
else
|
||||
WarpDrive.debugPrint(baseLockStrength + "," + getLockStrength());
|
||||
return getLockStrength();
|
||||
} else {
|
||||
unlock();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private AxisAlignedBB getAABB()
|
||||
{
|
||||
private AxisAlignedBB getAABB() {
|
||||
Vector3 tS = new Vector3(this);
|
||||
Vector3 bS = new Vector3(this);
|
||||
Vector3 scanPos = new Vector3(scanRange/2,1,scanRange/2);
|
||||
Vector3 scanPos = new Vector3( scanRange/2, 2, scanRange/2);
|
||||
Vector3 scanNeg = new Vector3(-scanRange/2,-1,-scanRange/2);
|
||||
if(WarpDriveConfig.TR_RELATIVE_COORDS)
|
||||
{
|
||||
if(WarpDriveConfig.TR_RELATIVE_COORDS) {
|
||||
tS.translate(sourceVec).translate(scanPos);
|
||||
bS.translate(sourceVec).translate(scanNeg);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tS = sourceVec.clone().translate(scanPos);
|
||||
bS = sourceVec.clone().translate(scanNeg);
|
||||
}
|
||||
return AxisAlignedBB.getBoundingBox(bS.x,bS.y,bS.z,tS.x,tS.y,tS.z);
|
||||
}
|
||||
|
||||
private ArrayList<EntityLivingBase> findEntities(Vector3 source, double lockStrength)
|
||||
{
|
||||
private ArrayList<Entity> findEntities(Vector3 source, double lockStrength) {
|
||||
AxisAlignedBB bb = getAABB();
|
||||
ArrayList<EntityLivingBase> output = new ArrayList<EntityLivingBase>();
|
||||
WarpDrive.debugPrint("Transporter:" +bb.toString());
|
||||
List data = worldObj.getEntitiesWithinAABBExcludingEntity(null, bb);
|
||||
for(Object ent : data)
|
||||
{
|
||||
WarpDrive.debugPrint("Transporter:"+ent.toString() + " found");
|
||||
if(lockStrength >= 1 || Math.random() < lockStrength) //If weak lock, don't transport (lazy java shouldn't do math.random() if strong lock)
|
||||
if(ent instanceof EntityLivingBase)
|
||||
output.add((EntityLivingBase) ent);
|
||||
ArrayList<Entity> output = new ArrayList<Entity>(data.size());
|
||||
for(Object ent : data) {
|
||||
if (lockStrength >= 1 || worldObj.rand.nextDouble() < lockStrength) {// If weak lock, don't transport
|
||||
WarpDrive.debugPrint("" + this + " Entity '" + ent.toString() + "' found and added");
|
||||
if (ent instanceof Entity) {
|
||||
output.add((Entity) ent);
|
||||
}
|
||||
} else {
|
||||
WarpDrive.debugPrint("" + this + " Entity '" + ent.toString() + "' discarded");
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue