Code cleanup & Fixed IC2 reactor monitor
Removed LUA help methods that are in the wiki Replaced Vector3 with VectorI when applicable Fixed asynchronous laser beam in Enantiomorphic reactor Removed redundant code existing in Forge Fixed default mining laser radius
This commit is contained in:
parent
c0d5105bd3
commit
c5244398c7
16 changed files with 368 additions and 398 deletions
|
@ -32,6 +32,7 @@ import cr0s.warpdrive.data.JumpBlock;
|
||||||
import cr0s.warpdrive.data.MovingEntity;
|
import cr0s.warpdrive.data.MovingEntity;
|
||||||
import cr0s.warpdrive.data.Planet;
|
import cr0s.warpdrive.data.Planet;
|
||||||
import cr0s.warpdrive.data.Vector3;
|
import cr0s.warpdrive.data.Vector3;
|
||||||
|
import cr0s.warpdrive.data.VectorI;
|
||||||
import cr0s.warpdrive.world.SpaceTeleporter;
|
import cr0s.warpdrive.world.SpaceTeleporter;
|
||||||
|
|
||||||
public class EntityJump extends Entity {
|
public class EntityJump extends Entity {
|
||||||
|
@ -347,7 +348,7 @@ public class EntityJump extends Entity {
|
||||||
Planet transitionPlane = WarpDriveConfig.PLANETS[iPlane];
|
Planet transitionPlane = WarpDriveConfig.PLANETS[iPlane];
|
||||||
if (worldObj.provider.dimensionId == transitionPlane.dimensionId) {
|
if (worldObj.provider.dimensionId == transitionPlane.dimensionId) {
|
||||||
planeFound = true;
|
planeFound = true;
|
||||||
int planeDistance = transitionPlane.isValidToSpace(new Vector3(this));
|
int planeDistance = transitionPlane.isValidToSpace(new VectorI(this));
|
||||||
if (planeDistance == 0) {
|
if (planeDistance == 0) {
|
||||||
planeValid = true;
|
planeValid = true;
|
||||||
moveX = transitionPlane.spaceCenterX - transitionPlane.dimensionCenterX;
|
moveX = transitionPlane.spaceCenterX - transitionPlane.dimensionCenterX;
|
||||||
|
@ -386,7 +387,7 @@ public class EntityJump extends Entity {
|
||||||
Planet closestTransitionPlane = null;
|
Planet closestTransitionPlane = null;
|
||||||
for (int iPlane = 0; (!planeFound) && iPlane < WarpDriveConfig.PLANETS.length; iPlane++) {
|
for (int iPlane = 0; (!planeFound) && iPlane < WarpDriveConfig.PLANETS.length; iPlane++) {
|
||||||
Planet transitionPlane = WarpDriveConfig.PLANETS[iPlane];
|
Planet transitionPlane = WarpDriveConfig.PLANETS[iPlane];
|
||||||
int planeDistance = transitionPlane.isValidFromSpace(new Vector3(this));
|
int planeDistance = transitionPlane.isValidFromSpace(new VectorI(this));
|
||||||
if (planeDistance == 0) {
|
if (planeDistance == 0) {
|
||||||
planeFound = true;
|
planeFound = true;
|
||||||
moveX = transitionPlane.dimensionCenterX - transitionPlane.spaceCenterX;
|
moveX = transitionPlane.dimensionCenterX - transitionPlane.spaceCenterX;
|
||||||
|
|
|
@ -65,9 +65,9 @@ public abstract class BlockAbstractContainer extends BlockContainer {
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block b) {
|
public void onNeighborBlockChange(World w, int x, int y, int z, Block b) {
|
||||||
super.onNeighborBlockChange(w, x, y, z, b);
|
super.onNeighborBlockChange(w, x, y, z, b);
|
||||||
TileEntity te = w.getTileEntity(x, y, z);
|
TileEntity tileEntity = w.getTileEntity(x, y, z);
|
||||||
if (te instanceof IBlockUpdateDetector) {
|
if (tileEntity instanceof IBlockUpdateDetector) {
|
||||||
((IBlockUpdateDetector) te).updatedNeighbours();
|
((IBlockUpdateDetector) tileEntity).updatedNeighbours();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import cr0s.warpdrive.WarpDrive;
|
||||||
|
|
||||||
public class BlockLaserMedium extends BlockContainer {
|
public class BlockLaserMedium extends BlockContainer {
|
||||||
private IIcon[] iconBuffer;
|
private IIcon[] iconBuffer;
|
||||||
|
|
||||||
public BlockLaserMedium(int texture, Material material) {
|
public BlockLaserMedium(int texture, Material material) {
|
||||||
super(material);
|
super(material);
|
||||||
setHardness(0.5F);
|
setHardness(0.5F);
|
||||||
|
@ -24,7 +24,7 @@ public class BlockLaserMedium extends BlockContainer {
|
||||||
setCreativeTab(WarpDrive.creativeTabWarpDrive);
|
setCreativeTab(WarpDrive.creativeTabWarpDrive);
|
||||||
setBlockName("warpdrive.machines.LaserMedium");
|
setBlockName("warpdrive.machines.LaserMedium");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||||
iconBuffer = new IIcon[16];
|
iconBuffer = new IIcon[16];
|
||||||
|
@ -41,21 +41,21 @@ public class BlockLaserMedium extends BlockContainer {
|
||||||
iconBuffer[10] = par1IconRegister.registerIcon("warpdrive:laserMediumSide10");
|
iconBuffer[10] = par1IconRegister.registerIcon("warpdrive:laserMediumSide10");
|
||||||
iconBuffer[11] = par1IconRegister.registerIcon("warpdrive:laserMediumTopBottom");
|
iconBuffer[11] = par1IconRegister.registerIcon("warpdrive:laserMediumTopBottom");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIcon getIcon(int side, int metadata) {
|
public IIcon getIcon(int side, int metadata) {
|
||||||
if (side == 0 || side == 1) {
|
if (side == 0 || side == 1) {
|
||||||
return iconBuffer[11];
|
return iconBuffer[11];
|
||||||
}
|
}
|
||||||
|
|
||||||
return iconBuffer[metadata];
|
return iconBuffer[metadata];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World var1, int i) {
|
public TileEntity createNewTileEntity(World var1, int i) {
|
||||||
return new TileEntityLaserMedium();
|
return new TileEntityLaserMedium();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the quantity of items to drop on block destruction.
|
* Returns the quantity of items to drop on block destruction.
|
||||||
*/
|
*/
|
||||||
|
@ -63,7 +63,7 @@ public class BlockLaserMedium extends BlockContainer {
|
||||||
public int quantityDropped(Random par1Random) {
|
public int quantityDropped(Random par1Random) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the items to drop on destruction.
|
* Returns the ID of the items to drop on destruction.
|
||||||
*/
|
*/
|
||||||
|
@ -71,24 +71,24 @@ public class BlockLaserMedium extends BlockContainer {
|
||||||
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
||||||
return Item.getItemFromBlock(this);
|
return Item.getItemFromBlock(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called upon block activation (right click on the block.)
|
* Called upon block activation (right click on the block.)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
|
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par5EntityPlayer.getHeldItem() == null) {
|
if (entityPlayer.getHeldItem() == null) {
|
||||||
TileEntity te = par1World.getTileEntity(par2, par3, par4);
|
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
|
||||||
if (te != null && te instanceof TileEntityAbstractEnergy) {
|
if (tileEntity != null && tileEntity instanceof TileEntityAbstractEnergy) {
|
||||||
WarpDrive.addChatMessage(par5EntityPlayer, ((TileEntityAbstractEnergy) te).getStatus());
|
WarpDrive.addChatMessage(entityPlayer, ((TileEntityAbstractEnergy) tileEntity).getStatus());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,17 +5,6 @@ import cr0s.warpdrive.data.Vector3;
|
||||||
|
|
||||||
public abstract class TileEntityAbstractBase extends TileEntity
|
public abstract class TileEntityAbstractBase extends TileEntity
|
||||||
{
|
{
|
||||||
public static final Vector3[] adjacentSideOffsets = new Vector3[6];
|
|
||||||
static
|
|
||||||
{
|
|
||||||
adjacentSideOffsets[0] = new Vector3( 0, 0, 1);
|
|
||||||
adjacentSideOffsets[1] = new Vector3( 0, 0,-1);
|
|
||||||
adjacentSideOffsets[2] = new Vector3( 0, 1, 0);
|
|
||||||
adjacentSideOffsets[3] = new Vector3( 0,-1, 0);
|
|
||||||
adjacentSideOffsets[4] = new Vector3( 1, 0, 0);
|
|
||||||
adjacentSideOffsets[5] = new Vector3(-1, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static int toInt(double d) {
|
protected static int toInt(double d) {
|
||||||
return (int) Math.round(d);
|
return (int) Math.round(d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,14 @@ import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
import cr0s.warpdrive.WarpDrive;
|
import cr0s.warpdrive.WarpDrive;
|
||||||
import cr0s.warpdrive.block.TileEntityAbstractLaser;
|
import cr0s.warpdrive.block.TileEntityAbstractLaser;
|
||||||
import cr0s.warpdrive.block.TileEntityLaserMedium;
|
import cr0s.warpdrive.block.TileEntityLaserMedium;
|
||||||
import cr0s.warpdrive.conf.WarpDriveConfig;
|
import cr0s.warpdrive.conf.WarpDriveConfig;
|
||||||
import cr0s.warpdrive.data.Vector3;
|
import cr0s.warpdrive.data.Vector3;
|
||||||
|
import cr0s.warpdrive.data.VectorI;
|
||||||
import cr0s.warpdrive.network.PacketHandler;
|
import cr0s.warpdrive.network.PacketHandler;
|
||||||
|
|
||||||
public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser
|
public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser
|
||||||
|
@ -25,31 +27,25 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser
|
||||||
private int fortuneLevel = 0;
|
private int fortuneLevel = 0;
|
||||||
|
|
||||||
private TileEntityLaserMedium booster = null;
|
private TileEntityLaserMedium booster = null;
|
||||||
private Vector3 minerVector;
|
private Vector3 laserOutput;
|
||||||
|
|
||||||
abstract boolean canSilkTouch();
|
abstract boolean canSilkTouch();
|
||||||
abstract int minFortune();
|
abstract int minFortune();
|
||||||
abstract int maxFortune();
|
abstract int maxFortune();
|
||||||
abstract double laserBelow();
|
ForgeDirection laserOutputSide = ForgeDirection.UP;
|
||||||
|
|
||||||
abstract float getColorR();
|
abstract float getColorR();
|
||||||
abstract float getColorG();
|
abstract float getColorG();
|
||||||
abstract float getColorB();
|
abstract float getColorB();
|
||||||
|
|
||||||
public TileEntityAbstractMiner()
|
public TileEntityAbstractMiner() {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
fixMinerVector();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixMinerVector()
|
@Override
|
||||||
{
|
public void validate() {
|
||||||
if(minerVector == null)
|
super.validate();
|
||||||
minerVector = new Vector3(xCoord,yCoord-laserBelow(),zCoord);
|
laserOutput = new Vector3(this).translate(0.5D).translate(laserOutputSide, 0.5D);
|
||||||
minerVector.x = xCoord;
|
|
||||||
minerVector.y = yCoord - (laserBelow());
|
|
||||||
minerVector.z = zCoord;
|
|
||||||
minerVector.translate(0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ItemStack> getItemStackFromBlock(int i, int j, int k, Block block, int blockMeta)
|
private List<ItemStack> getItemStackFromBlock(int i, int j, int k, Block block, int blockMeta)
|
||||||
|
@ -78,9 +74,8 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser
|
||||||
private IInventory findChest() {
|
private IInventory findChest() {
|
||||||
TileEntity result = null;
|
TileEntity result = null;
|
||||||
|
|
||||||
for(int i = 0; i < 6; i++) {
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
Vector3 sideOffset = adjacentSideOffsets[i];
|
result = worldObj.getTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ);
|
||||||
result = worldObj.getTileEntity(xCoord + sideOffset.intX(), yCoord + sideOffset.intY(), zCoord + sideOffset.intZ());
|
|
||||||
if (result != null && !(result instanceof TileEntityAbstractMiner) && (result instanceof IInventory)) {
|
if (result != null && !(result instanceof TileEntityAbstractMiner) && (result instanceof IInventory)) {
|
||||||
return (IInventory) result;
|
return (IInventory) result;
|
||||||
}
|
}
|
||||||
|
@ -204,31 +199,30 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser
|
||||||
|
|
||||||
//MINING FUNCTIONS
|
//MINING FUNCTIONS
|
||||||
|
|
||||||
protected void laserBlock(Vector3 valuable)
|
protected void laserBlock(VectorI valuable)
|
||||||
{
|
{
|
||||||
fixMinerVector();
|
|
||||||
float r = getColorR();
|
float r = getColorR();
|
||||||
float g = getColorG();
|
float g = getColorG();
|
||||||
float b = getColorB();
|
float b = getColorB();
|
||||||
PacketHandler.sendBeamPacket(worldObj, minerVector, valuable.clone().translate(0.5D), r, g, b, 2 * WarpDriveConfig.MINING_LASER_MINE_DELAY_TICKS, 0, 50);
|
PacketHandler.sendBeamPacket(worldObj, laserOutput, valuable.getBlockCenter(), r, g, b, 2 * WarpDriveConfig.MINING_LASER_MINE_DELAY_TICKS, 0, 50);
|
||||||
//worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);
|
//worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mineBlock(Vector3 valuable, Block block, int blockMeta)
|
private void mineBlock(VectorI valuable, Block block, int blockMeta)
|
||||||
{
|
{
|
||||||
laserBlock(valuable);
|
laserBlock(valuable);
|
||||||
worldObj.playAuxSFXAtEntity(null, 2001, valuable.intX(), valuable.intY(), valuable.intZ(), (blockMeta << 12));
|
worldObj.playAuxSFXAtEntity(null, 2001, valuable.x, valuable.y, valuable.z, (blockMeta << 12));
|
||||||
worldObj.setBlockToAir(valuable.intX(), valuable.intY(), valuable.intZ());
|
worldObj.setBlockToAir(valuable.x, valuable.y, valuable.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean harvestBlock(Vector3 valuable)
|
protected boolean harvestBlock(VectorI valuable)
|
||||||
{
|
{
|
||||||
Block block = worldObj.getBlock(valuable.intX(), valuable.intY(), valuable.intZ());
|
Block block = worldObj.getBlock(valuable.x, valuable.y, valuable.z);
|
||||||
int blockMeta = worldObj.getBlockMetadata(valuable.intX(), valuable.intY(), valuable.intZ());
|
int blockMeta = worldObj.getBlockMetadata(valuable.x, valuable.y, valuable.z);
|
||||||
if (!block.isAssociatedBlock(Blocks.water) && !block.isAssociatedBlock(Blocks.lava))
|
if (!block.isAssociatedBlock(Blocks.water) && !block.isAssociatedBlock(Blocks.lava))
|
||||||
{
|
{
|
||||||
boolean didPlace = true;
|
boolean didPlace = true;
|
||||||
List<ItemStack> stacks = getItemStackFromBlock(valuable.intX(), valuable.intY(), valuable.intZ(), block, blockMeta);
|
List<ItemStack> stacks = getItemStackFromBlock(valuable.x, valuable.y, valuable.z, block, blockMeta);
|
||||||
if (stacks != null)
|
if (stacks != null)
|
||||||
{
|
{
|
||||||
for (ItemStack stack : stacks)
|
for (ItemStack stack : stacks)
|
||||||
|
@ -239,10 +233,11 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser
|
||||||
mineBlock(valuable, block, blockMeta);
|
mineBlock(valuable, block, blockMeta);
|
||||||
return didPlace;
|
return didPlace;
|
||||||
}
|
}
|
||||||
else if (block.isAssociatedBlock(Blocks.water))
|
else if (block.isAssociatedBlock(Blocks.water)) {
|
||||||
// Evaporate water
|
// Evaporate water
|
||||||
worldObj.playSoundEffect(valuable.intX() + 0.5D, valuable.intY() + 0.5D, valuable.intZ() + 0.5D, "random.fizz", 0.5F, 2.6F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.8F);
|
worldObj.playSoundEffect(valuable.x + 0.5D, valuable.y + 0.5D, valuable.z + 0.5D, "random.fizz", 0.5F, 2.6F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.8F);
|
||||||
worldObj.setBlockToAir(valuable.intX(), valuable.intY(), valuable.intZ());
|
}
|
||||||
|
worldObj.setBlockToAir(valuable.x, valuable.y, valuable.z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,11 +351,6 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser
|
||||||
super.readFromNBT(tag);
|
super.readFromNBT(tag);
|
||||||
silkTouch = tag.getBoolean("silkTouch");
|
silkTouch = tag.getBoolean("silkTouch");
|
||||||
fortuneLevel = tag.getInteger("fortuneLevel");
|
fortuneLevel = tag.getInteger("fortuneLevel");
|
||||||
|
|
||||||
minerVector.x = xCoord;
|
|
||||||
minerVector.y = yCoord - (laserBelow());
|
|
||||||
minerVector.z = zCoord;
|
|
||||||
minerVector = minerVector.translate(0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,14 +5,15 @@ import java.util.LinkedList;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import cr0s.warpdrive.WarpDrive;
|
import cr0s.warpdrive.WarpDrive;
|
||||||
import cr0s.warpdrive.conf.WarpDriveConfig;
|
import cr0s.warpdrive.conf.WarpDriveConfig;
|
||||||
import cr0s.warpdrive.data.Vector3;
|
import cr0s.warpdrive.data.VectorI;
|
||||||
import dan200.computercraft.api.lua.ILuaContext;
|
import dan200.computercraft.api.lua.ILuaContext;
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
|
|
||||||
public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
Boolean active = false;
|
private boolean active = false;
|
||||||
|
|
||||||
private int mode = 0;
|
private int mode = 0;
|
||||||
private boolean doLeaves = false;
|
private boolean doLeaves = false;
|
||||||
|
@ -30,11 +31,12 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
private int radiusX = radiusDefault;
|
private int radiusX = radiusDefault;
|
||||||
private int radiusZ = radiusDefault;
|
private int radiusZ = radiusDefault;
|
||||||
|
|
||||||
LinkedList<Vector3> logs;
|
LinkedList<VectorI> logs;
|
||||||
private int logIndex = 0;
|
private int logIndex = 0;
|
||||||
|
|
||||||
public TileEntityLaserTreeFarm() {
|
public TileEntityLaserTreeFarm() {
|
||||||
super();
|
super();
|
||||||
|
laserOutputSide = ForgeDirection.UP;
|
||||||
IC2_sinkTier = 2;
|
IC2_sinkTier = 2;
|
||||||
IC2_sourceTier = 2;
|
IC2_sourceTier = 2;
|
||||||
peripheralName = "warpdriveLaserTreefarm";
|
peripheralName = "warpdriveLaserTreefarm";
|
||||||
|
@ -72,8 +74,8 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
mode = 0;
|
mode = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Vector3 pos = logs.get(logIndex);
|
VectorI pos = logs.get(logIndex);
|
||||||
Block block = worldObj.getBlock(pos.intX(), pos.intY(), pos.intZ());
|
Block block = worldObj.getBlock(pos.x, pos.y, pos.z);
|
||||||
|
|
||||||
if (mode == 1) {
|
if (mode == 1) {
|
||||||
int cost = calculateBlockCost(block);
|
int cost = calculateBlockCost(block);
|
||||||
|
@ -101,7 +103,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
if (consumeEnergyFromBooster(cost, true)) {
|
if (consumeEnergyFromBooster(cost, true)) {
|
||||||
if (isRoomForHarvest()) {
|
if (isRoomForHarvest()) {
|
||||||
if (block.isAssociatedBlock(Block.getBlockFromItem(WarpDriveConfig.IC2_rubberWood.getItem()))) {
|
if (block.isAssociatedBlock(Block.getBlockFromItem(WarpDriveConfig.IC2_rubberWood.getItem()))) {
|
||||||
int metadata = worldObj.getBlockMetadata(pos.intX(), pos.intY(), pos.intZ());
|
int metadata = worldObj.getBlockMetadata(pos.x, pos.y, pos.z);
|
||||||
if (metadata >= 2 && metadata <= 5) {
|
if (metadata >= 2 && metadata <= 5) {
|
||||||
if (WarpDriveConfig.LOGGING_COLLECTION) {
|
if (WarpDriveConfig.LOGGING_COLLECTION) {
|
||||||
WarpDrive.logger.info("wetspot found");
|
WarpDrive.logger.info("wetspot found");
|
||||||
|
@ -110,7 +112,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
ItemStack resin = WarpDriveConfig.IC2_Resin.copy();
|
ItemStack resin = WarpDriveConfig.IC2_Resin.copy();
|
||||||
resin.stackSize = (int) Math.round(Math.random() * 4);
|
resin.stackSize = (int) Math.round(Math.random() * 4);
|
||||||
dumpToInv(resin);
|
dumpToInv(resin);
|
||||||
worldObj.setBlockMetadataWithNotify(pos.intX(), pos.intY(), pos.intZ(), metadata+6, 3);
|
worldObj.setBlockMetadataWithNotify(pos.x, pos.y, pos.z, metadata + 6, 3);
|
||||||
laserBlock(pos);
|
laserBlock(pos);
|
||||||
totalHarvested++;
|
totalHarvested++;
|
||||||
delayMul = 4;
|
delayMul = 4;
|
||||||
|
@ -155,33 +157,28 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
return WarpDriveConfig.minerLeaves.contains(block);
|
return WarpDriveConfig.minerLeaves.contains(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addTree(LinkedList<Vector3> list, Vector3 newTree) {
|
private static void addTree(LinkedList<VectorI> list, VectorI newTree) {
|
||||||
if (WarpDriveConfig.LOGGING_COLLECTION) {
|
if (WarpDriveConfig.LOGGING_COLLECTION) {
|
||||||
WarpDrive.logger.info("Adding tree position:" + newTree.x + "," + newTree.y + "," + newTree.z);
|
WarpDrive.logger.info("Adding tree position:" + newTree.x + "," + newTree.y + "," + newTree.z);
|
||||||
}
|
}
|
||||||
list.add(newTree);
|
list.add(newTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinkedList<Vector3> scanTrees() {
|
private LinkedList<VectorI> scanTrees() {
|
||||||
int xmax, zmax, x1, x2, z1, z2;
|
int xmax, zmax;
|
||||||
int xmin, zmin;
|
int xmin, zmin;
|
||||||
x1 = xCoord + radiusX;
|
xmax = xCoord + radiusX;
|
||||||
x2 = xCoord - radiusX;
|
xmin = xCoord - radiusX;
|
||||||
xmin = Math.min(x1, x2);
|
zmax = zCoord + radiusZ;
|
||||||
xmax = Math.max(x1, x2);
|
zmin = zCoord - radiusZ;
|
||||||
|
|
||||||
z1 = zCoord + radiusZ;
|
LinkedList<VectorI> logPositions = new LinkedList<VectorI>();
|
||||||
z2 = zCoord - radiusZ;
|
|
||||||
zmin = Math.min(z1, z2);
|
|
||||||
zmax = Math.max(z1, z2);
|
|
||||||
|
|
||||||
LinkedList<Vector3> logPositions = new LinkedList<Vector3>();
|
|
||||||
|
|
||||||
for(int x = xmin; x <= xmax; x++) {
|
for(int x = xmin; x <= xmax; x++) {
|
||||||
for(int z = zmin; z <= zmax; z++) {
|
for(int z = zmin; z <= zmax; z++) {
|
||||||
Block block = worldObj.getBlock(x, yCoord, z);
|
Block block = worldObj.getBlock(x, yCoord, z);
|
||||||
if (isLog(block)) {
|
if (isLog(block)) {
|
||||||
Vector3 pos = new Vector3(x, yCoord, z);
|
VectorI pos = new VectorI(x, yCoord, z);
|
||||||
logPositions.add(pos);
|
logPositions.add(pos);
|
||||||
scanNearby(logPositions, x, yCoord, z, 0);
|
scanNearby(logPositions, x, yCoord, z, 0);
|
||||||
}
|
}
|
||||||
|
@ -190,14 +187,14 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
return logPositions;
|
return logPositions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanNearby(LinkedList<Vector3> current, int x, int y, int z, int d) {
|
private void scanNearby(LinkedList<VectorI> current, int x, int y, int z, int d) {
|
||||||
int[] deltas = {0, -1, 1};
|
int[] deltas = {0, -1, 1};
|
||||||
for(int dx : deltas) {
|
for(int dx : deltas) {
|
||||||
for(int dy = 1; dy >= 0; dy--) {
|
for(int dy = 1; dy >= 0; dy--) {
|
||||||
for(int dz : deltas) {
|
for(int dz : deltas) {
|
||||||
Block block = worldObj.getBlock(x + dx, y + dy, z + dz);
|
Block block = worldObj.getBlock(x + dx, y + dy, z + dz);
|
||||||
if (isLog(block) || (doLeaves && isLeaf(block))) {
|
if (isLog(block) || (doLeaves && isLeaf(block))) {
|
||||||
Vector3 pos = new Vector3(x + dx, y + dy, z + dz);
|
VectorI pos = new VectorI(x + dx, y + dy, z + dz);
|
||||||
if (!current.contains(pos)) {
|
if (!current.contains(pos)) {
|
||||||
addTree(current, pos);
|
addTree(current, pos);
|
||||||
if (d < 35) {
|
if (d < 35) {
|
||||||
|
@ -343,11 +340,6 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected double laserBelow() {
|
|
||||||
return -0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getColorR() {
|
protected float getColorR() {
|
||||||
return 0.2f;
|
return 0.2f;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import cr0s.warpdrive.block.TileEntityAbstractInterfaced;
|
||||||
import cr0s.warpdrive.block.TileEntityLaserMedium;
|
import cr0s.warpdrive.block.TileEntityLaserMedium;
|
||||||
import cr0s.warpdrive.conf.WarpDriveConfig;
|
import cr0s.warpdrive.conf.WarpDriveConfig;
|
||||||
import cr0s.warpdrive.data.Vector3;
|
import cr0s.warpdrive.data.Vector3;
|
||||||
|
import cr0s.warpdrive.data.VectorI;
|
||||||
import cr0s.warpdrive.network.PacketHandler;
|
import cr0s.warpdrive.network.PacketHandler;
|
||||||
import dan200.computercraft.api.lua.ILuaContext;
|
import dan200.computercraft.api.lua.ILuaContext;
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
|
@ -49,7 +50,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
private boolean enoughPower = false;
|
private boolean enoughPower = false;
|
||||||
private int currentLayer;
|
private int currentLayer;
|
||||||
|
|
||||||
private ArrayList<Vector3> valuablesInLayer = new ArrayList<Vector3>();
|
private ArrayList<VectorI> valuablesInLayer = new ArrayList<VectorI>();
|
||||||
private int valuableIndex = 0;
|
private int valuableIndex = 0;
|
||||||
|
|
||||||
private int layerOffset = 1;
|
private int layerOffset = 1;
|
||||||
|
@ -79,7 +80,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
|
|
||||||
boolean isOnEarth = (worldObj.provider.dimensionId == 0);
|
boolean isOnEarth = (worldObj.provider.dimensionId == 0);
|
||||||
|
|
||||||
Vector3 minerVector = new Vector3(xCoord + 0.5D, yCoord, zCoord + 0.5D);
|
Vector3 laserOutput = new Vector3(xCoord + 0.5D, yCoord, zCoord + 0.5D);
|
||||||
|
|
||||||
if (currentState == STATE_WARMUP) { // warming up
|
if (currentState == STATE_WARMUP) { // warming up
|
||||||
delayTicksWarmup++;
|
delayTicksWarmup++;
|
||||||
|
@ -104,10 +105,10 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
}
|
}
|
||||||
// show current layer
|
// show current layer
|
||||||
int age = Math.max(40, 5 * WarpDriveConfig.MINING_LASER_SCAN_DELAY_TICKS);
|
int age = Math.max(40, 5 * WarpDriveConfig.MINING_LASER_SCAN_DELAY_TICKS);
|
||||||
double xmax = xCoord + WarpDriveConfig.MINING_LASER_MAX_RADIUS + 1.0D;
|
double xmax = xCoord + WarpDriveConfig.MINING_LASER_RADIUS_BLOCKS + 1.0D;
|
||||||
double xmin = xCoord - WarpDriveConfig.MINING_LASER_MAX_RADIUS + 0.0D;
|
double xmin = xCoord - WarpDriveConfig.MINING_LASER_RADIUS_BLOCKS + 0.0D;
|
||||||
double zmax = zCoord + WarpDriveConfig.MINING_LASER_MAX_RADIUS + 1.0D;
|
double zmax = zCoord + WarpDriveConfig.MINING_LASER_RADIUS_BLOCKS + 1.0D;
|
||||||
double zmin = zCoord - WarpDriveConfig.MINING_LASER_MAX_RADIUS + 0.0D;
|
double zmin = zCoord - WarpDriveConfig.MINING_LASER_RADIUS_BLOCKS + 0.0D;
|
||||||
double y = currentLayer + 1.0D;
|
double y = currentLayer + 1.0D;
|
||||||
PacketHandler.sendBeamPacket(worldObj, new Vector3(xmin, y, zmin), new Vector3(xmax, y, zmin), 0.3F, 0.0F, 1.0F, age, 0, 50);
|
PacketHandler.sendBeamPacket(worldObj, new Vector3(xmin, y, zmin), new Vector3(xmax, y, zmin), 0.3F, 0.0F, 1.0F, age, 0, 50);
|
||||||
PacketHandler.sendBeamPacket(worldObj, new Vector3(xmax, y, zmin), new Vector3(xmax, y, zmax), 0.3F, 0.0F, 1.0F, age, 0, 50);
|
PacketHandler.sendBeamPacket(worldObj, new Vector3(xmax, y, zmin), new Vector3(xmax, y, zmax), 0.3F, 0.0F, 1.0F, age, 0, 50);
|
||||||
|
@ -130,17 +131,17 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
// scan
|
// scan
|
||||||
scanLayer();
|
scanLayer();
|
||||||
if (valuablesInLayer.size() > 0) {
|
if (valuablesInLayer.size() > 0) {
|
||||||
int r = (int) Math.ceil(WarpDriveConfig.MINING_LASER_MAX_RADIUS / 2.0D);
|
int r = (int) Math.ceil(WarpDriveConfig.MINING_LASER_RADIUS_BLOCKS / 2.0D);
|
||||||
int offset = (yCoord - currentLayer) % (2 * r);
|
int offset = (yCoord - currentLayer) % (2 * r);
|
||||||
int age = Math.max(20, Math.round(2.5F * WarpDriveConfig.MINING_LASER_SCAN_DELAY_TICKS));
|
int age = Math.max(20, Math.round(2.5F * WarpDriveConfig.MINING_LASER_SCAN_DELAY_TICKS));
|
||||||
double y = currentLayer + 1.0D;
|
double y = currentLayer + 1.0D;
|
||||||
PacketHandler.sendBeamPacket(worldObj, minerVector, new Vector3(xCoord - r + offset, y, zCoord + r).translate(0.3D),
|
PacketHandler.sendBeamPacket(worldObj, laserOutput, new Vector3(xCoord - r + offset, y, zCoord + r).translate(0.3D),
|
||||||
0.0F, 0.0F, 1.0F, age, 0, 50);
|
0.0F, 0.0F, 1.0F, age, 0, 50);
|
||||||
PacketHandler.sendBeamPacket(worldObj, minerVector, new Vector3(xCoord + r, y, zCoord + r - offset).translate(0.3D),
|
PacketHandler.sendBeamPacket(worldObj, laserOutput, new Vector3(xCoord + r, y, zCoord + r - offset).translate(0.3D),
|
||||||
0.0F, 0.0F, 1.0F, age, 0, 50);
|
0.0F, 0.0F, 1.0F, age, 0, 50);
|
||||||
PacketHandler.sendBeamPacket(worldObj, minerVector, new Vector3(xCoord + r - offset, y, zCoord - r).translate(0.3D),
|
PacketHandler.sendBeamPacket(worldObj, laserOutput, new Vector3(xCoord + r - offset, y, zCoord - r).translate(0.3D),
|
||||||
0.0F, 0.0F, 1.0F, age, 0, 50);
|
0.0F, 0.0F, 1.0F, age, 0, 50);
|
||||||
PacketHandler.sendBeamPacket(worldObj, minerVector, new Vector3(xCoord - r, y, zCoord - r + offset).translate(0.3D),
|
PacketHandler.sendBeamPacket(worldObj, laserOutput, new Vector3(xCoord - r, y, zCoord - r + offset).translate(0.3D),
|
||||||
0.0F, 0.0F, 1.0F, age, 0, 50);
|
0.0F, 0.0F, 1.0F, age, 0, 50);
|
||||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
|
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
|
||||||
delayTicksMine = 0;
|
delayTicksMine = 0;
|
||||||
|
@ -178,19 +179,18 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
updateMetadata(BlockMiningLaser.ICON_MININGPOWERED);
|
updateMetadata(BlockMiningLaser.ICON_MININGPOWERED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("[ML] Mining: " + (valuableIndex + 1) +
|
// System.out.println("[ML] Mining: " + (valuableIndex + 1) + "/" + valuablesInLayer.size());
|
||||||
// "/" + valuablesInLayer.size());
|
VectorI valuable = valuablesInLayer.get(valuableIndex);
|
||||||
Vector3 valuable = valuablesInLayer.get(valuableIndex);
|
|
||||||
valuableIndex++;
|
valuableIndex++;
|
||||||
// Mine valuable ore
|
// Mine valuable ore
|
||||||
Block block = worldObj.getBlock(valuable.intX(), valuable.intY(), valuable.intZ());
|
Block block = worldObj.getBlock(valuable.x, valuable.y, valuable.z);
|
||||||
// Skip if block is too hard or its empty block (check again in
|
// Skip if block is too hard or its empty block (check again in
|
||||||
// case it changed)
|
// case it changed)
|
||||||
if (!canDig(block, valuable.intX(), valuable.intY(), valuable.intZ())) {
|
if (!canDig(block, valuable.x, valuable.y, valuable.z)) {
|
||||||
delayTicksMine = Math.round(WarpDriveConfig.MINING_LASER_MINE_DELAY_TICKS * 0.8F);
|
delayTicksMine = Math.round(WarpDriveConfig.MINING_LASER_MINE_DELAY_TICKS * 0.8F);
|
||||||
}
|
}
|
||||||
int age = Math.max(10, Math.round((4 + worldObj.rand.nextFloat()) * WarpDriveConfig.MINING_LASER_MINE_DELAY_TICKS));
|
int age = Math.max(10, Math.round((4 + worldObj.rand.nextFloat()) * WarpDriveConfig.MINING_LASER_MINE_DELAY_TICKS));
|
||||||
PacketHandler.sendBeamPacket(worldObj, minerVector, new Vector3(valuable.intX(), valuable.intY(), valuable.intZ()).translate(0.5D), 1.0F, 1.0F,
|
PacketHandler.sendBeamPacket(worldObj, laserOutput, new Vector3(valuable.x, valuable.y, valuable.z).translate(0.5D), 1.0F, 1.0F,
|
||||||
0.0F, age, 0, 50);
|
0.0F, age, 0, 50);
|
||||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);
|
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);
|
||||||
harvestBlock(valuable);
|
harvestBlock(valuable);
|
||||||
|
@ -240,15 +240,15 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void harvestBlock(Vector3 valuable) {
|
private void harvestBlock(VectorI valuable) {
|
||||||
Block block = worldObj.getBlock(valuable.intX(), valuable.intY(), valuable.intZ());
|
Block block = worldObj.getBlock(valuable.x, valuable.y, valuable.z);
|
||||||
int blockMeta = worldObj.getBlockMetadata(valuable.intX(), valuable.intY(), valuable.intZ());
|
int blockMeta = worldObj.getBlockMetadata(valuable.x, valuable.y, valuable.z);
|
||||||
if (block != null && (block instanceof BlockLiquid)) {
|
if (block != null && (block instanceof BlockLiquid)) {
|
||||||
// Evaporate fluid
|
// Evaporate fluid
|
||||||
worldObj.playSoundEffect(valuable.intX() + 0.5D, valuable.intY() + 0.5D, valuable.intZ() + 0.5D, "random.fizz", 0.5F,
|
worldObj.playSoundEffect(valuable.x + 0.5D, valuable.y + 0.5D, valuable.z + 0.5D, "random.fizz", 0.5F,
|
||||||
2.6F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.8F);
|
2.6F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.8F);
|
||||||
} else {
|
} else {
|
||||||
List<ItemStack> stacks = getItemStackFromBlock(valuable.intX(), valuable.intY(), valuable.intZ(), block, blockMeta);
|
List<ItemStack> stacks = getItemStackFromBlock(valuable.x, valuable.y, valuable.z, block, blockMeta);
|
||||||
if (stacks != null) {
|
if (stacks != null) {
|
||||||
boolean overflow = false;
|
boolean overflow = false;
|
||||||
int qtyLeft = 0;
|
int qtyLeft = 0;
|
||||||
|
@ -274,9 +274,9 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// standard harvest block effect
|
// standard harvest block effect
|
||||||
worldObj.playAuxSFXAtEntity(null, 2001, valuable.intX(), valuable.intY(), valuable.intZ(), Block.getIdFromBlock(block) + (blockMeta << 12));
|
worldObj.playAuxSFXAtEntity(null, 2001, valuable.x, valuable.y, valuable.z, Block.getIdFromBlock(block) + (blockMeta << 12));
|
||||||
}
|
}
|
||||||
worldObj.setBlockToAir(valuable.intX(), valuable.intY(), valuable.intZ());
|
worldObj.setBlockToAir(valuable.x, valuable.y, valuable.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IInventory findChest() {
|
private IInventory findChest() {
|
||||||
|
@ -416,10 +416,10 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
block = worldObj.getBlock(x, currentLayer, z);
|
block = worldObj.getBlock(x, currentLayer, z);
|
||||||
if (canDig(block, x, currentLayer, z)) {
|
if (canDig(block, x, currentLayer, z)) {
|
||||||
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
||||||
valuablesInLayer.add(new Vector3(x, currentLayer, z));
|
valuablesInLayer.add(new VectorI(x, currentLayer, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (radius = 1; radius <= WarpDriveConfig.MINING_LASER_MAX_RADIUS; radius++) {
|
for (radius = 1; radius <= WarpDriveConfig.MINING_LASER_RADIUS_BLOCKS; radius++) {
|
||||||
xmax = xCoord + radius;
|
xmax = xCoord + radius;
|
||||||
xmin = xCoord - radius;
|
xmin = xCoord - radius;
|
||||||
zmax = zCoord + radius;
|
zmax = zCoord + radius;
|
||||||
|
@ -430,7 +430,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
block = worldObj.getBlock(x, currentLayer, z);
|
block = worldObj.getBlock(x, currentLayer, z);
|
||||||
if (canDig(block, x, currentLayer, z)) {
|
if (canDig(block, x, currentLayer, z)) {
|
||||||
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
||||||
valuablesInLayer.add(new Vector3(x, currentLayer, z));
|
valuablesInLayer.add(new VectorI(x, currentLayer, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
block = worldObj.getBlock(x, currentLayer, z);
|
block = worldObj.getBlock(x, currentLayer, z);
|
||||||
if (canDig(block, x, currentLayer, z)) {
|
if (canDig(block, x, currentLayer, z)) {
|
||||||
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
||||||
valuablesInLayer.add(new Vector3(x, currentLayer, z));
|
valuablesInLayer.add(new VectorI(x, currentLayer, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,7 +450,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
block = worldObj.getBlock(x, currentLayer, z);
|
block = worldObj.getBlock(x, currentLayer, z);
|
||||||
if (canDig(block, x, currentLayer, z)) {
|
if (canDig(block, x, currentLayer, z)) {
|
||||||
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
||||||
valuablesInLayer.add(new Vector3(x, currentLayer, z));
|
valuablesInLayer.add(new VectorI(x, currentLayer, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,7 +460,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
block = worldObj.getBlock(x, currentLayer, z);
|
block = worldObj.getBlock(x, currentLayer, z);
|
||||||
if (canDig(block, x, currentLayer, z)) {
|
if (canDig(block, x, currentLayer, z)) {
|
||||||
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
||||||
valuablesInLayer.add(new Vector3(x, currentLayer, z));
|
valuablesInLayer.add(new VectorI(x, currentLayer, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced {
|
||||||
block = worldObj.getBlock(x, currentLayer, z);
|
block = worldObj.getBlock(x, currentLayer, z);
|
||||||
if (canDig(block, x, currentLayer, z)) {
|
if (canDig(block, x, currentLayer, z)) {
|
||||||
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks
|
||||||
valuablesInLayer.add(new Vector3(x, currentLayer, z));
|
valuablesInLayer.add(new VectorI(x, currentLayer, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package cr0s.warpdrive.block.energy;
|
package cr0s.warpdrive.block.energy;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import cr0s.warpdrive.WarpDrive;
|
import cr0s.warpdrive.WarpDrive;
|
||||||
|
@ -31,4 +33,24 @@ public class BlockIC2reactorLaserMonitor extends BlockContainer {
|
||||||
public TileEntity createNewTileEntity(World var1, int i) {
|
public TileEntity createNewTileEntity(World var1, int i) {
|
||||||
return new TileEntityIC2reactorLaserMonitor();
|
return new TileEntityIC2reactorLaserMonitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called upon block activation (right click on the block.)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
|
||||||
|
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entityPlayer.getHeldItem() == null) {
|
||||||
|
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
|
||||||
|
if (tileEntity != null && tileEntity instanceof TileEntityIC2reactorLaserMonitor) {
|
||||||
|
WarpDrive.addChatMessage(entityPlayer, ((TileEntityIC2reactorLaserMonitor) tileEntity).getStatus());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,38 +269,15 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
}
|
}
|
||||||
return exploding;
|
return exploding;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes the arguments passed by function call and returns an appropriate string
|
|
||||||
private static String helpStr(Object[] args) {
|
|
||||||
if (args.length > 0) {
|
|
||||||
String arg = args[0].toString().toLowerCase();
|
|
||||||
if (arg.equals("getactive")) {
|
|
||||||
return "getActive(): returns true if the reactor is active and false otherwise";
|
|
||||||
} else if (arg.equals("setactive")) {
|
|
||||||
return "setActive(bool): activates the reactor if passed true and deactivates if passed false";
|
|
||||||
} else if (arg.equals("energy")) {
|
|
||||||
return WarpDrive.defEnergyStr;
|
|
||||||
} else if (arg.equals("instability")) {
|
|
||||||
return "instability(): returns the 4 instability values (100 is the point when the reactor explodes)";
|
|
||||||
} else if (arg.equals("release")) {
|
|
||||||
return "release(bool): sets the reactor to output all energy or disables outputting of energy";
|
|
||||||
} else if (arg.equals("releaserate")) {
|
|
||||||
return "releaseRate(int): sets the reactor to try to release exactly int/tick";
|
|
||||||
} else if (arg.equals("releaseabove")) {
|
|
||||||
return "releaseAbove(int): releases all energy above stored int";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return WarpDrive.defHelpStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatedNeighbours() {
|
public void updatedNeighbours() {
|
||||||
TileEntity te;
|
TileEntity te;
|
||||||
super.updatedNeighbours();
|
super.updatedNeighbours();
|
||||||
|
|
||||||
int[] xo = { 0, 0, -2, 2 };
|
int[] xo = { 0, 0, -2, 2 };
|
||||||
int[] zo = { 2, -2, 0, 0 };
|
int[] zo = { 2, -2, 0, 0 };
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
te = worldObj.getTileEntity(xCoord + xo[i], yCoord, zCoord + zo[i]);
|
te = worldObj.getTileEntity(xCoord + xo[i], yCoord, zCoord + zo[i]);
|
||||||
if (te instanceof TileEntityEnanReactorLaser) {
|
if (te instanceof TileEntityEnanReactorLaser) {
|
||||||
|
@ -308,10 +285,10 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenComputer callback methods
|
// OpenComputer callback methods
|
||||||
// FIXME: implement OpenComputers...
|
// FIXME: implement OpenComputers...
|
||||||
|
|
||||||
public Object[] active(Object[] arguments) throws Exception {
|
public Object[] active(Object[] arguments) throws Exception {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
boolean activate = false;
|
boolean activate = false;
|
||||||
|
@ -335,7 +312,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
return new Object[] { active, MODE_STRING[releaseMode], releaseRate };
|
return new Object[] { active, MODE_STRING[releaseMode], releaseRate };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] release(Object[] arguments) throws Exception {
|
private Object[] release(Object[] arguments) throws Exception {
|
||||||
boolean doRelease = false;
|
boolean doRelease = false;
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
|
@ -344,14 +321,14 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new Exception("Function expects an boolean value");
|
throw new Exception("Function expects an boolean value");
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseMode = doRelease ? MODE_MANUAL_RELEASE : MODE_DONT_RELEASE;
|
releaseMode = doRelease ? MODE_MANUAL_RELEASE : MODE_DONT_RELEASE;
|
||||||
releaseAbove = 0;
|
releaseAbove = 0;
|
||||||
releaseRate = 0;
|
releaseRate = 0;
|
||||||
}
|
}
|
||||||
return new Object[] { releaseMode != MODE_DONT_RELEASE };
|
return new Object[] { releaseMode != MODE_DONT_RELEASE };
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] releaseRate(Object[] arguments) throws Exception {
|
private Object[] releaseRate(Object[] arguments) throws Exception {
|
||||||
int rate = -1;
|
int rate = -1;
|
||||||
try {
|
try {
|
||||||
|
@ -359,7 +336,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new Exception("Function expects an integer value");
|
throw new Exception("Function expects an integer value");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rate <= 0) {
|
if (rate <= 0) {
|
||||||
releaseMode = MODE_DONT_RELEASE;
|
releaseMode = MODE_DONT_RELEASE;
|
||||||
releaseRate = 0;
|
releaseRate = 0;
|
||||||
|
@ -368,10 +345,10 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
releaseRate = rate;
|
releaseRate = rate;
|
||||||
releaseMode = MODE_RELEASE_AT_RATE;
|
releaseMode = MODE_RELEASE_AT_RATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Object[] { MODE_STRING[releaseMode], releaseRate };
|
return new Object[] { MODE_STRING[releaseMode], releaseRate };
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] releaseAbove(Object[] arguments) throws Exception {
|
private Object[] releaseAbove(Object[] arguments) throws Exception {
|
||||||
int above = -1;
|
int above = -1;
|
||||||
try {
|
try {
|
||||||
|
@ -379,7 +356,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new Exception("Function expects an integer value");
|
throw new Exception("Function expects an integer value");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (above <= 0) {
|
if (above <= 0) {
|
||||||
releaseMode = 0;
|
releaseMode = 0;
|
||||||
releaseAbove = MODE_DONT_RELEASE;
|
releaseAbove = MODE_DONT_RELEASE;
|
||||||
|
@ -387,51 +364,48 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
releaseMode = MODE_RELEASE_ABOVE;
|
releaseMode = MODE_RELEASE_ABOVE;
|
||||||
releaseAbove = above;
|
releaseAbove = above;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Object[] { MODE_STRING[releaseMode], releaseAbove };
|
return new Object[] { MODE_STRING[releaseMode], releaseAbove };
|
||||||
}
|
}
|
||||||
|
|
||||||
// ComputerCraft IPeripheral methods implementation
|
// ComputerCraft IPeripheral methods implementation
|
||||||
@Override
|
@Override
|
||||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) {
|
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) {
|
||||||
// computer is alive => start updating reactor
|
// computer is alive => start updating reactor
|
||||||
hold = false;
|
hold = false;
|
||||||
|
|
||||||
String methodName = methodsArray[method];
|
String methodName = methodsArray[method];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (methodName.equals("active")) {
|
if (methodName.equals("active")) {
|
||||||
return active(arguments);
|
return active(arguments);
|
||||||
|
|
||||||
} else if (methodName.equals("energy")) {
|
} else if (methodName.equals("energy")) {
|
||||||
return new Object[] { containedEnergy, WarpDriveConfig.ENAN_REACTOR_MAX_ENERGY_STORED, releasedLastCycle / WarpDriveConfig.ENAN_REACTOR_UPDATE_INTERVAL_TICKS };
|
return new Object[] { containedEnergy, WarpDriveConfig.ENAN_REACTOR_MAX_ENERGY_STORED, releasedLastCycle / WarpDriveConfig.ENAN_REACTOR_UPDATE_INTERVAL_TICKS };
|
||||||
|
|
||||||
} else if (methodName.equals("instability")) {
|
} else if (methodName.equals("instability")) {
|
||||||
Object[] retVal = new Object[4];
|
Object[] retVal = new Object[4];
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
retVal[i] = instabilityValues[i];
|
retVal[i] = instabilityValues[i];
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
||||||
} else if (methodName.equals("release")) {
|
} else if (methodName.equals("release")) {
|
||||||
return release(arguments);
|
return release(arguments);
|
||||||
|
|
||||||
} else if (methodName.equals("releaseRate")) {
|
} else if (methodName.equals("releaseRate")) {
|
||||||
return releaseRate(arguments);
|
return releaseRate(arguments);
|
||||||
|
|
||||||
} else if (methodName.equals("releaseAbove")) {
|
} else if (methodName.equals("releaseAbove")) {
|
||||||
return releaseAbove(arguments);
|
return releaseAbove(arguments);
|
||||||
|
|
||||||
} else if (methodName.equals("help")) {
|
|
||||||
return new Object[] { helpStr(arguments) };
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return new String[] { e.getMessage() };
|
return new String[] { e.getMessage() };
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// POWER INTERFACES
|
// POWER INTERFACES
|
||||||
@Override
|
@Override
|
||||||
public int getPotentialEnergyOutput() {
|
public int getPotentialEnergyOutput() {
|
||||||
|
@ -459,7 +433,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
||||||
}
|
}
|
||||||
return convertRFtoInternal(result);
|
return convertRFtoInternal(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canOutputEnergy(ForgeDirection from) {
|
public boolean canOutputEnergy(ForgeDirection from) {
|
||||||
if (from.equals(ForgeDirection.UP) || from.equals(ForgeDirection.DOWN)) {
|
if (from.equals(ForgeDirection.UP) || from.equals(ForgeDirection.DOWN)) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import cr0s.warpdrive.WarpDrive;
|
||||||
import cr0s.warpdrive.api.IBlockUpdateDetector;
|
import cr0s.warpdrive.api.IBlockUpdateDetector;
|
||||||
import cr0s.warpdrive.block.TileEntityAbstractLaser;
|
import cr0s.warpdrive.block.TileEntityAbstractLaser;
|
||||||
import cr0s.warpdrive.block.TileEntityLaserMedium;
|
import cr0s.warpdrive.block.TileEntityLaserMedium;
|
||||||
|
import cr0s.warpdrive.conf.WarpDriveConfig;
|
||||||
import cr0s.warpdrive.data.Vector3;
|
import cr0s.warpdrive.data.Vector3;
|
||||||
import cr0s.warpdrive.network.PacketHandler;
|
import cr0s.warpdrive.network.PacketHandler;
|
||||||
import dan200.computercraft.api.lua.ILuaContext;
|
import dan200.computercraft.api.lua.ILuaContext;
|
||||||
|
@ -19,55 +20,54 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser implemen
|
||||||
ForgeDirection side = ForgeDirection.UNKNOWN;
|
ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||||
TileEntityLaserMedium booster;
|
TileEntityLaserMedium booster;
|
||||||
TileEntityEnanReactorCore reactor;
|
TileEntityEnanReactorCore reactor;
|
||||||
|
|
||||||
boolean useLaser = false;
|
private boolean isFirstUpdate = true;
|
||||||
boolean doOnce = false;
|
|
||||||
|
|
||||||
public TileEntityEnanReactorLaser() {
|
public TileEntityEnanReactorLaser() {
|
||||||
methodsArray = new String[] { "energy", "hasReactor", "side", "sendLaser", "help" };
|
methodsArray = new String[] { "energy", "hasReactor", "side", "sendLaser" };
|
||||||
peripheralName = "warpdriveEnanReactorLaser";
|
peripheralName = "warpdriveEnanReactorLaser";
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntityEnanReactorCore scanForReactor() {
|
public TileEntityEnanReactorCore scanForReactor() {
|
||||||
reactor = null;
|
reactor = null;
|
||||||
TileEntity te;
|
TileEntity tileEntity;
|
||||||
// I AM ON THE NORTH SIDE
|
// I AM ON THE NORTH SIDE
|
||||||
side = ForgeDirection.UNKNOWN;
|
side = ForgeDirection.UNKNOWN;
|
||||||
te = worldObj.getTileEntity(xCoord, yCoord, zCoord + 2);
|
tileEntity = worldObj.getTileEntity(xCoord, yCoord, zCoord + 2);
|
||||||
if (te instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord, yCoord, zCoord + 1)) {
|
if (tileEntity instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord, yCoord, zCoord + 1)) {
|
||||||
side = ForgeDirection.NORTH;
|
side = ForgeDirection.NORTH;
|
||||||
reactor = (TileEntityEnanReactorCore) te;
|
reactor = (TileEntityEnanReactorCore) tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I AM ON THE SOUTH SIDE
|
// I AM ON THE SOUTH SIDE
|
||||||
te = worldObj.getTileEntity(xCoord, yCoord, zCoord - 2);
|
tileEntity = worldObj.getTileEntity(xCoord, yCoord, zCoord - 2);
|
||||||
if (te instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord, yCoord, zCoord - 1)) {
|
if (tileEntity instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord, yCoord, zCoord - 1)) {
|
||||||
side = ForgeDirection.SOUTH;
|
side = ForgeDirection.SOUTH;
|
||||||
reactor = (TileEntityEnanReactorCore) te;
|
reactor = (TileEntityEnanReactorCore) tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I AM ON THE WEST SIDE
|
// I AM ON THE WEST SIDE
|
||||||
te = worldObj.getTileEntity(xCoord + 2, yCoord, zCoord);
|
tileEntity = worldObj.getTileEntity(xCoord + 2, yCoord, zCoord);
|
||||||
if (te instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord + 1, yCoord, zCoord)) {
|
if (tileEntity instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord + 1, yCoord, zCoord)) {
|
||||||
side = ForgeDirection.WEST;
|
side = ForgeDirection.WEST;
|
||||||
reactor = (TileEntityEnanReactorCore) te;
|
reactor = (TileEntityEnanReactorCore) tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I AM ON THE EAST SIDE
|
// I AM ON THE EAST SIDE
|
||||||
te = worldObj.getTileEntity(xCoord - 2, yCoord, zCoord);
|
tileEntity = worldObj.getTileEntity(xCoord - 2, yCoord, zCoord);
|
||||||
if (te instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord - 1, yCoord, zCoord)) {
|
if (tileEntity instanceof TileEntityEnanReactorCore && worldObj.isAirBlock(xCoord - 1, yCoord, zCoord)) {
|
||||||
side = ForgeDirection.EAST;
|
side = ForgeDirection.EAST;
|
||||||
reactor = (TileEntityEnanReactorCore) te;
|
reactor = (TileEntityEnanReactorCore) tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
setMetadata();
|
setMetadata();
|
||||||
|
|
||||||
if (reactor != null) {
|
if (reactor != null) {
|
||||||
reactorVec = new Vector3(reactor).translate(0.5);
|
reactorVec = new Vector3(reactor).translate(0.5);
|
||||||
}
|
}
|
||||||
return reactor;
|
return reactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMetadata() {
|
private void setMetadata() {
|
||||||
int metadata = 0;
|
int metadata = 0;
|
||||||
if (side != ForgeDirection.UNKNOWN) {
|
if (side != ForgeDirection.UNKNOWN) {
|
||||||
|
@ -77,56 +77,52 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser implemen
|
||||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 3);
|
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntityLaserMedium scanForBooster() {
|
public TileEntityLaserMedium scanForBooster() {
|
||||||
booster = null;
|
booster = null;
|
||||||
TileEntity te;
|
TileEntity tileEntity;
|
||||||
te = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
tileEntity = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||||
if (te != null && te instanceof TileEntityLaserMedium) {
|
if (tileEntity != null && tileEntity instanceof TileEntityLaserMedium) {
|
||||||
booster = (TileEntityLaserMedium) te;
|
booster = (TileEntityLaserMedium) tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
te = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
|
tileEntity = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
|
||||||
if (te != null && te instanceof TileEntityLaserMedium) {
|
if (tileEntity != null && tileEntity instanceof TileEntityLaserMedium) {
|
||||||
booster = (TileEntityLaserMedium) te;
|
booster = (TileEntityLaserMedium) tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return booster;
|
return booster;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (doOnce == false) {
|
if (isFirstUpdate) {
|
||||||
|
isFirstUpdate = false;
|
||||||
scanForReactor();
|
scanForReactor();
|
||||||
scanForBooster();
|
scanForBooster();
|
||||||
myVec = new Vector3(this).translate(0.5);
|
myVec = new Vector3(this).translate(0.5);
|
||||||
doOnce = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useLaser == true) {
|
|
||||||
PacketHandler.sendBeamPacket(worldObj, myVec, reactorVec, 0.1F, 0.2F, 1.0F, 25, 50, 100);
|
|
||||||
useLaser = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlink() {
|
public void unlink() {
|
||||||
side = ForgeDirection.UNKNOWN;
|
side = ForgeDirection.UNKNOWN;
|
||||||
setMetadata();
|
setMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatedNeighbours() {
|
public void updatedNeighbours() {
|
||||||
|
super.updatedNeighbours();
|
||||||
scanForBooster();
|
scanForBooster();
|
||||||
scanForReactor();
|
scanForReactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void laserReactor(int energy) {
|
private void laserReactor(int energy) {
|
||||||
if (energy <= 0) {
|
if (energy <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scanForBooster();
|
scanForBooster();
|
||||||
scanForReactor();
|
scanForReactor();
|
||||||
if (booster == null)
|
if (booster == null)
|
||||||
|
@ -134,39 +130,24 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser implemen
|
||||||
if (reactor == null)
|
if (reactor == null)
|
||||||
return;
|
return;
|
||||||
if (booster.consumeEnergy(energy, false)) {
|
if (booster.consumeEnergy(energy, false)) {
|
||||||
// WarpDrive.debugPrint("ReactorLaser on " + side.toString()
|
if (WarpDriveConfig.LOGGING_ENERGY && WarpDriveConfig.LOGGING_LUA) {
|
||||||
// +" side sending " + amount);
|
WarpDrive.logger.info("ReactorLaser on " + side.toString() + " side sending " + energy);
|
||||||
useLaser = true;
|
}
|
||||||
reactor.decreaseInstability(side, energy);
|
reactor.decreaseInstability(side, energy);
|
||||||
|
PacketHandler.sendBeamPacket(worldObj, myVec, reactorVec, 0.1F, 0.2F, 1.0F, 25, 50, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String helpStr(Object[] args) {
|
|
||||||
if (args.length > 0) {
|
|
||||||
String arg = args[0].toString().toLowerCase();
|
|
||||||
if (arg.equals("energy")) {
|
|
||||||
return WarpDrive.defEnergyStr;
|
|
||||||
} else if (arg.equals("hasReactor")) {
|
|
||||||
return "hasReactor(): returns true if the laser can see a reactor and false otherwise";
|
|
||||||
} else if (arg.equals("sendlaser")) {
|
|
||||||
return "sendLaser(int): sends a laser of energy int to the reactor";
|
|
||||||
} else if (arg.equals("side")) {
|
|
||||||
return "side(): returns 0-3 depending on which side of the reactor its on";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return WarpDrive.defHelpStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ComputerCraft methods
|
// ComputerCraft methods
|
||||||
@Override
|
@Override
|
||||||
@Optional.Method(modid = "ComputerCraft")
|
@Optional.Method(modid = "ComputerCraft")
|
||||||
|
@ -179,14 +160,15 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser implemen
|
||||||
} else {
|
} else {
|
||||||
return new Object[] { booster.getEnergyStored(), booster.getMaxEnergyStored() };
|
return new Object[] { booster.getEnergyStored(), booster.getMaxEnergyStored() };
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (methodName.equals("hasReactor")) {
|
} else if (methodName.equals("hasReactor")) {
|
||||||
return new Object[] { scanForReactor() != null };
|
return new Object[] { scanForReactor() != null };
|
||||||
|
|
||||||
} else if (methodName.equals("sendLaser")) {
|
} else if (methodName.equals("sendLaser")) {
|
||||||
if (arguments.length >= 1) {
|
if (arguments.length >= 1) {
|
||||||
laserReactor(toInt(arguments[0]));
|
laserReactor(toInt(arguments[0]));
|
||||||
}
|
}
|
||||||
} else if (methodName.equals("help")) {
|
|
||||||
return new Object[] { helpStr(arguments) };
|
|
||||||
} else if (methodName.equals("side")) {
|
} else if (methodName.equals("side")) {
|
||||||
return new Object[] { side.ordinal() - 2 };
|
return new Object[] { side.ordinal() - 2 };
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,63 +19,64 @@ import cr0s.warpdrive.item.ItemIC2reactorLaserFocus;
|
||||||
import cr0s.warpdrive.network.PacketHandler;
|
import cr0s.warpdrive.network.PacketHandler;
|
||||||
|
|
||||||
public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractLaser {
|
public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractLaser {
|
||||||
private final int workRate = 10;
|
private int ticks = WarpDriveConfig.IC2_REACTOR_COOLING_INTERVAL_TICKS;
|
||||||
private int ticks = 0;
|
|
||||||
|
|
||||||
public TileEntityIC2reactorLaserMonitor() {
|
public TileEntityIC2reactorLaserMonitor() {
|
||||||
super();
|
super();
|
||||||
IC2_sinkTier = 2;
|
IC2_sinkTier = 2;
|
||||||
IC2_sourceTier = 2;
|
IC2_sourceTier = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Object> findReactors() {//returns either IReactor or IReactorChamber tile entity
|
private static int[] deltaX = {-2, 2, 0, 0, 0, 0};
|
||||||
int[] xD = {-2, 2, 0, 0, 0, 0};
|
private static int[] deltaY = { 0, 0,-2, 2, 0, 0};
|
||||||
int[] yD = { 0, 0,-2, 2, 0, 0};
|
private static int[] deltaZ = { 0, 0, 0, 0,-2, 2};
|
||||||
int[] zD = { 0, 0, 0, 0,-2, 2};
|
|
||||||
Set<Object> output = new HashSet<Object>();
|
// returns IReactor tile entities
|
||||||
for(int i = 0; i < xD.length; i++) {
|
private Set<IReactor> findReactors() {
|
||||||
int xO = xCoord + xD[i];
|
Set<IReactor> output = new HashSet<IReactor>();
|
||||||
int yO = yCoord + yD[i];
|
|
||||||
int zO = zCoord + zD[i];
|
for(int i = 0; i < deltaX.length; i++) {
|
||||||
TileEntity te = worldObj.getTileEntity(xO, yO, zO);
|
TileEntity tileEntity = worldObj.getTileEntity(xCoord + deltaX[i], yCoord + deltaY[i], zCoord + deltaZ[i]);
|
||||||
if(te == null)
|
if (tileEntity == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (te instanceof IReactor) {
|
|
||||||
output.add(te);
|
if (tileEntity instanceof IReactor) {
|
||||||
} else if(te instanceof IReactorChamber) {
|
output.add((IReactor)tileEntity);
|
||||||
IReactor reactor = ((IReactorChamber)te).getReactor();
|
|
||||||
if(reactor == null)
|
} else if (tileEntity instanceof IReactorChamber) {
|
||||||
|
IReactor reactor = ((IReactorChamber)tileEntity).getReactor();
|
||||||
|
if (reactor == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore if we're right next to the reactor
|
||||||
ChunkCoordinates coords = reactor.getPosition();
|
ChunkCoordinates coords = reactor.getPosition();
|
||||||
|
if ( Math.abs(coords.posX - xCoord) == 1
|
||||||
if(Math.abs(coords.posX - xCoord) == 1)
|
|| Math.abs(coords.posY - yCoord) == 1
|
||||||
|
|| Math.abs(coords.posZ - zCoord) == 1) {
|
||||||
continue;
|
continue;
|
||||||
if(Math.abs(coords.posY - yCoord) == 1)
|
}
|
||||||
continue;
|
|
||||||
if(Math.abs(coords.posZ - zCoord) == 1)
|
output.add(reactor);
|
||||||
continue;
|
|
||||||
|
|
||||||
output.add(te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean coolReactor(IReactor react) {
|
private boolean coolReactor(IReactor reactor) {
|
||||||
boolean didCoolReactor = false;
|
boolean didCoolReactor = false;
|
||||||
for(int x = 0; x < 9; x++) {
|
for(int x = 0; x < 9 && !didCoolReactor; x++) {
|
||||||
for(int y = 0; y < 6; y++) {
|
for(int y = 0; y < 6 && !didCoolReactor; y++) {
|
||||||
ItemStack item = react.getItemAt(x, y);
|
ItemStack item = reactor.getItemAt(x, y);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if(item.getItem() instanceof ItemIC2reactorLaserFocus) {
|
if (item.getItem() instanceof ItemIC2reactorLaserFocus) {
|
||||||
int heat = item.getItemDamage();
|
int heatInLaserFocus = item.getItemDamage();
|
||||||
int heatRemoval = (int) Math.floor(Math.min(getEnergyStored() / WarpDriveConfig.IC2_REACTOR_ENERGY_PER_HEAT, heat));
|
int heatRemovable = (int) Math.floor(Math.min(getEnergyStored() / WarpDriveConfig.IC2_REACTOR_ENERGY_PER_HEAT, heatInLaserFocus));
|
||||||
if (heatRemoval > 0) {
|
if (heatRemovable > 0) {
|
||||||
didCoolReactor = true;
|
didCoolReactor = true;
|
||||||
consumeEnergy((int) Math.ceil(heatRemoval * WarpDriveConfig.IC2_REACTOR_ENERGY_PER_HEAT), false);
|
consumeEnergy((int) Math.ceil(heatRemovable * WarpDriveConfig.IC2_REACTOR_ENERGY_PER_HEAT), false);
|
||||||
item.setItemDamage(heat - heatRemoval);
|
item.setItemDamage(heatInLaserFocus - heatRemovable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,60 +84,55 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractLaser {
|
||||||
}
|
}
|
||||||
return didCoolReactor;
|
return didCoolReactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ticks++;
|
ticks--;
|
||||||
if (ticks > workRate) {
|
if (ticks <= 0) {
|
||||||
ticks = 0;
|
ticks = WarpDriveConfig.IC2_REACTOR_COOLING_INTERVAL_TICKS;
|
||||||
Vector3 myPos = new Vector3(this).translate(0.5);
|
Vector3 myPos = new Vector3(this).translate(0.5);
|
||||||
Set<Object> reactors = findReactors();
|
Set<IReactor> reactors = findReactors();
|
||||||
if(reactors.size() == 0)
|
if (reactors.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
for(Object o : reactors)
|
|
||||||
{
|
for(IReactor reactor : reactors) {
|
||||||
IReactor react = null;
|
if (coolReactor(reactor)) {
|
||||||
if(o instanceof TileEntity)
|
PacketHandler.sendBeamPacket(worldObj, myPos, new Vector3(reactor.getPosition()).translate(0.5D), 0.0f, 0.8f, 1.0f, 20, 0, 20);
|
||||||
{
|
|
||||||
if(o instanceof IReactor)
|
|
||||||
react = (IReactor)o;
|
|
||||||
else if(o instanceof IReactorChamber)
|
|
||||||
react = ((IReactorChamber)o).getReactor();
|
|
||||||
if(react != null)
|
|
||||||
{
|
|
||||||
if(coolReactor(react))
|
|
||||||
{
|
|
||||||
TileEntity te = (TileEntity)o;
|
|
||||||
PacketHandler.sendBeamPacket(worldObj, myPos, new Vector3(te.xCoord,te.yCoord,te.zCoord).translate(0.5D), 0f, 0.8f, 1f, 20, 0, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag) {
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
super.writeToNBT(tag);
|
super.writeToNBT(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag) {
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
super.readFromNBT(tag);
|
super.readFromNBT(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStatus() {
|
||||||
|
Set<IReactor> reactors = findReactors();
|
||||||
|
return getBlockType().getLocalizedName()
|
||||||
|
+ String.format(" energy level is %.0f/%.0f EU.", convertInternalToEU(getEnergyStored()), convertInternalToEU(getMaxEnergyStored()))
|
||||||
|
+ ((reactors == null || reactors.size() == 0) ? " No reactor found!" : " " + reactors.size() + " reactor(s) connected.");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored() {
|
public int getMaxEnergyStored() {
|
||||||
return WarpDriveConfig.IC2_REACTOR_MAX_ENERGY_STORED;
|
return WarpDriveConfig.IC2_REACTOR_MAX_ENERGY_STORED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInputEnergy(ForgeDirection from) {
|
public boolean canInputEnergy(ForgeDirection from) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.Optional;
|
import cpw.mods.fml.common.Optional;
|
||||||
import cr0s.warpdrive.WarpDrive;
|
|
||||||
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
|
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
|
||||||
import cr0s.warpdrive.conf.WarpDriveConfig;
|
import cr0s.warpdrive.conf.WarpDriveConfig;
|
||||||
import cr0s.warpdrive.data.Vector3;
|
import cr0s.warpdrive.data.Vector3;
|
||||||
|
@ -26,15 +25,15 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
private static final int MODE_INACTIVE = 0;
|
private static final int MODE_INACTIVE = 0;
|
||||||
private static final int MODE_UP = 1;
|
private static final int MODE_UP = 1;
|
||||||
private static final int MODE_DOWN = 2;
|
private static final int MODE_DOWN = 2;
|
||||||
|
|
||||||
private int firstUncoveredY;
|
private int firstUncoveredY;
|
||||||
private int mode = MODE_INACTIVE;
|
private int mode = MODE_INACTIVE;
|
||||||
private boolean isEnabled = false;
|
private boolean isEnabled = false;
|
||||||
private boolean computerEnabled = true;
|
private boolean computerEnabled = true;
|
||||||
private int computerMode = MODE_REDSTONE;
|
private int computerMode = MODE_REDSTONE;
|
||||||
|
|
||||||
private int tickCount = 0;
|
private int tickCount = 0;
|
||||||
|
|
||||||
public TileEntityLift() {
|
public TileEntityLift() {
|
||||||
super();
|
super();
|
||||||
IC2_sinkTier = 2;
|
IC2_sinkTier = 2;
|
||||||
|
@ -43,22 +42,21 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
methodsArray = new String[] {
|
methodsArray = new String[] {
|
||||||
"getEnergyLevel",
|
"getEnergyLevel",
|
||||||
"mode",
|
"mode",
|
||||||
"active",
|
"active" };
|
||||||
"help" };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tickCount++;
|
tickCount++;
|
||||||
if (tickCount >= WarpDriveConfig.LIFT_UPDATE_INTERVAL_TICKS) {
|
if (tickCount >= WarpDriveConfig.LIFT_UPDATE_INTERVAL_TICKS) {
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
|
|
||||||
// Switching mode
|
// Switching mode
|
||||||
if ( computerMode == MODE_DOWN
|
if ( computerMode == MODE_DOWN
|
||||||
|| (computerMode == MODE_REDSTONE && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))) {
|
|| (computerMode == MODE_REDSTONE && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))) {
|
||||||
|
@ -66,12 +64,12 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
} else {
|
} else {
|
||||||
mode = MODE_UP;
|
mode = MODE_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
isEnabled = computerEnabled && isPassableBlock(yCoord + 1)
|
isEnabled = computerEnabled && isPassableBlock(yCoord + 1)
|
||||||
&& isPassableBlock(yCoord + 2)
|
&& isPassableBlock(yCoord + 2)
|
||||||
&& isPassableBlock(yCoord - 1)
|
&& isPassableBlock(yCoord - 1)
|
||||||
&& isPassableBlock(yCoord - 2);
|
&& isPassableBlock(yCoord - 2);
|
||||||
|
|
||||||
if (getEnergyStored() < WarpDriveConfig.LIFT_ENERGY_PER_ENTITY
|
if (getEnergyStored() < WarpDriveConfig.LIFT_ENERGY_PER_ENTITY
|
||||||
|| !isEnabled) {
|
|| !isEnabled) {
|
||||||
mode = MODE_INACTIVE;
|
mode = MODE_INACTIVE;
|
||||||
|
@ -81,12 +79,12 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBlockMetadata() != mode) {
|
if (getBlockMetadata() != mode) {
|
||||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord,
|
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord,
|
||||||
mode, 2); // current mode
|
mode, 2); // current mode
|
||||||
}
|
}
|
||||||
|
|
||||||
// Launch a beam: search non-air blocks under lift
|
// Launch a beam: search non-air blocks under lift
|
||||||
for (int ny = yCoord - 2; ny > 0; ny--) {
|
for (int ny = yCoord - 2; ny > 0; ny--) {
|
||||||
if (!isPassableBlock(ny)) {
|
if (!isPassableBlock(ny)) {
|
||||||
|
@ -94,7 +92,7 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yCoord - firstUncoveredY >= 2) {
|
if (yCoord - firstUncoveredY >= 2) {
|
||||||
if (mode == MODE_UP) {
|
if (mode == MODE_UP) {
|
||||||
PacketHandler.sendBeamPacket(worldObj, new Vector3(
|
PacketHandler.sendBeamPacket(worldObj, new Vector3(
|
||||||
|
@ -107,12 +105,12 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
xCoord + 0.5D, firstUncoveredY, zCoord + 0.5D), 0f,
|
xCoord + 0.5D, firstUncoveredY, zCoord + 0.5D), 0f,
|
||||||
0f, 1f, 40, 0, 100);
|
0f, 1f, 40, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
liftEntity();
|
liftEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPassableBlock(int yPosition) {
|
private boolean isPassableBlock(int yPosition) {
|
||||||
Block block = worldObj.getBlock(xCoord, yPosition, zCoord);
|
Block block = worldObj.getBlock(xCoord, yPosition, zCoord);
|
||||||
//TODO: Make configurable or less specific
|
//TODO: Make configurable or less specific
|
||||||
|
@ -121,17 +119,17 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
|| block.isAssociatedBlock(Blocks.standing_sign)
|
|| block.isAssociatedBlock(Blocks.standing_sign)
|
||||||
|| worldObj.isAirBlock(xCoord, yPosition, zCoord);
|
|| worldObj.isAirBlock(xCoord, yPosition, zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void liftEntity() {
|
private void liftEntity() {
|
||||||
final double CUBE_RADIUS = 0.4;
|
final double CUBE_RADIUS = 0.4;
|
||||||
double xmax, zmax;
|
double xmax, zmax;
|
||||||
double xmin, zmin;
|
double xmin, zmin;
|
||||||
|
|
||||||
xmin = xCoord + 0.5 - CUBE_RADIUS;
|
xmin = xCoord + 0.5 - CUBE_RADIUS;
|
||||||
xmax = xCoord + 0.5 + CUBE_RADIUS;
|
xmax = xCoord + 0.5 + CUBE_RADIUS;
|
||||||
zmin = zCoord + 0.5 - CUBE_RADIUS;
|
zmin = zCoord + 0.5 - CUBE_RADIUS;
|
||||||
zmax = zCoord + 0.5 + CUBE_RADIUS;
|
zmax = zCoord + 0.5 + CUBE_RADIUS;
|
||||||
|
|
||||||
// Lift up
|
// Lift up
|
||||||
if (mode == MODE_UP) {
|
if (mode == MODE_UP) {
|
||||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin, firstUncoveredY, zmin, xmax, yCoord, zmax);
|
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin, firstUncoveredY, zmin, xmax, yCoord, zmax);
|
||||||
|
@ -170,34 +168,34 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag) {
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
super.readFromNBT(tag);
|
super.readFromNBT(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag) {
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
super.writeToNBT(tag);
|
super.writeToNBT(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored() {
|
public int getMaxEnergyStored() {
|
||||||
return WarpDriveConfig.LIFT_MAX_ENERGY_STORED;
|
return WarpDriveConfig.LIFT_MAX_ENERGY_STORED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInputEnergy(ForgeDirection from) {
|
public boolean canInputEnergy(ForgeDirection from) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenComputer callback methods
|
// OpenComputer callback methods
|
||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] mode(Context context, Arguments arguments) {
|
public Object[] mode(Context context, Arguments arguments) {
|
||||||
return mode(argumentsOCtoCC(arguments));
|
return mode(argumentsOCtoCC(arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] active(Context context, Arguments arguments) {
|
public Object[] active(Context context, Arguments arguments) {
|
||||||
|
@ -206,7 +204,7 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
}
|
}
|
||||||
return new Object[] { computerEnabled ? false : isEnabled };
|
return new Object[] { computerEnabled ? false : isEnabled };
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] mode(Object[] arguments) {
|
private Object[] mode(Object[] arguments) {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
if (arguments[0].toString().equals("up")) {
|
if (arguments[0].toString().equals("up")) {
|
||||||
|
@ -227,41 +225,23 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String helpStr(Object[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
String methodName = args[0].toString().toLowerCase();
|
|
||||||
if (methodName.equals("getEnergyLevel")) {
|
|
||||||
return WarpDrive.defEnergyStr;
|
|
||||||
} else if (methodName.equals("mode")) {
|
|
||||||
return "mode(\"up\" or \"down\" or \"redstone\"): sets the mode\nmode(): returns the current mode";
|
|
||||||
} else if (methodName.equals("active")) {
|
|
||||||
return "active(boolean): sets whether the laser is active\nactive(): returns whether the laser is active";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return WarpDrive.defHelpStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ComputerCraft IPeripheral methods implementation
|
// ComputerCraft IPeripheral methods implementation
|
||||||
@Override
|
@Override
|
||||||
@Optional.Method(modid = "ComputerCraft")
|
@Optional.Method(modid = "ComputerCraft")
|
||||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context,
|
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) {
|
||||||
int method, Object[] arguments) {
|
|
||||||
String methodName = methodsArray[method];
|
String methodName = methodsArray[method];
|
||||||
if (methodName.equals("getEnergyLevel")) {
|
if (methodName.equals("getEnergyLevel")) {
|
||||||
return getEnergyLevel();
|
return getEnergyLevel();
|
||||||
|
|
||||||
} else if (methodName.equals("mode")) {
|
} else if (methodName.equals("mode")) {
|
||||||
return mode(arguments);
|
return mode(arguments);
|
||||||
|
|
||||||
} else if (methodName.equals("active")) {
|
} else if (methodName.equals("active")) {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
computerEnabled = toBool(arguments);
|
computerEnabled = toBool(arguments);
|
||||||
}
|
}
|
||||||
return new Object[] { computerEnabled ? false : isEnabled };
|
return new Object[] { computerEnabled ? false : isEnabled };
|
||||||
|
|
||||||
} else if (methodName.equals("help")) {
|
|
||||||
return new Object[] { helpStr(arguments) };
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class WarpDriveConfig {
|
||||||
private static File configDirectory;
|
private static File configDirectory;
|
||||||
private static DocumentBuilder xmlDocumentBuilder;
|
private static DocumentBuilder xmlDocumentBuilder;
|
||||||
private static final String[] defaultXMLfilenames = { "structures-default.xml" };
|
private static final String[] defaultXMLfilenames = { "structures-default.xml" };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The variables which store whether or not individual mods are loaded
|
* The variables which store whether or not individual mods are loaded
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +51,7 @@ public class WarpDriveConfig {
|
||||||
public static boolean isThermalExpansionLoaded = false;
|
public static boolean isThermalExpansionLoaded = false;
|
||||||
public static boolean isAdvancedRepulsionSystemsLoaded = false;
|
public static boolean isAdvancedRepulsionSystemsLoaded = false;
|
||||||
public static boolean isMagicalCropsLoaded = false;
|
public static boolean isMagicalCropsLoaded = false;
|
||||||
|
|
||||||
// ForgeMultipart (microblocks) support
|
// ForgeMultipart (microblocks) support
|
||||||
public static Method forgeMultipart_helper_createTileFromNBT = null;
|
public static Method forgeMultipart_helper_createTileFromNBT = null;
|
||||||
public static Method forgeMultipart_helper_sendDescPacket = null;
|
public static Method forgeMultipart_helper_sendDescPacket = null;
|
||||||
|
@ -199,7 +199,7 @@ public class WarpDriveConfig {
|
||||||
// - overall consumption in 'ores, space' is ML_EU_PER_LAYER_SPACE + ((ML_MAX_RADIUS * 2 + 1) ^ 2) * ML_EU_PER_BLOCK_SPACE * ML_EU_MUL_ORESONLY / 25 => ~ 28630 EU/layer
|
// - overall consumption in 'ores, space' is ML_EU_PER_LAYER_SPACE + ((ML_MAX_RADIUS * 2 + 1) ^ 2) * ML_EU_PER_BLOCK_SPACE * ML_EU_MUL_ORESONLY / 25 => ~ 28630 EU/layer
|
||||||
// - at radius 5, one layer takes 403 ticks (2 * ML_SCAN_DELAY_TICKS + ML_MINE_DELAY_TICKS * (ML_MAX_RADIUS * 2 + 1) ^ 2)
|
// - at radius 5, one layer takes 403 ticks (2 * ML_SCAN_DELAY_TICKS + ML_MINE_DELAY_TICKS * (ML_MAX_RADIUS * 2 + 1) ^ 2)
|
||||||
public static int MINING_LASER_MAX_MEDIUMS_COUNT = 1;
|
public static int MINING_LASER_MAX_MEDIUMS_COUNT = 1;
|
||||||
public static int MINING_LASER_MAX_RADIUS = 16;
|
public static int MINING_LASER_RADIUS_BLOCKS = 5;
|
||||||
public static int MINING_LASER_WARMUP_DELAY_TICKS = 20;
|
public static int MINING_LASER_WARMUP_DELAY_TICKS = 20;
|
||||||
public static int MINING_LASER_SCAN_DELAY_TICKS = 20;
|
public static int MINING_LASER_SCAN_DELAY_TICKS = 20;
|
||||||
public static int MINING_LASER_MINE_DELAY_TICKS = 3;
|
public static int MINING_LASER_MINE_DELAY_TICKS = 3;
|
||||||
|
@ -234,26 +234,27 @@ public class WarpDriveConfig {
|
||||||
// IC2 Reactor monitor
|
// IC2 Reactor monitor
|
||||||
public static int IC2_REACTOR_MAX_ENERGY_STORED = 1000000;
|
public static int IC2_REACTOR_MAX_ENERGY_STORED = 1000000;
|
||||||
public static double IC2_REACTOR_ENERGY_PER_HEAT = 2;
|
public static double IC2_REACTOR_ENERGY_PER_HEAT = 2;
|
||||||
|
public static int IC2_REACTOR_COOLING_INTERVAL_TICKS = 10;
|
||||||
|
|
||||||
// Transporter
|
// Transporter
|
||||||
public static int TRANSPORTER_MAX_ENERGY = 1000000;
|
public static int TRANSPORTER_MAX_ENERGY = 1000000;
|
||||||
public static boolean TRANSPORTER_USE_RELATIVE_COORDS = true;
|
public static boolean TRANSPORTER_USE_RELATIVE_COORDS = true;
|
||||||
public static double TRANSPORTER_ENERGY_PER_BLOCK = 100.0;
|
public static double TRANSPORTER_ENERGY_PER_BLOCK = 100.0;
|
||||||
public static double TRANSPORTER_MAX_BOOST_MUL = 4.0;
|
public static double TRANSPORTER_MAX_BOOST_MUL = 4.0;
|
||||||
|
|
||||||
// Enantiomorphic Power reactor
|
// Enantiomorphic Power reactor
|
||||||
public static int ENAN_REACTOR_MAX_ENERGY_STORED = 100000000;
|
public static int ENAN_REACTOR_MAX_ENERGY_STORED = 100000000;
|
||||||
public static int ENAN_REACTOR_UPDATE_INTERVAL_TICKS = 5;
|
public static int ENAN_REACTOR_UPDATE_INTERVAL_TICKS = 5;
|
||||||
public static int ENAN_REACTOR_MAX_LASERS_PER_SECOND = 6;
|
public static int ENAN_REACTOR_MAX_LASERS_PER_SECOND = 6;
|
||||||
|
|
||||||
// Power store
|
// Power store
|
||||||
public static int ENERGY_BANK_MAX_ENERGY_STORED = 1000000;
|
public static int ENERGY_BANK_MAX_ENERGY_STORED = 1000000;
|
||||||
|
|
||||||
// Laser Lift
|
// Laser Lift
|
||||||
public static int LIFT_MAX_ENERGY_STORED = 2400;
|
public static int LIFT_MAX_ENERGY_STORED = 2400;
|
||||||
public static int LIFT_ENERGY_PER_ENTITY = 800;
|
public static int LIFT_ENERGY_PER_ENTITY = 800;
|
||||||
public static int LIFT_UPDATE_INTERVAL_TICKS = 10;
|
public static int LIFT_UPDATE_INTERVAL_TICKS = 10;
|
||||||
|
|
||||||
// Chunk Loader
|
// Chunk Loader
|
||||||
public static int CL_MAX_ENERGY = 1000000;
|
public static int CL_MAX_ENERGY = 1000000;
|
||||||
public static int CL_MAX_DISTANCE = 2;
|
public static int CL_MAX_DISTANCE = 2;
|
||||||
|
@ -292,22 +293,6 @@ public class WarpDriveConfig {
|
||||||
|
|
||||||
// read configuration file
|
// read configuration file
|
||||||
loadWarpDriveConfig(new File(configDirectory, WarpDrive.MODID + ".cfg"));
|
loadWarpDriveConfig(new File(configDirectory, WarpDrive.MODID + ".cfg"));
|
||||||
|
|
||||||
// read XML files
|
|
||||||
File[] files = configDirectory.listFiles(new FilenameFilter() {
|
|
||||||
@Override
|
|
||||||
public boolean accept(File file_notUsed, String name) {
|
|
||||||
return name.endsWith(".xml");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (files.length == 0) {
|
|
||||||
for(String defaultXMLfilename : defaultXMLfilenames) {
|
|
||||||
unpackResourceToFolder(defaultXMLfilename, "config", configDirectory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FillerManager.loadOres(configDirectory);
|
|
||||||
StructureManager.loadStructures(configDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadWarpDriveConfig(File file) {
|
public static void loadWarpDriveConfig(File file) {
|
||||||
|
@ -542,8 +527,8 @@ public class WarpDriveConfig {
|
||||||
// Mining Laser
|
// Mining Laser
|
||||||
MINING_LASER_MAX_MEDIUMS_COUNT = clamp(1, 64,
|
MINING_LASER_MAX_MEDIUMS_COUNT = clamp(1, 64,
|
||||||
config.get("mining_laser", "max_mediums_count", MINING_LASER_MAX_MEDIUMS_COUNT).getInt());
|
config.get("mining_laser", "max_mediums_count", MINING_LASER_MAX_MEDIUMS_COUNT).getInt());
|
||||||
MINING_LASER_MAX_RADIUS = clamp(1, 64,
|
MINING_LASER_RADIUS_BLOCKS = clamp(1, 64,
|
||||||
config.get("mining_laser", "max_radius", MINING_LASER_MAX_RADIUS).getInt());
|
config.get("mining_laser", "radius_blocks", MINING_LASER_RADIUS_BLOCKS).getInt());
|
||||||
|
|
||||||
MINING_LASER_WARMUP_DELAY_TICKS = clamp(1, 300,
|
MINING_LASER_WARMUP_DELAY_TICKS = clamp(1, 300,
|
||||||
config.get("mining_laser", "warmup_delay_ticks", MINING_LASER_WARMUP_DELAY_TICKS).getInt());
|
config.get("mining_laser", "warmup_delay_ticks", MINING_LASER_WARMUP_DELAY_TICKS).getInt());
|
||||||
|
@ -607,6 +592,8 @@ public class WarpDriveConfig {
|
||||||
config.get("ic2_reactor_laser", "max_energy_stored", IC2_REACTOR_MAX_ENERGY_STORED).getInt());
|
config.get("ic2_reactor_laser", "max_energy_stored", IC2_REACTOR_MAX_ENERGY_STORED).getInt());
|
||||||
IC2_REACTOR_ENERGY_PER_HEAT = clamp(2.0D, 100000.0D,
|
IC2_REACTOR_ENERGY_PER_HEAT = clamp(2.0D, 100000.0D,
|
||||||
config.get("ic2_reactor_laser", "energy_per_heat", IC2_REACTOR_ENERGY_PER_HEAT).getDouble(2));
|
config.get("ic2_reactor_laser", "energy_per_heat", IC2_REACTOR_ENERGY_PER_HEAT).getDouble(2));
|
||||||
|
IC2_REACTOR_COOLING_INTERVAL_TICKS = clamp(0, 1200,
|
||||||
|
config.get("ic2_reactor_laser", "cooling_interval_ticks", IC2_REACTOR_COOLING_INTERVAL_TICKS).getInt());
|
||||||
|
|
||||||
// Transporter
|
// Transporter
|
||||||
TRANSPORTER_MAX_ENERGY = clamp(1, Integer.MAX_VALUE,
|
TRANSPORTER_MAX_ENERGY = clamp(1, Integer.MAX_VALUE,
|
||||||
|
@ -756,7 +743,24 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void postInit() {
|
public static void postInit() {
|
||||||
|
// read XML files
|
||||||
|
File[] files = configDirectory.listFiles(new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File file_notUsed, String name) {
|
||||||
|
return name.endsWith(".xml");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (files.length == 0) {
|
||||||
|
for(String defaultXMLfilename : defaultXMLfilenames) {
|
||||||
|
unpackResourceToFolder(defaultXMLfilename, "config", configDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FillerManager.loadOres(configDirectory);
|
||||||
|
StructureManager.loadStructures(configDirectory);
|
||||||
|
|
||||||
LoadOreDict();
|
LoadOreDict();
|
||||||
|
|
||||||
FillerManager.finishLoading();
|
FillerManager.finishLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class Planet implements Cloneable {
|
||||||
* @param currentPosition current position in the planet/dimension
|
* @param currentPosition current position in the planet/dimension
|
||||||
* @return distance to transition borders, 0 if take off is possible
|
* @return distance to transition borders, 0 if take off is possible
|
||||||
*/
|
*/
|
||||||
public int isValidToSpace(Vector3 currentPosition) {
|
public int isValidToSpace(VectorI currentPosition) {
|
||||||
if ((Math.abs(currentPosition.x - dimensionCenterX) <= borderSizeX) && (Math.abs(currentPosition.z - dimensionCenterZ) <= borderSizeZ)) {
|
if ((Math.abs(currentPosition.x - dimensionCenterX) <= borderSizeX) && (Math.abs(currentPosition.z - dimensionCenterZ) <= borderSizeZ)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class Planet implements Cloneable {
|
||||||
* @param currentPosition current position in space
|
* @param currentPosition current position in space
|
||||||
* @return distance to transition borders, 0 if entry is possible
|
* @return distance to transition borders, 0 if entry is possible
|
||||||
*/
|
*/
|
||||||
public int isValidFromSpace(Vector3 currentPosition) {
|
public int isValidFromSpace(VectorI currentPosition) {
|
||||||
if ((Math.abs(currentPosition.x - spaceCenterX) <= borderSizeX) && (Math.abs(currentPosition.z - spaceCenterZ) <= borderSizeZ)) {
|
if ((Math.abs(currentPosition.x - spaceCenterX) <= borderSizeX) && (Math.abs(currentPosition.z - spaceCenterZ) <= borderSizeZ)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,40 @@ public class Vector3 implements Cloneable {
|
||||||
this.z += par1;
|
this.z += par1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modify current vector by translation of amount block in side direction
|
||||||
|
public Vector3 translate(final ForgeDirection side, final double amount) {
|
||||||
|
switch (side) {
|
||||||
|
case DOWN:
|
||||||
|
y -= amount;
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
y += amount;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
z -= amount;
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
z += amount;
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
x -= amount;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
x += amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// modify current vector by translation of 1 block in side direction
|
||||||
|
public Vector3 translate(final ForgeDirection side) {
|
||||||
|
x += side.offsetX;
|
||||||
|
y += side.offsetY;
|
||||||
|
z += side.offsetZ;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public static Vector3 translate(Vector3 translate, Vector3 par1) {
|
public static Vector3 translate(Vector3 translate, Vector3 par1) {
|
||||||
translate.x += par1.x;
|
translate.x += par1.x;
|
||||||
translate.y += par1.y;
|
translate.y += par1.y;
|
||||||
|
@ -226,7 +259,7 @@ public class Vector3 implements Cloneable {
|
||||||
translate.z += par1;
|
translate.z += par1;
|
||||||
return translate;
|
return translate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 subtract(Vector3 amount) {
|
public Vector3 subtract(Vector3 amount) {
|
||||||
return this.translate(amount.clone().invert());
|
return this.translate(amount.clone().invert());
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,11 @@ public class VectorI implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Vector3 getBlockCenter() {
|
||||||
|
return new Vector3(x + 0.5D, y + 0.5D, z + 0.5D);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VectorI clone() {
|
public VectorI clone() {
|
||||||
return new VectorI(x, y, z);
|
return new VectorI(x, y, z);
|
||||||
|
@ -178,7 +183,9 @@ public class VectorI implements Cloneable {
|
||||||
|
|
||||||
// modify current vector by translation of 1 block in side direction
|
// modify current vector by translation of 1 block in side direction
|
||||||
public VectorI translate(final ForgeDirection side) {
|
public VectorI translate(final ForgeDirection side) {
|
||||||
translate(side, 1);
|
x += side.offsetX;
|
||||||
|
y += side.offsetY;
|
||||||
|
z += side.offsetZ;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue