Added Tesla colorful electric bolts!
This commit is contained in:
parent
a575d4476b
commit
28219bcdd0
2 changed files with 70 additions and 5 deletions
|
@ -5,6 +5,8 @@ package resonantinduction.tesla;
|
||||||
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
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.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
|
@ -33,6 +35,21 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
|
||||||
((TileEntityTesla) tileEntity).updatePositionStatus();
|
((TileEntityTesla) tileEntity).updatePositionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||||
|
{
|
||||||
|
if (entityPlayer.getCurrentEquippedItem() != null)
|
||||||
|
{
|
||||||
|
if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
((TileEntityTesla) tileEntity).setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,8 @@ import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.block.BlockFurnace;
|
import net.minecraft.block.BlockFurnace;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
import resonantinduction.ITesla;
|
import resonantinduction.ITesla;
|
||||||
|
@ -21,6 +23,9 @@ import resonantinduction.base.Vector3;
|
||||||
*/
|
*/
|
||||||
public class TileEntityTesla extends TileEntityBase implements ITesla
|
public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
{
|
{
|
||||||
|
public static final Vector3[] dyeColors = new Vector3[] { new Vector3(), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0.5, 0.5, 0), new Vector3(0, 0, 1), new Vector3(0.5, 0, 05), new Vector3(0, 0.3, 1), new Vector3(0.8, 0.8, 0.8), new Vector3(0.3, 0.3, 0.3), new Vector3(0.8, 0.1, 0.2), new Vector3(0.1, 0.8, 0.2), new Vector3(0, 0.8, 0.8), new Vector3(0.1, 0.1, 1), new Vector3(0.5, 0.2, 0.5), new Vector3(0.7, 0.5, 0.1), new Vector3(1, 1, 1) };
|
||||||
|
|
||||||
|
private int dyeID = -1;
|
||||||
private float energy = 0;
|
private float energy = 0;
|
||||||
private boolean doTransfer = false;
|
private boolean doTransfer = false;
|
||||||
|
|
||||||
|
@ -40,8 +45,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
/**
|
/**
|
||||||
* Only transfer if it is the bottom controlling Tesla tower.
|
* Only transfer if it is the bottom controlling Tesla tower.
|
||||||
*/
|
*/
|
||||||
// && this.getEnergyStored() > 0 && this.doTransfer
|
if (this.ticks % 2 == 0 && this.isController() && this.getEnergyStored() > 0 && this.doTransfer && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
|
||||||
if (this.ticks % 2 == 0 && this.isController() && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
|
|
||||||
{
|
{
|
||||||
Set<ITesla> transferTeslaCoils = new HashSet<ITesla>();
|
Set<ITesla> transferTeslaCoils = new HashSet<ITesla>();
|
||||||
|
|
||||||
|
@ -69,7 +73,23 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
{
|
{
|
||||||
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)));
|
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)));
|
||||||
this.transfer(-transferEnergy);
|
this.transfer(-transferEnergy);
|
||||||
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this.getTopTelsa()).translate(new Vector3(0.5)), new Vector3((TileEntity) tesla).translate(new Vector3(0.5)));
|
|
||||||
|
Vector3 teslaVector = new Vector3((TileEntity) tesla);
|
||||||
|
|
||||||
|
if (tesla instanceof TileEntityTesla)
|
||||||
|
{
|
||||||
|
teslaVector = new Vector3(((TileEntityTesla) tesla).getControllingTelsa());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dyeID != -1)
|
||||||
|
{
|
||||||
|
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this.getTopTelsa()).translate(new Vector3(0.5)), teslaVector.translate(new Vector3(0.5)), (float) dyeColors[this.dyeID].x, (float) dyeColors[this.dyeID].y, (float) dyeColors[this.dyeID].z);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this.getTopTelsa()).translate(new Vector3(0.5)), teslaVector.translate(new Vector3(0.5)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +151,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
|
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
|
||||||
|
|
||||||
furnaceTile.furnaceBurnTime++;
|
furnaceTile.furnaceBurnTime++;
|
||||||
this.transfer(-ResonantInduction.POWER_PER_COAL / 20);
|
this.transfer(-ResonantInduction.POWER_PER_COAL / 22);
|
||||||
|
|
||||||
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
|
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +161,12 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isController()
|
private boolean isController()
|
||||||
{
|
{
|
||||||
return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord) == 0;
|
return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord) == 0;
|
||||||
|
@ -167,7 +193,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
|
|
||||||
public int getRange()
|
public int getRange()
|
||||||
{
|
{
|
||||||
return 5 * this.getHeight();
|
return 5 * (this.getHeight() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePositionStatus()
|
public void updatePositionStatus()
|
||||||
|
@ -285,4 +311,26 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDye(int id)
|
||||||
|
{
|
||||||
|
this.dyeID = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a tile entity from NBT.
|
||||||
|
*/
|
||||||
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
this.dyeID = nbt.getInteger("dyeID");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a tile entity to NBT.
|
||||||
|
*/
|
||||||
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
nbt.setInteger("dyeID", this.dyeID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue