Got Tesla transfer working
This commit is contained in:
parent
97c117b7c3
commit
d6efc5540b
10 changed files with 47 additions and 14 deletions
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
|
@ -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 resonantinduction.base.Vector3;
|
||||||
import resonantinduction.render.BlockRenderingHandler;
|
import resonantinduction.render.BlockRenderingHandler;
|
||||||
import resonantinduction.render.RenderTesla;
|
import resonantinduction.render.RenderTesla;
|
||||||
import resonantinduction.tesla.TileEntityTesla;
|
import resonantinduction.tesla.TileEntityTesla;
|
||||||
|
@ -33,4 +34,9 @@ public class ClientProxy extends CommonProxy
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package resonantinduction;
|
package resonantinduction;
|
||||||
|
|
||||||
|
import resonantinduction.base.Vector3;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
@ -30,4 +31,9 @@ public class CommonProxy implements IGuiHandler
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ResonantInduction
|
||||||
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
|
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
|
||||||
public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "models/";
|
public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "models/";
|
||||||
|
|
||||||
public static final String LANGUAGE_DIRECTORY = TEXTURE_DIRECTORY + "languages/";
|
public static final String LANGUAGE_DIRECTORY = DIRECTORY + "languages/";
|
||||||
public static final String[] LANGUAGES = new String[] { "en_US" };
|
public static final String[] LANGUAGES = new String[] { "en_US" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,6 @@ public class ResonantInduction
|
||||||
CONFIGURATION.save();
|
CONFIGURATION.save();
|
||||||
|
|
||||||
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
|
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
|
||||||
|
|
||||||
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
|
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
|
||||||
this.proxy.registerRenderers();
|
this.proxy.registerRenderers();
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,6 @@ public class Vector3
|
||||||
public double distance(Vector3 compare)
|
public double distance(Vector3 compare)
|
||||||
{
|
{
|
||||||
Vector3 difference = this.difference(compare);
|
Vector3 difference = this.difference(compare);
|
||||||
return this.getMagnitude();
|
return difference.getMagnitude();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
src/resonantinduction/fx/FxElectric.java
Normal file
15
src/resonantinduction/fx/FxElectric.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package resonantinduction.fx;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Electric shock Fxs.
|
||||||
|
*
|
||||||
|
* @author Calclavia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FxElectric
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
package resonantinduction.model;
|
package resonantinduction.model;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public class ModelTeslaBottom extends ModelBase
|
public class ModelTeslaBottom extends ModelBase
|
||||||
{
|
{
|
||||||
// fields
|
// fields
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package resonantinduction.model;
|
package resonantinduction.model;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public class ModelTeslaMiddle extends ModelBase
|
public class ModelTeslaMiddle extends ModelBase
|
||||||
{
|
{
|
||||||
// fields
|
// fields
|
||||||
|
|
|
@ -24,6 +24,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
||||||
{
|
{
|
||||||
public static final BlockRenderingHandler INSTANCE = new BlockRenderingHandler();
|
public static final BlockRenderingHandler INSTANCE = new BlockRenderingHandler();
|
||||||
|
private static final int ID = RenderingRegistry.getNextAvailableRenderId();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||||
|
@ -54,7 +55,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
||||||
@Override
|
@Override
|
||||||
public int getRenderId()
|
public int getRenderId()
|
||||||
{
|
{
|
||||||
return RenderingRegistry.getNextAvailableRenderId();
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,15 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size();
|
if (transferTeslaCoils.size() > 0)
|
||||||
|
|
||||||
for (ITesla tesla : transferTeslaCoils)
|
|
||||||
{
|
{
|
||||||
tesla.transfer(transferEnergy);
|
float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size();
|
||||||
this.transfer(-transferEnergy);
|
|
||||||
|
for (ITesla tesla : transferTeslaCoils)
|
||||||
|
{
|
||||||
|
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)));
|
||||||
|
this.transfer(-transferEnergy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +69,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
{
|
{
|
||||||
TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
|
TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
|
||||||
|
|
||||||
boolean doBlockStateUpdate = false;
|
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
|
||||||
|
|
||||||
if (furnaceTile.furnaceBurnTime == 0)
|
if (furnaceTile.furnaceBurnTime == 0)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +79,6 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
furnaceTile.decrStackSize(1, 1);
|
furnaceTile.decrStackSize(1, 1);
|
||||||
furnaceTile.furnaceBurnTime = burnTime;
|
furnaceTile.furnaceBurnTime = burnTime;
|
||||||
}
|
}
|
||||||
doBlockStateUpdate = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -84,9 +86,8 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
furnaceTile.furnaceBurnTime--;
|
furnaceTile.furnaceBurnTime--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doBlockStateUpdate)
|
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
BlockFurnace.updateFurnaceBlockState(furnaceTile.furnaceBurnTime > 0, furnaceTile.worldObj, furnaceTile.xCoord, furnaceTile.yCoord, furnaceTile.zCoord);
|
BlockFurnace.updateFurnaceBlockState(furnaceTile.furnaceBurnTime > 0, furnaceTile.worldObj, furnaceTile.xCoord, furnaceTile.yCoord, furnaceTile.zCoord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,6 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
|
||||||
@Override
|
@Override
|
||||||
public void transfer(float transferEnergy)
|
public void transfer(float transferEnergy)
|
||||||
{
|
{
|
||||||
System.out.println(transferEnergy);
|
|
||||||
this.energy += transferEnergy;
|
this.energy += transferEnergy;
|
||||||
this.doTransfer = true;
|
this.doTransfer = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue