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