Added quantum tesla

This commit is contained in:
Calclavia 2013-08-04 22:45:32 -04:00
parent e3ab3e67ea
commit 258afcd33f
3 changed files with 78 additions and 4 deletions

View file

@ -68,6 +68,11 @@ public class FXElectricBolt extends EntityFX
this.start = new BoltPoint(startVec);
this.end = new BoltPoint(targetVec);
if (this.end.y == Double.POSITIVE_INFINITY)
{
this.end.y = Minecraft.getMinecraft().thePlayer.posY + 30;
}
/** By default, we do an electrical color */
this.segmentCount = 1;
this.particleMaxAge = (3 + this.rand.nextInt(3) - 1);

View file

@ -4,13 +4,14 @@
package resonantinduction.tesla;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase;
import resonantinduction.base.Vector3;
import resonantinduction.entangler.ItemCoordLink;
import resonantinduction.render.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -63,6 +64,43 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
}
return true;
}
else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
{
if (tileEntity.linkCoord == null)
{
ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem());
Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem());
if (linkVec != null)
{
if (linkVec.getTileEntity(world) instanceof TileEntityTesla)
{
tileEntity.linkCoord = new Vector3(((TileEntityTesla) linkVec.getTileEntity(world)).getTopTelsa());
tileEntity.dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem());
if (!world.isRemote)
{
entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]");
}
link.clearLink(entityPlayer.getCurrentEquippedItem());
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "ambient.weather.thunder", 5, 1);
return true;
}
}
}
else
{
tileEntity.linkCoord = null;
if (!world.isRemote)
{
entityPlayer.addChatMessage("Unlinked Tesla.");
}
return true;
}
}
}
else
{

View file

@ -15,6 +15,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.DamageSource;
@ -58,6 +59,12 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
private TileEntityTesla topCache = null;
private TileEntityTesla controlCache = null;
/**
* Quantum Tesla
*/
public Vector3 linkCoord;
public int dimID;
/**
* Client
*/
@ -82,8 +89,27 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
if (this.isController())
{
// TODO: Fix client side issue. || this.worldObj.isRemote
if (this.ticks % (5 + this.worldObj.rand.nextInt(2)) == 0 && ((this.getEnergyStored() > 0 && this.doTransfer) || this.worldObj.isRemote) && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
if (((this.doTransfer) || this.worldObj.isRemote) && this.ticks % (5 + this.worldObj.rand.nextInt(2)) == 0 && this.getEnergyStored() > 0 && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
{
/**
* Quantum transportation.
*/
if (this.linkCoord != null)
{
if (!this.worldObj.isRemote)
{
TileEntity tileEntity = MinecraftServer.getServer().worldServerForDimension(this.dimID).getBlockTileEntity((int) this.linkCoord.x, (int) this.linkCoord.y, (int) this.linkCoord.z);
if (tileEntity instanceof TileEntityTesla && !tileEntity.isInvalid())
{
this.transfer(((TileEntityTesla) tileEntity), this.getEnergyStored());
}
}
final TileEntityTesla topTesla = this.getTopTelsa();
final Vector3 topTeslaVector = new Vector3(topTesla);
}
List<ITesla> transferTeslaCoils = new ArrayList<ITesla>();
for (ITesla tesla : TeslaGrid.instance().get())
@ -163,8 +189,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
double distance = topTeslaVector.distance(targetVector);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) dyeColors[this.dyeID].x, (float) dyeColors[this.dyeID].y, (float) dyeColors[this.dyeID].z);
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true);
this.transfer(-transferEnergy, true);
this.transfer(tesla, transferEnergy);
if (this.attackEntities && this.zapCounter % 5 == 0)
{
@ -257,6 +282,12 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
this.clearCache();
}
private void transfer(ITesla tesla, float transferEnergy)
{
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true);
this.transfer(-transferEnergy, true);
}
@Override
public boolean canReceive(TileEntity tileEntity)
{