Merge branch 'master' of https://github.com/calclavia/Resonant-Induction
This commit is contained in:
commit
0134b505d2
3 changed files with 182 additions and 85 deletions
|
@ -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);
|
||||
|
|
|
@ -4,13 +4,15 @@
|
|||
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.server.MinecraftServer;
|
||||
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 +65,45 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
|
|||
}
|
||||
return true;
|
||||
}
|
||||
else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
||||
{
|
||||
if (tileEntity.linked == null)
|
||||
{
|
||||
ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem());
|
||||
Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem());
|
||||
|
||||
if (linkVec != null)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
int dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem());
|
||||
World otherWorld = MinecraftServer.getServer().worldServerForDimension(dimID);
|
||||
|
||||
if (linkVec.getTileEntity(otherWorld) instanceof TileEntityTesla)
|
||||
{
|
||||
tileEntity.setLink(new Vector3(((TileEntityTesla) linkVec.getTileEntity(otherWorld)).getTopTelsa()), dimID);
|
||||
|
||||
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.linked = null;
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entityPlayer.addChatMessage("Unlinked Tesla.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -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 linked;
|
||||
public int linkDim;
|
||||
|
||||
/**
|
||||
* Client
|
||||
*/
|
||||
|
@ -82,8 +89,26 @@ 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.linked != null)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
TileEntity tileEntity = MinecraftServer.getServer().worldServerForDimension(this.linkDim).getBlockTileEntity((int) this.linked.x, (int) this.linked.y, (int) this.linked.z);
|
||||
|
||||
if (tileEntity instanceof TileEntityTesla && !tileEntity.isInvalid())
|
||||
{
|
||||
this.transfer(((TileEntityTesla) tileEntity), this.getEnergyStored());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
List<ITesla> transferTeslaCoils = new ArrayList<ITesla>();
|
||||
|
||||
for (ITesla tesla : TeslaGrid.instance().get())
|
||||
|
@ -163,8 +188,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)
|
||||
{
|
||||
|
@ -186,6 +210,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.zapCounter++;
|
||||
this.outputBlacklist.clear();
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -493,6 +524,12 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
this.dyeID = nbt.getInteger("dyeID");
|
||||
this.canReceive = nbt.getBoolean("canReceive");
|
||||
this.attackEntities = nbt.getBoolean("attackEntities");
|
||||
|
||||
if (nbt.hasKey("link_x") && nbt.hasKey("link_y") && nbt.hasKey("link_z"))
|
||||
{
|
||||
this.linked = new Vector3(nbt.getInteger("link_x"), nbt.getInteger("link_y"), nbt.getInteger("link_z"));
|
||||
this.linkDim = nbt.getInteger("linkDim");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -505,6 +542,20 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
nbt.setInteger("dyeID", this.dyeID);
|
||||
nbt.setBoolean("canReceive", this.canReceive);
|
||||
nbt.setBoolean("attackEntities", this.attackEntities);
|
||||
|
||||
if (this.linked != null)
|
||||
{
|
||||
nbt.setInteger("link_x", (int) this.linked.x);
|
||||
nbt.setInteger("link_y", (int) this.linked.y);
|
||||
nbt.setInteger("link_z", (int) this.linked.z);
|
||||
nbt.setInteger("linkDim", this.linkDim);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLink(Vector3 vector3, int dimID)
|
||||
{
|
||||
this.linked = vector3;
|
||||
this.linkDim = dimID;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue