mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Started reworking API for 1.5.
This commit is contained in:
parent
806dda8827
commit
298d97639e
@ -1,6 +1,10 @@
|
|||||||
package li.cil.oc.api;
|
package li.cil.oc.api;
|
||||||
|
|
||||||
import li.cil.oc.api.detail.*;
|
import li.cil.oc.api.detail.DriverAPI;
|
||||||
|
import li.cil.oc.api.detail.FileSystemAPI;
|
||||||
|
import li.cil.oc.api.detail.ItemAPI;
|
||||||
|
import li.cil.oc.api.detail.MachineAPI;
|
||||||
|
import li.cil.oc.api.detail.NetworkAPI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Central reference for the API.
|
* Central reference for the API.
|
||||||
@ -11,7 +15,7 @@ import li.cil.oc.api.detail.*;
|
|||||||
*/
|
*/
|
||||||
public class API {
|
public class API {
|
||||||
public static final String ID_OWNER = "OpenComputers|Core";
|
public static final String ID_OWNER = "OpenComputers|Core";
|
||||||
public static final String VERSION = "4.2.4";
|
public static final String VERSION = "5.0.0-alpha";
|
||||||
|
|
||||||
public static DriverAPI driver = null;
|
public static DriverAPI driver = null;
|
||||||
public static FileSystemAPI fileSystem = null;
|
public static FileSystemAPI fileSystem = null;
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package li.cil.oc.api;
|
package li.cil.oc.api;
|
||||||
|
|
||||||
import li.cil.oc.api.detail.Builder;
|
import li.cil.oc.api.detail.Builder;
|
||||||
import li.cil.oc.api.network.*;
|
import li.cil.oc.api.network.Environment;
|
||||||
|
import li.cil.oc.api.network.Node;
|
||||||
|
import li.cil.oc.api.network.Packet;
|
||||||
|
import li.cil.oc.api.network.Visibility;
|
||||||
|
import li.cil.oc.api.network.WirelessEndpoint;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
@ -558,24 +558,6 @@ public interface TextBuffer extends ManagedEnvironment, Persistable {
|
|||||||
*/
|
*/
|
||||||
void mouseScroll(double x, double y, int delta, EntityPlayer player);
|
void mouseScroll(double x, double y, int delta, EntityPlayer player);
|
||||||
|
|
||||||
// TODO Remove deprecated overloads in 1.5.
|
|
||||||
|
|
||||||
/** @deprecated Use the floating-point variant instead. */
|
|
||||||
@Deprecated
|
|
||||||
void mouseDown(int x, int y, int button, EntityPlayer player);
|
|
||||||
|
|
||||||
/** @deprecated Use the floating-point variant instead. */
|
|
||||||
@Deprecated
|
|
||||||
void mouseDrag(int x, int y, int button, EntityPlayer player);
|
|
||||||
|
|
||||||
/** @deprecated Use the floating-point variant instead. */
|
|
||||||
@Deprecated
|
|
||||||
void mouseUp(int x, int y, int button, EntityPlayer player);
|
|
||||||
|
|
||||||
/** @deprecated Use the floating-point variant instead. */
|
|
||||||
@Deprecated
|
|
||||||
void mouseScroll(int x, int y, int delta, EntityPlayer player);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package li.cil.oc.api.detail;
|
package li.cil.oc.api.detail;
|
||||||
|
|
||||||
import li.cil.oc.api.network.*;
|
import li.cil.oc.api.network.Component;
|
||||||
|
import li.cil.oc.api.network.ComponentConnector;
|
||||||
|
import li.cil.oc.api.network.Connector;
|
||||||
|
import li.cil.oc.api.network.Node;
|
||||||
|
import li.cil.oc.api.network.Visibility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for building {@link Node}s via {@link li.cil.oc.api.Network#newNode}.
|
* Used for building {@link Node}s via {@link li.cil.oc.api.Network#newNode}.
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package li.cil.oc.api.detail;
|
package li.cil.oc.api.detail;
|
||||||
|
|
||||||
import li.cil.oc.api.network.*;
|
import li.cil.oc.api.network.Environment;
|
||||||
|
import li.cil.oc.api.network.Node;
|
||||||
|
import li.cil.oc.api.network.Packet;
|
||||||
|
import li.cil.oc.api.network.Visibility;
|
||||||
|
import li.cil.oc.api.network.WirelessEndpoint;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,8 +14,8 @@ public class RobotAnalyzeEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
public final EntityPlayer player;
|
public final EntityPlayer player;
|
||||||
|
|
||||||
public RobotAnalyzeEvent(Robot robot, EntityPlayer player) {
|
public RobotAnalyzeEvent(Agent agent, EntityPlayer player) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
public class RobotAttackEntityEvent extends RobotEvent {
|
public class RobotAttackEntityEvent extends RobotEvent {
|
||||||
@ -10,8 +10,8 @@ public class RobotAttackEntityEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
public final Entity target;
|
public final Entity target;
|
||||||
|
|
||||||
protected RobotAttackEntityEvent(Robot robot, Entity target) {
|
protected RobotAttackEntityEvent(Agent agent, Entity target) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,8 +22,8 @@ public class RobotAttackEntityEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class Pre extends RobotAttackEntityEvent {
|
public static class Pre extends RobotAttackEntityEvent {
|
||||||
public Pre(Robot robot, Entity target) {
|
public Pre(Agent agent, Entity target) {
|
||||||
super(robot, target);
|
super(agent, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ public class RobotAttackEntityEvent extends RobotEvent {
|
|||||||
* Fired after a robot has attacked an entity.
|
* Fired after a robot has attacked an entity.
|
||||||
*/
|
*/
|
||||||
public static class Post extends RobotAttackEntityEvent {
|
public static class Post extends RobotAttackEntityEvent {
|
||||||
public Post(Robot robot, Entity target) {
|
public Post(Agent agent, Entity target) {
|
||||||
super(robot, target);
|
super(agent, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class RobotBreakBlockEvent extends RobotEvent {
|
public abstract class RobotBreakBlockEvent extends RobotEvent {
|
||||||
protected RobotBreakBlockEvent(Robot robot) {
|
protected RobotBreakBlockEvent(Agent agent) {
|
||||||
super(robot);
|
super(agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,8 +31,8 @@ public abstract class RobotBreakBlockEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
private double breakTime;
|
private double breakTime;
|
||||||
|
|
||||||
public Pre(Robot robot, World world, int x, int y, int z, double breakTime) {
|
public Pre(Agent agent, World world, int x, int y, int z, double breakTime) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@ -71,8 +71,8 @@ public abstract class RobotBreakBlockEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
public final double experience;
|
public final double experience;
|
||||||
|
|
||||||
public Post(Robot robot, double experience) {
|
public Post(Agent agent, double experience) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.experience = experience;
|
this.experience = experience;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for events generated by robots.
|
* Base class for events generated by robots.
|
||||||
@ -10,9 +10,9 @@ public abstract class RobotEvent extends Event {
|
|||||||
/**
|
/**
|
||||||
* The robot for which this event was fired.
|
* The robot for which this event was fired.
|
||||||
*/
|
*/
|
||||||
public final Robot robot;
|
public final Agent agent;
|
||||||
|
|
||||||
protected RobotEvent(Robot robot) {
|
protected RobotEvent(Agent agent) {
|
||||||
this.robot = robot;
|
this.agent = agent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a robot performed an action that would cause exhaustion for a
|
* Fired when a robot performed an action that would cause exhaustion for a
|
||||||
@ -12,8 +12,8 @@ public class RobotExhaustionEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
public final double exhaustion;
|
public final double exhaustion;
|
||||||
|
|
||||||
public RobotExhaustionEvent(Robot robot, double exhaustion) {
|
public RobotExhaustionEvent(Agent agent, double exhaustion) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.exhaustion = exhaustion;
|
this.exhaustion = exhaustion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public abstract class RobotMoveEvent extends RobotEvent {
|
public abstract class RobotMoveEvent extends RobotEvent {
|
||||||
@ -10,8 +10,8 @@ public abstract class RobotMoveEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
public final ForgeDirection direction;
|
public final ForgeDirection direction;
|
||||||
|
|
||||||
protected RobotMoveEvent(Robot robot, ForgeDirection direction) {
|
protected RobotMoveEvent(Agent agent, ForgeDirection direction) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,8 +22,8 @@ public abstract class RobotMoveEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class Pre extends RobotMoveEvent {
|
public static class Pre extends RobotMoveEvent {
|
||||||
public Pre(Robot robot, ForgeDirection direction) {
|
public Pre(Agent agent, ForgeDirection direction) {
|
||||||
super(robot, direction);
|
super(agent, direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ public abstract class RobotMoveEvent extends RobotEvent {
|
|||||||
* Fired after a robot moved.
|
* Fired after a robot moved.
|
||||||
*/
|
*/
|
||||||
public static class Post extends RobotMoveEvent {
|
public static class Post extends RobotMoveEvent {
|
||||||
public Post(Robot robot, ForgeDirection direction) {
|
public Post(Agent agent, ForgeDirection direction) {
|
||||||
super(robot, direction);
|
super(agent, direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ public abstract class RobotPlaceBlockEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
public final int x, y, z;
|
public final int x, y, z;
|
||||||
|
|
||||||
protected RobotPlaceBlockEvent(Robot robot, ItemStack stack, World world, int x, int y, int z) {
|
protected RobotPlaceBlockEvent(Agent agent, ItemStack stack, World world, int x, int y, int z) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@ -37,8 +37,8 @@ public abstract class RobotPlaceBlockEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class Pre extends RobotPlaceBlockEvent {
|
public static class Pre extends RobotPlaceBlockEvent {
|
||||||
public Pre(Robot robot, ItemStack stack, World world, int x, int y, int z) {
|
public Pre(Agent agent, ItemStack stack, World world, int x, int y, int z) {
|
||||||
super(robot, stack, world, x, y, z);
|
super(agent, stack, world, x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +46,8 @@ public abstract class RobotPlaceBlockEvent extends RobotEvent {
|
|||||||
* Fired after a robot placed a block.
|
* Fired after a robot placed a block.
|
||||||
*/
|
*/
|
||||||
public static class Post extends RobotPlaceBlockEvent {
|
public static class Post extends RobotPlaceBlockEvent {
|
||||||
public Post(Robot robot, ItemStack stack, World world, int x, int y, int z) {
|
public Post(Agent agent, ItemStack stack, World world, int x, int y, int z) {
|
||||||
super(robot, stack, world, x, y, z);
|
super(agent, stack, world, x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired when a robot tries to place a block and has no point of
|
* This event is fired when a robot tries to place a block and has no point of
|
||||||
@ -13,8 +13,8 @@ import li.cil.oc.api.internal.Robot;
|
|||||||
public class RobotPlaceInAirEvent extends RobotEvent {
|
public class RobotPlaceInAirEvent extends RobotEvent {
|
||||||
private boolean isAllowed = false;
|
private boolean isAllowed = false;
|
||||||
|
|
||||||
public RobotPlaceInAirEvent(Robot robot) {
|
public RobotPlaceInAirEvent(Agent agent) {
|
||||||
super(robot);
|
super(agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
import org.lwjgl.util.vector.Vector3f;
|
import org.lwjgl.util.vector.Vector3f;
|
||||||
import org.lwjgl.util.vector.Vector4f;
|
import org.lwjgl.util.vector.Vector4f;
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ public class RobotRenderEvent extends RobotEvent {
|
|||||||
*/
|
*/
|
||||||
public final MountPoint[] mountPoints;
|
public final MountPoint[] mountPoints;
|
||||||
|
|
||||||
public RobotRenderEvent(Robot robot, MountPoint[] mountPoints) {
|
public RobotRenderEvent(Agent agent, MountPoint[] mountPoints) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.mountPoints = mountPoints;
|
this.mountPoints = mountPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import li.cil.oc.api.internal.Robot;
|
import li.cil.oc.api.internal.Agent;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class RobotUsedToolEvent extends RobotEvent {
|
public class RobotUsedToolEvent extends RobotEvent {
|
||||||
@ -11,8 +11,8 @@ public class RobotUsedToolEvent extends RobotEvent {
|
|||||||
|
|
||||||
protected double damageRate;
|
protected double damageRate;
|
||||||
|
|
||||||
protected RobotUsedToolEvent(Robot robot, ItemStack toolBeforeUse, ItemStack toolAfterUse, double damageRate) {
|
protected RobotUsedToolEvent(Agent agent, ItemStack toolBeforeUse, ItemStack toolAfterUse, double damageRate) {
|
||||||
super(robot);
|
super(agent);
|
||||||
this.toolBeforeUse = toolBeforeUse;
|
this.toolBeforeUse = toolBeforeUse;
|
||||||
this.toolAfterUse = toolAfterUse;
|
this.toolAfterUse = toolAfterUse;
|
||||||
this.damageRate = damageRate;
|
this.damageRate = damageRate;
|
||||||
@ -36,8 +36,8 @@ public class RobotUsedToolEvent extends RobotEvent {
|
|||||||
* experience upgrade, for example.
|
* experience upgrade, for example.
|
||||||
*/
|
*/
|
||||||
public static class ComputeDamageRate extends RobotUsedToolEvent {
|
public static class ComputeDamageRate extends RobotUsedToolEvent {
|
||||||
public ComputeDamageRate(Robot robot, ItemStack toolBeforeUse, ItemStack toolAfterUse, double damageRate) {
|
public ComputeDamageRate(Agent agent, ItemStack toolBeforeUse, ItemStack toolAfterUse, double damageRate) {
|
||||||
super(robot, toolBeforeUse, toolAfterUse, damageRate);
|
super(agent, toolBeforeUse, toolAfterUse, damageRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,8 +63,8 @@ public class RobotUsedToolEvent extends RobotEvent {
|
|||||||
* durability is stored in the item's NBT tag.
|
* durability is stored in the item's NBT tag.
|
||||||
*/
|
*/
|
||||||
public static class ApplyDamageRate extends RobotUsedToolEvent {
|
public static class ApplyDamageRate extends RobotUsedToolEvent {
|
||||||
public ApplyDamageRate(Robot robot, ItemStack toolBeforeUse, ItemStack toolAfterUse, double damageRate) {
|
public ApplyDamageRate(Agent agent, ItemStack toolBeforeUse, ItemStack toolAfterUse, double damageRate) {
|
||||||
super(robot, toolBeforeUse, toolAfterUse, damageRate);
|
super(agent, toolBeforeUse, toolAfterUse, damageRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
src/main/java/li/cil/oc/api/internal/Agent.java
Normal file
22
src/main/java/li/cil/oc/api/internal/Agent.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package li.cil.oc.api.internal;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General marker interface for autonomous agents such as robots and drones.
|
||||||
|
*/
|
||||||
|
public interface Agent {
|
||||||
|
/**
|
||||||
|
* Returns the fake player used to represent the agent as an entity for
|
||||||
|
* certain actions that require one.
|
||||||
|
* <p/>
|
||||||
|
* This will automatically be positioned and rotated to represent the
|
||||||
|
* agent's current position and rotation in the world. Use this to trigger
|
||||||
|
* events involving the agent that require a player entity.
|
||||||
|
* <p/>
|
||||||
|
* Note that this <em>may</em> be the common OpenComputers fake player.
|
||||||
|
*
|
||||||
|
* @return the fake player for the agent.
|
||||||
|
*/
|
||||||
|
EntityPlayer player();
|
||||||
|
}
|
@ -18,7 +18,7 @@ import net.minecraft.util.Vec3;
|
|||||||
* i.e. without having to link against internal classes. This also means
|
* i.e. without having to link against internal classes. This also means
|
||||||
* that <em>you should not implement this</em>.
|
* that <em>you should not implement this</em>.
|
||||||
*/
|
*/
|
||||||
public interface Drone extends EnvironmentHost, Rotatable, Tiered {
|
public interface Drone extends Agent, EnvironmentHost, Rotatable, Tiered {
|
||||||
/**
|
/**
|
||||||
* The machine currently hosted by this drone.
|
* The machine currently hosted by this drone.
|
||||||
*/
|
*/
|
||||||
|
@ -31,25 +31,12 @@ import net.minecraftforge.fluids.IFluidTank;
|
|||||||
* <p/>
|
* <p/>
|
||||||
* This interface is <em>not meant to be implemented</em>, just used.
|
* This interface is <em>not meant to be implemented</em>, just used.
|
||||||
*/
|
*/
|
||||||
public interface Robot extends Environment, EnvironmentHost, Rotatable, Tiered, ISidedInventory, IFluidHandler {
|
public interface Robot extends Agent, Environment, EnvironmentHost, Rotatable, Tiered, ISidedInventory, IFluidHandler {
|
||||||
/**
|
/**
|
||||||
* The machine currently hosted by this robot.
|
* The machine currently hosted by this robot.
|
||||||
*/
|
*/
|
||||||
Machine machine();
|
Machine machine();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the fake player used to represent the robot as an entity for
|
|
||||||
* certain actions that require one.
|
|
||||||
* <p/>
|
|
||||||
* This will automatically be positioned and rotated to represent the
|
|
||||||
* robot's current position and rotation in the world. Use this to trigger
|
|
||||||
* events involving the robot that require a player entity, and for more
|
|
||||||
* in-depth interaction with the robots' inventory.
|
|
||||||
*
|
|
||||||
* @return the fake player for the robot.
|
|
||||||
*/
|
|
||||||
EntityPlayer player();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of hot-swappable component slots in this robot.
|
* The number of hot-swappable component slots in this robot.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -20,7 +20,7 @@ import li.cil.oc.api.machine.Machine;
|
|||||||
* via the API, i.e. without having to link against internal classes. This
|
* via the API, i.e. without having to link against internal classes. This
|
||||||
* also means that <em>you should not implement this</em>.
|
* also means that <em>you should not implement this</em>.
|
||||||
*/
|
*/
|
||||||
public interface Server extends EnvironmentHost {
|
public interface Server extends EnvironmentHost, Tiered {
|
||||||
/**
|
/**
|
||||||
* The machine currently hosted by this server.
|
* The machine currently hosted by this server.
|
||||||
*/
|
*/
|
||||||
@ -35,9 +35,4 @@ public interface Server extends EnvironmentHost {
|
|||||||
* The slot of the server rack this server is in.
|
* The slot of the server rack this server is in.
|
||||||
*/
|
*/
|
||||||
int slot();
|
int slot();
|
||||||
|
|
||||||
/**
|
|
||||||
* The tier of the server.
|
|
||||||
*/
|
|
||||||
int tier();
|
|
||||||
}
|
}
|
||||||
|
@ -72,16 +72,6 @@ public interface MachineHost extends EnvironmentHost {
|
|||||||
*/
|
*/
|
||||||
int componentSlot(String address);
|
int componentSlot(String address);
|
||||||
|
|
||||||
/**
|
|
||||||
* This is called by the machine when its state changed (which can be
|
|
||||||
* multiple times per actual game tick), to notify the owner that it should
|
|
||||||
* save its state on the next world save.
|
|
||||||
* <p/>
|
|
||||||
* This method is called from executor threads, so it must be thread-safe.
|
|
||||||
*/
|
|
||||||
// TODO Merge with {@link EnvironmentHost#markChanged} in 1.5
|
|
||||||
void markForSaving();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called on the owner when the machine's {@link Environment#onConnect(Node)}
|
* This is called on the owner when the machine's {@link Environment#onConnect(Node)}
|
||||||
* method gets called. This can be useful for reacting to network events
|
* method gets called. This can be useful for reacting to network events
|
||||||
|
@ -6,6 +6,7 @@ import li.cil.oc.api.network.Message;
|
|||||||
import li.cil.oc.api.network.Node;
|
import li.cil.oc.api.network.Node;
|
||||||
import li.cil.oc.api.network.Visibility;
|
import li.cil.oc.api.network.Visibility;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +18,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
* network as an index structure to find other nodes connected to them.
|
* network as an index structure to find other nodes connected to them.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public abstract class TileEntityEnvironment extends TileEntity implements Environment {
|
public abstract class TileEntityEnvironment extends TileEntity implements Environment, IUpdatePlayerListBox {
|
||||||
/**
|
/**
|
||||||
* This must be set in subclasses to the node that is used to represent
|
* This must be set in subclasses to the node that is used to represent
|
||||||
* this tile entity.
|
* this tile entity.
|
||||||
@ -96,8 +97,7 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
|
|||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void update() {
|
||||||
super.updateEntity();
|
|
||||||
// On the first update, try to add our node to nearby networks. We do
|
// On the first update, try to add our node to nearby networks. We do
|
||||||
// this in the update logic, not in validate() because we need to access
|
// this in the update logic, not in validate() because we need to access
|
||||||
// neighboring tile entities, which isn't possible in validate().
|
// neighboring tile entities, which isn't possible in validate().
|
||||||
|
@ -415,20 +415,6 @@ class TextBuffer(val host: EnvironmentHost) extends prefab.ManagedEnvironment wi
|
|||||||
override def mouseScroll(x: Double, y: Double, delta: Int, player: EntityPlayer) =
|
override def mouseScroll(x: Double, y: Double, delta: Int, player: EntityPlayer) =
|
||||||
proxy.mouseScroll(x, y, delta, player)
|
proxy.mouseScroll(x, y, delta, player)
|
||||||
|
|
||||||
// TODO Remove in 1.5
|
|
||||||
|
|
||||||
override def mouseDown(x: Int, y: Int, button: Int, player: EntityPlayer) =
|
|
||||||
mouseDown(x, y, button, player)
|
|
||||||
|
|
||||||
override def mouseDrag(x: Int, y: Int, button: Int, player: EntityPlayer) =
|
|
||||||
mouseDrag(x, y, button, player)
|
|
||||||
|
|
||||||
override def mouseUp(x: Int, y: Int, button: Int, player: EntityPlayer) =
|
|
||||||
mouseUp(x, y, button, player)
|
|
||||||
|
|
||||||
override def mouseScroll(x: Int, y: Int, delta: Int, player: EntityPlayer) =
|
|
||||||
mouseScroll(x, y, delta, player)
|
|
||||||
|
|
||||||
def copyToAnalyzer(line: Int, player: EntityPlayer): Unit = {
|
def copyToAnalyzer(line: Int, player: EntityPlayer): Unit = {
|
||||||
proxy.copyToAnalyzer(line, player)
|
proxy.copyToAnalyzer(line, player)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ import net.minecraft.item.ItemStack
|
|||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraft.util.Vec3
|
import net.minecraft.util.Vec3
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
|
import net.minecraft.world.WorldServer
|
||||||
|
import net.minecraftforge.common.util.FakePlayerFactory
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
import net.minecraftforge.fluids.IFluidTank
|
import net.minecraftforge.fluids.IFluidTank
|
||||||
|
|
||||||
@ -117,6 +119,8 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
|
|
||||||
override def tier = info.tier
|
override def tier = info.tier
|
||||||
|
|
||||||
|
override def player(): EntityPlayer = FakePlayerFactory.get(world.asInstanceOf[WorldServer], Settings.get.fakePlayerProfile)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
// Forward context stuff to our machine. Interface needed for some components
|
// Forward context stuff to our machine. Interface needed for some components
|
||||||
// to work correctly (such as the chunkloader upgrade).
|
// to work correctly (such as the chunkloader upgrade).
|
||||||
@ -213,8 +217,6 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
|
|
||||||
override def componentSlot(address: String) = -1 // TODO
|
override def componentSlot(address: String) = -1 // TODO
|
||||||
|
|
||||||
override def markForSaving() {}
|
|
||||||
|
|
||||||
override def onMachineConnect(node: Node) {}
|
override def onMachineConnect(node: Node) {}
|
||||||
|
|
||||||
override def onMachineDisconnect(node: Node) {}
|
override def onMachineDisconnect(node: Node) {}
|
||||||
|
@ -7,8 +7,9 @@ import li.cil.oc.api.event.RobotPlaceInAirEvent
|
|||||||
object AngelUpgradeHandler {
|
object AngelUpgradeHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onPlaceInAir(e: RobotPlaceInAirEvent) {
|
def onPlaceInAir(e: RobotPlaceInAirEvent) {
|
||||||
val startComponents = 1 + e.robot.containerCount + e.robot.inventorySize
|
// TODO Generalize Agent interface for access to their components.
|
||||||
e.setAllowed(((1 to e.robot.containerCount) ++ (startComponents until startComponents + e.robot.componentCount)).
|
// val startComponents = 1 + e.robot.containerCount + e.robot.inventorySize
|
||||||
exists(slot => api.Items.get(e.robot.getStackInSlot(slot)) == api.Items.get("angelUpgrade")))
|
// e.setAllowed(((1 to e.robot.containerCount) ++ (startComponents until startComponents + e.robot.componentCount)).
|
||||||
|
// exists(slot => api.Items.get(e.robot.getStackInSlot(slot)) == api.Items.get("angelUpgrade")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,12 +55,13 @@ object ChunkloaderUpgradeHandler extends LoadingCallback {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onMove(e: RobotMoveEvent.Post) {
|
def onMove(e: RobotMoveEvent.Post) {
|
||||||
for (slot <- 0 until e.robot.getSizeInventory) {
|
// TODO Generalize Agent interface for access to their components.
|
||||||
e.robot.getComponentInSlot(slot) match {
|
// for (slot <- 0 until e.robot.getSizeInventory) {
|
||||||
case loader: UpgradeChunkloader => updateLoadedChunk(loader)
|
// e.robot.getComponentInSlot(slot) match {
|
||||||
case _ =>
|
// case loader: UpgradeChunkloader => updateLoadedChunk(loader)
|
||||||
}
|
// case _ =>
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateLoadedChunk(loader: UpgradeChunkloader) {
|
def updateLoadedChunk(loader: UpgradeChunkloader) {
|
||||||
|
@ -4,6 +4,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
|||||||
import li.cil.oc.Localization
|
import li.cil.oc.Localization
|
||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.api.event._
|
import li.cil.oc.api.event._
|
||||||
|
import li.cil.oc.api.internal.Agent
|
||||||
import li.cil.oc.api.internal.Robot
|
import li.cil.oc.api.internal.Robot
|
||||||
import li.cil.oc.server.component
|
import li.cil.oc.server.component
|
||||||
import org.lwjgl.opengl.GL11
|
import org.lwjgl.opengl.GL11
|
||||||
@ -11,7 +12,7 @@ import org.lwjgl.opengl.GL11
|
|||||||
object ExperienceUpgradeHandler {
|
object ExperienceUpgradeHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotAnalyze(e: RobotAnalyzeEvent) {
|
def onRobotAnalyze(e: RobotAnalyzeEvent) {
|
||||||
val (level, experience) = getLevelAndExperience(e.robot)
|
val (level, experience) = getLevelAndExperience(e.agent)
|
||||||
// This is basically a 'does it have an experience upgrade' check.
|
// This is basically a 'does it have an experience upgrade' check.
|
||||||
if (experience != 0.0) {
|
if (experience != 0.0) {
|
||||||
e.player.addChatMessage(Localization.Analyzer.RobotXp(experience, level))
|
e.player.addChatMessage(Localization.Analyzer.RobotXp(experience, level))
|
||||||
@ -20,45 +21,46 @@ object ExperienceUpgradeHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotComputeDamageRate(e: RobotUsedToolEvent.ComputeDamageRate) {
|
def onRobotComputeDamageRate(e: RobotUsedToolEvent.ComputeDamageRate) {
|
||||||
e.setDamageRate(e.getDamageRate * math.max(0, 1 - getLevel(e.robot) * Settings.get.toolEfficiencyPerLevel))
|
e.setDamageRate(e.getDamageRate * math.max(0, 1 - getLevel(e.agent) * Settings.get.toolEfficiencyPerLevel))
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotBreakBlockPre(e: RobotBreakBlockEvent.Pre) {
|
def onRobotBreakBlockPre(e: RobotBreakBlockEvent.Pre) {
|
||||||
val boost = math.max(0, 1 - getLevel(e.robot) * Settings.get.harvestSpeedBoostPerLevel)
|
val boost = math.max(0, 1 - getLevel(e.agent) * Settings.get.harvestSpeedBoostPerLevel)
|
||||||
e.setBreakTime(e.getBreakTime * boost)
|
e.setBreakTime(e.getBreakTime * boost)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotAttackEntityPost(e: RobotAttackEntityEvent.Post) {
|
def onRobotAttackEntityPost(e: RobotAttackEntityEvent.Post) {
|
||||||
if (e.robot.getComponentInSlot(e.robot.selectedSlot()) != null && e.target.isDead) {
|
// TODO Generalize Agent interface for access to their components.
|
||||||
addExperience(e.robot, Settings.get.robotActionXp)
|
// if (e.robot.getComponentInSlot(e.robot.selectedSlot()) != null && e.target.isDead) {
|
||||||
}
|
// addExperience(e.robot, Settings.get.robotActionXp)
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotBreakBlockPost(e: RobotBreakBlockEvent.Post) {
|
def onRobotBreakBlockPost(e: RobotBreakBlockEvent.Post) {
|
||||||
addExperience(e.robot, e.experience * Settings.get.robotOreXpRate + Settings.get.robotActionXp)
|
addExperience(e.agent, e.experience * Settings.get.robotOreXpRate + Settings.get.robotActionXp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotPlaceBlockPost(e: RobotPlaceBlockEvent.Post) {
|
def onRobotPlaceBlockPost(e: RobotPlaceBlockEvent.Post) {
|
||||||
addExperience(e.robot, Settings.get.robotActionXp)
|
addExperience(e.agent, Settings.get.robotActionXp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotMovePost(e: RobotMoveEvent.Post) {
|
def onRobotMovePost(e: RobotMoveEvent.Post) {
|
||||||
addExperience(e.robot, Settings.get.robotExhaustionXpRate * 0.01)
|
addExperience(e.agent, Settings.get.robotExhaustionXpRate * 0.01)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotExhaustion(e: RobotExhaustionEvent) {
|
def onRobotExhaustion(e: RobotExhaustionEvent) {
|
||||||
addExperience(e.robot, Settings.get.robotExhaustionXpRate * e.exhaustion)
|
addExperience(e.agent, Settings.get.robotExhaustionXpRate * e.exhaustion)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onRobotRender(e: RobotRenderEvent) {
|
def onRobotRender(e: RobotRenderEvent) {
|
||||||
val level = if (e.robot != null) getLevel(e.robot) else 0
|
val level = if (e.agent != null) getLevel(e.agent) else 0
|
||||||
if (level > 19) {
|
if (level > 19) {
|
||||||
GL11.glColor3f(0.4f, 1, 1)
|
GL11.glColor3f(0.4f, 1, 1)
|
||||||
}
|
}
|
||||||
@ -70,39 +72,42 @@ object ExperienceUpgradeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def getLevel(robot: Robot) = {
|
private def getLevel(agent: Agent) = {
|
||||||
var level = 0
|
var level = 0
|
||||||
for (index <- 0 until robot.getSizeInventory) {
|
// TODO Generalize Agent interface for access to their components.
|
||||||
robot.getComponentInSlot(index) match {
|
// for (index <- 0 until agent.getSizeInventory) {
|
||||||
case upgrade: component.UpgradeExperience =>
|
// agent.getComponentInSlot(index) match {
|
||||||
level += upgrade.level
|
// case upgrade: component.UpgradeExperience =>
|
||||||
case _ =>
|
// level += upgrade.level
|
||||||
}
|
// case _ =>
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
level
|
level
|
||||||
}
|
}
|
||||||
|
|
||||||
private def getLevelAndExperience(robot: Robot) = {
|
private def getLevelAndExperience(agent: Agent) = {
|
||||||
var level = 0
|
var level = 0
|
||||||
var experience = 0.0
|
var experience = 0.0
|
||||||
for (index <- 0 until robot.getSizeInventory) {
|
// TODO Generalize Agent interface for access to their components.
|
||||||
robot.getComponentInSlot(index) match {
|
// for (index <- 0 until agent.getSizeInventory) {
|
||||||
case upgrade: component.UpgradeExperience =>
|
// agent.getComponentInSlot(index) match {
|
||||||
level += upgrade.level
|
// case upgrade: component.UpgradeExperience =>
|
||||||
experience += upgrade.experience
|
// level += upgrade.level
|
||||||
case _ =>
|
// experience += upgrade.experience
|
||||||
}
|
// case _ =>
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
(level, experience)
|
(level, experience)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def addExperience(robot: Robot, amount: Double) {
|
private def addExperience(agent: Agent, amount: Double) {
|
||||||
for (index <- 0 until robot.getSizeInventory) {
|
// TODO Generalize Agent interface for access to their components.
|
||||||
robot.getComponentInSlot(index) match {
|
// for (index <- 0 until agent.getSizeInventory) {
|
||||||
case upgrade: component.UpgradeExperience =>
|
// agent.getComponentInSlot(index) match {
|
||||||
upgrade.addExperience(amount)
|
// case upgrade: component.UpgradeExperience =>
|
||||||
case _ =>
|
// upgrade.addExperience(amount)
|
||||||
}
|
// case _ =>
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ object RobotCommonHandler {
|
|||||||
val damage = e.toolAfterUse.getItemDamage - e.toolBeforeUse.getItemDamage
|
val damage = e.toolAfterUse.getItemDamage - e.toolBeforeUse.getItemDamage
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
val actualDamage = damage * e.getDamageRate
|
val actualDamage = damage * e.getDamageRate
|
||||||
val repairedDamage = if (e.robot.player.getRNG.nextDouble() > 0.5) damage - math.floor(actualDamage).toInt else damage - math.ceil(actualDamage).toInt
|
val repairedDamage = if (e.agent.player.getRNG.nextDouble() > 0.5) damage - math.floor(actualDamage).toInt else damage - math.ceil(actualDamage).toInt
|
||||||
e.toolAfterUse.setItemDamage(e.toolAfterUse.getItemDamage - repairedDamage)
|
e.toolAfterUse.setItemDamage(e.toolAfterUse.getItemDamage - repairedDamage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,13 @@ import li.cil.oc.server.component.WirelessNetworkCard
|
|||||||
object WirelessNetworkCardHandler {
|
object WirelessNetworkCardHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onMove(e: RobotMoveEvent.Post) {
|
def onMove(e: RobotMoveEvent.Post) {
|
||||||
val startComponents = 1 + e.robot.containerCount + e.robot.inventorySize
|
// TODO Generalize Agent interface for access to their components.
|
||||||
for (slot <- (1 to e.robot.containerCount) ++ (startComponents until startComponents + e.robot.componentCount)) {
|
// val startComponents = 1 + e.robot.containerCount + e.robot.inventorySize
|
||||||
e.robot.getComponentInSlot(slot) match {
|
// for (slot <- (1 to e.robot.containerCount) ++ (startComponents until startComponents + e.robot.componentCount)) {
|
||||||
case card: WirelessNetworkCard => api.Network.updateWirelessNetwork(card)
|
// e.robot.getComponentInSlot(slot) match {
|
||||||
case _ =>
|
// case card: WirelessNetworkCard => api.Network.updateWirelessNetwork(card)
|
||||||
}
|
// case _ =>
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,8 +345,6 @@ class TabletWrapper(var stack: ItemStack, var player: EntityPlayer) extends Comp
|
|||||||
|
|
||||||
override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))
|
override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))
|
||||||
|
|
||||||
override def markForSaving() {}
|
|
||||||
|
|
||||||
override def onMachineConnect(node: Node) = onConnect(node)
|
override def onMachineConnect(node: Node) = onConnect(node)
|
||||||
|
|
||||||
override def onMachineDisconnect(node: Node) = onDisconnect(node)
|
override def onMachineDisconnect(node: Node) = onDisconnect(node)
|
||||||
|
@ -262,8 +262,6 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def markForSaving() = robot.markForSaving()
|
|
||||||
|
|
||||||
override def hasRedstoneCard = robot.hasRedstoneCard
|
override def hasRedstoneCard = robot.hasRedstoneCard
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -39,8 +39,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
|||||||
|
|
||||||
private var _isRunning = false
|
private var _isRunning = false
|
||||||
|
|
||||||
private var markChunkDirty = false
|
|
||||||
|
|
||||||
private val _users = mutable.Set.empty[String]
|
private val _users = mutable.Set.empty[String]
|
||||||
|
|
||||||
protected def runSound = Option("computer_running")
|
protected def runSound = Option("computer_running")
|
||||||
@ -87,8 +85,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
override def markForSaving() = markChunkDirty = true
|
|
||||||
|
|
||||||
override def installedComponents = components collect {
|
override def installedComponents = components collect {
|
||||||
case Some(component) => component
|
case Some(component) => component
|
||||||
}
|
}
|
||||||
@ -118,11 +114,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
|||||||
// GPU which would otherwise loose track of its screen).
|
// GPU which would otherwise loose track of its screen).
|
||||||
machine.update()
|
machine.update()
|
||||||
|
|
||||||
if (markChunkDirty) {
|
|
||||||
markChunkDirty = false
|
|
||||||
world.markTileEntityChunkModified(x, y, z, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isRunning != machine.isRunning) {
|
if (_isRunning != machine.isRunning) {
|
||||||
_isRunning = machine.isRunning
|
_isRunning = machine.isRunning
|
||||||
markDirty()
|
markDirty()
|
||||||
|
@ -14,7 +14,7 @@ object EventHandlerRedstoneFlux {
|
|||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
val actualDamage = damage * e.getDamageRate
|
val actualDamage = damage * e.getDamageRate
|
||||||
val repairedDamage =
|
val repairedDamage =
|
||||||
if (e.robot.player.getRNG.nextDouble() > 0.5)
|
if (e.agent.player.getRNG.nextDouble() > 0.5)
|
||||||
damage - math.floor(actualDamage).toInt
|
damage - math.floor(actualDamage).toInt
|
||||||
else
|
else
|
||||||
damage - math.ceil(actualDamage).toInt
|
damage - math.ceil(actualDamage).toInt
|
||||||
|
@ -15,7 +15,7 @@ object EventHandlerGregTech {
|
|||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
val actualDamage = damage * e.getDamageRate
|
val actualDamage = damage * e.getDamageRate
|
||||||
val repairedDamage =
|
val repairedDamage =
|
||||||
if (e.robot.player.getRNG.nextDouble() > 0.5)
|
if (e.agent.player.getRNG.nextDouble() > 0.5)
|
||||||
damage - math.floor(actualDamage).toInt
|
damage - math.floor(actualDamage).toInt
|
||||||
else
|
else
|
||||||
damage - math.ceil(actualDamage).toInt
|
damage - math.ceil(actualDamage).toInt
|
||||||
|
@ -28,7 +28,7 @@ object EventHandlerIndustrialCraft2 {
|
|||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
val actualDamage = damage * e.getDamageRate
|
val actualDamage = damage * e.getDamageRate
|
||||||
val repairedDamage =
|
val repairedDamage =
|
||||||
if (e.robot.player.getRNG.nextDouble() > 0.5)
|
if (e.agent.player.getRNG.nextDouble() > 0.5)
|
||||||
damage - math.floor(actualDamage).toInt
|
damage - math.floor(actualDamage).toInt
|
||||||
else
|
else
|
||||||
damage - math.ceil(actualDamage).toInt
|
damage - math.ceil(actualDamage).toInt
|
||||||
|
@ -16,7 +16,7 @@ object EventHandlerTinkersConstruct {
|
|||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
val actualDamage = damage * e.getDamageRate
|
val actualDamage = damage * e.getDamageRate
|
||||||
val repairedDamage =
|
val repairedDamage =
|
||||||
if (e.robot.player.getRNG.nextDouble() > 0.5)
|
if (e.agent.player.getRNG.nextDouble() > 0.5)
|
||||||
damage - math.floor(actualDamage).toInt
|
damage - math.floor(actualDamage).toInt
|
||||||
else
|
else
|
||||||
damage - math.ceil(actualDamage).toInt
|
damage - math.ceil(actualDamage).toInt
|
||||||
|
@ -94,8 +94,6 @@ class Server(val rack: tileentity.ServerRack, val slot: Int) extends Environment
|
|||||||
|
|
||||||
override def world = rack.world
|
override def world = rack.world
|
||||||
|
|
||||||
override def markForSaving() = rack.markForSaving()
|
|
||||||
|
|
||||||
override def markChanged() = rack.markChanged()
|
override def markChanged() = rack.markChanged()
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -168,7 +168,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
}
|
}
|
||||||
case Machine.State.Paused if remainingPause > 0 =>
|
case Machine.State.Paused if remainingPause > 0 =>
|
||||||
remainingPause = 0
|
remainingPause = 0
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
true
|
true
|
||||||
case Machine.State.Stopping =>
|
case Machine.State.Stopping =>
|
||||||
switchTo(Machine.State.Restarting)
|
switchTo(Machine.State.Restarting)
|
||||||
@ -196,7 +196,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
state.push(Machine.State.Paused)
|
state.push(Machine.State.Paused)
|
||||||
}
|
}
|
||||||
remainingPause = ticksToPause
|
remainingPause = ticksToPause
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
return true
|
return true
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -772,7 +772,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
remainIdle = 0
|
remainIdle = 0
|
||||||
|
|
||||||
// Mark state change in owner, to send it to clients.
|
// Mark state change in owner, to send it to clients.
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
})
|
})
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
@ -789,7 +789,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark state change in owner, to send it to clients.
|
// Mark state change in owner, to send it to clients.
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user