Jump to content




Creating a new peripheral - What did I wrong ?


  • You cannot reply to this topic
2 replies to this topic

#1 JustPingo

  • Members
  • 108 posts
  • LocationFrance

Posted 07 October 2014 - 05: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 !

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 07 October 2014 - 05:21 PM

Please post your IPeripheralProvider as well. Please ensure you've properly registered your IPeripheralProvider with the ComputerCraft API.

#3 JustPingo

  • Members
  • 108 posts
  • LocationFrance

Posted 07 October 2014 - 05:34 PM

Oh my bad! I wasn't correctly registering the PeripheralProvider in the Init method.
Thank you!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users