Conflicts:
	README.md
This commit is contained in:
Aidan Brady 2013-08-01 23:25:15 -04:00
commit ae666900be
25 changed files with 1543 additions and 2 deletions

View file

@ -1,6 +1,6 @@
Resonant Induction
======
Resonsnt Induction is a Minecraft mod focusing on eletricity and the manipulation of it to bring forth new contraptions into Minecraft.
Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!
### Developers
* Calclavia
@ -9,5 +9,14 @@ Resonsnt Induction is a Minecraft mod focusing on eletricity and the manipulatio
### Artist
* Archadia
### Compilation
In order to compile the source code into binary form, you must have a working Minecraft Forge workspace.
1. Install Minecraft Forge source (http://files.minecraftforge.net).
2. Clone the repository and copy all source code into the MCP "src" folder.
3. Run the "recompile" script and run then run the "reobfuscate_srg" script in the MCP folder.
4. Zip up everything in the output folder ("reobf") into a jar file.
5. Install it into Minecraft just like any other Forge mod.
### License
Resonant Induction is under the Calclavia Mod License (http://calclavia.com/license/cl).
"Resonant Induction" is under the Calclavia Mod License (http://calclavia.com/license/cl).

7
build.properties Normal file
View file

@ -0,0 +1,7 @@
dir.development=./
dir.mcp=${dir.development}forge/mcp
version.minecraft=1.6.2
version.mod.major=0
version.mod.minor=0
version.mod.revis=1
version.universalelectricity=2.0.0

80
build.xml Normal file
View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Potential Expansion" default="build">
<property file="build.properties" />
<property environment="env" />
<property name="file.main" value="Potential_Expansion.jar" />
<property name="file.api" value="Potential_Expansion_API.zip" />
<property name="file.mainfile" value="Potential_Expansion_v${version.mod.major}.${version.mod.minor}.${version.mod.revis}.${env.BUILD_NUMBER}.jar" />
<property name="file.apifile" value="Potential_Expansion_API_v${version.mod.major}.${version.mod.minor}.${version.mod.revis}.${env.BUILD_NUMBER}.zip" />
<target name="build">
<copy todir="${dir.development}">
<fileset dir="../Minecraft Forge Latest/" />
</copy>
<copy todir="${dir.mcp}/src/minecraft">
<fileset dir="${dir.development}src">
<exclude name=".git/**"/>
<exclude name="**/*.xml"/>
</fileset>
</copy>
<mkdir dir="DevContents" />
<mkdir dir="UeContents" />
<mkdir dir="BcContents" />
<mkdir dir="output" />
<replace dir="${dir.mcp}/src/minecraft" token="@MAJOR@" value="${version.mod.major}" />
<replace dir="${dir.mcp}/src/minecraft" token="@MINOR@" value="${version.mod.minor}" />
<replace dir="${dir.mcp}/src/minecraft" token="@REVIS@" value="${version.mod.revis}" />
<replace dir="${dir.mcp}/src/minecraft" token="@BUILD@" value="${env.BUILD_NUMBER}" />
<exec dir="${dir.mcp}" executable="cmd" osfamily="windows">
<arg line="recompile.bat" />
</exec>
<exec dir="${dir.mcp}" executable="cmd" osfamily="windows">
<arg line="reobfuscate_srg.bat" />
</exec>
<exec dir="${dir.mcp}" executable="bash" osfamily="unix">
<arg line="recompile.sh" />
</exec>
<exec dir="${dir.mcp}" executable="bash" osfamily="unix">
<arg line="reobfuscate_srg.sh" />
</exec>
<copy todir="JarContents">
<fileset dir="${dir.mcp}/reobf/minecraft" excludes=".git/**" />
<fileset dir="${dir.development}resources">
<exclude name=".git/**"/>
<exclude name="**/*.java"/>
<exclude name="**/*.xml"/>
</fileset>
</copy>
<!--
<copy todir="APIContents">
<fileset dir="${dir.development}src/powerexpansion/api" excludes=".git/**" />
</copy>-->
<jar destfile="output/${file.mainfile}">
<fileset dir="JarContents" />
</jar><!--
<zip destfile="output/${file.apifile}">
<fileset dir="APIContents" />
</zip>-->
<copy todir="output" file="build.properties" />
<!-- OUTPUT LATEST JAR AND ZIP FILES -->
<jar destfile="${file.main}">
<fileset dir="JarContents" />
</jar><!--
<zip destfile="${file.api}">
<fileset dir="APIContents" />
</zip>-->
</target>
</project>

View file

@ -0,0 +1,5 @@
# English @author Calclavia
itemGroup.resonantinduction=Resonant Induction
tile.resonantinduction\:tesla.name=Tesla Coil

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,44 @@
/**
*
*/
package resonantinduction;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import resonantinduction.base.Vector3;
import resonantinduction.fx.FXElectricBolt;
import resonantinduction.render.BlockRenderingHandler;
import resonantinduction.render.RenderTesla;
import resonantinduction.tesla.TileEntityTesla;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Calclavia
*
*/
@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy
{
@Override
public void registerRenderers()
{
RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
@Override
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
{
Minecraft.getMinecraft().effectRenderer.addEffect(new FXElectricBolt(world, start, target).setColor(r, g, b));
}
}

View file

@ -0,0 +1,39 @@
/**
*
*/
package resonantinduction;
import resonantinduction.base.Vector3;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
/**
* @author Calclavia
*
*/
public class CommonProxy implements IGuiHandler
{
public void registerRenderers()
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
{
}
}

View file

@ -0,0 +1,14 @@
/**
*
*/
package resonantinduction;
/**
* @author Calclavia
*
*/
public interface ITesla
{
public void transfer(float transferEnergy);
}

View file

@ -0,0 +1,31 @@
/**
*
*/
package resonantinduction;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
/**
* @author Calclavia
*
*/
public class PacketHandler implements IPacketHandler
{
/*
* (non-Javadoc)
*
* @see
* cpw.mods.fml.common.network.IPacketHandler#onPacketData(net.minecraft.network.INetworkManager
* , net.minecraft.network.packet.Packet250CustomPayload, cpw.mods.fml.common.network.Player)
*/
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
{
}
}

View file

@ -0,0 +1,161 @@
package resonantinduction;
import java.io.File;
import java.util.Arrays;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.ShapedOreRecipe;
import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
/**
* @author Calclavia
*
*/
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = ResonantInduction.VERSION)
@NetworkMod(channels = ResonantInduction.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class ResonantInduction
{
/**
* Mod Information
*/
public static final String ID = "resonantinduction";
public static final String NAME = "Resonant Induction";
public static final String CHANNEL = "resonantinduc";
public static final String MAJOR_VERSION = "@MAJOR@";
public static final String MINOR_VERSION = "@MINOR@";
public static final String REVISION_VERSION = "@REVIS@";
public static final String BUILD_VERSION = "@BUILD@";
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
@Instance(ID)
public static ResonantInduction INSTNACE;
@SidedProxy(clientSide = ID + ".ClientProxy", serverSide = ID + ".CommonProxy")
public static CommonProxy proxy;
@Mod.Metadata(ID)
public static ModMetadata metadata;
public static final Logger LOGGER = Logger.getLogger(NAME);
/**
* Directory Information
*/
public static final String DOMAIN = "resonantinduction";
public static final String PREFIX = DOMAIN + ":";
public static final String DIRECTORY = "/assets/" + DOMAIN + "/";
public static final String TEXTURE_DIRECTORY = "textures/";
public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "/gui";
public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
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 = DIRECTORY + "languages/";
public static final String[] LANGUAGES = new String[] { "en_US" };
/**
* Settings
*/
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), NAME + ".cfg"));
public static float POWER_PER_COAL = 5;
/** Block ID by Jyzarc */
private static final int BLOCK_ID_PREFIX = 3200;
/** Item ID by Horfius */
private static final int ITEM_ID_PREFIX = 20150;
private static int NEXT_BLOCK_ID = BLOCK_ID_PREFIX;
private static int NEXT_ITEM_ID = ITEM_ID_PREFIX;
public static int getNextBlockID()
{
return NEXT_BLOCK_ID++;
}
public static int getNextItemID()
{
return NEXT_ITEM_ID++;
}
/**
* Blocks and Items
*/
public static Block blockTesla;
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
LOGGER.setParent(FMLLog.getLogger());
CONFIGURATION.load();
POWER_PER_COAL = (float) CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Coal Wattage", POWER_PER_COAL).getDouble(POWER_PER_COAL);
blockTesla = new BlockTesla(getNextBlockID());
CONFIGURATION.save();
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
this.proxy.registerRenderers();
TabRI.ITEMSTACK = new ItemStack(blockTesla);
}
@EventHandler
public void init(FMLInitializationEvent evt)
{
LOGGER.fine("Languages Loaded:" + loadLanguages(LANGUAGE_DIRECTORY, LANGUAGES));
metadata.modId = ID;
metadata.name = NAME;
metadata.description = "Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!";
metadata.url = "http://universalelectricity.com";
metadata.version = VERSION + BUILD_VERSION;
metadata.authorList = Arrays.asList(new String[] { "Calclavia", "Aidancbrady" });
metadata.logoFile = "/";
metadata.credits = "Thanks to Archadia for the assets.";
metadata.autogenerated = true;
}
@EventHandler
public void preInit(FMLPostInitializationEvent evt)
{
/**
* Recipes
*/
/** by Jyzarc */
GameRegistry.addRecipe(new ShapedOreRecipe(blockTesla, "EEE", " C ", " I ", 'E', Item.eyeOfEnder, 'C', Item.redstone, 'I', Block.blockIron));
}
public static int loadLanguages(String languagePath, String[] languageSupported)
{
int loaded = 0;
for (String language : languageSupported)
{
LanguageRegistry.instance().loadLocalization(languagePath + language + ".properties", language, false);
loaded++;
}
return loaded;
}
}

View file

@ -0,0 +1,30 @@
/**
*
*/
package resonantinduction;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
/**
* @author Calclavia
*
*/
public class TabRI extends CreativeTabs
{
public static final TabRI INSTANCE = new TabRI(CreativeTabs.getNextID(), ResonantInduction.ID);
public static ItemStack ITEMSTACK;
public TabRI(int par1, String par2Str)
{
super(par1, par2Str);
}
@Override
public ItemStack getIconItemStack()
{
return ITEMSTACK;
}
}

View file

@ -0,0 +1,25 @@
/**
*
*/
package resonantinduction.base;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.Configuration;
import resonantinduction.ResonantInduction;
import resonantinduction.TabRI;
/**
* @author Calclavia
*
*/
public class BlockBase extends Block
{
public BlockBase(String name, int id, Material material)
{
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), material);
this.setCreativeTab(TabRI.INSTANCE);
this.setUnlocalizedName(ResonantInduction.PREFIX + name);
this.func_111022_d(ResonantInduction.PREFIX + name);
}
}

View file

@ -0,0 +1,32 @@
/**
*
*/
package resonantinduction.base;
import net.minecraft.tileentity.TileEntity;
/**
* @author Calclavia
*
*/
public class TileEntityBase extends TileEntity
{
protected long ticks = 0;
public void initiate()
{
}
@Override
public void updateEntity()
{
super.updateEntity();
if (this.ticks++ == 0)
{
this.initiate();
}
}
}

View file

@ -0,0 +1,130 @@
/**
*
*/
package resonantinduction.base;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
/**
* @author Calclavia
*
*/
public class Vector3
{
public double x, y, z;
public Vector3(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
public Vector3()
{
this(0, 0, 0);
}
public Vector3(double amount)
{
this(amount, amount, amount);
}
public Vector3(Vector3 clone)
{
this(clone.x, clone.y, clone.z);
}
public Vector3(TileEntity tileEntity)
{
this(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
}
public Vector3(Entity entity)
{
this(entity.posX, entity.posY, entity.posZ);
}
public Vector3 scale(double amount)
{
return this.scale(new Vector3(amount));
}
public Vector3 scale(Vector3 amount)
{
return new Vector3(this.x * amount.x, this.y * amount.y, this.z * amount.z);
}
public Vector3 difference(Vector3 compare)
{
return new Vector3(compare.x - this.x, compare.y - this.y, compare.z - this.z);
}
public double getMagnitudeSquared()
{
return this.x * this.x + this.y * this.y + this.z * this.z;
}
public double getMagnitude()
{
return Math.sqrt(this.getMagnitudeSquared());
}
public double distance(Vector3 compare)
{
Vector3 difference = this.difference(compare);
return difference.getMagnitude();
}
/**
* Cross product functions
*
* @return The cross product between this vector and another.
*/
public Vector3 crossProduct(Vector3 vec2)
{
return new Vector3(this.y * vec2.z - this.z * vec2.y, this.z * vec2.x - this.x * vec2.z, this.x * vec2.y - this.y * vec2.x);
}
public Vector3 xCrossProduct()
{
return new Vector3(0.0D, this.z, -this.y);
}
public Vector3 zCrossProduct()
{
return new Vector3(-this.y, this.x, 0.0D);
}
public double dotProduct(Vector3 vec2)
{
return this.x * vec2.x + this.y * vec2.y + this.z * vec2.z;
}
/**
* @return The perpendicular vector.
*/
public Vector3 getPerpendicular()
{
if (this.z == 0.0F)
{
return this.zCrossProduct();
}
return this.xCrossProduct();
}
/**
* @return True if this Vector3 is zero.
*/
public boolean isZero()
{
return (this.x == 0.0F) && (this.y == 0.0F) && (this.z == 0.0F);
}
public Vector3 translate(Vector3 offset)
{
return new Vector3(this.x + offset.x, this.y + offset.y, this.z + offset.z);
}
}

View file

@ -0,0 +1,169 @@
/**
*
*/
package resonantinduction.fx;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction;
import resonantinduction.base.Vector3;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Electric shock Fxs.
*
* @author Calclavia
*
*/
@SideOnly(Side.CLIENT)
public class FXElectricBolt extends EntityFX
{
public static final ResourceLocation FADED_SPHERE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "fadedSphere.png");
public static final ResourceLocation PARTICLE_RESOURCE = new ResourceLocation("textures/particle/particles.png");
private final float boltWidth = 0.05f;
private BoltPoint start;
private BoltPoint target;
private double boltLength;
private int segmentCount;
private Set<BoltSegment> segments = new HashSet<BoltSegment>();
public FXElectricBolt(World world, Vector3 start, Vector3 target)
{
super(world, start.x, start.y, start.z);
this.start = new BoltPoint(target);
this.target = new BoltPoint(target);
this.boltLength = start.distance(target);
this.segments.add(new BoltSegment(this.start, this.target));
}
public FXElectricBolt setColor(float r, float g, float b)
{
this.particleRed = r;
this.particleGreen = g;
this.particleBlue = b;
return this;
}
public void calculate()
{
}
@Override
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
}
@Override
public void renderParticle(Tessellator tessellator, float partialFrame, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
tessellator.draw();
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(FADED_SPHERE);
GL11.glPushMatrix();
/**
* Do rendering here.
*/
GL11.glDepthMask(true);
GL11.glEnable(3042);
Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch);
int renderLength = (int) (this.particleAge + partialFrame + this.boltLength * 3) / (int) (this.boltLength * 3) * this.segmentCount;
for (BoltSegment segment : this.segments)
{
// TODO: Weight? Scale
double width = this.width * (new Vector3(player).distance(segment.start) / 5 + 1);
Vector3 prevDiff = playerVector.crossProduct(segment.prevDiff).scale(this.width);
Vector3 nextDiff = playerVector.crossProduct(segment.nextDiff).scale(this.width);
Vector3 renderStart = segment.start;
Vector3 renderEnd = segment.end;
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha);
float rx1 = (float) (renderStart.x - interpPosX);
float ry1 = (float) (renderStart.y - interpPosY);
float rz1 = (float) (renderStart.z - interpPosZ);
float rx2 = (float) (renderEnd.x - interpPosX);
float ry2 = (float) (renderEnd.y - interpPosY);
float rz2 = (float) (renderEnd.z - interpPosZ);
tessellator.addVertexWithUV(rx2 - nextDiff.x, ry2 - nextDiff.y, rz2 - nextDiff.z, 0.5D, 0.0D);
tessellator.addVertexWithUV(rx1 - prevDiff.x, ry1 - prevDiff.y, rz1 - prevDiff.z, 0.5D, 0.0D);
tessellator.addVertexWithUV(rx1 + prevDiff.x, ry1 + prevDiff.y, rz1 + prevDiff.z, 0.5D, 1.0D);
tessellator.addVertexWithUV(rx2 + nextDiff.x, ry2 + nextDiff.y, rz2 + nextDiff.z, 0.5D, 1.0D);
}
GL11.glDisable(3042);
GL11.glDepthMask(false);
GL11.glPopMatrix();
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(PARTICLE_RESOURCE);
tessellator.startDrawingQuads();
}
@Override
public boolean shouldRenderInPass(int pass)
{
return pass == 2;
}
public class BoltPoint extends Vector3
{
public Vector3 base;
public Vector3 offset;
public BoltPoint(Vector3 base, Vector3 offset)
{
super(base.translate(offset));
this.base = base;
this.offset = offset;
}
public BoltPoint(Vector3 base)
{
this(base, new Vector3());
}
}
public class BoltSegment
{
public BoltPoint start;
public BoltPoint end;
public BoltSegment prev;
public BoltSegment next;
public Vector3 prevDiff;
public Vector3 nextDiff;
public BoltSegment(BoltPoint start, BoltPoint end)
{
this.start = start;
this.end = end;
}
}
}

View file

@ -0,0 +1,206 @@
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
ModelRenderer Base;
ModelRenderer BackBottomSide;
ModelRenderer FrontBottomSide;
ModelRenderer SlantedFrontPanel;
ModelRenderer SlantedPanelBase;
ModelRenderer TopBase;
ModelRenderer FrontTopPole;
ModelRenderer SideTopPole;
ModelRenderer LeftAntennae;
ModelRenderer RightAntennae;
ModelRenderer BackAntennae;
ModelRenderer FrontAntennae;
ModelRenderer TopBasePanel;
ModelRenderer ChargePack;
ModelRenderer WireLeftBottomPole;
ModelRenderer WireLeftTopPole;
ModelRenderer WireRightBottomPole;
ModelRenderer WireRightTopPole;
ModelRenderer BackRightConnector;
ModelRenderer BackLeftConnector;
ModelRenderer FrontLeftConnector;
ModelRenderer FrontRightConnector;
public ModelTeslaBottom()
{
textureWidth = 128;
textureHeight = 128;
Base = new ModelRenderer(this, 0, 0);
Base.addBox(0F, 0F, 0F, 9, 10, 9);
Base.setRotationPoint(-4.5F, 14F, -4.5F);
Base.setTextureSize(128, 128);
Base.mirror = true;
setRotation(Base, 0F, 0F, 0F);
BackBottomSide = new ModelRenderer(this, 38, 0);
BackBottomSide.addBox(0F, 0F, 0F, 11, 7, 2);
BackBottomSide.setRotationPoint(-5.5F, 17F, 1F);
BackBottomSide.setTextureSize(128, 128);
BackBottomSide.mirror = true;
setRotation(BackBottomSide, 0F, 0F, 0F);
FrontBottomSide = new ModelRenderer(this, 38, 0);
FrontBottomSide.addBox(0F, 0F, 0F, 11, 7, 2);
FrontBottomSide.setRotationPoint(-5.5F, 17F, -3F);
FrontBottomSide.setTextureSize(128, 128);
FrontBottomSide.mirror = true;
setRotation(FrontBottomSide, 0F, 0F, 0F);
SlantedFrontPanel = new ModelRenderer(this, 38, 10);
SlantedFrontPanel.addBox(0F, 0F, 0F, 4, 6, 2);
SlantedFrontPanel.setRotationPoint(-2F, 17F, -4F);
SlantedFrontPanel.setTextureSize(128, 128);
SlantedFrontPanel.mirror = true;
setRotation(SlantedFrontPanel, -0.4234231F, 0F, 0F);
SlantedPanelBase = new ModelRenderer(this, 51, 10);
SlantedPanelBase.addBox(0F, 0F, 0F, 6, 3, 2);
SlantedPanelBase.setRotationPoint(-3F, 21F, -6.5F);
SlantedPanelBase.setTextureSize(128, 128);
SlantedPanelBase.mirror = true;
setRotation(SlantedPanelBase, 0F, 0F, 0F);
TopBase = new ModelRenderer(this, 0, 20);
TopBase.addBox(0F, 0F, 0F, 6, 5, 6);
TopBase.setRotationPoint(-3F, 9F, -3F);
TopBase.setTextureSize(128, 128);
TopBase.mirror = true;
setRotation(TopBase, 0F, 0F, 0F);
FrontTopPole = new ModelRenderer(this, 0, 32);
FrontTopPole.addBox(0F, 0F, 0F, 2, 2, 8);
FrontTopPole.setRotationPoint(-1F, 10F, -4F);
FrontTopPole.setTextureSize(128, 128);
FrontTopPole.mirror = true;
setRotation(FrontTopPole, 0F, 0F, 0F);
SideTopPole = new ModelRenderer(this, 0, 43);
SideTopPole.addBox(0F, 0F, 0F, 8, 2, 2);
SideTopPole.setRotationPoint(-4F, 10F, -1F);
SideTopPole.setTextureSize(128, 128);
SideTopPole.mirror = true;
setRotation(SideTopPole, 0F, 0F, 0F);
LeftAntennae = new ModelRenderer(this, 25, 20);
LeftAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
LeftAntennae.setRotationPoint(-4.5F, 8.8F, -0.5F);
LeftAntennae.setTextureSize(128, 128);
LeftAntennae.mirror = true;
setRotation(LeftAntennae, 0F, 0F, 0F);
RightAntennae = new ModelRenderer(this, 30, 20);
RightAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
RightAntennae.setRotationPoint(3.5F, 8.8F, -0.5F);
RightAntennae.setTextureSize(128, 128);
RightAntennae.mirror = true;
setRotation(RightAntennae, 0F, 0F, 0F);
BackAntennae = new ModelRenderer(this, 25, 25);
BackAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
BackAntennae.setRotationPoint(-0.5F, 8.8F, 3.5F);
BackAntennae.setTextureSize(128, 128);
BackAntennae.mirror = true;
setRotation(BackAntennae, 0F, 0F, 0F);
FrontAntennae = new ModelRenderer(this, 30, 25);
FrontAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
FrontAntennae.setRotationPoint(-0.5F, 8.8F, -4.5F);
FrontAntennae.setTextureSize(128, 128);
FrontAntennae.mirror = true;
setRotation(FrontAntennae, 0F, 0F, 0F);
TopBasePanel = new ModelRenderer(this, 36, 20);
TopBasePanel.addBox(0F, 0F, 0F, 7, 1, 7);
TopBasePanel.setRotationPoint(-3.5F, 13F, -3.5F);
TopBasePanel.setTextureSize(128, 128);
TopBasePanel.mirror = true;
setRotation(TopBasePanel, 0F, 0F, 0F);
ChargePack = new ModelRenderer(this, 37, 29);
ChargePack.addBox(0F, 0F, 0F, 6, 7, 3);
ChargePack.setRotationPoint(-3F, 17F, 3.5F);
ChargePack.setTextureSize(128, 128);
ChargePack.mirror = true;
setRotation(ChargePack, 0F, 0F, 0F);
WireLeftBottomPole = new ModelRenderer(this, 21, 32);
WireLeftBottomPole.addBox(0F, 0F, 0F, 1, 10, 1);
WireLeftBottomPole.setRotationPoint(-2F, 11.86667F, 6F);
WireLeftBottomPole.setTextureSize(128, 128);
WireLeftBottomPole.mirror = true;
setRotation(WireLeftBottomPole, 0F, 0F, 0F);
WireLeftTopPole = new ModelRenderer(this, 26, 32);
WireLeftTopPole.addBox(0F, 0F, 0F, 1, 1, 4);
WireLeftTopPole.setRotationPoint(-2F, 10.86667F, 3F);
WireLeftTopPole.setTextureSize(128, 128);
WireLeftTopPole.mirror = true;
setRotation(WireLeftTopPole, 0F, 0F, 0F);
WireRightBottomPole = new ModelRenderer(this, 21, 32);
WireRightBottomPole.addBox(0F, 0F, 0F, 1, 10, 1);
WireRightBottomPole.setRotationPoint(1F, 11.86667F, 6F);
WireRightBottomPole.setTextureSize(128, 128);
WireRightBottomPole.mirror = true;
setRotation(WireRightBottomPole, 0F, 0F, 0F);
WireRightTopPole = new ModelRenderer(this, 26, 38);
WireRightTopPole.addBox(0F, 0F, 0F, 1, 1, 4);
WireRightTopPole.setRotationPoint(1F, 10.86667F, 3F);
WireRightTopPole.setTextureSize(128, 128);
WireRightTopPole.mirror = true;
setRotation(WireRightTopPole, 0F, 0F, 0F);
BackRightConnector = new ModelRenderer(this, 65, 0);
BackRightConnector.addBox(0F, 0F, 0F, 1, 1, 1);
BackRightConnector.setRotationPoint(1F, 8F, 1.066667F);
BackRightConnector.setTextureSize(128, 128);
BackRightConnector.mirror = true;
setRotation(BackRightConnector, 0F, 0F, 0F);
BackLeftConnector = new ModelRenderer(this, 65, 0);
BackLeftConnector.addBox(0F, 0F, 0F, 1, 1, 1);
BackLeftConnector.setRotationPoint(-2F, 8F, 1F);
BackLeftConnector.setTextureSize(128, 128);
BackLeftConnector.mirror = true;
setRotation(BackLeftConnector, 0F, 0F, 0F);
FrontLeftConnector = new ModelRenderer(this, 65, 0);
FrontLeftConnector.addBox(0F, 0F, 0F, 1, 1, 1);
FrontLeftConnector.setRotationPoint(-2F, 8F, -2F);
FrontLeftConnector.setTextureSize(128, 128);
FrontLeftConnector.mirror = true;
setRotation(FrontLeftConnector, 0F, 0F, 0F);
FrontRightConnector = new ModelRenderer(this, 65, 0);
FrontRightConnector.addBox(0F, 0F, 0F, 1, 1, 1);
FrontRightConnector.setRotationPoint(1F, 8F, -2F);
FrontRightConnector.setTextureSize(128, 128);
FrontRightConnector.mirror = true;
setRotation(FrontRightConnector, 0F, 0F, 0F);
}
public void render(float f5)
{
Base.render(f5);
BackBottomSide.render(f5);
FrontBottomSide.render(f5);
SlantedFrontPanel.render(f5);
SlantedPanelBase.render(f5);
TopBase.render(f5);
FrontTopPole.render(f5);
SideTopPole.render(f5);
LeftAntennae.render(f5);
RightAntennae.render(f5);
BackAntennae.render(f5);
FrontAntennae.render(f5);
TopBasePanel.render(f5);
ChargePack.render(f5);
WireLeftBottomPole.render(f5);
WireLeftTopPole.render(f5);
WireRightBottomPole.render(f5);
WireRightTopPole.render(f5);
BackRightConnector.render(f5);
BackLeftConnector.render(f5);
FrontLeftConnector.render(f5);
FrontRightConnector.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -0,0 +1,215 @@
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
ModelRenderer Base;
ModelRenderer Collumn1;
ModelRenderer Collumn2;
ModelRenderer CrossCollumn1;
ModelRenderer Collumn3;
ModelRenderer Ball;
ModelRenderer Plate;
ModelRenderer TopBase;
ModelRenderer FrontPole;
ModelRenderer SidePole;
ModelRenderer FrontAntennae;
ModelRenderer BackAntennae;
ModelRenderer LeftAntennae;
ModelRenderer RightAntennae;
ModelRenderer CrossCollumn2;
ModelRenderer CrossCollumn3;
ModelRenderer Collumn4;
ModelRenderer CrossCollumn4;
ModelRenderer BallStand;
ModelRenderer FrontTopLeftPole;
ModelRenderer FrontTopRightPole;
ModelRenderer SideTopFirstPole;
ModelRenderer SodeTopLastPole;
public ModelTeslaMiddle()
{
textureWidth = 128;
textureHeight = 128;
Base = new ModelRenderer(this, 0, 0);
Base.addBox(0F, 0F, 0F, 6, 6, 6);
Base.setRotationPoint(-3F, 18F, -3F);
Base.setTextureSize(128, 128);
Base.mirror = true;
setRotation(Base, 0F, 0F, 0F);
Collumn1 = new ModelRenderer(this, 0, 20);
Collumn1.addBox(0F, 0F, 0F, 1, 4, 1);
Collumn1.setRotationPoint(-3F, 14F, -3F);
Collumn1.setTextureSize(128, 128);
Collumn1.mirror = true;
setRotation(Collumn1, 0F, 0F, 0F);
Collumn2 = new ModelRenderer(this, 0, 20);
Collumn2.addBox(0F, 0F, 0F, 1, 4, 1);
Collumn2.setRotationPoint(2F, 14F, -3F);
Collumn2.setTextureSize(128, 128);
Collumn2.mirror = true;
setRotation(Collumn2, 0F, 0F, 0F);
CrossCollumn1 = new ModelRenderer(this, 5, 20);
CrossCollumn1.addBox(0F, 0F, 0F, 4, 1, 1);
CrossCollumn1.setRotationPoint(-2F, 15.5F, -3F);
CrossCollumn1.setTextureSize(128, 128);
CrossCollumn1.mirror = true;
setRotation(CrossCollumn1, 0F, 0F, 0F);
Collumn3 = new ModelRenderer(this, 0, 20);
Collumn3.addBox(0F, 0F, 0F, 1, 4, 1);
Collumn3.setRotationPoint(2F, 14F, 2F);
Collumn3.setTextureSize(128, 128);
Collumn3.mirror = true;
setRotation(Collumn3, 0F, 0F, 0F);
Ball = new ModelRenderer(this, 0, 15);
Ball.addBox(-1F, -1F, -1F, 2, 2, 2);
Ball.setRotationPoint(0F, 16F, 0F);
Ball.setTextureSize(128, 128);
Ball.mirror = true;
setRotation(Ball, 0F, 0F, 0F);
Plate = new ModelRenderer(this, 25, 0);
Plate.addBox(0F, 0F, 0F, 7, 1, 7);
Plate.setRotationPoint(-3.5F, 13F, -3.5F);
Plate.setTextureSize(128, 128);
Plate.mirror = true;
setRotation(Plate, 0F, 0F, 0F);
TopBase = new ModelRenderer(this, 25, 9);
TopBase.addBox(0F, 0F, 0F, 4, 5, 4);
TopBase.setRotationPoint(-2F, 8F, -2F);
TopBase.setTextureSize(128, 128);
TopBase.mirror = true;
setRotation(TopBase, 0F, 0F, 0F);
FrontPole = new ModelRenderer(this, 0, 26);
FrontPole.addBox(0F, 0F, 0F, 2, 2, 8);
FrontPole.setRotationPoint(-1F, 20F, -4F);
FrontPole.setTextureSize(128, 128);
FrontPole.mirror = true;
setRotation(FrontPole, 0F, 0F, 0F);
SidePole = new ModelRenderer(this, 0, 37);
SidePole.addBox(0F, 0F, 0F, 8, 2, 2);
SidePole.setRotationPoint(-4F, 20F, -1F);
SidePole.setTextureSize(128, 128);
SidePole.mirror = true;
setRotation(SidePole, 0F, 0F, 0F);
FrontAntennae = new ModelRenderer(this, 25, 19);
FrontAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
FrontAntennae.setRotationPoint(-0.5F, 18.8F, -4.466667F);
FrontAntennae.setTextureSize(128, 128);
FrontAntennae.mirror = true;
setRotation(FrontAntennae, 0F, 0F, 0F);
BackAntennae = new ModelRenderer(this, 25, 19);
BackAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
BackAntennae.setRotationPoint(-0.5F, 18.8F, 3.533333F);
BackAntennae.setTextureSize(128, 128);
BackAntennae.mirror = true;
setRotation(BackAntennae, 0F, 0F, 0F);
LeftAntennae = new ModelRenderer(this, 25, 19);
LeftAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
LeftAntennae.setRotationPoint(-4.5F, 18.8F, -0.5F);
LeftAntennae.setTextureSize(128, 128);
LeftAntennae.mirror = true;
setRotation(LeftAntennae, 0F, 0F, 0F);
RightAntennae = new ModelRenderer(this, 25, 19);
RightAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
RightAntennae.setRotationPoint(3.5F, 18.8F, -0.5F);
RightAntennae.setTextureSize(128, 128);
RightAntennae.mirror = true;
setRotation(RightAntennae, 0F, 0F, 0F);
CrossCollumn2 = new ModelRenderer(this, 30, 19);
CrossCollumn2.addBox(0F, 0F, 0F, 1, 1, 4);
CrossCollumn2.setRotationPoint(2F, 15.5F, -2F);
CrossCollumn2.setTextureSize(128, 128);
CrossCollumn2.mirror = true;
setRotation(CrossCollumn2, 0F, 0F, 0F);
CrossCollumn3 = new ModelRenderer(this, 5, 20);
CrossCollumn3.addBox(0F, 0F, 0F, 4, 1, 1);
CrossCollumn3.setRotationPoint(-2F, 15.5F, 2F);
CrossCollumn3.setTextureSize(128, 128);
CrossCollumn3.mirror = true;
setRotation(CrossCollumn3, 0F, 0F, 0F);
Collumn4 = new ModelRenderer(this, 0, 20);
Collumn4.addBox(0F, 0F, 0F, 1, 4, 1);
Collumn4.setRotationPoint(-3F, 14F, 2F);
Collumn4.setTextureSize(128, 128);
Collumn4.mirror = true;
setRotation(Collumn4, 0F, 0F, 0F);
CrossCollumn4 = new ModelRenderer(this, 30, 19);
CrossCollumn4.addBox(0F, 0F, 0F, 1, 1, 4);
CrossCollumn4.setRotationPoint(-3F, 15.5F, -2F);
CrossCollumn4.setTextureSize(128, 128);
CrossCollumn4.mirror = true;
setRotation(CrossCollumn4, 0F, 0F, 0F);
BallStand = new ModelRenderer(this, 9, 16);
BallStand.addBox(0F, 0F, 0F, 1, 1, 1);
BallStand.setRotationPoint(-0.5F, 17F, -0.5F);
BallStand.setTextureSize(128, 128);
BallStand.mirror = true;
setRotation(BallStand, 0F, 0F, 0F);
FrontTopLeftPole = new ModelRenderer(this, 42, 9);
FrontTopLeftPole.addBox(0F, 0F, 0F, 1, 4, 5);
FrontTopLeftPole.setRotationPoint(-1.5F, 9F, -2.5F);
FrontTopLeftPole.setTextureSize(128, 128);
FrontTopLeftPole.mirror = true;
setRotation(FrontTopLeftPole, 0F, 0F, 0F);
FrontTopRightPole = new ModelRenderer(this, 42, 9);
FrontTopRightPole.addBox(0F, 0F, 0F, 1, 4, 5);
FrontTopRightPole.setRotationPoint(0.5F, 9F, -2.5F);
FrontTopRightPole.setTextureSize(128, 128);
FrontTopRightPole.mirror = true;
setRotation(FrontTopRightPole, 0F, 0F, 0F);
SideTopFirstPole = new ModelRenderer(this, 42, 19);
SideTopFirstPole.addBox(0F, 0F, 0F, 5, 4, 1);
SideTopFirstPole.setRotationPoint(-2.5F, 9F, -1.5F);
SideTopFirstPole.setTextureSize(128, 128);
SideTopFirstPole.mirror = true;
setRotation(SideTopFirstPole, 0F, 0F, 0F);
SodeTopLastPole = new ModelRenderer(this, 42, 19);
SodeTopLastPole.addBox(0F, 0F, 0F, 5, 4, 1);
SodeTopLastPole.setRotationPoint(-2.5F, 9F, 0.5F);
SodeTopLastPole.setTextureSize(128, 128);
SodeTopLastPole.mirror = true;
setRotation(SodeTopLastPole, 0F, 0F, 0F);
}
public void render(float f5)
{
Base.render(f5);
Collumn1.render(f5);
Collumn2.render(f5);
CrossCollumn1.render(f5);
Collumn3.render(f5);
Ball.render(f5);
Plate.render(f5);
TopBase.render(f5);
FrontPole.render(f5);
SidePole.render(f5);
FrontAntennae.render(f5);
BackAntennae.render(f5);
LeftAntennae.render(f5);
RightAntennae.render(f5);
CrossCollumn2.render(f5);
CrossCollumn3.render(f5);
Collumn4.render(f5);
CrossCollumn4.render(f5);
BallStand.render(f5);
FrontTopLeftPole.render(f5);
FrontTopRightPole.render(f5);
SideTopFirstPole.render(f5);
SodeTopLastPole.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -0,0 +1,61 @@
/**
*
*/
package resonantinduction.render;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import resonantinduction.tesla.BlockTesla;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Calclavia
*
*/
@SideOnly(Side.CLIENT)
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)
{
if (block instanceof BlockTesla)
{
GL11.glPushMatrix();
GL11.glTranslated(0.5, 1.5, 0.5);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(RenderTesla.TEXTURE_BOTTOM);
RenderTesla.MODEL_BOTTOM.render(0.0625f);
GL11.glPopMatrix();
}
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
return false;
}
@Override
public boolean shouldRender3DInInventory()
{
return true;
}
@Override
public int getRenderId()
{
return ID;
}
}

View file

@ -0,0 +1,42 @@
/**
*
*/
package resonantinduction.render;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import resonantinduction.ResonantInduction;
import resonantinduction.model.ModelTeslaBottom;
import resonantinduction.model.ModelTeslaMiddle;
/**
* @author Calclavia
*
*/
@SideOnly(Side.CLIENT)
public class RenderTesla extends TileEntitySpecialRenderer
{
public static final ResourceLocation TEXTURE_BOTTOM = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "tesla_bottom.png");
public static final ResourceLocation TEXTURE_MIDDILE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "tesla_middile.png");
public static final ResourceLocation TEXTURE_TOP = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "tesla_bottom.png");
public static final ModelTeslaBottom MODEL_BOTTOM = new ModelTeslaBottom();
public static final ModelTeslaMiddle MODEL_MIDDILE = new ModelTeslaMiddle();
@Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
this.func_110628_a(TEXTURE_BOTTOM);
MODEL_BOTTOM.render(0.0625f);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,53 @@
/**
*
*/
package resonantinduction.tesla;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase;
import resonantinduction.render.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Calclavia
*
*/
public class BlockTesla extends BlockBase implements ITileEntityProvider
{
public BlockTesla(int id)
{
super("tesla", id, Material.iron);
this.func_111022_d(ResonantInduction.PREFIX + "machine");
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileEntityTesla();
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.INSTANCE.getRenderId();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
}

View file

@ -0,0 +1,68 @@
/**
*
*/
package resonantinduction.tesla;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import resonantinduction.ITesla;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
/**
* @author Calclavia
*
*/
public class TeslaGrid
{
private static final TeslaGrid INSTANCE_CLIENT = new TeslaGrid();
private static final TeslaGrid INSTANCE_SERVER = new TeslaGrid();
private final Set<ITesla> tileEntities = new HashSet<ITesla>();
public void register(ITesla iTesla)
{
Iterator<ITesla> it = this.tileEntities.iterator();
while (it.hasNext())
{
ITesla tesla = it.next();
if (tesla instanceof TileEntity)
{
if (!((TileEntity) tesla).isInvalid())
{
continue;
}
}
it.remove();
}
this.tileEntities.add(iTesla);
}
public void unregister(ITesla iTesla)
{
this.tileEntities.remove(iTesla);
}
public Set<ITesla> get()
{
return this.tileEntities;
}
public static TeslaGrid instance()
{
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
{
return INSTANCE_SERVER;
}
return INSTANCE_CLIENT;
}
}

View file

@ -0,0 +1,120 @@
/**
*
*/
package resonantinduction.tesla;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.BlockFurnace;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import resonantinduction.ITesla;
import resonantinduction.ResonantInduction;
import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3;
/**
* @author Calclavia
*
*/
public class TileEntityTesla extends TileEntityBase implements ITesla
{
private float energy = 0;
private boolean doTransfer = false;
@Override
public void initiate()
{
TeslaGrid.instance().register(this);
}
@Override
public void updateEntity()
{
super.updateEntity();
if (this.ticks % 2 == 0 && this.getEnergyStored() > 0 && this.doTransfer)
{
Set<ITesla> transferTeslaCoils = new HashSet<ITesla>();
for (ITesla tesla : TeslaGrid.instance().get())
{
if (new Vector3((TileEntity) tesla).distance(new Vector3(this)) < this.getRange())
{
transferTeslaCoils.add(tesla);
}
}
if (transferTeslaCoils.size() > 0)
{
float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size();
for (ITesla tesla : transferTeslaCoils)
{
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)));
this.transfer(-transferEnergy);
}
}
}
/**
* Draws power from furnace below it.
*
* @author Calclavia
*/
TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
if (tileEntity instanceof TileEntityFurnace)
{
TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
if (furnaceTile.furnaceBurnTime == 0)
{
int burnTime = TileEntityFurnace.getItemBurnTime(furnaceTile.getStackInSlot(1));
if (burnTime > 0)
{
furnaceTile.decrStackSize(1, 1);
furnaceTile.furnaceBurnTime = burnTime;
}
}
else
{
this.transfer(ResonantInduction.POWER_PER_COAL / 20);
furnaceTile.furnaceBurnTime--;
}
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
{
BlockFurnace.updateFurnaceBlockState(furnaceTile.furnaceBurnTime > 0, furnaceTile.worldObj, furnaceTile.xCoord, furnaceTile.yCoord, furnaceTile.zCoord);
}
}
}
@Override
public void transfer(float transferEnergy)
{
this.energy += transferEnergy;
this.doTransfer = true;
}
public float getEnergyStored()
{
return this.energy;
}
public int getRange()
{
return 8;
}
@Override
public void invalidate()
{
TeslaGrid.instance().unregister(this);
super.invalidate();
}
}