change package and started coding mechanical rod

since i want the steam piston to output a rotational energy rather than
strait electric i started coding the mechanical rod. It has a max range
of 10 blocks, and only transfers energy in one direction. Later i'll add
a gear box to allow for several directions, as well as speed control.
Also right now the system is design to use rpm as power units but later
i'm change it to correct units, since rpm just describes speed and not
power.
This commit is contained in:
Rseifert 2012-09-25 16:21:52 -04:00
parent 241424ceb5
commit 813392f5e1
23 changed files with 256 additions and 33 deletions

View file

@ -5,8 +5,8 @@ import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraftforge.client.MinecraftForgeClient;
import basicpipes.BasicPipesMain;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.pumps.TileEntityPump;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.machines.TileEntityPump;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import cpw.mods.fml.common.network.IGuiHandler;

View file

@ -7,13 +7,13 @@ import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration;
import universalelectricity.BasicComponents;
import universalelectricity.network.PacketManager;
import basicpipes.pipes.BlockPipe;
import basicpipes.pipes.ItemGuage;
import basicpipes.pipes.ItemParts;
import basicpipes.pipes.ItemPipe;
import basicpipes.conductors.BlockPipe;
import basicpipes.conductors.ItemGuage;
import basicpipes.conductors.ItemParts;
import basicpipes.conductors.ItemPipe;
import basicpipes.machines.BlockMachine;
import basicpipes.machines.BlockValve;
import basicpipes.pipes.api.Liquid;
import basicpipes.pumps.BlockMachine;
import basicpipes.pumps.BlockValve;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PostInit;
@ -70,7 +70,7 @@ public class BasicPipesMain{
{
proxy.preInit();
GameRegistry.registerBlock(pipe);
GameRegistry.registerBlock(machine,basicpipes.pumps.ItemMachine.class);
GameRegistry.registerBlock(machine,basicpipes.machines.ItemMachine.class);
}
@Init
public void load(FMLInitializationEvent evt)

View file

@ -1,7 +1,7 @@
package basicpipes;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.pumps.TileEntityPump;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.machines.TileEntityPump;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;

View file

@ -1,4 +1,4 @@
package basicpipes.pipes;
package basicpipes.conductors;
import java.util.Random;

View file

@ -0,0 +1,59 @@
package basicpipes.conductors;
import net.minecraft.src.Block;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class BlockRod extends universalelectricity.prefab.BlockMachine {
public BlockRod(int par1) {
super("MechanicRod", par1, Material.iron);
}
@Override
protected int damageDropped(int metadata)
{
return 0;
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer)
{
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 5)
{
world.setBlockMetadataWithNotify(x, y, z, 0);
}
else
{
world.setBlockMetadataWithNotify(x,y,z,meta+1);
}
return true;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityRod();
}
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return -1;
}
}

View file

@ -1,4 +1,4 @@
package basicpipes.pipes;
package basicpipes.conductors;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,4 +1,4 @@
package basicpipes.pipes;
package basicpipes.conductors;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,4 +1,4 @@
package basicpipes.pipes;
package basicpipes.conductors;
import java.util.List;

View file

@ -1,4 +1,4 @@
package basicpipes.pipes;
package basicpipes.conductors;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NetworkManager;

View file

@ -0,0 +1,133 @@
package basicpipes.conductors;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.network.IPacketReceiver;
import universalelectricity.network.PacketManager;
import basicpipes.BasicPipesMain;
import basicpipes.pipes.api.ILiquidConsumer;
import basicpipes.pipes.api.IMechenical;
import basicpipes.pipes.api.Liquid;
public class TileEntityRod extends TileEntity implements IPacketReceiver,IMechenical {
private int count = 0;
private float rotation = 0;
public int rpm = 0;//rpm received from producer
public int loadRPM = 0; //rpm lost to the load
public int currentRPM = 0;
public TileEntity front = null;
public TileEntity back = null;
ForgeDirection frontD;
ForgeDirection backD;
@Override
public void handlePacketData(NetworkManager network,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
try{
this.rpm = dataStream.readInt();
this.loadRPM = dataStream.readInt();
this.currentRPM = dataStream.readInt();
}catch(Exception e)
{
}
}
public Object[] data()
{
return new Object[]{rpm,loadRPM,currentRPM};
}
@Override
public void updateEntity()
{
if(count++ >= 5)
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
frontD = ForgeDirection.getOrientation(meta);
backD = ForgeDirection.getOrientation(meta).getOpposite();
count = 0;
if(!worldObj.isRemote)
{
back = worldObj.getBlockTileEntity(xCoord+backD.offsetX, yCoord+backD.offsetY, zCoord+backD.offsetZ);
front = worldObj.getBlockTileEntity(xCoord+frontD.offsetX, yCoord+frontD.offsetY, zCoord+frontD.offsetZ);
if(!(back instanceof IMechenical))
{
back = null;
}
if(!(front instanceof IMechenical))
{
front = null;
}
if(back != null && front != null)
{
this.rpm = ((IMechenical) back).getRPM(backD);
this.loadRPM = ((IMechenical) front).useRPM(rpm)+10;
this.currentRPM = rpm-loadRPM-10;//minus 10 is what it take to over come the rods friction
if(currentRPM < 0)
{
//TODO add stress to rod and break if left stressed too long
}
}else
{
if(currentRPM > 0)
{
currentRPM-=10;
if(currentRPM < 0)
{
currentRPM = 0;
}
}
}
PacketManager.sendTileEntityPacketWithRange(this, BasicPipesMain.channel, 20, this.data());
}
this.rotation = currentRPM * 240;
if(back != null && back instanceof TileEntityRod)
{
this.rotation = ((TileEntityRod)front).rotation;
}
}
}
@Override
public int getRPM(ForgeDirection side) {
return this.currentRPM;
}
@Override
public boolean canOutputSide(ForgeDirection side) {
if(frontD != null && side == frontD)
{
return true;
}
return false;
}
@Override
public boolean canInputSide(ForgeDirection side) {
if(backD != null && side == backD)
{
return true;
}
return false;
}
@Override
public int useRPM(int RPM) {
// TODO Auto-generated method stub
return 10+loadRPM;
}
}

View file

@ -1,4 +1,4 @@
package basicpipes.pumps;
package basicpipes.machines;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package basicpipes.pumps;
package basicpipes.machines;
import java.util.ArrayList;
import net.minecraft.src.*;

View file

@ -1,4 +1,4 @@
package basicpipes.pumps;
package basicpipes.machines;
import java.util.List;

View file

@ -1,4 +1,4 @@
package basicpipes.pumps;
package basicpipes.machines;
import java.util.List;

View file

@ -1,4 +1,4 @@
package basicpipes.pumps;
package basicpipes.machines;
import universalelectricity.implement.IElectricityReceiver;
import net.minecraft.src.NBTTagCompound;

View file

@ -1,4 +1,4 @@
package basicpipes.pumps;
package basicpipes.machines;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;

View file

@ -1,8 +1,8 @@
package basicpipes.pumps;
package basicpipes.machines;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.pipes.api.ILiquidConsumer;
import basicpipes.pipes.api.Liquid;
import basicpipes.pipes.api.TradeHelper;

View file

@ -0,0 +1,30 @@
package basicpipes.pipes.api;
import net.minecraftforge.common.ForgeDirection;
// mechanical
public interface IMechenical {
/**
*
* @param side the rpm is coming from
* @return rpm that the block is running at
*/
public int getRPM(ForgeDirection side);
/**
*
* @param side
* @return if mechanical force can be outputed from this side
*/
public boolean canOutputSide(ForgeDirection side);
/**
*
* @param side
* @return if mechanical force can be inputed from this side
*/
public boolean canInputSide(ForgeDirection side);
/**
*
* @param RPM being applied to this machine
* @return the rpm after the load has been applied
*/
public int useRPM(int RPM);//will change later to include force of rotation
}

View file

@ -17,8 +17,9 @@ public enum Liquid {
Air("Air",false,true,0,-1),
Methain("Methain",true,true,-1,-1),
BioFuel("BioFuel",true,false,-1,-1),
Coolent("Coolent",true,false,-1,-1),
NukeWaste("NukeWaste",true,false,-1,-1),
Coolent("Coolent",false,false,-1,-1),
NukeWaste("NukeWaste",false,false,-1,-1),
Ether("Ether",false,false,-1,-1),
DEFUALT("Empty",false,false,-1,-1);
public final boolean flamable;//can it catch on fire, not used but might be
public final boolean isGas;//is it a gas, used to find if it floats

View file

@ -175,8 +175,8 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
{
ElectricityManager.instance.produceElectricity(this, connectedElectricUnit, this.generateRate*this.getTickInterval(), this.getVoltage());
}
}
}
}
}
}
}
/**

View file

@ -2,8 +2,8 @@ package basicpipes;
import steampower.SteamPowerMain;
import basicpipes.PipeProxy;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.pumps.TileEntityPump;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.machines.TileEntityPump;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry;

View file

@ -6,7 +6,7 @@ import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.pipes.api.Liquid;

View file

@ -5,9 +5,9 @@ import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.machines.TileEntityPump;
import basicpipes.pipes.api.Liquid;
import basicpipes.pumps.TileEntityPump;
public class RenderPump extends TileEntitySpecialRenderer