Merge branch 'master' of https://github.com/calclavia/Resonant-Induction
This commit is contained in:
commit
51e2bef632
12 changed files with 82 additions and 22 deletions
BIN
resources/assets/resonantinduction/sound/electricshock1.ogg
Normal file
BIN
resources/assets/resonantinduction/sound/electricshock1.ogg
Normal file
Binary file not shown.
BIN
resources/assets/resonantinduction/sound/electricshock2.ogg
Normal file
BIN
resources/assets/resonantinduction/sound/electricshock2.ogg
Normal file
Binary file not shown.
BIN
resources/assets/resonantinduction/sound/electricshock3.ogg
Normal file
BIN
resources/assets/resonantinduction/sound/electricshock3.ogg
Normal file
Binary file not shown.
BIN
resources/assets/resonantinduction/sound/electricshock4.ogg
Normal file
BIN
resources/assets/resonantinduction/sound/electricshock4.ogg
Normal file
Binary file not shown.
BIN
resources/assets/resonantinduction/sound/electricshock5.ogg
Normal file
BIN
resources/assets/resonantinduction/sound/electricshock5.ogg
Normal file
Binary file not shown.
BIN
resources/assets/resonantinduction/sound/electricshock6.ogg
Normal file
BIN
resources/assets/resonantinduction/sound/electricshock6.ogg
Normal file
Binary file not shown.
BIN
resources/assets/resonantinduction/sound/electricshock7.ogg
Normal file
BIN
resources/assets/resonantinduction/sound/electricshock7.ogg
Normal file
Binary file not shown.
|
@ -5,6 +5,7 @@ package resonantinduction;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import resonantinduction.base.Vector3;
|
import resonantinduction.base.Vector3;
|
||||||
import resonantinduction.contractor.TileEntityEMContractor;
|
import resonantinduction.contractor.TileEntityEMContractor;
|
||||||
import resonantinduction.fx.FXElectricBolt;
|
import resonantinduction.fx.FXElectricBolt;
|
||||||
|
@ -28,6 +29,8 @@ public class ClientProxy extends CommonProxy
|
||||||
@Override
|
@Override
|
||||||
public void registerRenderers()
|
public void registerRenderers()
|
||||||
{
|
{
|
||||||
|
MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
|
||||||
|
|
||||||
RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE);
|
RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE);
|
||||||
|
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class PacketHandler implements IPacketHandler
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +114,7 @@ public class PacketHandler implements IPacketHandler
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
data.writeInt(PacketType.TILE.ordinal());
|
||||||
data.writeInt(tileEntity.xCoord);
|
data.writeInt(tileEntity.xCoord);
|
||||||
data.writeInt(tileEntity.yCoord);
|
data.writeInt(tileEntity.yCoord);
|
||||||
data.writeInt(tileEntity.zCoord);
|
data.writeInt(tileEntity.zCoord);
|
||||||
|
|
32
src/resonantinduction/SoundHandler.java
Normal file
32
src/resonantinduction/SoundHandler.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package resonantinduction;
|
||||||
|
|
||||||
|
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||||
|
import net.minecraftforge.event.ForgeSubscribe;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Calclavia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class SoundHandler
|
||||||
|
{
|
||||||
|
public static final SoundHandler INSTANCE = new SoundHandler();
|
||||||
|
|
||||||
|
public static final String[] SOUND_FILES = { "electricshock1.ogg", "electricshock2.ogg", "electricshock3.ogg", "electricshock4.ogg", "electricshock5.ogg", "electricshock6.ogg", "electricshock7.ogg" };
|
||||||
|
|
||||||
|
@ForgeSubscribe
|
||||||
|
public void loadSoundEvents(SoundLoadEvent event)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < SOUND_FILES.length; i++)
|
||||||
|
{
|
||||||
|
event.manager.soundPoolSounds.addSound(ResonantInduction.PREFIX + SOUND_FILES[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResonantInduction.LOGGER.fine("Loaded sound fxs");
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,7 +61,6 @@ public class FXElectricBolt extends EntityFX
|
||||||
this.end = new BoltPoint(targetVec);
|
this.end = new BoltPoint(targetVec);
|
||||||
|
|
||||||
/** By default, we do an electrical color */
|
/** By default, we do an electrical color */
|
||||||
this.setColor(0.5f + (this.rand.nextFloat() * 0.1f), 0.6f + (this.rand.nextFloat() * 0.1f), 1);
|
|
||||||
this.segmentCount = 1;
|
this.segmentCount = 1;
|
||||||
this.particleAge = (3 + this.rand.nextInt(3) - 1);
|
this.particleAge = (3 + this.rand.nextInt(3) - 1);
|
||||||
this.particleMaxAge = (3 + this.rand.nextInt(3) - 1);
|
this.particleMaxAge = (3 + this.rand.nextInt(3) - 1);
|
||||||
|
@ -105,9 +104,9 @@ public class FXElectricBolt extends EntityFX
|
||||||
|
|
||||||
public FXElectricBolt setColor(float r, float g, float b)
|
public FXElectricBolt setColor(float r, float g, float b)
|
||||||
{
|
{
|
||||||
this.particleRed = r;
|
this.particleRed = r + (this.rand.nextFloat() * 0.1f) - 0.1f;
|
||||||
this.particleGreen = g;
|
this.particleGreen = g + (this.rand.nextFloat() * 0.1f) - 0.1f;
|
||||||
this.particleBlue = b;
|
this.particleBlue = b + (this.rand.nextFloat() * 0.1f) - 0.1f;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,19 +13,24 @@ 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;
|
||||||
|
import resonantinduction.PacketHandler;
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
|
import resonantinduction.base.IPacketReceiver;
|
||||||
import resonantinduction.base.TileEntityBase;
|
import resonantinduction.base.TileEntityBase;
|
||||||
import resonantinduction.base.Vector3;
|
import resonantinduction.base.Vector3;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TileEntityTesla extends TileEntityBase implements ITesla
|
public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketReceiver
|
||||||
{
|
{
|
||||||
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;
|
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.7, 0.2, 0.2), new Vector3(0.1, 0.872, 0.884), new Vector3(0, 0.8, 0.8), new Vector3(0.46f, 0.932, 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 = 12;
|
||||||
private float energy = 0;
|
private float energy = 0;
|
||||||
private boolean doTransfer = false;
|
private boolean doTransfer = false;
|
||||||
|
|
||||||
|
@ -42,10 +47,12 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
|
boolean doPacketUpdate = this.getEnergyStored() > 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only transfer if it is the bottom controlling Tesla tower.
|
* Only transfer if it is the bottom controlling Tesla tower.
|
||||||
*/
|
*/
|
||||||
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.getEnergyStored() > 0 && (this.doTransfer || this.worldObj.isRemote) && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
|
||||||
{
|
{
|
||||||
Set<ITesla> transferTeslaCoils = new HashSet<ITesla>();
|
Set<ITesla> transferTeslaCoils = new HashSet<ITesla>();
|
||||||
|
|
||||||
|
@ -71,8 +78,10 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
|
|
||||||
for (ITesla tesla : transferTeslaCoils)
|
for (ITesla tesla : transferTeslaCoils)
|
||||||
{
|
{
|
||||||
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)));
|
if (this.ticks % 20 == 0)
|
||||||
this.transfer(-transferEnergy);
|
{
|
||||||
|
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergyStored() / 10, (float) (1 - 0.2 * (this.dyeID / 16)));
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 teslaVector = new Vector3((TileEntity) tesla);
|
Vector3 teslaVector = new Vector3((TileEntity) tesla);
|
||||||
|
|
||||||
|
@ -81,15 +90,10 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
teslaVector = new Vector3(((TileEntityTesla) tesla).getControllingTelsa());
|
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);
|
||||||
{
|
|
||||||
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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)));
|
||||||
|
this.transfer(-transferEnergy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,8 +154,8 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
*/
|
*/
|
||||||
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
|
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
|
||||||
|
|
||||||
furnaceTile.furnaceBurnTime++;
|
furnaceTile.furnaceBurnTime += 2;
|
||||||
this.transfer(-ResonantInduction.POWER_PER_COAL / 22);
|
this.transfer(-ResonantInduction.POWER_PER_COAL / 20);
|
||||||
|
|
||||||
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
|
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
|
||||||
{
|
{
|
||||||
|
@ -159,12 +163,31 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.getEnergyStored() > 0 != doPacketUpdate)
|
||||||
|
{
|
||||||
|
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
return null;
|
return PacketHandler.getTileEntityPacket(this, this.getEnergyStored(), this.dyeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(ByteArrayDataInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.energy = input.readFloat();
|
||||||
|
this.dyeID = input.readInt();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isController()
|
private boolean isController()
|
||||||
|
@ -314,6 +337,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
public void setDye(int id)
|
public void setDye(int id)
|
||||||
{
|
{
|
||||||
this.dyeID = id;
|
this.dyeID = id;
|
||||||
|
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue