Merge branch 'master' of https://github.com/calclavia/Resonant-Induction
This commit is contained in:
commit
0d052c8090
6 changed files with 234 additions and 5 deletions
|
@ -19,4 +19,4 @@ In order to compile the source code into binary form, you must have a working Mi
|
||||||
5. Install it into Minecraft just like any other Forge mod.
|
5. Install it into Minecraft just like any other Forge mod.
|
||||||
|
|
||||||
### License
|
### License
|
||||||
"Resonant Induction" is under the Calclavia Mod License (http://calclavia.com/license/cl).
|
"Resonant Induction" is under the Educational Public License (http://calclavia.com/license/rpl).
|
||||||
|
|
|
@ -197,9 +197,26 @@ public class ResonantInduction
|
||||||
/**
|
/**
|
||||||
* Recipes
|
* Recipes
|
||||||
*/
|
*/
|
||||||
/** by Jyzarc */
|
/** Capacitor **/
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockTesla, "EEE", " C ", " I ", 'E', Item.eyeOfEnder, 'C', Item.redstone, 'I', Block.blockIron));
|
GameRegistry.addRecipe(new ShapedOreRecipe(itemCapacitor, "RRR", "RIR", "RRR", 'R', Item.redstone, 'I', Item.ingotIron));
|
||||||
|
|
||||||
|
/** Linker **/
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(itemLinker, " E ", "GCG", " E ", 'E', Item.eyeOfEnder, 'C', itemCapacitor, 'G', Item.ingotGold));
|
||||||
|
|
||||||
|
/** Quantum Entangler **/
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(itemQuantumEntangler, "EEE", "ILI", "EEE", 'E', Item.eyeOfEnder, 'L', itemLinker, 'I', Item.ingotIron));
|
||||||
|
|
||||||
|
/** Tesla - by Jyzarc */
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockTesla, "EEE", " C ", " I ", 'E', Item.eyeOfEnder, 'C', itemCapacitor, 'I', Block.blockIron));
|
||||||
|
|
||||||
|
/** Multimeter */
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockMultimeter, "RRR", "ICI", "III", 'R', Item.redstone, 'C', itemCapacitor, 'I', Item.ingotIron));
|
||||||
|
|
||||||
|
/** Multimeter */
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockBattery, "III", "IRI", "III", 'R', Block.blockRedstone, 'I', Item.ingotIron));
|
||||||
|
|
||||||
|
/** EM Contractor */
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockEMContractor, " I ", "GCG", "WWW", 'W', Block.wood, 'C', itemCapacitor, 'G', Item.ingotGold, 'I', Item.ingotIron));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int loadLanguages(String languagePath, String[] languageSupported)
|
public static int loadLanguages(String languagePath, String[] languageSupported)
|
||||||
|
|
|
@ -248,7 +248,7 @@ public class Vector3
|
||||||
{
|
{
|
||||||
MovingObjectPosition pickedEntity = null;
|
MovingObjectPosition pickedEntity = null;
|
||||||
Vec3 startingPosition = this.toVec3();
|
Vec3 startingPosition = this.toVec3();
|
||||||
Vec3 look = target.normalize().toVec3();
|
Vec3 look = target.clone().difference(this).normalize().toVec3();
|
||||||
double reachDistance = this.distance(target);
|
double reachDistance = this.distance(target);
|
||||||
Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);
|
Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
*/
|
*/
|
||||||
package resonantinduction.battery;
|
package resonantinduction.battery;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import resonantinduction.api.IBattery;
|
import resonantinduction.api.IBattery;
|
||||||
|
@ -23,6 +27,13 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
||||||
this.setMaxDamage(1000);
|
this.setMaxDamage(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||||
|
{
|
||||||
|
double energyStored = this.getEnergyStored(itemStack);
|
||||||
|
par3List.add("Energy: " + energyStored + " J");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnergyStored(ItemStack itemStack, float amount)
|
public void setEnergyStored(ItemStack itemStack, float amount)
|
||||||
{
|
{
|
||||||
|
@ -31,6 +42,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
||||||
itemStack.setTagCompound(new NBTTagCompound());
|
itemStack.setTagCompound(new NBTTagCompound());
|
||||||
}
|
}
|
||||||
itemStack.getTagCompound().setFloat("energyStored", amount);
|
itemStack.getTagCompound().setFloat("energyStored", amount);
|
||||||
|
itemStack.setItemDamage((int) (amount / this.getMaxEnergyStored()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,4 +60,16 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
||||||
{
|
{
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||||
|
{
|
||||||
|
ItemStack chargedStack = new ItemStack(par1, 1, 0);
|
||||||
|
this.setEnergyStored(chargedStack, this.getMaxEnergyStored());
|
||||||
|
par3List.add(chargedStack);
|
||||||
|
ItemStack unchargedStack = new ItemStack(par1, 1, 0);
|
||||||
|
this.setEnergyStored(unchargedStack, 0);
|
||||||
|
par3List.add(unchargedStack);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,27 @@
|
||||||
*/
|
*/
|
||||||
package resonantinduction.render;
|
package resonantinduction.render;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Icon;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
|
import resonantinduction.base.Vector3;
|
||||||
import resonantinduction.model.ModelBattery;
|
import resonantinduction.model.ModelBattery;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -23,16 +37,184 @@ public class RenderBattery extends TileEntitySpecialRenderer
|
||||||
{
|
{
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery.png");
|
public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery.png");
|
||||||
public static final ModelBattery MODEL = new ModelBattery();
|
public static final ModelBattery MODEL = new ModelBattery();
|
||||||
|
private EntityItem fakeBattery;
|
||||||
|
private Random random = new Random();
|
||||||
|
protected RenderManager renderManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||||
{
|
{
|
||||||
|
if (this.fakeBattery == null)
|
||||||
|
{
|
||||||
|
this.fakeBattery = new EntityItem(t.worldObj, 0, 0, 0, new ItemStack(ResonantInduction.itemCapacitor));
|
||||||
|
this.fakeBattery.age = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.renderManager == null)
|
||||||
|
{
|
||||||
|
this.renderManager = RenderManager.instance;
|
||||||
|
}
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||||
this.func_110628_a(TEXTURE);
|
this.func_110628_a(TEXTURE);
|
||||||
MODEL.render(0.0625f);
|
MODEL.render(0.0625f);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
int renderAmount = 16;
|
||||||
|
|
||||||
|
itemRender:
|
||||||
|
for (int i = 2; i < 6; i++)
|
||||||
|
{
|
||||||
|
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||||
|
Block block = Block.blocksList[new Vector3(t).translate(new Vector3(direction)).getBlockID(t.worldObj)];
|
||||||
|
if (block == null || (block != null && block.isOpaqueCube()))
|
||||||
|
{
|
||||||
|
for (int slot = 0; slot < 4; slot++)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.7f, (float) z + 0.5f);
|
||||||
|
|
||||||
|
float translateX = 0;
|
||||||
|
float translateY = 0;
|
||||||
|
|
||||||
|
switch (slot)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
translateX = 0.25f;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
translateX = 0.25f;
|
||||||
|
translateY = -0.5f;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
translateX = -0.25f;
|
||||||
|
translateY = -0.5f;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
translateX = -0.25f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case NORTH:
|
||||||
|
GL11.glTranslatef(-0.5f, 0, 0);
|
||||||
|
GL11.glTranslatef(0, translateY, translateX);
|
||||||
|
GL11.glRotatef(90, 0, 1, 0);
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
GL11.glTranslatef(0, 0, -0.5f);
|
||||||
|
GL11.glTranslatef(translateX, translateY, 0);
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
GL11.glTranslatef(0.5f, 0, 0);
|
||||||
|
GL11.glTranslatef(0, translateY, translateX);
|
||||||
|
GL11.glRotatef(90, 0, 1, 0);
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
GL11.glTranslatef(0, 0, 0.5f);
|
||||||
|
GL11.glTranslatef(translateX, translateY, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||||
|
this.renderItemSimple(this.fakeBattery);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
if (renderAmount-- <= 0)
|
||||||
|
{
|
||||||
|
break itemRender;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void renderItemSimple(EntityItem entityItem)
|
||||||
|
{
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
ItemStack itemStack = entityItem.getEntityItem();
|
||||||
|
|
||||||
|
for (int k = 0; k < itemStack.getItem().getRenderPasses(itemStack.getItemDamage()); ++k)
|
||||||
|
{
|
||||||
|
Icon icon = itemStack.getItem().getIcon(itemStack, k);
|
||||||
|
|
||||||
|
if (icon == null)
|
||||||
|
{
|
||||||
|
TextureManager texturemanager = Minecraft.getMinecraft().func_110434_K();
|
||||||
|
ResourceLocation resourcelocation = texturemanager.func_130087_a(entityItem.getEntityItem().getItemSpriteNumber());
|
||||||
|
icon = ((TextureMap) texturemanager.func_110581_b(resourcelocation)).func_110572_b("missingno");
|
||||||
|
}
|
||||||
|
|
||||||
|
float f4 = ((Icon) icon).getMinU();
|
||||||
|
float f5 = ((Icon) icon).getMaxU();
|
||||||
|
float f6 = ((Icon) icon).getMinV();
|
||||||
|
float f7 = ((Icon) icon).getMaxV();
|
||||||
|
float f8 = 1.0F;
|
||||||
|
float f9 = 0.5F;
|
||||||
|
float f10 = 0.25F;
|
||||||
|
float f11;
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
float f12 = 0.0625F;
|
||||||
|
f11 = 0.021875F;
|
||||||
|
ItemStack itemstack = entityItem.getEntityItem();
|
||||||
|
int j = itemstack.stackSize;
|
||||||
|
byte b0 = getMiniItemCount(itemstack);
|
||||||
|
|
||||||
|
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));
|
||||||
|
|
||||||
|
for (int kj = 0; kj < b0; ++kj)
|
||||||
|
{
|
||||||
|
// Makes items offset when in 3D, like when in 2D, looks much better. Considered a
|
||||||
|
// vanilla bug...
|
||||||
|
if (kj > 0)
|
||||||
|
{
|
||||||
|
float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||||
|
float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||||
|
float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||||
|
GL11.glTranslatef(x, y, f12 + f11);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL11.glTranslatef(0f, 0f, f12 + f11);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack.getItemSpriteNumber() == 0)
|
||||||
|
{
|
||||||
|
this.func_110776_a(TextureMap.field_110575_b);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.func_110776_a(TextureMap.field_110576_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||||
|
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) icon).getOriginX(), ((Icon) icon).getOriginY(), f12);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void func_110776_a(ResourceLocation par1ResourceLocation)
|
||||||
|
{
|
||||||
|
this.renderManager.renderEngine.func_110577_a(par1ResourceLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getMiniItemCount(ItemStack stack)
|
||||||
|
{
|
||||||
|
byte ret = 1;
|
||||||
|
if (stack.stackSize > 1)
|
||||||
|
ret = 2;
|
||||||
|
if (stack.stackSize > 15)
|
||||||
|
ret = 3;
|
||||||
|
if (stack.stackSize > 31)
|
||||||
|
ret = 4;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,16 +53,22 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
|
||||||
{
|
{
|
||||||
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (entityPlayer.getCurrentEquippedItem().itemID == Item.redstone.itemID)
|
else if (entityPlayer.getCurrentEquippedItem().itemID == Item.redstone.itemID)
|
||||||
{
|
{
|
||||||
tileEntity.toggleEntityAttack();
|
boolean status = tileEntity.toggleEntityAttack();
|
||||||
|
|
||||||
if (!entityPlayer.capabilities.isCreativeMode)
|
if (!entityPlayer.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!world.isRemote)
|
||||||
|
{
|
||||||
|
entityPlayer.addChatMessage("Toggled entity attack to: " + status);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
||||||
|
|
Loading…
Reference in a new issue