Turtle Upgrade Peripherals
theoriginalbit opened this issue ยท 1 comments
You can't cache the peripherals in your upgrades. #createPeripheral(ITurtleAccess, TurtleSide)
shouldn't retain the new instance like you've done in PeripheralXP and the likes. Doing so will mean all Turtles share the same peripheral, which can really cause problems, especially if it is location dependent! When you need the IPeripheral back in #update(ITurtleAccess, TurtleSide)
, you can do
@Override
public void update(ITurtleAccess access, TurtleSide side) {
IPeripheral periph = access.getPeripheral(side);
if (periph instanceof PeripheralXP) {
PeripheralXP xp = (PeripheralXP) periph;
// do what you need here
}
}