mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
updated sgt api
This commit is contained in:
parent
ab1c4abc92
commit
e584af09e3
@ -25,7 +25,7 @@ trait AbstractBusAware extends TileEntity with ComponentInventory with IBusDevic
|
||||
def getZCoord = z
|
||||
|
||||
protected def hasAbstractBusCard = components exists {
|
||||
case abstractBus: component.AbstractBus => true
|
||||
case _: component.AbstractBus => true
|
||||
}
|
||||
|
||||
override protected def onItemAdded(slot: Int, stack: ItemStack) {
|
||||
@ -57,13 +57,8 @@ trait AbstractBusAware extends TileEntity with ComponentInventory with IBusDevic
|
||||
addAbstractBus()
|
||||
}
|
||||
|
||||
override def onChunkUnload() {
|
||||
super.onChunkUnload()
|
||||
removeAbstractBus()
|
||||
}
|
||||
|
||||
override def invalidate() {
|
||||
super.onChunkUnload()
|
||||
abstract override def onDisconnect(node: Node) {
|
||||
super.onDisconnect(node)
|
||||
removeAbstractBus()
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,7 @@ class AbstractBus(val owner: tileentity.Computer) extends ManagedComponent with
|
||||
def handlePacket(packet: BusPacket) {
|
||||
val lip = packet.getPlainText
|
||||
val data = Map(lip.getEntryList.map(key => (key, lip.get(key))): _*)
|
||||
// TODO do we want to push metadata, too?
|
||||
val metadata = Map("mod" -> "", "device" -> "", "player" -> "")
|
||||
val metadata = Map("mod" -> lip.getMetadata.modID, "device" -> lip.getMetadata.deviceName, "player" -> lip.getMetadata.playerName)
|
||||
owner.signal("bus_message", Int.box(packet.getProtocolID), Int.box(packet.getSender), Int.box(packet.getTarget), data, metadata)
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,13 @@ public final class BusPacketLIP extends BusPacket {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The LIPMetadata object on this object. May be null.
|
||||
*/
|
||||
public LIPMetadata getMetadata(){
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override // We don't need this. At all.
|
||||
protected void fillPlainText(BusPacketLIP lip){}
|
||||
|
@ -6,8 +6,8 @@ public class Address {
|
||||
public static Address create(Symbol[] symbols){
|
||||
try{
|
||||
boolean used[] = new boolean[40];
|
||||
if(symbols.length < 7) throw new Exception("Address too short.");
|
||||
if(symbols.length > 9) throw new Exception("Address too long.");
|
||||
if(symbols.length < 7) throw new Exception("Address too short: " + symbols.length);
|
||||
if(symbols.length > 9) throw new Exception("Address too long: " + symbols.length);
|
||||
for(int i = 0; i < used.length; i++){
|
||||
used[i] = (i == 0);
|
||||
}
|
||||
@ -74,4 +74,9 @@ public class Address {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return length();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user