Posted 13 March 2012 - 06:17 PM
This framework was from the very first peripheral I made, it should work as I don't believe the API has changed.
Note #1: Doesn't use Forge Sprites/Textures
Note #2: Change everything to your own Names
Note #3: If this is too hard to understand, you SHOULDN'T be making a peripheral.
mod_Block.java
TileEntityName.java
BlockName.java
Note #1: Doesn't use Forge Sprites/Textures
Note #2: Change everything to your own Names
Note #3: If this is too hard to understand, you SHOULDN'T be making a peripheral.
mod_Block.java
Spoiler
package net.minecraft.src;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public class mod_Block extends BaseMod
{
public static final Block Namehere = new BlockName(160, 0).setBlockName("name").setHardness(3F).setResistance(4F).setLightValue(1F);
public void load()
{
Namehere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/images/block.png");
ModLoader.RegisterBlock(Namehere);
ModLoader.AddName(Namehere, "In-Game Name Here");
ModLoader.AddRecipe(new ItemStack(Namehere, 1), new Object [] {"#", Character.valueOf('#'), Block.dirt});
ModLoader.RegisterTileEntity(TileEntityName.class, "name");
}
public String getVersion()
{
return "1.1";
}
}
Spoiler
package net.minecraft.src;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
import net.minecraft.src.*;
public class TileEntityName extends TileEntity
implements IPeripheral
{
public synchronized void detach(IComputerAccess icomputeraccess) // tried sync and without
{
}
public void attach(IComputerAccess icomputeraccess, String s)
{
}
public String getType() {
return "name";
}
public String[] getMethodNames()
{
return (new String[] { "test" });
}
public Object[] callMethod(IComputerAccess icomputeraccess, int i, Object aobj[])
throws Exception
{
if (i == 0)
{
return (new Object[] {"param1", "param2", 7123, true, false, "param6"});
}
return null;
}
public boolean canAttachToSide(int i)
{
return true;
}
}
BlockName.java
Spoiler
package net.minecraft.src;
import java.util.*;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public class BlockName extends BlockContainer
{
public TileEntity getBlockEntity() {
return new TileEntityName();
}
public BlockName(int i, int j)
{
super(i, j, Material.iron);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Namehere.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}