From d55343116a4a1bb65e44e18598447d80ac1d4b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Wed, 4 Jun 2014 20:28:15 +0200 Subject: [PATCH] Updated SGT2 API. --- .../stargatetech2/api/IStargateTechAPI.java | 6 + .../java/stargatetech2/api/bus/BusPacket.java | 27 ++- .../stargatetech2/api/bus/BusPacketLIP.java | 3 +- .../api/bus/BusPacketNetScan.java | 39 +++++ .../stargatetech2/api/bus/BusProtocols.java | 8 +- .../stargatetech2/api/bus/IBusDriver.java | 12 ++ .../api/shields/IShieldController.java | 37 ---- .../api/shields/IShieldable.java | 35 ---- .../api/shields/ITileShieldEmitter.java | 65 ------- .../api/shields/ShieldPermissions.java | 165 ------------------ .../stargatetech2/api/stargate/DialError.java | 22 +++ .../stargatetech2/api/stargate/DialEvent.java | 38 ++++ .../api/stargate/IDynamicWorldLoader.java | 21 +++ .../api/stargate/IStargateNetwork.java | 44 +++++ .../api/stargate/IStargatePlacer.java | 17 ++ .../api/stargate/ITileStargateBase.java | 6 +- .../api/world/EventWorldGen.java | 28 +++ .../cil/oc/server/component/AbstractBus.scala | 6 +- src/main/scala/li/cil/oc/util/mods/Mods.scala | 2 +- 19 files changed, 272 insertions(+), 309 deletions(-) create mode 100644 src/api/java/stargatetech2/api/bus/BusPacketNetScan.java delete mode 100644 src/api/java/stargatetech2/api/shields/IShieldController.java delete mode 100644 src/api/java/stargatetech2/api/shields/IShieldable.java delete mode 100644 src/api/java/stargatetech2/api/shields/ITileShieldEmitter.java delete mode 100644 src/api/java/stargatetech2/api/shields/ShieldPermissions.java create mode 100644 src/api/java/stargatetech2/api/stargate/DialError.java create mode 100644 src/api/java/stargatetech2/api/stargate/DialEvent.java create mode 100644 src/api/java/stargatetech2/api/stargate/IDynamicWorldLoader.java create mode 100644 src/api/java/stargatetech2/api/stargate/IStargatePlacer.java create mode 100644 src/api/java/stargatetech2/api/world/EventWorldGen.java diff --git a/src/api/java/stargatetech2/api/IStargateTechAPI.java b/src/api/java/stargatetech2/api/IStargateTechAPI.java index 04e0ad6ed..1906dc4c1 100644 --- a/src/api/java/stargatetech2/api/IStargateTechAPI.java +++ b/src/api/java/stargatetech2/api/IStargateTechAPI.java @@ -3,6 +3,7 @@ package stargatetech2.api; import net.minecraft.creativetab.CreativeTabs; import net.minecraftforge.fluids.Fluid; import stargatetech2.api.stargate.IStargateNetwork; +import stargatetech2.api.stargate.IStargatePlacer; public interface IStargateTechAPI { /** @@ -20,6 +21,11 @@ public interface IStargateTechAPI { */ public IStargateNetwork getStargateNetwork(); + /** + * @return The IStargatePlacer singleton instance, a.k.a Seeding Ship for the fans. + */ + public IStargatePlacer getSeedingShip(); + /** * @return The current IFactory instance. */ diff --git a/src/api/java/stargatetech2/api/bus/BusPacket.java b/src/api/java/stargatetech2/api/bus/BusPacket.java index 10116cd4c..351d25ba9 100644 --- a/src/api/java/stargatetech2/api/bus/BusPacket.java +++ b/src/api/java/stargatetech2/api/bus/BusPacket.java @@ -1,6 +1,9 @@ package stargatetech2.api.bus; -public abstract class BusPacket { +import java.util.LinkedList; + +public abstract class BusPacket{ + private LinkedList responses; private final short sender; private final short target; private final boolean hasLIP; @@ -11,6 +14,7 @@ public abstract class BusPacket { * @param hasLIP Whether or not this packet supports being converted to a plain text (LIP) format. */ protected BusPacket(short sender, short target, boolean hasLIP){ + this.responses = new LinkedList(); this.sender = sender; this.target = target; this.hasLIP = hasLIP; @@ -65,4 +69,25 @@ public abstract class BusPacket { public final boolean hasPlainText(){ return hasLIP; } + + /** + * Adds a response to this packet that to give the sender some feedback. + * The object type depends on the packet subclass. + * + * Note that clients converting the packet to LIP format + * lose the ability to send feedback. + * + * @param response The response to add. + */ + public final void addResponse(R response){ + if(response == null) throw new IllegalArgumentException("A Response cannot be null!"); + responses.add(response); + } + + /** + * @return All the responses other clients added to this packet. + */ + public final LinkedList getResponses(){ + return new LinkedList(responses); + } } diff --git a/src/api/java/stargatetech2/api/bus/BusPacketLIP.java b/src/api/java/stargatetech2/api/bus/BusPacketLIP.java index 063d19b89..dcc873f0f 100644 --- a/src/api/java/stargatetech2/api/bus/BusPacketLIP.java +++ b/src/api/java/stargatetech2/api/bus/BusPacketLIP.java @@ -15,8 +15,7 @@ import java.util.Hashtable; * * @author LordFokas */ -public final class BusPacketLIP extends BusPacket { - public static final int PROTOCOL_ID = BusProtocols.addProtocol(BusPacketLIP.class); +public final class BusPacketLIP extends BusPacket { private boolean isEditable = true; private LIPMetadata metadata = null; private Hashtable data = new Hashtable(); diff --git a/src/api/java/stargatetech2/api/bus/BusPacketNetScan.java b/src/api/java/stargatetech2/api/bus/BusPacketNetScan.java new file mode 100644 index 000000000..e4706bb98 --- /dev/null +++ b/src/api/java/stargatetech2/api/bus/BusPacketNetScan.java @@ -0,0 +1,39 @@ +package stargatetech2.api.bus; + +import java.util.LinkedList; + +public final class BusPacketNetScan extends BusPacket { + private LinkedList devices = new LinkedList(); + + public BusPacketNetScan(short target) { + super((short)0xFFFF, target, false); + } + + // We're not using this + @Override protected void fillPlainText(BusPacketLIP lip){} + + public void addDevice(Device device){ + devices.add(device); + } + + public LinkedList getDevices(){ + return new LinkedList(devices); + } + + public static final class Device{ + public final String description, name; + public final short address; + public final boolean enabled; + public final int x, y, z; + + public Device(String desc, String name, short address, boolean enabled, int x, int y, int z){ + this.description = desc; + this.name = name; + this.address = address; + this.enabled = enabled; + this.x = x; + this.y = y; + this.z = z; + } + } +} \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/bus/BusProtocols.java b/src/api/java/stargatetech2/api/bus/BusProtocols.java index 8cfceb4e6..fc81dd5fb 100644 --- a/src/api/java/stargatetech2/api/bus/BusProtocols.java +++ b/src/api/java/stargatetech2/api/bus/BusProtocols.java @@ -2,7 +2,7 @@ package stargatetech2.api.bus; import java.util.ArrayList; -public final class BusProtocols { +public final class BusProtocols { private static final ArrayList> protocols = new ArrayList(); /** @@ -29,4 +29,10 @@ public final class BusProtocols { } private BusProtocols(){} + + + + // A list of all the protocols implemented by StargateTech 2 + public static final int PROTOCOL_LIP = addProtocol(BusPacketLIP.class); + public static final int PROTOCOL_NETSCAN = addProtocol(BusPacketNetScan.class); } diff --git a/src/api/java/stargatetech2/api/bus/IBusDriver.java b/src/api/java/stargatetech2/api/bus/IBusDriver.java index d4c25d6ae..624366820 100644 --- a/src/api/java/stargatetech2/api/bus/IBusDriver.java +++ b/src/api/java/stargatetech2/api/bus/IBusDriver.java @@ -50,4 +50,16 @@ public interface IBusDriver { * @return The address of this IBusDriver's IBusInterface. */ public short getInterfaceAddress(); + + /** + * @return this driver's short name.
+ * Should be readable and indicate what kind of device it is.
+ * Example: Shield Controller + */ + public String getShortName(); + + /** + * @return a short description of what this device is. + */ + public String getDescription(); } \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/shields/IShieldController.java b/src/api/java/stargatetech2/api/shields/IShieldController.java deleted file mode 100644 index 4f3fa4763..000000000 --- a/src/api/java/stargatetech2/api/shields/IShieldController.java +++ /dev/null @@ -1,37 +0,0 @@ -package stargatetech2.api.shields; - -/** - * Implemented by the Shield Controller TileEntities. - * - * @author LordFokas - */ -public interface IShieldController { - /** - * Given the way shield emitters work together, you cannot - * directly access their ShieldPermissions object. - * This means you cannot use this method to change - * permissions on a shield. - * - * @return A deep clone of the ShieldPermissions object that - * defines this controller's shield behavior. - */ - public ShieldPermissions getPermissions(); - - /** - * @return True if the shield is activated, false otherwise. - */ - public boolean isShieldOn(); - - /** - * @return The name of the player who owns this Shield Controller. - */ - public String getOwner(); - - /** - * Checks if a player can access this device. - * - * @param player The player's name. - * @return Whether or not this player can access this device. - */ - public boolean hasAccess(String player); -} \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/shields/IShieldable.java b/src/api/java/stargatetech2/api/shields/IShieldable.java deleted file mode 100644 index 50003e0e3..000000000 --- a/src/api/java/stargatetech2/api/shields/IShieldable.java +++ /dev/null @@ -1,35 +0,0 @@ -package stargatetech2.api.shields; - -import net.minecraft.world.World; - -/** - * Used by shield emitters to make shieldable blocks in their way raise and lower their shields. - * - * @author LordFokas - */ -public interface IShieldable { - /** - * Called by shield emitters to make blocks raise their shields. - * The block on {px, py, pz} contains an IShieldController from - * which you can get the current ShieldPermissions object. - * - * @param world The world this IShieldable is on. - * @param x This IShieldable's X Coordinate. - * @param y This IShieldable's Y Coordinate. - * @param z This IShieldable's Z Coordinate. - * @param px The X Coordinate of the shield controller in charge of the shield on this block. - * @param py The Y Coordinate of the shield controller in charge of the shield on this block. - * @param pz The Z Coordinate of the shield controller in charge of the shield on this block. - */ - public void onShield(World world, int x, int y, int z, int px, int py, int pz); - - /** - * Called by shield emitters to make blocks lower their shields. - * - * @param world The world this IShieldable is on. - * @param x This IShieldable's X Coordinate. - * @param y This IShieldable's Y Coordinate. - * @param z This IShieldable's Z Coordinate. - */ - public void onUnshield(World world, int x, int y, int z); -} \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/shields/ITileShieldEmitter.java b/src/api/java/stargatetech2/api/shields/ITileShieldEmitter.java deleted file mode 100644 index 96dd027b0..000000000 --- a/src/api/java/stargatetech2/api/shields/ITileShieldEmitter.java +++ /dev/null @@ -1,65 +0,0 @@ -package stargatetech2.api.shields; - -/** - * Implemented by the shield emitter TileEntities. - * - * @author LordFokas - */ -public interface ITileShieldEmitter { - /** - * Given the way shield emitters work together, you cannot - * directly access their ShieldPermissions object. - * This means you cannot use this method to change - * permissions on a shield. - * - * @return A deep clone of theShieldPermissions object that - * defines this emitter's shield behavior. - */ - public ShieldPermissions getPermissions(); - - /** - * @return True if the shield is activated, false otherwise. - */ - public boolean isShieldOn(); - - /** - * Update the permissions on this emitter. - * It will propagate to the whole shield. - * - * @param isAllow true if allowing this flag, false if disallowing. - * @param flag The flag we're (dis)allowing. - * @see stargatetech2.api.ShieldPermissions - */ - public void updatePermissions(boolean isAllow, int flag); - - /** - * Update the exceptions on this emitter. - * It will propagate to the whole shield. - * - * @param isAdding true if we're adding a player to the exceptions, false if removing. - * @param player The name of the player we're adding / removing. - * @see stargatetech2.api.ShieldPermissions - */ - public void updateExceptions(boolean isAdding, String player); - - /** - * Sets the owner of this Shield Emitter. - * An owner has previleges no other players have. - * - * @param owner The owner's player name. - */ - public void setOwner(String owner); - - /** - * @return The player name of this machine's owner. - */ - public String getOwner(); - - /** - * Checks if a player can access this device. - * - * @param player The player's name. - * @return Whether or not this player can access this device. - */ - public boolean canAccess(String player); -} \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/shields/ShieldPermissions.java b/src/api/java/stargatetech2/api/shields/ShieldPermissions.java deleted file mode 100644 index da06013bd..000000000 --- a/src/api/java/stargatetech2/api/shields/ShieldPermissions.java +++ /dev/null @@ -1,165 +0,0 @@ -package stargatetech2.api.shields; - -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityMinecart; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; - - -public class ShieldPermissions { - // Permission Flags - public static final int PERM_FRIEND = 0x01; - public static final int PERM_PLAYER = 0x02; - public static final int PERM_VILLAGER = 0x04; - public static final int PERM_ANIMAL = 0x08; - public static final int PERM_MONSTER = 0x10; - public static final int PERM_VESSEL = 0x20; - - private int permValue = 0; - private LinkedList playerExceptions = new LinkedList(); - - /** - * @return A default ShieldPermissions object. - */ - public static ShieldPermissions getDefault(){ - ShieldPermissions perm = new ShieldPermissions(); - perm.allow(PERM_FRIEND | PERM_PLAYER); - return perm; - } - - /** - * @param perm Make shields allow this PERM_* flag. - * Combinations (binary or) are allowed. - */ - public void allow(int perm){ - permValue |= perm; - } - - /** - * @param perm Make shields disallow this PERM_* flag. - * Combinations (binary or) are allowed. - */ - public void disallow(int perm){ - permValue &= ~perm; - } - - /** - * Add an exception to the current player permission setting. - * @param player The name of the player to add to the exceptions. - */ - public void setPlayerException(String player){ - if(!playerExceptions.contains(player)) - playerExceptions.add(player); - } - - /** - * Remove an exception from the current player permission setting. - * @param player The name of the player to remove from the exceptions. - */ - public void removePlayerException(String player){ - playerExceptions.remove(player); - } - - /** - * @return A list of strings containing the names of all the players - * who currently are exceptions to the player permission setting. - */ - public List getExceptionList(){ - return playerExceptions; - } - - /** - * Check if this entity is allowed to go through the shields. - * - * @param entity The entity to be checked. - * @param doDismount If set to true, when an allowed entity is being ridden - * by a disallowed one, it's rider will be dismounted so this entity can pass. - * @return Whether this entity can go through or not. - */ - public boolean isEntityAllowed(Entity entity, boolean doDismount){ - boolean allow = false; - if(entity instanceof EntityPlayer){ - if(hasBit(PERM_PLAYER)){ - allow = true; - } - if(playerExceptions.contains(entity.getEntityName())){ - allow = !allow; - } - }else if(entity instanceof EntityVillager){ - allow = hasBit(PERM_VILLAGER); - }else if(entity instanceof EntityAnimal){ - allow = hasBit(PERM_ANIMAL); - }else if(entity instanceof EntityMob){ - allow = hasBit(PERM_MONSTER); - }else if(entity instanceof EntityMinecart){ - allow = hasBit(PERM_VESSEL); - } - if(allow && entity.riddenByEntity != null && doDismount && entity.worldObj.isRemote == false){ - if(!isEntityAllowed(entity.riddenByEntity, true)){ - Entity rider = entity.riddenByEntity; - if(rider instanceof EntityPlayer){ - rider.mountEntity(null); - }else{ - rider.ridingEntity = null; - rider.prevPosY += 1; - rider.posY += 1; - entity.riddenByEntity = null; - } - } - } - return allow; - } - - /** - * @param bit A binary flag to check against these permissions. - * While usually this is a PERM_* flag, any combination of bits is allowed. - * @return Whether this flag exists in these permissions or not. - */ - public boolean hasBit(int bit){ - return (permValue & bit) != 0; - } - - /** - * @return A deep clone of this object. - */ - public ShieldPermissions deepClone(){ - ShieldPermissions clone = new ShieldPermissions(); - clone.permValue = this.permValue; - for(String player : playerExceptions){ - clone.playerExceptions.add(player); - } - return clone; - } - - // This really doesn't need an explanation... - public static ShieldPermissions readFromNBT(NBTTagCompound nbt){ - ShieldPermissions permissions = getDefault(); - if(nbt != null){ - int exceptions = nbt.getInteger("exceptions"); - permissions.permValue = nbt.getInteger("permValue"); - permissions.playerExceptions = new LinkedList(); - for(int i = 0; i < exceptions; i++){ - permissions.setPlayerException(nbt.getString("pex" + i)); - } - } - return permissions; - } - - // ... does it? - public NBTTagCompound writeToNBT(){ - NBTTagCompound nbt = new NBTTagCompound(); - int exceptions = playerExceptions.size(); - nbt.setInteger("permValue", permValue); - nbt.setInteger("exceptions", exceptions); - for(int i = 0; i < exceptions; i++){ - nbt.setString("pex" + i, playerExceptions.get(i)); - } - return nbt; - } -} \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/stargate/DialError.java b/src/api/java/stargatetech2/api/stargate/DialError.java new file mode 100644 index 000000000..efb5b272d --- /dev/null +++ b/src/api/java/stargatetech2/api/stargate/DialError.java @@ -0,0 +1,22 @@ +package stargatetech2.api.stargate; + +public enum DialError{ + // Dialing Errors + SOURCE_ADDRESS_NOT_FOUND, + TARGET_ADDRESS_NOT_FOUND, + SOURCE_WORLD_NOT_FOUND, + TARGET_WORLD_NOT_FOUND, + CANNOT_DIAL_SAME_WORLD, + FAILED_CHUNKLOADING_SOURCE, + FAILED_CHUNKLOADING_TARGET, + SOURCE_GATE_NOT_FOUND, + TARGET_GATE_NOT_FOUND, + NOT_ENOUGH_POWER, + TARGET_GATE_BUSY, + SOURCE_GATE_BUSY, + + // Logic + DIALING_EVENT_CANCELED, + SUCCESSFULLY_DIALED, + UNKNOWN_LOGIC_ERROR; +} diff --git a/src/api/java/stargatetech2/api/stargate/DialEvent.java b/src/api/java/stargatetech2/api/stargate/DialEvent.java new file mode 100644 index 000000000..14337f268 --- /dev/null +++ b/src/api/java/stargatetech2/api/stargate/DialEvent.java @@ -0,0 +1,38 @@ +package stargatetech2.api.stargate; + +import net.minecraftforge.event.Cancelable; +import net.minecraftforge.event.Event; + +public abstract class DialEvent extends Event { + public final Address sourceAddress; + public final Address destAddress; + public final int duration; + + public DialEvent(Address src, Address dst, int dur) { + sourceAddress = src; + destAddress = dst; + duration = dur; + } + + @Cancelable + public static class Pre extends DialEvent { + public Pre(Address src, Address dst, int dur) { + super(src, dst, dur); + } + } + + public static class Success extends DialEvent { + public Success(Address src, Address dst, int dur) { + super(src, dst, dur); + } + } + + public static class Error extends DialEvent { + public final DialError error; + + public Error(Address src, Address dst, DialError error) { + super(src, dst, -1); + this.error = error; + } + } +} diff --git a/src/api/java/stargatetech2/api/stargate/IDynamicWorldLoader.java b/src/api/java/stargatetech2/api/stargate/IDynamicWorldLoader.java new file mode 100644 index 000000000..88c9a26df --- /dev/null +++ b/src/api/java/stargatetech2/api/stargate/IDynamicWorldLoader.java @@ -0,0 +1,21 @@ +package stargatetech2.api.stargate; + + +public interface IDynamicWorldLoader { + /** + * @param address The address we're creating a new world for. + * @return Whether or not this loader will create a new world for this non-existing address. + */ + public boolean willCreateWorldFor(Address address); + + /** + * Actually create a new world for this address. + * This world must not exist already! + * Do not forget to use the seedingShip to place a stargate on this world, or the pending + * wormhole will not connect. + * + * @param address The address we're creating a new world for. + * @param seedingShip The IStargatePlacer we'll use to place our stargate. + */ + public void loadWorldFor(Address address, IStargatePlacer seedingShip); +} \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/stargate/IStargateNetwork.java b/src/api/java/stargatetech2/api/stargate/IStargateNetwork.java index 7bd3ce4c5..c66fe3a81 100644 --- a/src/api/java/stargatetech2/api/stargate/IStargateNetwork.java +++ b/src/api/java/stargatetech2/api/stargate/IStargateNetwork.java @@ -33,4 +33,48 @@ public interface IStargateNetwork { * @return The Stargate's address, or null if the location doesn't contain a Stargate. */ public Address getAddressOf(World world, int x, int y, int z); + + /** + * Returns the address of the Stargate nearest to the specified location, or null if there is no gate within the specified radius + * @param world The world the target Stargate is in. + * @param x The target Stargate's X coordinate. + * @param y The target Stargate's Y coordinate. + * @param z The target Stargate's Z coordinate. + * @param radius The maximum radius to look for a Stargate. Use -1 to search the whole world. + * @return The Stargate's address, or null if no Stargate was found + */ + public Address findNearestStargate(World world, int x, int y, int z, int radius); + + /** + * Register a new IDynamicWorldLoader. + * + * @param dwl The IDynamicWorldLoader to register. + */ + public void registerDynamicWorldLoader(IDynamicWorldLoader dwl); + + /** + * Unregister a known IDynamicWorldLoader. + * + * @param dwl The IDynamicWorldLoader to unregister. + */ + public void unregisterDynamicWorldLoader(IDynamicWorldLoader dwl); + + /** + * Reserve an address prefix for your DWL. + * If a Stargate attempts to dial a world with that prefix, + * your DWL is given exclusivity in generating that world. + * + * @param dwl Your IDynamicWorldLoader + * @param prefix And array of exactly 3 non-null and non-void symbols representing a dimension. + * @return whether or not the prefix has been successfully reserved. + */ + public boolean reserveDimensionPrefix(IDynamicWorldLoader dwl, Symbol[] prefix); + + /** + * Checks if the specified prefix is associated with a dimension or reserved by a {@link IDynamicWorldLoader}. + * + * @param prefix An array of exactly 3 non-null and non-void symbols representing a dimension. + * @return Whether or not the prefix is either used or reserved. + */ + public boolean prefixExists(Symbol[] prefix); } \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/stargate/IStargatePlacer.java b/src/api/java/stargatetech2/api/stargate/IStargatePlacer.java new file mode 100644 index 000000000..348c12143 --- /dev/null +++ b/src/api/java/stargatetech2/api/stargate/IStargatePlacer.java @@ -0,0 +1,17 @@ +package stargatetech2.api.stargate; + +import net.minecraft.world.World; + +public interface IStargatePlacer { + /** + * Attempts to place a Stargate in the givel location. + * + * @param w Our world. + * @param x The stargate base's (bottom center block) X coord. + * @param y The stargate base's (bottom center block) Y coord. + * @param z The stargate base's (bottom center block) Z coord. + * @param facing The direction the stargate should be facing. Should be a value in [0 - 3]. + * @return Whether the Stargate was placed or not. + */ + public boolean placeStargate(World w, int x, int y, int z, int facing); +} diff --git a/src/api/java/stargatetech2/api/stargate/ITileStargateBase.java b/src/api/java/stargatetech2/api/stargate/ITileStargateBase.java index b765cace1..1ff40cf4e 100644 --- a/src/api/java/stargatetech2/api/stargate/ITileStargateBase.java +++ b/src/api/java/stargatetech2/api/stargate/ITileStargateBase.java @@ -14,6 +14,10 @@ package stargatetech2.api.stargate; * @author LordFokas */ public interface ITileStargateBase extends ITileStargate{ + public enum DialMethod{ + MANUAL, // Dialing Computers + AUTO // DHDs + } /** * Used to try making the Stargate dial an address. @@ -22,5 +26,5 @@ public interface ITileStargateBase extends ITileStargate{ * @param timeout How many seconds the connection will last. (1 - 38; default: 38); * @return whether the dialing sequence started (true) or failed (false). */ - public boolean dial(Address address, int timeout); + public DialError dial(Address address, int timeout, DialMethod method); } \ No newline at end of file diff --git a/src/api/java/stargatetech2/api/world/EventWorldGen.java b/src/api/java/stargatetech2/api/world/EventWorldGen.java new file mode 100644 index 000000000..c252ff53d --- /dev/null +++ b/src/api/java/stargatetech2/api/world/EventWorldGen.java @@ -0,0 +1,28 @@ +package stargatetech2.api.world; + +import net.minecraft.world.World; +import net.minecraftforge.event.Event; +import net.minecraftforge.event.Event.HasResult; + +@HasResult +public class EventWorldGen extends Event { + + public final World world; + public final int chunkX; + public final int chunkZ; + public final GenType type; + + public EventWorldGen(World world, int cX, int cZ, GenType type) { + this.world = world; + this.chunkX = cX; + this.chunkZ = cZ; + this.type = type; + } + + public static enum GenType { + STARGATE, + LOOT_POD, + VEIN_NAQUADAH; + } + +} diff --git a/src/main/scala/li/cil/oc/server/component/AbstractBus.scala b/src/main/scala/li/cil/oc/server/component/AbstractBus.scala index 06ba36d62..dc0cbd191 100644 --- a/src/main/scala/li/cil/oc/server/component/AbstractBus.scala +++ b/src/main/scala/li/cil/oc/server/component/AbstractBus.scala @@ -27,9 +27,13 @@ class AbstractBus(val device: IBusDevice) extends component.ManagedComponent wit // ----------------------------------------------------------------------- // + override def getShortName = "Computer" + + override def getDescription = "An OpenComputers computer or server." + override def canHandlePacket(sender: Short, protocolID: Int, hasLIP: Boolean) = hasLIP - override def handlePacket(packet: BusPacket) { + override def handlePacket(packet: BusPacket[_]) { val lip = packet.getPlainText val data = Map(lip.getEntryList.map(key => (key, lip.get(key))): _*) val metadata = Map("mod" -> lip.getMetadata.modID, "device" -> lip.getMetadata.deviceName, "player" -> lip.getMetadata.playerName) diff --git a/src/main/scala/li/cil/oc/util/mods/Mods.scala b/src/main/scala/li/cil/oc/util/mods/Mods.scala index 87fe9504d..529f95388 100644 --- a/src/main/scala/li/cil/oc/util/mods/Mods.scala +++ b/src/main/scala/li/cil/oc/util/mods/Mods.scala @@ -27,7 +27,7 @@ object Mods { val PortalGun = new SimpleMod("PortalGun") val ProjectRed = new SimpleMod("ProjRed|Transmission") val RedLogic = new SimpleMod("RedLogic") - val StargateTech2 = new SimpleMod("StargateTech2@[0.6.0,)") + val StargateTech2 = new SimpleMod("StargateTech2@[0.7.0,)") val ThermalExpansion = new SimpleMod("ThermalExpansion") val TinkersConstruct = new SimpleMod("TConstruct") val UniversalElectricity = new SimpleMod("UniversalElectricity@[3.1,)")