Got Tesla transfer working

This commit is contained in:
Calclavia 2013-08-01 22:19:01 -04:00
parent 97c117b7c3
commit d6efc5540b
10 changed files with 47 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -5,6 +5,7 @@ package resonantinduction;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import resonantinduction.base.Vector3;
import resonantinduction.render.BlockRenderingHandler;
import resonantinduction.render.RenderTesla;
import resonantinduction.tesla.TileEntityTesla;
@ -33,4 +34,9 @@ public class ClientProxy extends CommonProxy
return null;
}
@Override
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
{
}
}

View file

@ -3,6 +3,7 @@
*/
package resonantinduction;
import resonantinduction.base.Vector3;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
@ -30,4 +31,9 @@ public class CommonProxy implements IGuiHandler
return null;
}
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
{
}
}

View file

@ -67,7 +67,7 @@ public class ResonantInduction
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
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" };
/**
@ -111,7 +111,6 @@ public class ResonantInduction
CONFIGURATION.save();
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
this.proxy.registerRenderers();

View file

@ -48,6 +48,6 @@ public class Vector3
public double distance(Vector3 compare)
{
Vector3 difference = this.difference(compare);
return this.getMagnitude();
return difference.getMagnitude();
}
}

View file

@ -0,0 +1,15 @@
/**
*
*/
package resonantinduction.fx;
/**
* Electric shock Fxs.
*
* @author Calclavia
*
*/
public class FxElectric
{
}

View file

@ -1,8 +1,11 @@
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.ModelRenderer;
@SideOnly(Side.CLIENT)
public class ModelTeslaBottom extends ModelBase
{
// fields

View file

@ -1,8 +1,11 @@
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.ModelRenderer;
@SideOnly(Side.CLIENT)
public class ModelTeslaMiddle extends ModelBase
{
// fields

View file

@ -24,6 +24,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
{
public static final BlockRenderingHandler INSTANCE = new BlockRenderingHandler();
private static final int ID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
@ -54,7 +55,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
@Override
public int getRenderId()
{
return RenderingRegistry.getNextAvailableRenderId();
return ID;
}
}

View file

@ -46,12 +46,15 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
}
}
float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size();
for (ITesla tesla : transferTeslaCoils)
if (transferTeslaCoils.size() > 0)
{
tesla.transfer(transferEnergy);
this.transfer(-transferEnergy);
float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size();
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;
boolean doBlockStateUpdate = false;
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
if (furnaceTile.furnaceBurnTime == 0)
{
@ -76,7 +79,6 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
furnaceTile.decrStackSize(1, 1);
furnaceTile.furnaceBurnTime = burnTime;
}
doBlockStateUpdate = true;
}
else
{
@ -84,9 +86,8 @@ public class TileEntityTesla extends TileEntityBase implements ITesla
furnaceTile.furnaceBurnTime--;
}
if (doBlockStateUpdate)
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
{
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
public void transfer(float transferEnergy)
{
System.out.println(transferEnergy);
this.energy += transferEnergy;
this.doTransfer = true;
}