Added generator model, fixed grate and generator rotation

This commit is contained in:
Calclavia 2014-01-15 20:50:19 +08:00
parent cfddbc97ab
commit 19f7aac383
15 changed files with 319 additions and 78 deletions

View file

@ -1,6 +1,6 @@
package resonantinduction.archaic.imprint;
import resonantinduction.core.prefab.block.BlockRotatableBase;
import resonantinduction.core.prefab.block.BlockRIRotatable;
/**
* A block that represents a filter for item transportation.
@ -8,7 +8,7 @@ import resonantinduction.core.prefab.block.BlockRotatableBase;
* @author Calclavia
*
*/
public class BlockFilter extends BlockRotatableBase
public class BlockFilter extends BlockRIRotatable
{
public BlockFilter(int id)
{

View file

@ -1,6 +1,3 @@
/**
*
*/
package resonantinduction.core.prefab.block;
import net.minecraftforge.common.Configuration;
@ -14,9 +11,14 @@ import calclavia.lib.prefab.block.BlockRotatable;
* @author Calclavia
*
*/
public class BlockRotatableBase extends BlockRotatable
public class BlockRIRotatable extends BlockRotatable
{
public BlockRotatableBase(String name, int id)
public BlockRIRotatable(String name)
{
this(name, Settings.getNextItemID());
}
public BlockRIRotatable(String name, int id)
{
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), UniversalElectricity.machine);
this.setCreativeTab(ResonantInductionTabs.CORE);

View file

@ -2,17 +2,16 @@ package resonantinduction.electrical.generator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.core.prefab.block.BlockRI;
import resonantinduction.core.prefab.block.BlockRIRotatable;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockGenerator extends BlockRI
public class BlockGenerator extends BlockRIRotatable
{
public BlockGenerator()
{
super("generator");
this.setBlockBounds(0, 0, 0, 1, 0.5f, 1);
}
@Override

View file

@ -0,0 +1,171 @@
package resonantinduction.electrical.generator;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelGenerator extends ModelBase
{
// fields
ModelRenderer Bottom;
ModelRenderer Left;
ModelRenderer CenterRod;
ModelRenderer Right;
ModelRenderer RightTopCorner;
ModelRenderer LeftTopCorner;
ModelRenderer LeftBottomCorner;
ModelRenderer RightBottomCorner;
ModelRenderer BottomCase;
ModelRenderer TopCase;
ModelRenderer LeftBrace;
ModelRenderer RightBrace;
ModelRenderer BackBracer;
ModelRenderer FrontBracer;
ModelRenderer FrontDisc;
ModelRenderer FrontDisc2;
ModelRenderer BackDisc;
ModelRenderer BackDisc2;
public ModelGenerator()
{
textureWidth = 128;
textureHeight = 128;
Bottom = new ModelRenderer(this, 0, 74);
Bottom.addBox(-7F, -1F, -7F, 14, 2, 14);
Bottom.setRotationPoint(0F, 23F, 0F);
Bottom.setTextureSize(128, 128);
Bottom.mirror = true;
setRotation(Bottom, 0F, 0F, 0F);
Left = new ModelRenderer(this, 17, 49);
Left.addBox(-1F, -4F, -3F, 2, 8, 6);
Left.setRotationPoint(7F, 15F, 0F);
Left.setTextureSize(128, 128);
Left.mirror = true;
setRotation(Left, 0F, 0F, 0F);
CenterRod = new ModelRenderer(this, 62, 0);
CenterRod.addBox(-1.5F, -1.5F, -8F, 3, 3, 16);
CenterRod.setRotationPoint(0F, 15F, 0F);
CenterRod.setTextureSize(128, 128);
CenterRod.mirror = true;
setRotation(CenterRod, 0F, 0F, 0F);
Right = new ModelRenderer(this, 0, 49);
Right.addBox(-1F, -4F, -3F, 2, 8, 6);
Right.setRotationPoint(-7F, 15F, 0F);
Right.setTextureSize(128, 128);
Right.mirror = true;
setRotation(Right, 0F, 0F, 0F);
RightTopCorner = new ModelRenderer(this, 0, 35);
RightTopCorner.addBox(-2F, -6F, -3F, 2, 6, 6);
RightTopCorner.setRotationPoint(-7F, 13F, 0F);
RightTopCorner.setTextureSize(128, 128);
RightTopCorner.mirror = true;
setRotation(RightTopCorner, 0F, 0F, 1.047198F);
LeftTopCorner = new ModelRenderer(this, 17, 35);
LeftTopCorner.addBox(0F, -6F, -3F, 2, 6, 6);
LeftTopCorner.setRotationPoint(7F, 13F, 0F);
LeftTopCorner.setTextureSize(128, 128);
LeftTopCorner.mirror = true;
setRotation(LeftTopCorner, 0F, 0F, -1.047198F);
LeftBottomCorner = new ModelRenderer(this, 17, 91);
LeftBottomCorner.addBox(0F, 0F, -3F, 2, 6, 6);
LeftBottomCorner.setRotationPoint(7F, 17F, 0F);
LeftBottomCorner.setTextureSize(128, 128);
LeftBottomCorner.mirror = true;
setRotation(LeftBottomCorner, 0F, 0F, 1.047198F);
RightBottomCorner = new ModelRenderer(this, 0, 91);
RightBottomCorner.addBox(-2F, 0F, -3F, 2, 6, 6);
RightBottomCorner.setRotationPoint(-7F, 17F, 0F);
RightBottomCorner.setTextureSize(128, 128);
RightBottomCorner.mirror = true;
setRotation(RightBottomCorner, 0F, 0F, -1.047198F);
BottomCase = new ModelRenderer(this, 3, 64);
BottomCase.addBox(0F, 0F, -3F, 6, 2, 6);
BottomCase.setRotationPoint(-3F, 20F, 0F);
BottomCase.setTextureSize(128, 128);
BottomCase.mirror = true;
setRotation(BottomCase, 0F, 0F, 0F);
TopCase = new ModelRenderer(this, 3, 26);
TopCase.addBox(0F, 0F, -3F, 6, 2, 6);
TopCase.setRotationPoint(-3F, 8F, 0F);
TopCase.setTextureSize(128, 128);
TopCase.mirror = true;
setRotation(TopCase, 0F, 0F, 0F);
LeftBrace = new ModelRenderer(this, 44, 64);
LeftBrace.addBox(0F, 0F, -1.5F, 3, 6, 3);
LeftBrace.setRotationPoint(3F, 17F, 0F);
LeftBrace.setTextureSize(128, 128);
LeftBrace.mirror = true;
setRotation(LeftBrace, 0F, 0F, 0F);
RightBrace = new ModelRenderer(this, 31, 64);
RightBrace.addBox(0F, 0F, -1.5F, 3, 6, 3);
RightBrace.setRotationPoint(-6F, 17F, 0F);
RightBrace.setTextureSize(128, 128);
RightBrace.mirror = true;
setRotation(RightBrace, 0F, 0F, 0F);
BackBracer = new ModelRenderer(this, 50, 0);
BackBracer.addBox(-2F, -3F, 5F, 4, 10, 1);
BackBracer.setRotationPoint(0F, 15F, 0F);
BackBracer.setTextureSize(128, 128);
BackBracer.mirror = true;
setRotation(BackBracer, 0F, 0F, 0F);
FrontBracer = new ModelRenderer(this, 50, 0);
FrontBracer.addBox(-2F, -3F, -6F, 4, 10, 1);
FrontBracer.setRotationPoint(0F, 15F, 0F);
FrontBracer.setTextureSize(128, 128);
FrontBracer.mirror = true;
setRotation(FrontBracer, 0F, 0F, 0F);
FrontDisc = new ModelRenderer(this, 65, 25);
FrontDisc.addBox(-5F, -5F, -5F, 10, 10, 2);
FrontDisc.setRotationPoint(0F, 15F, 0F);
FrontDisc.setTextureSize(128, 128);
FrontDisc.mirror = true;
setRotation(FrontDisc, 0F, 0F, 0.7853982F);
FrontDisc2 = new ModelRenderer(this, 65, 25);
FrontDisc2.addBox(-5F, -5F, -5F, 10, 10, 2);
FrontDisc2.setRotationPoint(0F, 15F, 0F);
FrontDisc2.setTextureSize(128, 128);
FrontDisc2.mirror = true;
setRotation(FrontDisc2, 0F, 0F, 0F);
BackDisc = new ModelRenderer(this, 65, 25);
BackDisc.addBox(-5F, -5F, 3F, 10, 10, 2);
BackDisc.setRotationPoint(0F, 15F, 0F);
BackDisc.setTextureSize(128, 128);
BackDisc.mirror = true;
setRotation(BackDisc, 0F, 0F, 0.7853982F);
BackDisc2 = new ModelRenderer(this, 65, 25);
BackDisc2.addBox(-5F, -5F, 3F, 10, 10, 2);
BackDisc2.setRotationPoint(0F, 15F, 0F);
BackDisc2.setTextureSize(128, 128);
BackDisc2.mirror = true;
setRotation(BackDisc2, 0F, 0F, 0F);
}
public void render(float f5)
{
Bottom.render(f5);
Left.render(f5);
CenterRod.render(f5);
Right.render(f5);
RightTopCorner.render(f5);
LeftTopCorner.render(f5);
LeftBottomCorner.render(f5);
RightBottomCorner.render(f5);
BottomCase.render(f5);
TopCase.render(f5);
LeftBrace.render(f5);
RightBrace.render(f5);
BackBracer.render(f5);
FrontBracer.render(f5);
FrontDisc.render(f5);
FrontDisc2.render(f5);
BackDisc.render(f5);
BackDisc2.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,53 @@
package resonantinduction.electrical.generator;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import resonantinduction.core.Reference;
import cpw.mods.fml.client.FMLClientHandler;
/**
* @author Calclavia
*
*/
public class RenderGenerator extends TileEntitySpecialRenderer
{
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "generator.png");
public static final ModelGenerator MODEL = new ModelGenerator();
@Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
{
glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
bindTexture(TEXTURE);
GL11.glRotatef(180, 0f, 0f, 1f);
// Rotate the model
int facingDirection = t.getBlockMetadata();
switch (facingDirection)
{
case 2:
GL11.glRotatef(180, 0f, 1f, 0f);
break;
case 3:
GL11.glRotatef(0, 0f, 1f, 0f);
break;
case 4:
GL11.glRotatef(90, 0f, 1f, 0f);
break;
case 5:
GL11.glRotatef(-90, 0f, 1f, 0f);
break;
}
MODEL.render(0.0625F);
glPopMatrix();
}
}

View file

@ -6,54 +6,60 @@ import resonantinduction.mechanical.network.IMechanical;
import universalelectricity.api.energy.EnergyStorageHandler;
import calclavia.lib.prefab.tile.TileElectrical;
/** A kinetic energy to electrical energy converter.
/**
* A kinetic energy to electrical energy converter.
*
* @author Calclavia */
* @author Calclavia
*/
public class TileGenerator extends TileElectrical implements IMechanical
{
//P = \tau \times 2 \pi \times \omega
private long power;
private long power;
/** Generator turns KE -> EE. Inverted one will turn EE -> KE. */
private boolean isInversed = false;
/** Generator turns KE -> EE. Inverted one will turn EE -> KE. */
private boolean isInversed = false;
public TileGenerator()
{
energy = new EnergyStorageHandler(10000);
}
public TileGenerator()
{
energy = new EnergyStorageHandler(10000);
}
@Override
public void updateEntity()
{
if (this.isFunctioning())
{
if (!isInversed)
{
this.energy.receiveEnergy(power, true);
this.produce();
}
else
{
// TODO:Do something here to set mechanical energy.
}
}
}
@Override
public void updateEntity()
{
if (this.isFunctioning())
{
if (!isInversed)
{
this.energy.receiveEnergy(power, true);
this.produce();
}
else
{
// TODO:Do something here to set mechanical energy.
}
}
}
private boolean isFunctioning()
{
return this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
}
private boolean isFunctioning()
{
return this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
}
@Override
public void onTorqueChange(ForgeDirection side, int speed)
{
// TODO Auto-generated method stub
}
@Override
public void setPower(long torque, float speed)
{
}
@Override
public void onTorqueChange(ForgeDirection side, int speed)
{
}
@Override
public int getForceSide(ForgeDirection side)
{
return 0;
}
@Override
public int getForceSide(ForgeDirection side)
{
// TODO Auto-generated method stub
return 0;
}
}

View file

@ -5,7 +5,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.block.BlockRotatableBase;
import resonantinduction.core.prefab.block.BlockRIRotatable;
import resonantinduction.mechanical.grinder.TilePurifier;
import universalelectricity.api.vector.VectorWorld;
@ -15,7 +15,7 @@ import universalelectricity.api.vector.VectorWorld;
* @author Calclavia
*
*/
public class BlockPurifier extends BlockRotatableBase implements ITileEntityProvider
public class BlockPurifier extends BlockRIRotatable implements ITileEntityProvider
{
public BlockPurifier()
{

View file

@ -1,8 +1,5 @@
package resonantinduction.mechanical.fluid.pump;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@ -15,9 +12,11 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockRI;
import resonantinduction.core.prefab.block.BlockRIRotatable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockGrate extends BlockRI
public class BlockGrate extends BlockRIRotatable
{
private Icon drainIcon;
private Icon fillIcon;
@ -55,9 +54,14 @@ public class BlockGrate extends BlockRI
}
@Override
public Icon getIcon(int par1, int par2)
public Icon getIcon(int side, int metadata)
{
return par1 != 1 && par1 != 0 ? this.blockIcon : this.drainIcon;
if (side == metadata)
{
return this.drainIcon;
}
return this.blockIcon;
}
@Override
@ -78,7 +82,6 @@ public class BlockGrate extends BlockRI
{
return this.fillIcon;
}
}
}

View file

@ -53,7 +53,6 @@ public class ItemTankRenderer implements IItemRenderer
GL11.glTranslatef(0.7F, .45F, 0.7F);
}
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Reference.DOMAIN, item.getItemDamage() == 1 ? "textures/blocks/obsidian.png" : "textures/blocks/iron_block.png"));
FluidStack fluid = null;
if (item.getTagCompound() != null && item.getTagCompound().hasKey("fluid"))
{

View file

@ -11,10 +11,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.mechanical.Mechanical;
import resonantinduction.mechanical.network.IMechanical;
import resonantinduction.mechanical.network.IMechanicalConnector;
import resonantinduction.mechanical.network.IMechanicalNetwork;
import resonantinduction.mechanical.network.MechanicalNetwork;
import universalelectricity.api.UniversalElectricity;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.vec.Cuboid6;
@ -99,6 +99,10 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
((PartGear) part).torque = torque;
}
}
else if(tile instanceof IMechanical)
{
((IMechanical)tile).setPower(torque, angularVelocity);
}
/** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */
for (int i = 0; i < 4; i++)

View file

@ -8,7 +8,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.block.BlockRotatableBase;
import resonantinduction.core.prefab.block.BlockRIRotatable;
import universalelectricity.api.vector.VectorWorld;
/**
@ -17,7 +17,7 @@ import universalelectricity.api.vector.VectorWorld;
* @author Calclavia
*
*/
public class BlockGrinderWheel extends BlockRotatableBase implements ITileEntityProvider
public class BlockGrinderWheel extends BlockRIRotatable implements ITileEntityProvider
{
public BlockGrinderWheel()
{

View file

@ -3,14 +3,18 @@ package resonantinduction.mechanical.network;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.net.IConnectable;
/** Applied to machines that connect to a mech network
/**
* Applied to machines that connect to a mech network
*
* @author Darkguardsman */
* @author Darkguardsman
*/
public interface IMechanical extends IConnectable
{
/** Called by the network when its torque value changes. */
public void onTorqueChange(ForgeDirection side, int speed);
public void setPower(long torque, float speed);
/** Gets the force on the side, zero is ignored, neg is input force, pos is output force */
public int getForceSide(ForgeDirection side);
/** Called by the network when its torque value changes. */
public void onTorqueChange(ForgeDirection side, int speed);
/** Gets the force on the side, zero is ignored, neg is input force, pos is output force */
public int getForceSide(ForgeDirection side);
}

View file

@ -27,11 +27,11 @@ import universalelectricity.core.net.NetworkTickHandler;
*/
public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalConnector, IMechanical> implements IMechanicalNetwork
{
private int force = 0;
private int torque = 0;
private int speed = 0;
private int resistance = 0;
private HashMap<IMechanical, ForceWrapper[]> forceMap = new HashMap<IMechanical, ForceWrapper[]>();
private HashMap<IMechanical, ForceWrapper[]> torqueMap = new HashMap<IMechanical, ForceWrapper[]>();
@Override
public void update()
@ -46,9 +46,9 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
{
// Reset all values related to wires
this.getNodes().clear();
this.forceMap.clear();
this.torqueMap.clear();
this.resistance = 0;
this.force = 0;
this.torque = 0;
this.speed = 0;
// Iterate threw list of wires
@ -95,14 +95,14 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
{
if (obj instanceof IMechanical)
{
ForceWrapper[] set = this.forceMap.get((IMechanical) obj);
ForceWrapper[] set = this.torqueMap.get((IMechanical) obj);
if (set == null)
{
set = new ForceWrapper[6];
}
this.getNodes().add((IMechanical) obj);
set[side.ordinal()] = new ForceWrapper(((IMechanical) obj).getForceSide(side.getOpposite()), ((IMechanical) obj).getForceSide(side.getOpposite()));
this.forceMap.put((IMechanical) obj, set);
this.torqueMap.put((IMechanical) obj, set);
}
}
}
@ -229,7 +229,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
@Override
public int getTorque()
{
return this.force;
return this.torque;
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B