This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
JustPingo's profile picture

Creating a new peripheral - What did I wrong ?

Started by JustPingo, 07 October 2014 - 04:07 PM
JustPingo #1
Posted 07 October 2014 - 06:07 PM
Hello !

I just started adding peripherals to my mod, but I encounter a problem. I did exactly what was said in the doc, and read some peripheral's sources, but when I place my block, it is not reconized as a peripheral…

Here is my TileEntity :

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;

public class TileEntityAntennaControler extends TileEntity implements IPeripheral {

public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)

	{

		this.readFromNBT(pkt.func_148857_g());

		this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);

	}

public Packet getDescriptionPacket()

	{

		NBTTagCompound nbttagcompound = new NBTTagCompound();

		this.writeToNBT(nbttagcompound);

		return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 3, nbttagcompound);

	}

public void readFromNBT(NBTTagCompound nbttag)
	{
		super.readFromNBT(nbttag);
	}

	public void writeToNBT(NBTTagCompound nbttag)
	{
		super.writeToNBT(nbttag);
	}

@Override
public String getType() {
return "ubernetworkingantenna";
}

@Override
public String[] getMethodNames() {
return (new String[] { "ping" });
}

@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
if (method == 0) return (new Object[] { (Boolean) true });
return null;
}

@Override
public void attach(IComputerAccess computer) {

}

@Override
public void detach(IComputerAccess computer) {

}

@Override
public boolean equals(IPeripheral other) {
if (other.getType() == this.getType()) return true;
else return false;
}

}

What did I wrong ?

Thanks in advance !
Lyqyd #2
Posted 07 October 2014 - 06:21 PM
Please post your IPeripheralProvider as well. Please ensure you've properly registered your IPeripheralProvider with the ComputerCraft API.
JustPingo #3
Posted 07 October 2014 - 06:34 PM
Oh my bad! I wasn't correctly registering the PeripheralProvider in the Init method.
Thank you!