diff --git a/build.gradle b/build.gradle
index 9be24adf4..0f3fd872f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -61,6 +61,7 @@ runServer {
}
repositories {
+/*
maven {
name = "bc"
url = "http://mod-buildcraft.com/"
@@ -127,6 +128,7 @@ repositories {
name 'Railcraft'
artifactPattern "http://addons.cursecdn.com/files/${config.rc.cf}/[module]_[revision].[ext]"
}
+*/
}
configurations {
@@ -136,6 +138,7 @@ configurations {
}
dependencies {
+/*
provided "api:rotarycraft:${config.rotc.version}"
provided "appeng:appliedenergistics2:${config.ae2.version}:dev"
provided "codechicken:CodeChickenLib:${config.minecraft.version}-${config.ccl.version}:dev"
@@ -161,7 +164,7 @@ dependencies {
provided name: 'ComputerCraft', version: config.cc.version, ext: 'jar'
provided name: 'EnderIO', version: config.eio.version, ext: 'jar'
provided name: 'Railcraft', version: config.rc.version, ext: 'jar'
-
+*/
compile 'com.google.code.findbugs:jsr305:1.3.9' // Annotations used by google libs.
embedded files('libs/OpenComputers-JNLua.jar', 'libs/OpenComputers-LuaJ.jar')
@@ -170,8 +173,43 @@ dependencies {
idea.module.scopes.PROVIDED.plus += configurations.provided
eclipse.classpath.plusConfigurations += configurations.provided
+sourceSets {
+ main {
+ scala {
+ srcDir 'src'
+ exclude 'li/cil/oc/integration/appeng/**'
+ exclude 'li/cil/oc/integration/buildcraft/**'
+ exclude 'li/cil/oc/integration/cofh/**'
+ exclude 'li/cil/oc/integration/computercraft/**'
+ exclude 'li/cil/oc/integration/enderstorage/**'
+ exclude 'li/cil/oc/integration/fmp/**'
+ exclude 'li/cil/oc/integration/forestry/**'
+ exclude 'li/cil/oc/integration/gregtech/**'
+ exclude 'li/cil/oc/integration/ic2/**'
+ exclude 'li/cil/oc/integration/mfr/**'
+ exclude 'li/cil/oc/integration/mystcraft/**'
+ exclude 'li/cil/oc/integration/nei/**'
+ exclude 'li/cil/oc/integration/railcraft/**'
+ exclude 'li/cil/oc/integration/stargatetech2/**'
+ exclude 'li/cil/oc/integration/tcon/**'
+ exclude 'li/cil/oc/integration/thermalexpansion/**'
+ exclude 'li/cil/oc/integration/thaumcraft/**'
+ exclude 'li/cil/oc/integration/tmechworks/**'
+ exclude 'li/cil/oc/integration/versionchecker/**'
+ exclude 'li/cil/oc/integration/waila/**'
+ exclude 'li/cil/oc/integration/wrcbe/**'
+ exclude 'li/cil/oc/integration/wrsve/**'
+ }
+ }
+}
+
minecraft {
version = "${config.minecraft.version}-${config.forge.version}"
+ runDir = "run"
+
+ // snapshot_YYYYMMDD snapshot are built nightly.
+ // stable_# stables are built at the discretion of the MCP team.
+ mappings = "snapshot_20141130"
replaceIn "li/cil/oc/OpenComputers.scala"
replace "@VERSION@", project.simpleVersion
diff --git a/build.properties b/build.properties
index 4f087c4ef..7ca3fa1aa 100644
--- a/build.properties
+++ b/build.properties
@@ -1,7 +1,7 @@
-minecraft.version=1.7.10
-forge.version=10.13.2.1236
+minecraft.version=1.8
+forge.version=11.14.0.1280-1.8
-oc.version=1.4.3
+oc.version=2.0.0
oc.subversion=dev
ae2.version=rv1-stable-1
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index d5c591c9c..b76121670 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3d52dd0ae..678d9d8de 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Mar 07 00:48:03 EST 2014
+#Wed Jul 02 15:54:47 CDT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
diff --git a/src/main/java/li/cil/oc/api/Driver.java b/src/main/java/li/cil/oc/api/Driver.java
index 0fa301f05..517d68825 100644
--- a/src/main/java/li/cil/oc/api/Driver.java
+++ b/src/main/java/li/cil/oc/api/Driver.java
@@ -5,6 +5,7 @@ import li.cil.oc.api.driver.Converter;
import li.cil.oc.api.driver.EnvironmentHost;
import li.cil.oc.api.driver.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import java.util.Collection;
@@ -86,14 +87,12 @@ public final class Driver {
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.Block)}.
*
* @param world the world containing the block.
- * @param x the X coordinate of the block.
- * @param y the Y coordinate of the block.
- * @param z the Z coordinate of the block.
+ * @param pos the position of the block.
* @return a driver for the block, or null if there is none.
*/
- public static Block driverFor(World world, int x, int y, int z) {
+ public static Block driverFor(World world, BlockPos pos) {
if (API.driver != null)
- return API.driver.driverFor(world, x, y, z);
+ return API.driver.driverFor(world, pos);
return null;
}
diff --git a/src/main/java/li/cil/oc/api/FileSystem.java b/src/main/java/li/cil/oc/api/FileSystem.java
index b9170805b..6daac03d9 100644
--- a/src/main/java/li/cil/oc/api/FileSystem.java
+++ b/src/main/java/li/cil/oc/api/FileSystem.java
@@ -107,24 +107,6 @@ public final class FileSystem {
return null;
}
- /**
- * Creates a new file system based on a ComputerCraft mount.
- *
- * This supports read-only and writable mounts from either CC 1.5x or
- * CC 1.6x. The argument is kept untyped to avoid having the OC API
- * depend on the CC API.
- *
- * If the passed type is unsupported, this will throw an exception.
- *
- * @param mount the mount to wrap with a file system.
- * @return a file system wrapping the specified mount.
- */
- public static li.cil.oc.api.fs.FileSystem fromComputerCraft(final Object mount) {
- if (API.fileSystem != null)
- return API.fileSystem.fromComputerCraft(mount);
- return null;
- }
-
/**
* Creates a network node that makes the specified file system available via
* the common file system driver.
diff --git a/src/main/java/li/cil/oc/api/component/TextBuffer.java b/src/main/java/li/cil/oc/api/component/TextBuffer.java
index c7297c631..05820bc09 100644
--- a/src/main/java/li/cil/oc/api/component/TextBuffer.java
+++ b/src/main/java/li/cil/oc/api/component/TextBuffer.java
@@ -1,7 +1,7 @@
package li.cil.oc.api.component;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
import li.cil.oc.api.Persistable;
import li.cil.oc.api.network.ManagedEnvironment;
import net.minecraft.entity.player.EntityPlayer;
diff --git a/src/main/java/li/cil/oc/api/component/package-info.java b/src/main/java/li/cil/oc/api/component/package-info.java
index 615dd621d..229794703 100644
--- a/src/main/java/li/cil/oc/api/component/package-info.java
+++ b/src/main/java/li/cil/oc/api/component/package-info.java
@@ -5,7 +5,7 @@
* components, which would otherwise require reflection or linking against the
* mod itself.
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Component",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/detail/DriverAPI.java b/src/main/java/li/cil/oc/api/detail/DriverAPI.java
index 1a0d1c470..f6f16c189 100644
--- a/src/main/java/li/cil/oc/api/detail/DriverAPI.java
+++ b/src/main/java/li/cil/oc/api/detail/DriverAPI.java
@@ -5,6 +5,7 @@ import li.cil.oc.api.driver.Converter;
import li.cil.oc.api.driver.EnvironmentHost;
import li.cil.oc.api.driver.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import java.util.Collection;
@@ -60,12 +61,10 @@ public interface DriverAPI {
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.Block)}.
*
* @param world the world containing the block.
- * @param x the X coordinate of the block.
- * @param y the Y coordinate of the block.
- * @param z the Z coordinate of the block.
+ * @param pos the position of the block.
* @return a driver for the block, or null if there is none.
*/
- Block driverFor(World world, int x, int y, int z);
+ Block driverFor(World world, BlockPos pos);
/**
* Looks up a driver for the specified item stack.
diff --git a/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java b/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java
index e0a53518d..4ae6459b0 100644
--- a/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java
+++ b/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java
@@ -67,20 +67,6 @@ public interface FileSystemAPI {
*/
FileSystem fromMemory(long capacity);
- /**
- * Creates a new file system based on a read-only ComputerCraft mount.
- *
- * This supports read-only and writable mounts from either CC 1.5x or
- * CC 1.6x. The argument is kept untyped to avoid having the OC API
- * depend on the CC API.
- *
- * If the passed type is unsupported, this will return null.
- *
- * @param mount the mount to wrap with a file system.
- * @return a file system wrapping the specified mount.
- */
- FileSystem fromComputerCraft(Object mount);
-
/**
* Creates a network node that makes the specified file system available via
* the common file system driver.
diff --git a/src/main/java/li/cil/oc/api/driver/Block.java b/src/main/java/li/cil/oc/api/driver/Block.java
index 895a629bf..83df9c8d0 100644
--- a/src/main/java/li/cil/oc/api/driver/Block.java
+++ b/src/main/java/li/cil/oc/api/driver/Block.java
@@ -1,6 +1,7 @@
package li.cil.oc.api.driver;
import li.cil.oc.api.network.ManagedEnvironment;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
/**
@@ -32,12 +33,10 @@ public interface Block {
* can force this by sending a neighbor block change notification.
*
* @param world the world in which the block to check lives.
- * @param x the X coordinate of the block to check.
- * @param y the Y coordinate of the block to check.
- * @param z the Z coordinate of the block to check.
+ * @param pos the position coordinate of the block to check.
* @return true if the block is supported; false otherwise.
*/
- boolean worksWith(World world, int x, int y, int z);
+ boolean worksWith(World world, BlockPos pos);
/**
* Create a new managed environment interfacing the specified block.
@@ -53,10 +52,8 @@ public interface Block {
* Adapter block that caused its creation.
*
* @param world the world containing the block to get the environment for.
- * @param x the X coordinate of the block to get the environment for.
- * @param y the Y coordinate of the block to get the environment for.
- * @param z the Z coordinate of the block to get the environment for.
+ * @param pos the position of the block to get the environment for.
* @return the environment for the block at that location.
*/
- ManagedEnvironment createEnvironment(World world, int x, int y, int z);
+ ManagedEnvironment createEnvironment(World world, BlockPos pos);
}
\ No newline at end of file
diff --git a/src/main/java/li/cil/oc/api/driver/MethodWhitelist.java b/src/main/java/li/cil/oc/api/driver/MethodWhitelist.java
index 0bb8814c5..969811f4a 100644
--- a/src/main/java/li/cil/oc/api/driver/MethodWhitelist.java
+++ b/src/main/java/li/cil/oc/api/driver/MethodWhitelist.java
@@ -15,7 +15,7 @@ package li.cil.oc.api.driver;
* suppress inventory functionality if your TileEntity implements IInventory.
*
* To do so, implement this interface in the environment that you
- * return from your driver's {@link Block#createEnvironment(net.minecraft.world.World, int, int, int)}
+ * return from your driver's {@link Block#createEnvironment(net.minecraft.world.World, net.minecraft.util.BlockPos)}
* method, and provide the names of the allowed methods from {@link #whitelistedMethods()}.
*
* Important: if multiple drivers apply to a single block that each
diff --git a/src/main/java/li/cil/oc/api/driver/NamedBlock.java b/src/main/java/li/cil/oc/api/driver/NamedBlock.java
index f604c7683..44b416647 100644
--- a/src/main/java/li/cil/oc/api/driver/NamedBlock.java
+++ b/src/main/java/li/cil/oc/api/driver/NamedBlock.java
@@ -7,7 +7,7 @@ package li.cil.oc.api.driver;
*
* This was previously to be implemented on the driver itself, but that has been
* deprecated. Implement it in the environment returned from the block driver's
- * {@link Block#createEnvironment(net.minecraft.world.World, int, int, int)}
+ * {@link Block#createEnvironment(net.minecraft.world.World, net.minecraft.util.BlockPos)}
* method instead.
*/
public interface NamedBlock {
diff --git a/src/main/java/li/cil/oc/api/driver/item/package-info.java b/src/main/java/li/cil/oc/api/driver/item/package-info.java
index 6c2d9fc02..24a730120 100644
--- a/src/main/java/li/cil/oc/api/driver/item/package-info.java
+++ b/src/main/java/li/cil/oc/api/driver/item/package-info.java
@@ -4,7 +4,7 @@
* These interfaces allow specializing item drivers to provide static data,
* that is without creating an actual environment.
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Driver|Item",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/driver/package-info.java b/src/main/java/li/cil/oc/api/driver/package-info.java
index 168e5d364..7a3ee423c 100644
--- a/src/main/java/li/cil/oc/api/driver/package-info.java
+++ b/src/main/java/li/cil/oc/api/driver/package-info.java
@@ -4,7 +4,7 @@
* Drivers are used to add items and third party blocks to the internal network,
* which is mostly used to make components wrapping them available to computers.
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Driver",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/event/FileSystemAccessEvent.java b/src/main/java/li/cil/oc/api/event/FileSystemAccessEvent.java
index 97d0518af..ff9343f9d 100644
--- a/src/main/java/li/cil/oc/api/event/FileSystemAccessEvent.java
+++ b/src/main/java/li/cil/oc/api/event/FileSystemAccessEvent.java
@@ -1,7 +1,7 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Cancelable;
-import cpw.mods.fml.common.eventhandler.Event;
+import net.minecraftforge.fml.common.eventhandler.Cancelable;
+import net.minecraftforge.fml.common.eventhandler.Event;
import li.cil.oc.api.network.Node;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -44,10 +44,10 @@ public class FileSystemAccessEvent extends Event {
*/
protected FileSystemAccessEvent(String sound, TileEntity tileEntity, NBTTagCompound data) {
this.sound = sound;
- this.world = tileEntity.getWorldObj();
- this.x = tileEntity.xCoord + 0.5;
- this.y = tileEntity.yCoord + 0.5;
- this.z = tileEntity.zCoord + 0.5;
+ this.world = tileEntity.getWorld();
+ this.x = tileEntity.getPos().getX() + 0.5;
+ this.y = tileEntity.getPos().getY() + 0.5;
+ this.z = tileEntity.getPos().getZ() + 0.5;
this.tileEntity = tileEntity;
this.data = data;
}
diff --git a/src/main/java/li/cil/oc/api/event/GeolyzerEvent.java b/src/main/java/li/cil/oc/api/event/GeolyzerEvent.java
index 92269f7eb..5adcd85b4 100644
--- a/src/main/java/li/cil/oc/api/event/GeolyzerEvent.java
+++ b/src/main/java/li/cil/oc/api/event/GeolyzerEvent.java
@@ -1,9 +1,9 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Cancelable;
-import cpw.mods.fml.common.eventhandler.Event;
+import net.minecraftforge.fml.common.eventhandler.Cancelable;
+import net.minecraftforge.fml.common.eventhandler.Event;
import li.cil.oc.api.driver.EnvironmentHost;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.util.EnumFacing;
import java.util.HashMap;
import java.util.Map;
@@ -73,14 +73,14 @@ public abstract class GeolyzerEvent extends Event {
/**
* The side of the geolyzer on which the block to scan is located.
*/
- public final ForgeDirection side;
+ public final EnumFacing side;
/**
* The retrieved data for the block being scanned.
*/
public final Map data = new HashMap();
- public Analyze(EnvironmentHost host, Map, ?> options, ForgeDirection side) {
+ public Analyze(EnvironmentHost host, Map, ?> options, EnumFacing side) {
super(host, options);
this.side = side;
}
diff --git a/src/main/java/li/cil/oc/api/event/RobotAttackEntityEvent.java b/src/main/java/li/cil/oc/api/event/RobotAttackEntityEvent.java
index 4eead6627..2a45806df 100644
--- a/src/main/java/li/cil/oc/api/event/RobotAttackEntityEvent.java
+++ b/src/main/java/li/cil/oc/api/event/RobotAttackEntityEvent.java
@@ -1,6 +1,6 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Cancelable;
+import net.minecraftforge.fml.common.eventhandler.Cancelable;
import li.cil.oc.api.internal.Robot;
import net.minecraft.entity.Entity;
diff --git a/src/main/java/li/cil/oc/api/event/RobotBreakBlockEvent.java b/src/main/java/li/cil/oc/api/event/RobotBreakBlockEvent.java
index 94288e25e..863437689 100644
--- a/src/main/java/li/cil/oc/api/event/RobotBreakBlockEvent.java
+++ b/src/main/java/li/cil/oc/api/event/RobotBreakBlockEvent.java
@@ -1,8 +1,9 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Cancelable;
import li.cil.oc.api.internal.Robot;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
+import net.minecraftforge.fml.common.eventhandler.Cancelable;
public abstract class RobotBreakBlockEvent extends RobotEvent {
protected RobotBreakBlockEvent(Robot robot) {
@@ -24,19 +25,17 @@ public abstract class RobotBreakBlockEvent extends RobotEvent {
/**
* The coordinates at which the block will be broken.
*/
- public final int x, y, z;
+ public final BlockPos pos;
/**
* The time it takes to break the block.
*/
private double breakTime;
- public Pre(Robot robot, World world, int x, int y, int z, double breakTime) {
+ public Pre(Robot robot, World world, BlockPos pos, double breakTime) {
super(robot);
this.world = world;
- this.x = x;
- this.y = y;
- this.z = z;
+ this.pos = pos;
this.breakTime = breakTime;
}
diff --git a/src/main/java/li/cil/oc/api/event/RobotEvent.java b/src/main/java/li/cil/oc/api/event/RobotEvent.java
index 074e4b6f4..ffc6ef5be 100644
--- a/src/main/java/li/cil/oc/api/event/RobotEvent.java
+++ b/src/main/java/li/cil/oc/api/event/RobotEvent.java
@@ -1,6 +1,6 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Event;
+import net.minecraftforge.fml.common.eventhandler.Event;
import li.cil.oc.api.internal.Robot;
/**
diff --git a/src/main/java/li/cil/oc/api/event/RobotMoveEvent.java b/src/main/java/li/cil/oc/api/event/RobotMoveEvent.java
index 29e90be63..415e6cc3e 100644
--- a/src/main/java/li/cil/oc/api/event/RobotMoveEvent.java
+++ b/src/main/java/li/cil/oc/api/event/RobotMoveEvent.java
@@ -1,16 +1,16 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Cancelable;
+import net.minecraftforge.fml.common.eventhandler.Cancelable;
import li.cil.oc.api.internal.Robot;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.util.EnumFacing;
public abstract class RobotMoveEvent extends RobotEvent {
/**
* The direction in which the robot will be moving.
*/
- public final ForgeDirection direction;
+ public final EnumFacing direction;
- protected RobotMoveEvent(Robot robot, ForgeDirection direction) {
+ protected RobotMoveEvent(Robot robot, EnumFacing direction) {
super(robot);
this.direction = direction;
}
@@ -22,7 +22,7 @@ public abstract class RobotMoveEvent extends RobotEvent {
*/
@Cancelable
public static class Pre extends RobotMoveEvent {
- public Pre(Robot robot, ForgeDirection direction) {
+ public Pre(Robot robot, EnumFacing direction) {
super(robot, direction);
}
}
@@ -31,7 +31,7 @@ public abstract class RobotMoveEvent extends RobotEvent {
* Fired after a robot moved.
*/
public static class Post extends RobotMoveEvent {
- public Post(Robot robot, ForgeDirection direction) {
+ public Post(Robot robot, EnumFacing direction) {
super(robot, direction);
}
}
diff --git a/src/main/java/li/cil/oc/api/event/RobotPlaceBlockEvent.java b/src/main/java/li/cil/oc/api/event/RobotPlaceBlockEvent.java
index d481268bd..598401ae1 100644
--- a/src/main/java/li/cil/oc/api/event/RobotPlaceBlockEvent.java
+++ b/src/main/java/li/cil/oc/api/event/RobotPlaceBlockEvent.java
@@ -1,6 +1,7 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Cancelable;
+import net.minecraft.util.BlockPos;
+import net.minecraftforge.fml.common.eventhandler.Cancelable;
import li.cil.oc.api.internal.Robot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -19,15 +20,13 @@ public abstract class RobotPlaceBlockEvent extends RobotEvent {
/**
* The coordinates at which the block will be placed.
*/
- public final int x, y, z;
+ public final BlockPos pos;
- protected RobotPlaceBlockEvent(Robot robot, ItemStack stack, World world, int x, int y, int z) {
+ protected RobotPlaceBlockEvent(Robot robot, ItemStack stack, World world, BlockPos pos) {
super(robot);
this.stack = stack;
this.world = world;
- this.x = x;
- this.y = y;
- this.z = z;
+ this.pos = pos;
}
/**
@@ -37,8 +36,8 @@ public abstract class RobotPlaceBlockEvent extends RobotEvent {
*/
@Cancelable
public static class Pre extends RobotPlaceBlockEvent {
- public Pre(Robot robot, ItemStack stack, World world, int x, int y, int z) {
- super(robot, stack, world, x, y, z);
+ public Pre(Robot robot, ItemStack stack, World world, BlockPos pos) {
+ super(robot, stack, world, pos);
}
}
@@ -46,8 +45,8 @@ public abstract class RobotPlaceBlockEvent extends RobotEvent {
* Fired after a robot placed a block.
*/
public static class Post extends RobotPlaceBlockEvent {
- public Post(Robot robot, ItemStack stack, World world, int x, int y, int z) {
- super(robot, stack, world, x, y, z);
+ public Post(Robot robot, ItemStack stack, World world, BlockPos pos) {
+ super(robot, stack, world, pos);
}
}
}
diff --git a/src/main/java/li/cil/oc/api/event/RobotRenderEvent.java b/src/main/java/li/cil/oc/api/event/RobotRenderEvent.java
index 58afc6a76..d034625ae 100644
--- a/src/main/java/li/cil/oc/api/event/RobotRenderEvent.java
+++ b/src/main/java/li/cil/oc/api/event/RobotRenderEvent.java
@@ -1,6 +1,6 @@
package li.cil.oc.api.event;
-import cpw.mods.fml.common.eventhandler.Cancelable;
+import net.minecraftforge.fml.common.eventhandler.Cancelable;
import li.cil.oc.api.internal.Robot;
import org.lwjgl.util.vector.Vector3f;
import org.lwjgl.util.vector.Vector4f;
diff --git a/src/main/java/li/cil/oc/api/event/package-info.java b/src/main/java/li/cil/oc/api/event/package-info.java
index 04a5d19ec..7fe9fe75e 100644
--- a/src/main/java/li/cil/oc/api/event/package-info.java
+++ b/src/main/java/li/cil/oc/api/event/package-info.java
@@ -2,7 +2,7 @@
* Events dispatched by OpenComputers to allow other mods to hook into some
* of its functionality.
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Event",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/fs/package-info.java b/src/main/java/li/cil/oc/api/fs/package-info.java
index 394969fb7..d1e3c5f2f 100644
--- a/src/main/java/li/cil/oc/api/fs/package-info.java
+++ b/src/main/java/li/cil/oc/api/fs/package-info.java
@@ -13,7 +13,7 @@
* that can be added as component nodes to the network, so they can be used
* from computers).
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|FileSystem",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/internal/Colored.java b/src/main/java/li/cil/oc/api/internal/Colored.java
index afdc901f4..c51d33acc 100644
--- a/src/main/java/li/cil/oc/api/internal/Colored.java
+++ b/src/main/java/li/cil/oc/api/internal/Colored.java
@@ -1,5 +1,7 @@
package li.cil.oc.api.internal;
+import net.minecraft.item.EnumDyeColor;
+
/**
* This interface is implemented by tile entities that can be colored by
* players, such as screens, computer cases and cables.
@@ -14,12 +16,12 @@ public interface Colored {
*
* @return the current color value.
*/
- int getColor();
+ EnumDyeColor getColor();
/**
* Set the color value.
*
* @param value the new color value.
*/
- void setColor(int value);
+ void setColor(EnumDyeColor value);
}
diff --git a/src/main/java/li/cil/oc/api/internal/Rotatable.java b/src/main/java/li/cil/oc/api/internal/Rotatable.java
index 9310cfe99..4171084ac 100644
--- a/src/main/java/li/cil/oc/api/internal/Rotatable.java
+++ b/src/main/java/li/cil/oc/api/internal/Rotatable.java
@@ -1,6 +1,6 @@
package li.cil.oc.api.internal;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.util.EnumFacing;
/**
* This interface is implemented by the computer case and robot tile entities
@@ -31,7 +31,7 @@ public interface Rotatable {
*
* @return the current facing.
*/
- ForgeDirection facing();
+ EnumFacing facing();
/**
* Converts a facing relative to the block's local coordinate
@@ -44,7 +44,7 @@ public interface Rotatable {
* @param value the value to translate.
* @return the translated orientation.
*/
- ForgeDirection toGlobal(ForgeDirection value);
+ EnumFacing toGlobal(EnumFacing value);
/**
* Converts a global orientation to a facing relative to the
@@ -57,5 +57,5 @@ public interface Rotatable {
* @param value the value to translate.
* @return the translated orientation.
*/
- ForgeDirection toLocal(ForgeDirection value);
+ EnumFacing toLocal(EnumFacing value);
}
diff --git a/src/main/java/li/cil/oc/api/internal/package-info.java b/src/main/java/li/cil/oc/api/internal/package-info.java
index 769993c1b..ad700a273 100644
--- a/src/main/java/li/cil/oc/api/internal/package-info.java
+++ b/src/main/java/li/cil/oc/api/internal/package-info.java
@@ -13,7 +13,7 @@
* used inside the specified environment (where the environment class may
* be assignable to one of the interfaces in this package).
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Internal",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/machine/package-info.java b/src/main/java/li/cil/oc/api/machine/package-info.java
index e9dfb589b..97807dcc8 100644
--- a/src/main/java/li/cil/oc/api/machine/package-info.java
+++ b/src/main/java/li/cil/oc/api/machine/package-info.java
@@ -16,7 +16,7 @@
* implemented, but merely to allow accessing some mod internals in a regulated
* fashion, such as {@link li.cil.oc.api.internal.Robot}.
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Machine",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/network/Analyzable.java b/src/main/java/li/cil/oc/api/network/Analyzable.java
index 769c12677..204d57720 100644
--- a/src/main/java/li/cil/oc/api/network/Analyzable.java
+++ b/src/main/java/li/cil/oc/api/network/Analyzable.java
@@ -1,6 +1,7 @@
package li.cil.oc.api.network;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.EnumFacing;
/**
* Allows defining a callback for when a block is right-clicked with an
@@ -30,5 +31,5 @@ public interface Analyzable {
* @return the nodes to display information for, usually an environment's
* main node (i.e. this.node()).
*/
- Node[] onAnalyze(EntityPlayer player, int side, float hitX, float hitY, float hitZ);
+ Node[] onAnalyze(EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ);
}
diff --git a/src/main/java/li/cil/oc/api/network/SidedEnvironment.java b/src/main/java/li/cil/oc/api/network/SidedEnvironment.java
index 79bc1c92a..49c796c18 100644
--- a/src/main/java/li/cil/oc/api/network/SidedEnvironment.java
+++ b/src/main/java/li/cil/oc/api/network/SidedEnvironment.java
@@ -1,9 +1,9 @@
package li.cil.oc.api.network;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.util.EnumFacing;
/**
* This interface is like {@link net.minecraft.inventory.ISidedInventory} is to
@@ -32,7 +32,7 @@ public interface SidedEnvironment {
* @return the node for the specified side.
* @see li.cil.oc.api.network.Environment#node
*/
- Node sidedNode(ForgeDirection side);
+ Node sidedNode(EnumFacing side);
/**
* Whether the environment provides a node to connect to on the specified
@@ -51,5 +51,5 @@ public interface SidedEnvironment {
* @return whether the environment provides a node for the specified side.
*/
@SideOnly(Side.CLIENT)
- boolean canConnect(ForgeDirection side);
+ boolean canConnect(EnumFacing side);
}
diff --git a/src/main/java/li/cil/oc/api/network/package-info.java b/src/main/java/li/cil/oc/api/network/package-info.java
index ef7ae77ed..4892d137c 100644
--- a/src/main/java/li/cil/oc/api/network/package-info.java
+++ b/src/main/java/li/cil/oc/api/network/package-info.java
@@ -4,7 +4,7 @@
* This mainly involves the (purely server-side!) network that is spanned over
* all of OpenComputers' components, including blocks and items alike.
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Network",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/package-info.java b/src/main/java/li/cil/oc/api/package-info.java
index 94fc3bdc2..f0d055739 100644
--- a/src/main/java/li/cil/oc/api/package-info.java
+++ b/src/main/java/li/cil/oc/api/package-info.java
@@ -34,7 +34,7 @@
*
*
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Core",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/api/prefab/DriverBlock.java b/src/main/java/li/cil/oc/api/prefab/DriverBlock.java
index bb9e1654f..d8b8e1fa9 100644
--- a/src/main/java/li/cil/oc/api/prefab/DriverBlock.java
+++ b/src/main/java/li/cil/oc/api/prefab/DriverBlock.java
@@ -1,8 +1,10 @@
package li.cil.oc.api.prefab;
import net.minecraft.block.Block;
+import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
@@ -29,15 +31,17 @@ public abstract class DriverBlock implements li.cil.oc.api.driver.Block {
}
@Override
- public boolean worksWith(final World world, final int x, final int y, final int z) {
- return worksWith(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
+ public boolean worksWith(final World world, final BlockPos pos) {
+ final IBlockState state = world.getBlockState(pos);
+ final Block block = state.getBlock();
+ return worksWith(block, block.getMetaFromState(state));
}
protected boolean worksWith(final Block referenceBlock, final int referenceMetadata) {
for (ItemStack stack : blocks) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
final ItemBlock item = (ItemBlock) stack.getItem();
- final Block supportedBlock = item.field_150939_a;
+ final Block supportedBlock = item.getBlock();
final int supportedMetadata = item.getMetadata(stack.getItemDamage());
if (referenceBlock == supportedBlock && (referenceMetadata == supportedMetadata || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
return true;
diff --git a/src/main/java/li/cil/oc/api/prefab/DriverTileEntity.java b/src/main/java/li/cil/oc/api/prefab/DriverTileEntity.java
index e9c6890ef..338462b79 100644
--- a/src/main/java/li/cil/oc/api/prefab/DriverTileEntity.java
+++ b/src/main/java/li/cil/oc/api/prefab/DriverTileEntity.java
@@ -1,20 +1,21 @@
package li.cil.oc.api.prefab;
import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public abstract class DriverTileEntity implements li.cil.oc.api.driver.Block {
public abstract Class> getTileEntityClass();
@Override
- public boolean worksWith(final World world, final int x, final int y, final int z) {
+ public boolean worksWith(final World world, final BlockPos pos) {
final Class> filter = getTileEntityClass();
if (filter == null) {
// This can happen if filter classes are deduced by reflection and
// the class in question is not present.
return false;
}
- final TileEntity tileEntity = world.getTileEntity(x, y, z);
+ final TileEntity tileEntity = world.getTileEntity(pos);
return tileEntity != null && filter.isAssignableFrom(tileEntity.getClass());
}
}
diff --git a/src/main/java/li/cil/oc/api/prefab/TileEntityEnvironment.java b/src/main/java/li/cil/oc/api/prefab/TileEntityEnvironment.java
index 75f83ac41..1f467dde0 100644
--- a/src/main/java/li/cil/oc/api/prefab/TileEntityEnvironment.java
+++ b/src/main/java/li/cil/oc/api/prefab/TileEntityEnvironment.java
@@ -6,6 +6,7 @@ import li.cil.oc.api.network.Message;
import li.cil.oc.api.network.Node;
import li.cil.oc.api.network.Visibility;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.gui.IUpdatePlayerListBox;
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.
*/
@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 tile entity.
@@ -96,8 +97,7 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
// ----------------------------------------------------------------------- //
@Override
- public void updateEntity() {
- super.updateEntity();
+ public void update() {
// 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
// neighboring tile entities, which isn't possible in validate().
diff --git a/src/main/java/li/cil/oc/api/prefab/TileEntitySidedEnvironment.java b/src/main/java/li/cil/oc/api/prefab/TileEntitySidedEnvironment.java
index 2d6c247e7..c5a5ddd15 100644
--- a/src/main/java/li/cil/oc/api/prefab/TileEntitySidedEnvironment.java
+++ b/src/main/java/li/cil/oc/api/prefab/TileEntitySidedEnvironment.java
@@ -4,8 +4,9 @@ import li.cil.oc.api.Network;
import li.cil.oc.api.network.Node;
import li.cil.oc.api.network.SidedEnvironment;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.util.EnumFacing;
/**
* TileEntities can implement the {@link li.cil.oc.api.network.SidedEnvironment}
@@ -18,7 +19,7 @@ import net.minecraftforge.common.util.ForgeDirection;
* network as an index structure to find other nodes connected to them.
*/
@SuppressWarnings("UnusedDeclaration")
-public abstract class TileEntitySidedEnvironment extends TileEntity implements SidedEnvironment {
+public abstract class TileEntitySidedEnvironment extends TileEntity implements SidedEnvironment, IUpdatePlayerListBox {
// See constructor.
protected Node[] nodes = new Node[6];
@@ -71,15 +72,14 @@ public abstract class TileEntitySidedEnvironment extends TileEntity implements S
// exists for a side won't work on the client.
@Override
- public Node sidedNode(final ForgeDirection side) {
- return side == ForgeDirection.UNKNOWN ? null : nodes[side.ordinal()];
+ public Node sidedNode(final EnumFacing side) {
+ return nodes[side.ordinal()];
}
// ----------------------------------------------------------------------- //
@Override
- public void updateEntity() {
- super.updateEntity();
+ public void update() {
// 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
// neighboring tile entities, which isn't possible in validate().
diff --git a/src/main/java/li/cil/oc/api/prefab/package-info.java b/src/main/java/li/cil/oc/api/prefab/package-info.java
index ba933b12c..306982259 100644
--- a/src/main/java/li/cil/oc/api/prefab/package-info.java
+++ b/src/main/java/li/cil/oc/api/prefab/package-info.java
@@ -7,7 +7,7 @@
* while leaving them in the same package with the same name and then ship them
* with your mod!
*/
-@cpw.mods.fml.common.API(
+@net.minecraftforge.fml.common.API(
owner = API.ID_OWNER,
provides = "OpenComputersAPI|Prefab",
apiVersion = API.VERSION)
diff --git a/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java b/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java
index 5667ae503..e360305fb 100644
--- a/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java
+++ b/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java
@@ -1,7 +1,7 @@
package li.cil.oc.common.asm;
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import cpw.mods.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
import li.cil.oc.api.Network;
import li.cil.oc.util.SideTracker;
import net.minecraft.tileentity.TileEntity;
diff --git a/src/main/java/li/cil/oc/util/SideTracker.java b/src/main/java/li/cil/oc/util/SideTracker.java
index 6618e795f..1a0f302ee 100644
--- a/src/main/java/li/cil/oc/util/SideTracker.java
+++ b/src/main/java/li/cil/oc/util/SideTracker.java
@@ -1,6 +1,6 @@
package li.cil.oc.util;
-import cpw.mods.fml.common.FMLCommonHandler;
+import net.minecraftforge.fml.common.FMLCommonHandler;
import java.util.Collections;
import java.util.Set;
diff --git a/src/main/resources/assets/opencomputers/blockstates/accessPoint.json b/src/main/resources/assets/opencomputers/blockstates/accessPoint.json
new file mode 100644
index 000000000..d479fef99
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/accessPoint.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:accessPoint" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/adapter.json b/src/main/resources/assets/opencomputers/blockstates/adapter.json
new file mode 100644
index 000000000..55444855f
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/adapter.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:adapter" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/capacitor.json b/src/main/resources/assets/opencomputers/blockstates/capacitor.json
new file mode 100644
index 000000000..7887a194f
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/capacitor.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:capacitor" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/case1.json b/src/main/resources/assets/opencomputers/blockstates/case1.json
new file mode 100644
index 000000000..fd8f30415
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/case1.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:case" },
+ "facing=south": { "model": "opencomputers:case", "y": 180 },
+ "facing=west": { "model": "opencomputers:case", "y": 270 },
+ "facing=east": { "model": "opencomputers:case", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/case2.json b/src/main/resources/assets/opencomputers/blockstates/case2.json
new file mode 100644
index 000000000..fd8f30415
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/case2.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:case" },
+ "facing=south": { "model": "opencomputers:case", "y": 180 },
+ "facing=west": { "model": "opencomputers:case", "y": 270 },
+ "facing=east": { "model": "opencomputers:case", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/case3.json b/src/main/resources/assets/opencomputers/blockstates/case3.json
new file mode 100644
index 000000000..fd8f30415
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/case3.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:case" },
+ "facing=south": { "model": "opencomputers:case", "y": 180 },
+ "facing=west": { "model": "opencomputers:case", "y": 270 },
+ "facing=east": { "model": "opencomputers:case", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/caseCreative.json b/src/main/resources/assets/opencomputers/blockstates/caseCreative.json
new file mode 100644
index 000000000..fd8f30415
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/caseCreative.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:case" },
+ "facing=south": { "model": "opencomputers:case", "y": 180 },
+ "facing=west": { "model": "opencomputers:case", "y": 270 },
+ "facing=east": { "model": "opencomputers:case", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/charger.json b/src/main/resources/assets/opencomputers/blockstates/charger.json
new file mode 100644
index 000000000..54cebc64e
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/charger.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:charger" },
+ "facing=south": { "model": "opencomputers:charger", "y": 180 },
+ "facing=west": { "model": "opencomputers:charger", "y": 270 },
+ "facing=east": { "model": "opencomputers:charger", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/disassembler.json b/src/main/resources/assets/opencomputers/blockstates/disassembler.json
new file mode 100644
index 000000000..8b7823ccf
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/disassembler.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:disassembler" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/diskDrive.json b/src/main/resources/assets/opencomputers/blockstates/diskDrive.json
new file mode 100644
index 000000000..21fa72cbf
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/diskDrive.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:diskDrive" },
+ "facing=south": { "model": "opencomputers:diskDrive", "y": 180 },
+ "facing=west": { "model": "opencomputers:diskDrive", "y": 270 },
+ "facing=east": { "model": "opencomputers:diskDrive", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/geolyzer.json b/src/main/resources/assets/opencomputers/blockstates/geolyzer.json
new file mode 100644
index 000000000..006954e9d
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/geolyzer.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:geolyzer" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/keyboard.json b/src/main/resources/assets/opencomputers/blockstates/keyboard.json
new file mode 100644
index 000000000..3db2890cf
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/keyboard.json
@@ -0,0 +1,16 @@
+{
+ "variants": {
+ "facing=north,up=up": { "model": "opencomputers:keyboard" },
+ "facing=south,up=up": { "model": "opencomputers:keyboard", "y": 180 },
+ "facing=west,up=up": { "model": "opencomputers:keyboard", "y": 270 },
+ "facing=east,up=up": { "model": "opencomputers:keyboard", "y": 90 },
+ "facing=up,up=north": { "model": "opencomputers:keyboard", "x": 90 },
+ "facing=up,up=south": { "model": "opencomputers:keyboard", "x": 90, "y": 180 },
+ "facing=up,up=east": { "model": "opencomputers:keyboard", "x": 90, "y": 270 },
+ "facing=up,up=west": { "model": "opencomputers:keyboard", "x": 90, "y": 90 },
+ "facing=down,up=north": { "model": "opencomputers:keyboard", "x": -90 },
+ "facing=down,up=south": { "model": "opencomputers:keyboard", "x": -90, "y": 180 },
+ "facing=down,up=east": { "model": "opencomputers:keyboard", "x": -90, "y": 270 },
+ "facing=down,up=west": { "model": "opencomputers:keyboard", "x": -90, "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/microcontroller.json b/src/main/resources/assets/opencomputers/blockstates/microcontroller.json
new file mode 100644
index 000000000..ae4a9aa8e
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/microcontroller.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:microcontroller" },
+ "facing=south": { "model": "opencomputers:microcontroller", "y": 180 },
+ "facing=west": { "model": "opencomputers:microcontroller", "y": 270 },
+ "facing=east": { "model": "opencomputers:microcontroller", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/motionSensor.json b/src/main/resources/assets/opencomputers/blockstates/motionSensor.json
new file mode 100644
index 000000000..908da7cea
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/motionSensor.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:motionSensor" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/powerConverter.json b/src/main/resources/assets/opencomputers/blockstates/powerConverter.json
new file mode 100644
index 000000000..a3154af12
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/powerConverter.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:powerConverter" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/powerDistributor.json b/src/main/resources/assets/opencomputers/blockstates/powerDistributor.json
new file mode 100644
index 000000000..e7ff0e85b
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/powerDistributor.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:powerDistributor" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/raid.json b/src/main/resources/assets/opencomputers/blockstates/raid.json
new file mode 100644
index 000000000..84de291f8
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/raid.json
@@ -0,0 +1,8 @@
+{
+ "variants": {
+ "facing=north": { "model": "opencomputers:raid" },
+ "facing=south": { "model": "opencomputers:raid", "y": 180 },
+ "facing=west": { "model": "opencomputers:raid", "y": 270 },
+ "facing=east": { "model": "opencomputers:raid", "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/redstone.json b/src/main/resources/assets/opencomputers/blockstates/redstone.json
new file mode 100644
index 000000000..bd41205b8
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/redstone.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:redstone" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/screen1.json b/src/main/resources/assets/opencomputers/blockstates/screen1.json
new file mode 100644
index 000000000..63ba96081
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/screen1.json
@@ -0,0 +1,16 @@
+{
+ "variants": {
+ "facing=north,up=up": { "model": "opencomputers:screen" },
+ "facing=south,up=up": { "model": "opencomputers:screen", "y": 180 },
+ "facing=west,up=up": { "model": "opencomputers:screen", "y": 270 },
+ "facing=east,up=up": { "model": "opencomputers:screen", "y": 90 },
+ "facing=up,up=north": { "model": "opencomputers:screen", "x": 90 },
+ "facing=up,up=south": { "model": "opencomputers:screen", "x": 90, "y": 180 },
+ "facing=up,up=east": { "model": "opencomputers:screen", "x": 90, "y": 270 },
+ "facing=up,up=west": { "model": "opencomputers:screen", "x": 90, "y": 90 },
+ "facing=down,up=north": { "model": "opencomputers:screen", "x": -90 },
+ "facing=down,up=south": { "model": "opencomputers:screen", "x": -90, "y": 180 },
+ "facing=down,up=east": { "model": "opencomputers:screen", "x": -90, "y": 270 },
+ "facing=down,up=west": { "model": "opencomputers:screen", "x": -90, "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/screen2.json b/src/main/resources/assets/opencomputers/blockstates/screen2.json
new file mode 100644
index 000000000..63ba96081
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/screen2.json
@@ -0,0 +1,16 @@
+{
+ "variants": {
+ "facing=north,up=up": { "model": "opencomputers:screen" },
+ "facing=south,up=up": { "model": "opencomputers:screen", "y": 180 },
+ "facing=west,up=up": { "model": "opencomputers:screen", "y": 270 },
+ "facing=east,up=up": { "model": "opencomputers:screen", "y": 90 },
+ "facing=up,up=north": { "model": "opencomputers:screen", "x": 90 },
+ "facing=up,up=south": { "model": "opencomputers:screen", "x": 90, "y": 180 },
+ "facing=up,up=east": { "model": "opencomputers:screen", "x": 90, "y": 270 },
+ "facing=up,up=west": { "model": "opencomputers:screen", "x": 90, "y": 90 },
+ "facing=down,up=north": { "model": "opencomputers:screen", "x": -90 },
+ "facing=down,up=south": { "model": "opencomputers:screen", "x": -90, "y": 180 },
+ "facing=down,up=east": { "model": "opencomputers:screen", "x": -90, "y": 270 },
+ "facing=down,up=west": { "model": "opencomputers:screen", "x": -90, "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/screen3.json b/src/main/resources/assets/opencomputers/blockstates/screen3.json
new file mode 100644
index 000000000..63ba96081
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/screen3.json
@@ -0,0 +1,16 @@
+{
+ "variants": {
+ "facing=north,up=up": { "model": "opencomputers:screen" },
+ "facing=south,up=up": { "model": "opencomputers:screen", "y": 180 },
+ "facing=west,up=up": { "model": "opencomputers:screen", "y": 270 },
+ "facing=east,up=up": { "model": "opencomputers:screen", "y": 90 },
+ "facing=up,up=north": { "model": "opencomputers:screen", "x": 90 },
+ "facing=up,up=south": { "model": "opencomputers:screen", "x": 90, "y": 180 },
+ "facing=up,up=east": { "model": "opencomputers:screen", "x": 90, "y": 270 },
+ "facing=up,up=west": { "model": "opencomputers:screen", "x": 90, "y": 90 },
+ "facing=down,up=north": { "model": "opencomputers:screen", "x": -90 },
+ "facing=down,up=south": { "model": "opencomputers:screen", "x": -90, "y": 180 },
+ "facing=down,up=east": { "model": "opencomputers:screen", "x": -90, "y": 270 },
+ "facing=down,up=west": { "model": "opencomputers:screen", "x": -90, "y": 90 }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/blockstates/switch.json b/src/main/resources/assets/opencomputers/blockstates/switch.json
new file mode 100644
index 000000000..18c289b04
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/blockstates/switch.json
@@ -0,0 +1,5 @@
+{
+ "variants": {
+ "normal": { "model": "opencomputers:switch" }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua
index ff1440526..1bed4ed2d 100644
--- a/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua
+++ b/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua
@@ -40,7 +40,7 @@ do
local w, h
if gpu and screen then
component.invoke(gpu, "bind", screen)
- w, h = component.invoke(gpu, "getResolution")
+ w, h = component.invoke(gpu, "maxResolution")
component.invoke(gpu, "setResolution", w, h)
component.invoke(gpu, "setBackground", 0x000000)
component.invoke(gpu, "setForeground", 0xFFFFFF)
diff --git a/src/main/resources/assets/opencomputers/models/block/accessPoint.json b/src/main/resources/assets/opencomputers/models/block/accessPoint.json
new file mode 100644
index 000000000..b942b819d
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/accessPoint.json
@@ -0,0 +1,6 @@
+{
+ "parent": "opencomputers:block/switch",
+ "textures": {
+ "top": "opencomputers:blocks/accessPoint_top"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/adapter.json b/src/main/resources/assets/opencomputers/models/block/adapter.json
new file mode 100644
index 000000000..a20ea7f23
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/adapter.json
@@ -0,0 +1,8 @@
+{
+ "parent": "block/cube_bottom_top",
+ "textures": {
+ "bottom": "opencomputers:blocks/generic_top",
+ "top": "opencomputers:blocks/adapter_top",
+ "side": "opencomputers:blocks/adapter_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/capacitor.json b/src/main/resources/assets/opencomputers/models/block/capacitor.json
new file mode 100644
index 000000000..b7ec2eb05
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/capacitor.json
@@ -0,0 +1,8 @@
+{
+ "parent": "block/cube_bottom_top",
+ "textures": {
+ "bottom": "opencomputers:blocks/generic_top",
+ "top": "opencomputers:blocks/capacitor_top",
+ "side": "opencomputers:blocks/capacitor_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/case.json b/src/main/resources/assets/opencomputers/models/block/case.json
new file mode 100644
index 000000000..4fd9da6ac
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/case.json
@@ -0,0 +1,10 @@
+{
+ "parent": "block/orientable",
+ "textures": {
+ "top": "opencomputers:blocks/case_top",
+ "bottom": "opencomputers:blocks/case_top",
+ "side": "opencomputers:blocks/case_side",
+ "south": "opencomputers:blocks/case_back",
+ "front": "opencomputers:blocks/case_front"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/charger.json b/src/main/resources/assets/opencomputers/models/block/charger.json
new file mode 100644
index 000000000..5609b1b6b
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/charger.json
@@ -0,0 +1,9 @@
+{
+ "parent": "block/orientable",
+ "textures": {
+ "bottom": "opencomputers:blocks/generic_top",
+ "top": "opencomputers:blocks/generic_top",
+ "side": "opencomputers:blocks/charger_side",
+ "front": "opencomputers:blocks/charger_front"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/disassembler.json b/src/main/resources/assets/opencomputers/models/block/disassembler.json
new file mode 100644
index 000000000..39eb6d7ff
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/disassembler.json
@@ -0,0 +1,8 @@
+{
+ "parent": "block/cube_bottom_top",
+ "textures": {
+ "bottom": "opencomputers:blocks/generic_top",
+ "top": "opencomputers:blocks/disassembler_top",
+ "side": "opencomputers:blocks/disassembler_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/diskDrive.json b/src/main/resources/assets/opencomputers/models/block/diskDrive.json
new file mode 100644
index 000000000..e3d17eadb
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/diskDrive.json
@@ -0,0 +1,9 @@
+{
+ "parent": "block/orientable",
+ "textures": {
+ "top": "opencomputers:blocks/generic_top",
+ "bottom": "opencomputers:blocks/generic_top",
+ "side": "opencomputers:blocks/diskDrive_side",
+ "front": "opencomputers:blocks/diskDrive_front"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/geolyzer.json b/src/main/resources/assets/opencomputers/models/block/geolyzer.json
new file mode 100644
index 000000000..7e4a03174
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/geolyzer.json
@@ -0,0 +1,8 @@
+{
+ "parent": "block/cube_bottom_top",
+ "textures": {
+ "top": "opencomputers:blocks/geolyzer_top",
+ "bottom": "opencomputers:blocks/generic_top",
+ "side": "opencomputers:blocks/geolyzer_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/keyboard.json b/src/main/resources/assets/opencomputers/models/block/keyboard.json
new file mode 100644
index 000000000..9812f3353
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/keyboard.json
@@ -0,0 +1,18 @@
+{
+ "textures": {
+ "all": "opencomputers:blocks/keyboard"
+ },
+ "elements": [
+ { "from": [ 1, 0, 4 ],
+ "to": [ 15, 1, 12 ],
+ "faces": {
+ "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#all" },
+ "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#all" },
+ "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#all" },
+ "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#all" },
+ "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#all" },
+ "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#all" }
+ }
+ }
+ ]
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/microcontroller.json b/src/main/resources/assets/opencomputers/models/block/microcontroller.json
new file mode 100644
index 000000000..d0b4b2ca3
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/microcontroller.json
@@ -0,0 +1,9 @@
+{
+ "parent": "block/orientable",
+ "textures": {
+ "top": "opencomputers:blocks/microcontroller_top",
+ "bottom": "opencomputers:blocks/microcontroller_top",
+ "side": "opencomputers:blocks/microcontroller_side",
+ "front": "opencomputers:blocks/microcontroller_front"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/motionSensor.json b/src/main/resources/assets/opencomputers/models/block/motionSensor.json
new file mode 100644
index 000000000..85ad09d69
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/motionSensor.json
@@ -0,0 +1,7 @@
+{
+ "parent": "block/cube_column",
+ "textures": {
+ "end": "opencomputers:blocks/motionSensor_top",
+ "side": "opencomputers:blocks/motionSensor_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/powerConverter.json b/src/main/resources/assets/opencomputers/models/block/powerConverter.json
new file mode 100644
index 000000000..e2fe5e647
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/powerConverter.json
@@ -0,0 +1,7 @@
+{
+ "parent": "block/cube_column",
+ "textures": {
+ "end": "opencomputers:blocks/generic_top",
+ "side": "opencomputers:blocks/powerConverter_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/powerDistributor.json b/src/main/resources/assets/opencomputers/models/block/powerDistributor.json
new file mode 100644
index 000000000..408292666
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/powerDistributor.json
@@ -0,0 +1,8 @@
+{
+ "parent": "block/cube_bottom_top",
+ "textures": {
+ "top": "opencomputers:blocks/powerDistributor_top",
+ "bottom": "opencomputers:blocks/generic_top",
+ "side": "opencomputers:blocks/powerDistributor_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/raid.json b/src/main/resources/assets/opencomputers/models/block/raid.json
new file mode 100644
index 000000000..8f1305c98
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/raid.json
@@ -0,0 +1,9 @@
+{
+ "parent": "block/orientable",
+ "textures": {
+ "top": "opencomputers:blocks/generic_top",
+ "bottom": "opencomputers:blocks/generic_top",
+ "side": "opencomputers:blocks/raid_side",
+ "front": "opencomputers:blocks/raid_front"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/redstone.json b/src/main/resources/assets/opencomputers/models/block/redstone.json
new file mode 100644
index 000000000..d7696238d
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/redstone.json
@@ -0,0 +1,7 @@
+{
+ "parent": "block/cube_column",
+ "textures": {
+ "end": "opencomputers:blocks/redstone_top",
+ "side": "opencomputers:blocks/redstone_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/screen.json b/src/main/resources/assets/opencomputers/models/block/screen.json
new file mode 100644
index 000000000..4beec80e0
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/screen.json
@@ -0,0 +1,8 @@
+{
+ "parent": "block/orientable",
+ "textures": {
+ "top": "opencomputers:blocks/screen_side",
+ "side": "opencomputers:blocks/screen_side",
+ "front": "opencomputers:blocks/screen_front"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/block/switch.json b/src/main/resources/assets/opencomputers/models/block/switch.json
new file mode 100644
index 000000000..0af961954
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/block/switch.json
@@ -0,0 +1,8 @@
+{
+ "parent": "block/cube_bottom_top",
+ "textures": {
+ "top": "opencomputers:blocks/switch_top",
+ "bottom": "opencomputers:blocks/generic_top",
+ "side": "opencomputers:blocks/switch_side"
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/accessPoint.json b/src/main/resources/assets/opencomputers/models/item/accessPoint.json
new file mode 100644
index 000000000..0a70f24a6
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/accessPoint.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/accessPoint",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/adapter.json b/src/main/resources/assets/opencomputers/models/item/adapter.json
new file mode 100644
index 000000000..294e08a6a
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/adapter.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/adapter",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/assembler.json b/src/main/resources/assets/opencomputers/models/item/assembler.json
new file mode 100644
index 000000000..8e945b115
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/assembler.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/assembler",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/capacitor.json b/src/main/resources/assets/opencomputers/models/item/capacitor.json
new file mode 100644
index 000000000..6d6b72ab3
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/capacitor.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/capacitor",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/case1.json b/src/main/resources/assets/opencomputers/models/item/case1.json
new file mode 100644
index 000000000..f676c6433
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/case1.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/case",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/case2.json b/src/main/resources/assets/opencomputers/models/item/case2.json
new file mode 100644
index 000000000..f676c6433
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/case2.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/case",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/case3.json b/src/main/resources/assets/opencomputers/models/item/case3.json
new file mode 100644
index 000000000..f676c6433
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/case3.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/case",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/caseCreative.json b/src/main/resources/assets/opencomputers/models/item/caseCreative.json
new file mode 100644
index 000000000..f676c6433
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/caseCreative.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/case",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/charger.json b/src/main/resources/assets/opencomputers/models/item/charger.json
new file mode 100644
index 000000000..d0da34721
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/charger.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/charger",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/disassembler.json b/src/main/resources/assets/opencomputers/models/item/disassembler.json
new file mode 100644
index 000000000..87d48ae03
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/disassembler.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/disassembler",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/diskDrive.json b/src/main/resources/assets/opencomputers/models/item/diskDrive.json
new file mode 100644
index 000000000..25425468e
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/diskDrive.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/diskDrive",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/geolyzer.json b/src/main/resources/assets/opencomputers/models/item/geolyzer.json
new file mode 100644
index 000000000..cd3c08328
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/geolyzer.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/geolyzer",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/microcontroller.json b/src/main/resources/assets/opencomputers/models/item/microcontroller.json
new file mode 100644
index 000000000..f84626848
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/microcontroller.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/microcontroller",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/motionSensor.json b/src/main/resources/assets/opencomputers/models/item/motionSensor.json
new file mode 100644
index 000000000..4e777bd31
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/motionSensor.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/motionSensor",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/powerConverter.json b/src/main/resources/assets/opencomputers/models/item/powerConverter.json
new file mode 100644
index 000000000..0925e9827
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/powerConverter.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/powerConverter",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/powerDistributor.json b/src/main/resources/assets/opencomputers/models/item/powerDistributor.json
new file mode 100644
index 000000000..97ae00d3f
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/powerDistributor.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/powerDistributor",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/raid.json b/src/main/resources/assets/opencomputers/models/item/raid.json
new file mode 100644
index 000000000..3ef295ebc
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/raid.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/raid",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/redstone.json b/src/main/resources/assets/opencomputers/models/item/redstone.json
new file mode 100644
index 000000000..c8c044eed
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/redstone.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/redstone",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/screen1.json b/src/main/resources/assets/opencomputers/models/item/screen1.json
new file mode 100644
index 000000000..9ddfb70f6
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/screen1.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/screen",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/screen2.json b/src/main/resources/assets/opencomputers/models/item/screen2.json
new file mode 100644
index 000000000..9ddfb70f6
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/screen2.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/screen",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/screen3.json b/src/main/resources/assets/opencomputers/models/item/screen3.json
new file mode 100644
index 000000000..9ddfb70f6
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/screen3.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/screen",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/serverRack.json b/src/main/resources/assets/opencomputers/models/item/serverRack.json
new file mode 100644
index 000000000..b18a96c28
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/serverRack.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/serverRack",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/models/item/switch.json b/src/main/resources/assets/opencomputers/models/item/switch.json
new file mode 100644
index 000000000..1eb0e4a0d
--- /dev/null
+++ b/src/main/resources/assets/opencomputers/models/item/switch.json
@@ -0,0 +1,10 @@
+{
+ "parent": "opencomputers:block/switch",
+ "display": {
+ "thirdperson": {
+ "rotation": [ 10, -45, 170 ],
+ "translation": [ 0, 1.5, -2.75 ],
+ "scale": [ 0.375, 0.375, 0.375 ]
+ }
+ }
+}
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/AccessPointTop.png b/src/main/resources/assets/opencomputers/textures/blocks/accessPoint_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/AccessPointTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/accessPoint_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/AdapterSide.png b/src/main/resources/assets/opencomputers/textures/blocks/adapter_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/AdapterSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/adapter_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/AdapterTop.png b/src/main/resources/assets/opencomputers/textures/blocks/adapter_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/AdapterTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/adapter_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/AssemblerSide.png b/src/main/resources/assets/opencomputers/textures/blocks/assembler_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/AssemblerSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/assembler_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/AssemblerTop.png b/src/main/resources/assets/opencomputers/textures/blocks/assembler_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/AssemblerTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/assembler_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CapacitorSide.png b/src/main/resources/assets/opencomputers/textures/blocks/capacitor_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/CapacitorSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/capacitor_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CapacitorTop.png b/src/main/resources/assets/opencomputers/textures/blocks/capacitor_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/CapacitorTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/capacitor_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CaseBack.png b/src/main/resources/assets/opencomputers/textures/blocks/case_back.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/CaseBack.png
rename to src/main/resources/assets/opencomputers/textures/blocks/case_back.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CaseFront.png b/src/main/resources/assets/opencomputers/textures/blocks/case_front.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/CaseFront.png
rename to src/main/resources/assets/opencomputers/textures/blocks/case_front.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CaseSide.png b/src/main/resources/assets/opencomputers/textures/blocks/case_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/CaseSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/case_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CaseTop.png b/src/main/resources/assets/opencomputers/textures/blocks/case_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/CaseTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/case_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/ChargerFront.png b/src/main/resources/assets/opencomputers/textures/blocks/charger_front.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/ChargerFront.png
rename to src/main/resources/assets/opencomputers/textures/blocks/charger_front.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/ChargerSide.png b/src/main/resources/assets/opencomputers/textures/blocks/charger_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/ChargerSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/charger_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/DisassemblerSide.png b/src/main/resources/assets/opencomputers/textures/blocks/disassembler_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/DisassemblerSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/disassembler_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/DisassemblerTop.png b/src/main/resources/assets/opencomputers/textures/blocks/disassembler_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/DisassemblerTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/disassembler_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/DiskDriveFront.png b/src/main/resources/assets/opencomputers/textures/blocks/diskDrive_front.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/DiskDriveFront.png
rename to src/main/resources/assets/opencomputers/textures/blocks/diskDrive_front.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/DiskDriveSide.png b/src/main/resources/assets/opencomputers/textures/blocks/diskDrive_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/DiskDriveSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/diskDrive_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/GenericSide.png b/src/main/resources/assets/opencomputers/textures/blocks/generic_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/GenericSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/generic_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/GenericTop.png b/src/main/resources/assets/opencomputers/textures/blocks/generic_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/GenericTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/generic_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/GeolyzerSide.png b/src/main/resources/assets/opencomputers/textures/blocks/geolyzer_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/GeolyzerSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/geolyzer_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/GeolyzerTop.png b/src/main/resources/assets/opencomputers/textures/blocks/geolyzer_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/GeolyzerTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/geolyzer_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/HologramSide.png b/src/main/resources/assets/opencomputers/textures/blocks/hologram_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/HologramSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/hologram_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/HologramTop0.png b/src/main/resources/assets/opencomputers/textures/blocks/hologram_top1.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/HologramTop0.png
rename to src/main/resources/assets/opencomputers/textures/blocks/hologram_top1.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/HologramTop1.png b/src/main/resources/assets/opencomputers/textures/blocks/hologram_top2.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/HologramTop1.png
rename to src/main/resources/assets/opencomputers/textures/blocks/hologram_top2.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/MicrocontrollerFront.png b/src/main/resources/assets/opencomputers/textures/blocks/microcontroller_front.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/MicrocontrollerFront.png
rename to src/main/resources/assets/opencomputers/textures/blocks/microcontroller_front.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/MicrocontrollerSide.png b/src/main/resources/assets/opencomputers/textures/blocks/microcontroller_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/MicrocontrollerSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/microcontroller_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/MicrocontrollerTop.png b/src/main/resources/assets/opencomputers/textures/blocks/microcontroller_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/MicrocontrollerTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/microcontroller_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/MotionSensorSide.png b/src/main/resources/assets/opencomputers/textures/blocks/motionSensor_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/MotionSensorSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/motionSensor_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/MotionSensorTop.png b/src/main/resources/assets/opencomputers/textures/blocks/motionSensor_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/MotionSensorTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/motionSensor_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/PowerConverterSide.png b/src/main/resources/assets/opencomputers/textures/blocks/powerConverter_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/PowerConverterSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/powerConverter_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/PowerDistributorSide.png b/src/main/resources/assets/opencomputers/textures/blocks/powerDistributor_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/PowerDistributorSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/powerDistributor_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/PowerDistributorTop.png b/src/main/resources/assets/opencomputers/textures/blocks/powerDistributor_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/PowerDistributorTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/powerDistributor_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/RaidFront.png b/src/main/resources/assets/opencomputers/textures/blocks/raid_front.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/RaidFront.png
rename to src/main/resources/assets/opencomputers/textures/blocks/raid_front.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/RaidSide.png b/src/main/resources/assets/opencomputers/textures/blocks/raid_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/RaidSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/raid_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/RedstoneSide.png b/src/main/resources/assets/opencomputers/textures/blocks/redstone_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/RedstoneSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/redstone_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/RedstoneTop.png b/src/main/resources/assets/opencomputers/textures/blocks/redstone_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/RedstoneTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/redstone_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/ServerRackFront.png b/src/main/resources/assets/opencomputers/textures/blocks/serverRack_front.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/ServerRackFront.png
rename to src/main/resources/assets/opencomputers/textures/blocks/serverRack_front.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/ServerRackSide.png b/src/main/resources/assets/opencomputers/textures/blocks/serverRack_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/ServerRackSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/serverRack_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/SwitchSide.png b/src/main/resources/assets/opencomputers/textures/blocks/switch_side.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/SwitchSide.png
rename to src/main/resources/assets/opencomputers/textures/blocks/switch_side.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/SwitchTop.png b/src/main/resources/assets/opencomputers/textures/blocks/switch_top.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/SwitchTop.png
rename to src/main/resources/assets/opencomputers/textures/blocks/switch_top.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/card.png b/src/main/resources/assets/opencomputers/textures/icons/card.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/card.png
rename to src/main/resources/assets/opencomputers/textures/icons/card.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/component_bus.png b/src/main/resources/assets/opencomputers/textures/icons/component_bus.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/component_bus.png
rename to src/main/resources/assets/opencomputers/textures/icons/component_bus.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/container.png b/src/main/resources/assets/opencomputers/textures/icons/container.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/container.png
rename to src/main/resources/assets/opencomputers/textures/icons/container.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/cpu.png b/src/main/resources/assets/opencomputers/textures/icons/cpu.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/cpu.png
rename to src/main/resources/assets/opencomputers/textures/icons/cpu.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/eeprom.png b/src/main/resources/assets/opencomputers/textures/icons/eeprom.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/eeprom.png
rename to src/main/resources/assets/opencomputers/textures/icons/eeprom.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/floppy.png b/src/main/resources/assets/opencomputers/textures/icons/floppy.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/floppy.png
rename to src/main/resources/assets/opencomputers/textures/icons/floppy.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/hdd.png b/src/main/resources/assets/opencomputers/textures/icons/hdd.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/hdd.png
rename to src/main/resources/assets/opencomputers/textures/icons/hdd.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/memory.png b/src/main/resources/assets/opencomputers/textures/icons/memory.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/memory.png
rename to src/main/resources/assets/opencomputers/textures/icons/memory.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/na.png b/src/main/resources/assets/opencomputers/textures/icons/na.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/na.png
rename to src/main/resources/assets/opencomputers/textures/icons/na.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/tablet.png b/src/main/resources/assets/opencomputers/textures/icons/tablet.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/tablet.png
rename to src/main/resources/assets/opencomputers/textures/icons/tablet.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/tier0.png b/src/main/resources/assets/opencomputers/textures/icons/tier0.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/tier0.png
rename to src/main/resources/assets/opencomputers/textures/icons/tier0.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/tier1.png b/src/main/resources/assets/opencomputers/textures/icons/tier1.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/tier1.png
rename to src/main/resources/assets/opencomputers/textures/icons/tier1.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/tier2.png b/src/main/resources/assets/opencomputers/textures/icons/tier2.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/tier2.png
rename to src/main/resources/assets/opencomputers/textures/icons/tier2.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/tool.png b/src/main/resources/assets/opencomputers/textures/icons/tool.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/tool.png
rename to src/main/resources/assets/opencomputers/textures/icons/tool.png
diff --git a/src/main/resources/assets/opencomputers/textures/items/icons/upgrade.png b/src/main/resources/assets/opencomputers/textures/icons/upgrade.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/items/icons/upgrade.png
rename to src/main/resources/assets/opencomputers/textures/icons/upgrade.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/HologramEffect.png b/src/main/resources/assets/opencomputers/textures/model/HologramEffect.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/HologramEffect.png
rename to src/main/resources/assets/opencomputers/textures/model/HologramEffect.png
diff --git a/src/main/resources/assets/opencomputers/textures/blocks/robot.png b/src/main/resources/assets/opencomputers/textures/model/robot.png
similarity index 100%
rename from src/main/resources/assets/opencomputers/textures/blocks/robot.png
rename to src/main/resources/assets/opencomputers/textures/model/robot.png
diff --git a/src/main/scala/li/cil/oc/Localization.scala b/src/main/scala/li/cil/oc/Localization.scala
index 328848133..6c25f7538 100644
--- a/src/main/scala/li/cil/oc/Localization.scala
+++ b/src/main/scala/li/cil/oc/Localization.scala
@@ -1,9 +1,9 @@
package li.cil.oc
-import cpw.mods.fml.common.event.FMLFingerprintViolationEvent
import net.minecraft.util.ChatComponentText
import net.minecraft.util.ChatComponentTranslation
import net.minecraft.util.StatCollector
+import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent
import scala.util.matching.Regex
diff --git a/src/main/scala/li/cil/oc/OpenComputers.scala b/src/main/scala/li/cil/oc/OpenComputers.scala
index 8d18f839a..b34811cbf 100644
--- a/src/main/scala/li/cil/oc/OpenComputers.scala
+++ b/src/main/scala/li/cil/oc/OpenComputers.scala
@@ -1,14 +1,14 @@
package li.cil.oc
-import cpw.mods.fml.common.Mod
-import cpw.mods.fml.common.Mod.EventHandler
-import cpw.mods.fml.common.SidedProxy
-import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent
-import cpw.mods.fml.common.event._
-import cpw.mods.fml.common.network.FMLEventChannel
import li.cil.oc.common.IMC
import li.cil.oc.common.Proxy
import li.cil.oc.server.CommandHandler
+import net.minecraftforge.fml.common.Mod
+import net.minecraftforge.fml.common.Mod.EventHandler
+import net.minecraftforge.fml.common.SidedProxy
+import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent
+import net.minecraftforge.fml.common.event._
+import net.minecraftforge.fml.common.network.FMLEventChannel
import org.apache.logging.log4j.LogManager
@Mod(modid = OpenComputers.ID, name = OpenComputers.Name,
diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala
index 56f5537e9..0041eee21 100644
--- a/src/main/scala/li/cil/oc/Settings.scala
+++ b/src/main/scala/li/cil/oc/Settings.scala
@@ -8,9 +8,9 @@ import java.util.UUID
import com.google.common.net.InetAddresses
import com.mojang.authlib.GameProfile
import com.typesafe.config._
-import cpw.mods.fml.common.Loader
-import cpw.mods.fml.common.versioning.DefaultArtifactVersion
-import cpw.mods.fml.common.versioning.VersionRange
+import net.minecraftforge.fml.common.Loader
+import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion
+import net.minecraftforge.fml.common.versioning.VersionRange
import li.cil.oc.api.component.TextBuffer.ColorDepth
import li.cil.oc.integration.Mods
import org.apache.commons.lang3.StringEscapeUtils
diff --git a/src/main/scala/li/cil/oc/client/GuiHandler.scala b/src/main/scala/li/cil/oc/client/GuiHandler.scala
index 06c6af472..fe6dca504 100644
--- a/src/main/scala/li/cil/oc/client/GuiHandler.scala
+++ b/src/main/scala/li/cil/oc/client/GuiHandler.scala
@@ -12,6 +12,8 @@ import li.cil.oc.common.item
import li.cil.oc.common.item.Tablet
import li.cil.oc.common.tileentity
import li.cil.oc.common.{GuiHandler => CommonGuiHandler}
+import li.cil.oc.util.BlockPosition
+import li.cil.oc.util.ExtendedWorld._
import net.minecraft.client.Minecraft
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.world.World
@@ -20,7 +22,7 @@ object GuiHandler extends CommonGuiHandler {
override def getClientGuiElement(id: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef = {
GuiType.Categories.get(id) match {
case Some(GuiType.Category.Block) =>
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(BlockPosition(x, y, z)) match {
case t: tileentity.Adapter if id == GuiType.Adapter.id =>
new gui.Adapter(player.inventory, t)
case t: tileentity.Assembler if id == GuiType.Assembler.id =>
@@ -93,7 +95,7 @@ object GuiHandler extends CommonGuiHandler {
case _ => false
}) match {
case Some(term) =>
- def inRange = player.isEntityAlive && !term.rack.isInvalid && term.rack.getDistanceFrom(player.posX, player.posY, player.posZ) < term.rack.range * term.rack.range
+ def inRange = player.isEntityAlive && !term.rack.isInvalid && term.rack.getDistanceSq(player.posX, player.posY, player.posZ) < term.rack.range * term.rack.range
if (inRange) {
if (term.keys.contains(key)) return new gui.Screen(term.buffer, true, () => true, () => {
// Check if someone else bound a term to our server.
diff --git a/src/main/scala/li/cil/oc/client/KeyBindings.scala b/src/main/scala/li/cil/oc/client/KeyBindings.scala
index a19c6cc0c..ac32c56d1 100644
--- a/src/main/scala/li/cil/oc/client/KeyBindings.scala
+++ b/src/main/scala/li/cil/oc/client/KeyBindings.scala
@@ -1,6 +1,6 @@
package li.cil.oc.client
-import cpw.mods.fml.client.FMLClientHandler
+import net.minecraftforge.fml.client.FMLClientHandler
import net.minecraft.client.settings.KeyBinding
import org.lwjgl.input.Keyboard
diff --git a/src/main/scala/li/cil/oc/client/OpenComponentsPresentException.scala b/src/main/scala/li/cil/oc/client/OpenComponentsPresentException.scala
index ff5d204df..85f990f9a 100644
--- a/src/main/scala/li/cil/oc/client/OpenComponentsPresentException.scala
+++ b/src/main/scala/li/cil/oc/client/OpenComponentsPresentException.scala
@@ -1,6 +1,6 @@
package li.cil.oc.client
-import cpw.mods.fml.client.CustomModLoadingErrorDisplayException
+import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException
import net.minecraft.client.gui.FontRenderer
import net.minecraft.client.gui.GuiErrorScreen
diff --git a/src/main/scala/li/cil/oc/client/PacketHandler.scala b/src/main/scala/li/cil/oc/client/PacketHandler.scala
index c04328b7a..a29c1180f 100644
--- a/src/main/scala/li/cil/oc/client/PacketHandler.scala
+++ b/src/main/scala/li/cil/oc/client/PacketHandler.scala
@@ -2,8 +2,6 @@ package li.cil.oc.client
import java.io.EOFException
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent
import li.cil.oc.Localization
import li.cil.oc.api.component
import li.cil.oc.api.event.FileSystemAccessEvent
@@ -18,9 +16,13 @@ import li.cil.oc.util.ExtendedWorld._
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.item.EnumDyeColor
import net.minecraft.nbt.CompressedStreamTools
+import net.minecraft.util.EnumFacing
+import net.minecraft.util.Vec3
import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent
import org.lwjgl.input.Keyboard
object PacketHandler extends CommonPacketHandler {
@@ -30,13 +32,12 @@ object PacketHandler extends CommonPacketHandler {
protected override def world(player: EntityPlayer, dimension: Int) = {
val world = player.worldObj
- if (world.provider.dimensionId == dimension) Some(world)
+ if (world.provider.getDimensionId == dimension) Some(world)
else None
}
override def dispatch(p: PacketParser) {
p.packetType match {
- case PacketType.AbstractBusState => onAbstractBusState(p)
case PacketType.Analyze => onAnalyze(p)
case PacketType.ChargerState => onChargerState(p)
case PacketType.ColorChange => onColorChange(p)
@@ -81,12 +82,6 @@ object PacketHandler extends CommonPacketHandler {
}
}
- def onAbstractBusState(p: PacketParser) =
- p.readTileEntity[AbstractBusAware]() match {
- case Some(t) => t.isAbstractBusAvailable = p.readBoolean()
- case _ => // Invalid packet.
- }
-
def onAnalyze(p: PacketParser) {
val address = p.readUTF()
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
@@ -107,7 +102,7 @@ object PacketHandler extends CommonPacketHandler {
def onColorChange(p: PacketParser) =
p.readTileEntity[Colored]() match {
case Some(t) =>
- t.color = p.readInt()
+ t.color = EnumDyeColor.byMetadata(p.readInt())
t.world.markBlockForUpdate(t.position)
case _ => // Invalid packet.
}
@@ -222,9 +217,10 @@ object PacketHandler extends CommonPacketHandler {
def onHologramPositionOffsetY(p: PacketParser) =
p.readTileEntity[Hologram]() match {
case Some(t) =>
- t.translation.xCoord = p.readDouble()
- t.translation.yCoord = p.readDouble()
- t.translation.zCoord = p.readDouble()
+ val x = p.readDouble()
+ val y = p.readDouble()
+ val z = p.readDouble()
+ t.translation = new Vec3(x, y, z)
case _ => // Invalid packet.
}
@@ -262,7 +258,7 @@ object PacketHandler extends CommonPacketHandler {
p.readTileEntity[RedstoneAware]() match {
case Some(t) =>
t.isOutputEnabled = p.readBoolean()
- for (d <- ForgeDirection.VALID_DIRECTIONS) {
+ for (d <- EnumFacing.values) {
t.output(d, p.readByte())
}
case _ => // Invalid packet.
@@ -311,7 +307,7 @@ object PacketHandler extends CommonPacketHandler {
case (Some(t), Some(d)) => t.robot.move(d)
case (_, Some(d)) =>
// Invalid packet, robot may be coming from outside our loaded area.
- PacketSender.sendRobotStateRequest(dimension, x + d.offsetX, y + d.offsetY, z + d.offsetZ)
+ PacketSender.sendRobotStateRequest(dimension, x + d.getFrontOffsetX, y + d.getFrontOffsetY, z + d.getFrontOffsetZ)
case _ => // Invalid packet.
}
}
diff --git a/src/main/scala/li/cil/oc/client/PacketSender.scala b/src/main/scala/li/cil/oc/client/PacketSender.scala
index cd807ec2d..40748e4d6 100644
--- a/src/main/scala/li/cil/oc/client/PacketSender.scala
+++ b/src/main/scala/li/cil/oc/client/PacketSender.scala
@@ -10,7 +10,7 @@ import li.cil.oc.common.tileentity.traits.Computer
import net.minecraft.client.Minecraft
import net.minecraft.client.audio.PositionedSoundRecord
import net.minecraft.util.ResourceLocation
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
object PacketSender {
// Timestamp after which the next clipboard message may be sent. Used to
@@ -161,7 +161,7 @@ object PacketSender {
pb.sendToServer()
}
- def sendServerSide(t: ServerRack, number: Int, side: Option[ForgeDirection]) {
+ def sendServerSide(t: ServerRack, number: Int, side: Option[EnumFacing]) {
val pb = new SimplePacketBuilder(PacketType.ServerSide)
pb.writeTileEntity(t)
diff --git a/src/main/scala/li/cil/oc/client/Proxy.scala b/src/main/scala/li/cil/oc/client/Proxy.scala
index b93b312c4..90eda0084 100644
--- a/src/main/scala/li/cil/oc/client/Proxy.scala
+++ b/src/main/scala/li/cil/oc/client/Proxy.scala
@@ -1,34 +1,43 @@
package li.cil.oc.client
-import cpw.mods.fml.client.registry.ClientRegistry
-import cpw.mods.fml.client.registry.RenderingRegistry
-import cpw.mods.fml.common.FMLCommonHandler
-import cpw.mods.fml.common.Loader
-import cpw.mods.fml.common.event.FMLInitializationEvent
-import cpw.mods.fml.common.event.FMLPreInitializationEvent
-import cpw.mods.fml.common.network.NetworkRegistry
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.client
import li.cil.oc.client.renderer.PetRenderer
import li.cil.oc.client.renderer.TextBufferRenderCache
import li.cil.oc.client.renderer.WirelessNetworkDebugRenderer
-import li.cil.oc.client.renderer.block.BlockRenderer
import li.cil.oc.client.renderer.entity.DroneRenderer
import li.cil.oc.client.renderer.item.ItemRenderer
import li.cil.oc.client.renderer.tileentity._
import li.cil.oc.common.component.TextBuffer
import li.cil.oc.common.entity.Drone
import li.cil.oc.common.init.Items
+import li.cil.oc.common.item.Delegate
import li.cil.oc.common.tileentity
import li.cil.oc.common.tileentity.ServerRack
import li.cil.oc.common.{Proxy => CommonProxy}
import li.cil.oc.util.Audio
+import net.minecraft.block.Block
+import net.minecraft.client.Minecraft
+import net.minecraft.client.renderer.ItemModelMesher
+import net.minecraft.client.resources.model.ModelResourceLocation
+import net.minecraft.item.Item
import net.minecraftforge.client.MinecraftForgeClient
import net.minecraftforge.common.MinecraftForge
+import net.minecraftforge.fml.client.registry.ClientRegistry
+import net.minecraftforge.fml.client.registry.RenderingRegistry
+import net.minecraftforge.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.Loader
+import net.minecraftforge.fml.common.event.FMLInitializationEvent
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
+import net.minecraftforge.fml.common.network.NetworkRegistry
import org.lwjgl.opengl.GLContext
+import scala.collection.mutable
+
private[oc] class Proxy extends CommonProxy {
+ private val pendingRegistrations = mutable.ArrayBuffer.empty[ItemModelMesher => Unit]
+
override def preInit(e: FMLPreInitializationEvent) {
if (Loader.isModLoaded("OpenComponents")) {
throw new OpenComponentsPresentException()
@@ -37,7 +46,21 @@ private[oc] class Proxy extends CommonProxy {
super.preInit(e)
MinecraftForge.EVENT_BUS.register(Sound)
- MinecraftForge.EVENT_BUS.register(gui.Icons)
+ MinecraftForge.EVENT_BUS.register(Textures)
+ }
+
+ override def registerModel(instance: Item, location: String): Unit ={
+ pendingRegistrations += ((mesher: ItemModelMesher) => {
+ mesher.register(instance, 0, new ModelResourceLocation(Settings.resourceDomain + ":" + location, "inventory"))
+ })
+ }
+
+ override def registerModel(instance: Delegate, name: String): Unit = {
+
+ }
+
+ override def registerModel(instance: Block, location: String): Unit = {
+ registerModel(Item.getItemFromBlock(instance), location)
}
override def init(e: FMLInitializationEvent) {
@@ -45,8 +68,13 @@ private[oc] class Proxy extends CommonProxy {
OpenComputers.channel.register(client.PacketHandler)
- Settings.blockRenderId = RenderingRegistry.getNextAvailableRenderId
- RenderingRegistry.registerBlockHandler(BlockRenderer)
+ // TODO block rendering
+// Settings.blockRenderId = RenderingRegistry.getNextAvailableRenderId
+// RenderingRegistry.registerBlockHandler(BlockRenderer)
+ val mesher =Minecraft.getMinecraft.getRenderItem.getItemModelMesher
+ pendingRegistrations.foreach(_(mesher))
+ pendingRegistrations.clear()
+
RenderingRegistry.registerEntityRenderingHandler(classOf[Drone], DroneRenderer)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Assembler], AssemblerRenderer)
diff --git a/src/main/scala/li/cil/oc/client/Sound.scala b/src/main/scala/li/cil/oc/client/Sound.scala
index eb1de250b..d9a24fa5b 100644
--- a/src/main/scala/li/cil/oc/client/Sound.scala
+++ b/src/main/scala/li/cil/oc/client/Sound.scala
@@ -8,19 +8,18 @@ import java.util.Timer
import java.util.TimerTask
import java.util.UUID
-import cpw.mods.fml.client.FMLClientHandler
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.relauncher.ReflectionHelper
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import net.minecraft.client.Minecraft
import net.minecraft.client.audio.SoundCategory
import net.minecraft.client.audio.SoundManager
-import net.minecraft.client.audio.SoundPoolEntry
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.event.sound.SoundLoadEvent
import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.client.FMLClientHandler
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.relauncher.ReflectionHelper
import paulscode.sound.SoundSystem
import paulscode.sound.SoundSystemConfig
@@ -110,7 +109,7 @@ object Sound {
}
private abstract class Command(val when: Long, val tileEntity: TileEntity) extends Ordered[Command] {
- def apply()
+ def apply(): Unit
override def compare(that: Command) = (that.when - when).toInt
}
@@ -159,16 +158,16 @@ object Sound {
}
def updatePosition() {
- soundSystem.setPosition(source, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)
+ soundSystem.setPosition(source, tileEntity.getPos.getX, tileEntity.getPos.getY, tileEntity.getPos.getZ)
}
def play(name: String) {
val resourceName = s"${Settings.resourceDomain}:$name"
val sound = Minecraft.getMinecraft.getSoundHandler.getSound(new ResourceLocation(resourceName))
- val resource = (sound.func_148720_g: SoundPoolEntry).getSoundPoolEntryLocation
+ val resource = sound.cloneEntry.getSoundPoolEntryLocation
if (!initialized) {
initialized = true
- soundSystem.newSource(false, source, toUrl(resource), resource.toString, true, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, SoundSystemConfig.ATTENUATION_LINEAR, 16)
+ soundSystem.newSource(false, source, toUrl(resource), resource.toString, true, tileEntity.getPos.getX, tileEntity.getPos.getY, tileEntity.getPos.getZ, SoundSystemConfig.ATTENUATION_LINEAR, 16)
updateVolume()
soundSystem.activate(source)
}
diff --git a/src/main/scala/li/cil/oc/client/Textures.scala b/src/main/scala/li/cil/oc/client/Textures.scala
index 324cab790..9ee50e321 100644
--- a/src/main/scala/li/cil/oc/client/Textures.scala
+++ b/src/main/scala/li/cil/oc/client/Textures.scala
@@ -1,125 +1,179 @@
package li.cil.oc.client
import li.cil.oc.Settings
+import li.cil.oc.common.Slot
+import li.cil.oc.common.Tier
+import net.minecraft.client.Minecraft
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.client.renderer.OpenGlHelper
import net.minecraft.client.renderer.texture.TextureManager
-import net.minecraft.util.IIcon
+import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.util.ResourceLocation
+import net.minecraftforge.client.event.TextureStitchEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object Textures {
val fontAntiAliased = new ResourceLocation(Settings.resourceDomain, "textures/font/chars.png")
val fontAliased = new ResourceLocation(Settings.resourceDomain, "textures/font/chars_aliased.png")
- val guiBackground = new ResourceLocation(Settings.resourceDomain, "textures/gui/background.png")
- val guiBar = new ResourceLocation(Settings.resourceDomain, "textures/gui/bar.png")
- val guiBorders = new ResourceLocation(Settings.resourceDomain, "textures/gui/borders.png")
- val guiButtonPower = new ResourceLocation(Settings.resourceDomain, "textures/gui/button_power.png")
- val guiButtonRange = new ResourceLocation(Settings.resourceDomain, "textures/gui/button_range.png")
- val guiButtonRun = new ResourceLocation(Settings.resourceDomain, "textures/gui/button_run.png")
- val guiButtonScroll = new ResourceLocation(Settings.resourceDomain, "textures/gui/button_scroll.png")
- val guiButtonSide = new ResourceLocation(Settings.resourceDomain, "textures/gui/button_side.png")
- val guiButtonSwitch = new ResourceLocation(Settings.resourceDomain, "textures/gui/button_switch.png")
- val guiComputer = new ResourceLocation(Settings.resourceDomain, "textures/gui/computer.png")
- val guiDatabase = new ResourceLocation(Settings.resourceDomain, "textures/gui/database.png")
- val guiDatabase1 = new ResourceLocation(Settings.resourceDomain, "textures/gui/database1.png")
- val guiDatabase2 = new ResourceLocation(Settings.resourceDomain, "textures/gui/database2.png")
- val guiDisassembler = new ResourceLocation(Settings.resourceDomain, "textures/gui/disassembler.png")
- val guiDrone = new ResourceLocation(Settings.resourceDomain, "textures/gui/drone.png")
- val guiKeyboardMissing = new ResourceLocation(Settings.resourceDomain, "textures/gui/keyboard_missing.png")
- val guiRaid = new ResourceLocation(Settings.resourceDomain, "textures/gui/raid.png")
- val guiRange = new ResourceLocation(Settings.resourceDomain, "textures/gui/range.png")
- val guiRobot = new ResourceLocation(Settings.resourceDomain, "textures/gui/robot.png")
- val guiRobotNoScreen = new ResourceLocation(Settings.resourceDomain, "textures/gui/robot_noscreen.png")
- val guiRobotAssembler = new ResourceLocation(Settings.resourceDomain, "textures/gui/robot_assembler.png")
- val guiRobotSelection = new ResourceLocation(Settings.resourceDomain, "textures/gui/robot_selection.png")
- val guiServer = new ResourceLocation(Settings.resourceDomain, "textures/gui/server.png")
- val guiSlot = new ResourceLocation(Settings.resourceDomain, "textures/gui/slot.png")
+ object GUI {
+ private def L(name: String) = new ResourceLocation(Settings.resourceDomain, "textures/gui/" + name + ".png")
- val blockCaseFrontOn = new ResourceLocation(Settings.resourceDomain, "textures/blocks/CaseFrontOn.png")
- val blockCaseFrontActivity = new ResourceLocation(Settings.resourceDomain, "textures/blocks/CaseFrontActivity.png")
- val blockDiskDriveFrontActivity = new ResourceLocation(Settings.resourceDomain, "textures/blocks/DiskDriveFrontActivity.png")
- val blockHologram = new ResourceLocation(Settings.resourceDomain, "textures/blocks/HologramEffect.png")
- val blockMicrocontrollerFrontLight = new ResourceLocation(Settings.resourceDomain, "textures/blocks/MicrocontrollerFrontLight.png")
- val blockMicrocontrollerFrontOn = new ResourceLocation(Settings.resourceDomain, "textures/blocks/MicrocontrollerFrontOn.png")
- val blockRackFrontOn = new ResourceLocation(Settings.resourceDomain, "textures/blocks/ServerRackFrontOn.png")
- val blockRackFrontActivity = new ResourceLocation(Settings.resourceDomain, "textures/blocks/ServerRackFrontActivity.png")
- val blockRaidFrontError = new ResourceLocation(Settings.resourceDomain, "textures/blocks/RaidFrontError.png")
- val blockRaidFrontActivity = new ResourceLocation(Settings.resourceDomain, "textures/blocks/RaidFrontActivity.png")
- val blockRobot = new ResourceLocation(Settings.resourceDomain, "textures/blocks/robot.png")
- val blockScreenUpIndicator = new ResourceLocation(Settings.resourceDomain, "textures/blocks/screen/up_indicator.png")
+ val Background = L("background")
+ val Bar = L("bar")
+ val Borders = L("borders")
+ val ButtonPower = L("button_power")
+ val ButtonRange = L("button_range")
+ val ButtonRun = L("button_run")
+ val ButtonScroll = L("button_scroll")
+ val ButtonSide = L("button_side")
+ val ButtonSwitch = L("button_switch")
+ val Computer = L("computer")
+ val Database = L("database")
+ val Database1 = L("database1")
+ val Database2 = L("database2")
+ val Disassembler = L("disassembler")
+ val Drone = L("drone")
+ val KeyboardMissing = L("keyboard_missing")
+ val Raid = L("raid")
+ val Range = L("range")
+ val Robot = L("robot")
+ val RobotAssembler = L("robot_assembler")
+ val RobotNoScreen = L("robot_noscreen")
+ val RobotSelection = L("robot_selection")
+ val Server = L("server")
+ val Slot = L("slot")
- val upgradeCrafting = new ResourceLocation(Settings.resourceDomain, "textures/model/UpgradeCrafting.png")
- val upgradeGenerator = new ResourceLocation(Settings.resourceDomain, "textures/model/UpgradeGenerator.png")
- val upgradeInventory = new ResourceLocation(Settings.resourceDomain, "textures/model/UpgradeInventory.png")
-
- object Cable {
- var iconCap: IIcon = _
+ def init(tm: TextureManager): Unit = {
+ tm.bindTexture(Background)
+ tm.bindTexture(Bar)
+ tm.bindTexture(Borders)
+ tm.bindTexture(ButtonPower)
+ tm.bindTexture(ButtonRange)
+ tm.bindTexture(ButtonRun)
+ tm.bindTexture(ButtonScroll)
+ tm.bindTexture(ButtonSide)
+ tm.bindTexture(ButtonSwitch)
+ tm.bindTexture(Computer)
+ tm.bindTexture(Database)
+ tm.bindTexture(Database1)
+ tm.bindTexture(Database2)
+ tm.bindTexture(Disassembler)
+ tm.bindTexture(Drone)
+ tm.bindTexture(KeyboardMissing)
+ tm.bindTexture(Raid)
+ tm.bindTexture(Range)
+ tm.bindTexture(Robot)
+ tm.bindTexture(RobotAssembler)
+ tm.bindTexture(RobotNoScreen)
+ tm.bindTexture(RobotSelection)
+ tm.bindTexture(Server)
+ tm.bindTexture(Slot)
+ }
}
- object Charger {
- var iconFrontCharging: IIcon = _
- var iconSideCharging: IIcon = _
+ object Icons {
+ private def L(name: String) = new ResourceLocation(Settings.resourceDomain, "textures/icons/" + name + ".png")
+
+ private val ForSlotType = Slot.All.map(name => name -> L(name)).toMap
+ private val ForTier = Map(Tier.None -> L("na")) ++ (Tier.One to Tier.Three).map(tier => tier -> L("tier" + tier)).toMap
+
+ def init(tm: TextureManager): Unit = {
+ for ((_, icon) <- ForSlotType) tm.bindTexture(icon)
+ for ((_, icon) <- ForTier) tm.bindTexture(icon)
+ }
+
+ def get(slotType: String) = ForSlotType.get(slotType).orNull
+
+ def get(tier: Int) = ForTier.get(tier).orNull
}
- object Disassembler {
- var iconSideOn: IIcon = _
- var iconTopOn: IIcon = _
+ object Model {
+ private def L(name: String) = new ResourceLocation(Settings.resourceDomain, "textures/model/" + name + ".png")
+
+ val HologramEffect = L("HologramEffect")
+ val Robot = L("robot")
+ val UpgradeCrafting = L("UpgradeCrafting")
+ val UpgradeGenerator = L("UpgradeGenerator")
+ val UpgradeInventory = L("UpgradeInventory")
+
+ def init(tm: TextureManager): Unit = {
+ tm.bindTexture(HologramEffect)
+ tm.bindTexture(Robot)
+ tm.bindTexture(UpgradeCrafting)
+ tm.bindTexture(UpgradeGenerator)
+ tm.bindTexture(UpgradeInventory)
+ }
}
- object Geolyzer {
- var iconTopOn: IIcon = _
+ // These are kept in the block texture atlas to support animations.
+ object Block {
+ private def L(name: String) = new ResourceLocation(Settings.resourceDomain, "blocks/" + name)
+
+ val AssemblerSideAssembling = L("AssemblerSideAssembling")
+ val AssemblerSideOn = L("AssemblerSideOn")
+ val AssemblerTopOn = L("AssemblerTopOn")
+ val CableCap = L("CableCap")
+ val CaseFrontActivity = L("CaseFrontActivity")
+ val CaseFrontOn = L("CaseFrontOn")
+ val ChargerFrontOn = L("ChargerFrontOn")
+ val ChargerSideOn = L("ChargerSideOn")
+ val DisassemblerSideOn = L("DisassemblerSideOn")
+ val DisassemblerTopOn = L("DisassemblerTopOn")
+ val DiskDriveFrontActivity = L("DiskDriveFrontActivity")
+ val GeolyzerTopOn = L("GeolyzerTopOn")
+ val MicrocontrollerFrontLight = L("MicrocontrollerFrontLight")
+ val MicrocontrollerFrontOn = L("MicrocontrollerFrontOn")
+ val PowerDistributorSideOn = L("PowerDistributorSideOn")
+ val PowerDistributorTopOn = L("PowerDistributorTopOn")
+ val RackFrontActivity = L("ServerRackFrontActivity")
+ val RackFrontOn = L("ServerRackFrontOn")
+ val RaidFrontActivity = L("RaidFrontActivity")
+ val RaidFrontError = L("RaidFrontError")
+ val ScreenUpIndicator = L("screen/up_indicator")
+ val SwitchSideOn = L("SwitchSideOn")
+
+ def init(map: TextureMap): Unit = {
+ map.registerSprite(AssemblerSideAssembling)
+ map.registerSprite(AssemblerSideOn)
+ map.registerSprite(AssemblerTopOn)
+ map.registerSprite(CableCap)
+ map.registerSprite(CaseFrontActivity)
+ map.registerSprite(CaseFrontOn)
+ map.registerSprite(ChargerFrontOn)
+ map.registerSprite(ChargerSideOn)
+ map.registerSprite(DisassemblerSideOn)
+ map.registerSprite(DisassemblerTopOn)
+ map.registerSprite(DiskDriveFrontActivity)
+ map.registerSprite(GeolyzerTopOn)
+ map.registerSprite(MicrocontrollerFrontLight)
+ map.registerSprite(MicrocontrollerFrontOn)
+ map.registerSprite(PowerDistributorSideOn)
+ map.registerSprite(PowerDistributorTopOn)
+ map.registerSprite(RackFrontActivity)
+ map.registerSprite(RackFrontOn)
+ map.registerSprite(RaidFrontActivity)
+ map.registerSprite(RaidFrontError)
+ map.registerSprite(ScreenUpIndicator)
+ map.registerSprite(SwitchSideOn)
+ }
+
+ def bind(): Unit = Minecraft.getMinecraft.renderEngine.bindTexture(TextureMap.locationBlocksTexture)
+
+ def unbind(): Unit = GlStateManager.bindTexture(0)
+
+ def getSprite(location: ResourceLocation) = Minecraft.getMinecraft.getTextureMapBlocks.getAtlasSprite(location.toString)
}
- object PowerDistributor {
- var iconSideOn: IIcon = _
- var iconTopOn: IIcon = _
- }
-
- object ServerRack {
- val icons = Array.fill[IIcon](6)(null)
- }
-
- object Assembler {
- var iconSideAssembling: IIcon = _
- var iconSideOn: IIcon = _
- var iconTopOn: IIcon = _
- }
-
- object Switch {
- var iconSideActivity: IIcon = _
- }
-
- def init(tm: TextureManager) {
+ @SubscribeEvent
+ def onTextureLoad(e: TextureStitchEvent.Pre): Unit = {
+ val tm = Minecraft.getMinecraft.getTextureManager
tm.bindTexture(fontAntiAliased)
tm.bindTexture(fontAliased)
- tm.bindTexture(guiBackground)
- tm.bindTexture(guiBar)
- tm.bindTexture(guiBorders)
- tm.bindTexture(guiButtonPower)
- tm.bindTexture(guiButtonRange)
- tm.bindTexture(guiButtonRun)
- tm.bindTexture(guiButtonSide)
- tm.bindTexture(guiComputer)
- tm.bindTexture(guiDrone)
- tm.bindTexture(guiKeyboardMissing)
- tm.bindTexture(guiRaid)
- tm.bindTexture(guiRange)
- tm.bindTexture(guiRobot)
- tm.bindTexture(guiRobotAssembler)
- tm.bindTexture(guiRobotSelection)
- tm.bindTexture(guiServer)
- tm.bindTexture(guiSlot)
-
- tm.bindTexture(blockCaseFrontOn)
- tm.bindTexture(blockCaseFrontActivity)
- tm.bindTexture(blockHologram)
- tm.bindTexture(blockMicrocontrollerFrontLight)
- tm.bindTexture(blockMicrocontrollerFrontOn)
- tm.bindTexture(blockRackFrontOn)
- tm.bindTexture(blockRobot)
- tm.bindTexture(blockScreenUpIndicator)
-
- tm.bindTexture(upgradeCrafting)
- tm.bindTexture(upgradeGenerator)
+ GUI.init(tm)
+ Icons.init(tm)
+ Model.init(tm)
+ Block.init(e.map)
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Adapter.scala b/src/main/scala/li/cil/oc/client/gui/Adapter.scala
index 412b4dbfe..5f46e94c3 100644
--- a/src/main/scala/li/cil/oc/client/gui/Adapter.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Adapter.scala
@@ -9,7 +9,7 @@ class Adapter(playerInventory: InventoryPlayer, val adapter: tileentity.Adapter)
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) = {
super.drawGuiContainerForegroundLayer(mouseX, mouseY)
fontRendererObj.drawString(
- Localization.localizeImmediately(adapter.getInventoryName),
+ Localization.localizeImmediately(adapter.getName),
8, 6, 0x404040)
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Assembler.scala b/src/main/scala/li/cil/oc/client/gui/Assembler.scala
index c8f7731bc..ede61b425 100644
--- a/src/main/scala/li/cil/oc/client/gui/Assembler.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Assembler.scala
@@ -56,7 +56,7 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse
override def initGui() {
super.initGui()
- runButton = new ImageButton(0, guiLeft + 7, guiTop + 89, 18, 18, Textures.guiButtonRun, canToggle = true)
+ runButton = new ImageButton(0, guiLeft + 7, guiTop + 89, 18, 18, Textures.GUI.ButtonRun, canToggle = true)
add(buttonList, runButton)
}
@@ -73,7 +73,7 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse
case _ => ""
}
fontRendererObj.drawString(message, 30, 94, 0x404040)
- if (runButton.func_146115_a) {
+ if (runButton.isMouseOver) {
val tooltip = new java.util.ArrayList[String]
tooltip.add(Localization.Assembler.Run)
info.foreach {
@@ -84,7 +84,7 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse
drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
}
}
- else if (func_146978_c(progress.x, progress.y, progress.width, progress.height, mouseX, mouseY)) {
+ else if (isPointInRegion(progress.x, progress.y, progress.width, progress.height, mouseX, mouseY)) {
val tooltip = new java.util.ArrayList[String]
val timeRemaining = formatTime(assemblerContainer.assemblyRemainingTime)
tooltip.add(Localization.Assembler.Progress(assemblerContainer.assemblyProgress, timeRemaining))
@@ -102,7 +102,7 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse
override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
GL11.glColor3f(1, 1, 1) // Required under Linux.
super.drawGuiContainerBackgroundLayer(dt, mouseX, mouseY)
- mc.renderEngine.bindTexture(Textures.guiRobotAssembler)
+ mc.renderEngine.bindTexture(Textures.GUI.RobotAssembler)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
if (assemblerContainer.isAssembling) progress.level = assemblerContainer.assemblyProgress / 100.0
else progress.level = 0
diff --git a/src/main/scala/li/cil/oc/client/gui/Case.scala b/src/main/scala/li/cil/oc/client/gui/Case.scala
index 9c19d64f1..e8ae0b803 100644
--- a/src/main/scala/li/cil/oc/client/gui/Case.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Case.scala
@@ -29,7 +29,7 @@ class Case(playerInventory: InventoryPlayer, val computer: tileentity.Case) exte
override def initGui() {
super.initGui()
- powerButton = new ImageButton(0, guiLeft + 70, guiTop + 33, 18, 18, Textures.guiButtonPower, canToggle = true)
+ powerButton = new ImageButton(0, guiLeft + 70, guiTop + 33, 18, 18, Textures.GUI.ButtonPower, canToggle = true)
add(buttonList, powerButton)
}
@@ -37,9 +37,9 @@ class Case(playerInventory: InventoryPlayer, val computer: tileentity.Case) exte
super.drawGuiContainerForegroundLayer(mouseX, mouseY)
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch.
fontRendererObj.drawString(
- Localization.localizeImmediately(computer.getInventoryName),
+ Localization.localizeImmediately(computer.getName),
8, 6, 0x404040)
- if (powerButton.func_146115_a) {
+ if (powerButton.isMouseOver) {
val tooltip = new java.util.ArrayList[String]
tooltip.add(if (computer.isRunning) Localization.Computer.TurnOff else Localization.Computer.TurnOn)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
@@ -49,7 +49,7 @@ class Case(playerInventory: InventoryPlayer, val computer: tileentity.Case) exte
override def drawSecondaryBackgroundLayer() {
GL11.glColor3f(1, 1, 1) // Required under Linux.
- mc.renderEngine.bindTexture(Textures.guiComputer)
+ mc.renderEngine.bindTexture(Textures.GUI.Computer)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Charger.scala b/src/main/scala/li/cil/oc/client/gui/Charger.scala
index 506f58b3c..f27af6a15 100644
--- a/src/main/scala/li/cil/oc/client/gui/Charger.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Charger.scala
@@ -9,7 +9,7 @@ class Charger(playerInventory: InventoryPlayer, val charger: tileentity.Charger)
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) = {
super.drawGuiContainerForegroundLayer(mouseX, mouseY)
fontRendererObj.drawString(
- Localization.localizeImmediately(charger.getInventoryName),
+ Localization.localizeImmediately(charger.getName),
8, 6, 0x404040)
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Database.scala b/src/main/scala/li/cil/oc/client/gui/Database.scala
index cc843dc78..c2270cf75 100644
--- a/src/main/scala/li/cil/oc/client/gui/Database.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Database.scala
@@ -15,16 +15,16 @@ class Database(playerInventory: InventoryPlayer, val databaseInventory: Database
override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
GL11.glColor4f(1, 1, 1, 1)
- mc.renderEngine.bindTexture(Textures.guiDatabase)
+ mc.renderEngine.bindTexture(Textures.GUI.Database)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
if (databaseInventory.tier > Tier.One) {
- mc.renderEngine.bindTexture(Textures.guiDatabase1)
+ mc.renderEngine.bindTexture(Textures.GUI.Database1)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
}
if (databaseInventory.tier > Tier.Two) {
- mc.renderEngine.bindTexture(Textures.guiDatabase2)
+ mc.renderEngine.bindTexture(Textures.GUI.Database2)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Disassembler.scala b/src/main/scala/li/cil/oc/client/gui/Disassembler.scala
index bf671334b..395642a40 100644
--- a/src/main/scala/li/cil/oc/client/gui/Disassembler.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Disassembler.scala
@@ -15,14 +15,14 @@ class Disassembler(playerInventory: InventoryPlayer, val disassembler: tileentit
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) = {
fontRendererObj.drawString(
- Localization.localizeImmediately(disassembler.getInventoryName),
+ Localization.localizeImmediately(disassembler.getName),
8, 6, 0x404040)
}
override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
GL11.glColor3f(1, 1, 1) // Required under Linux.
super.drawGuiContainerBackgroundLayer(dt, mouseX, mouseY)
- mc.renderEngine.bindTexture(Textures.guiDisassembler)
+ mc.renderEngine.bindTexture(Textures.GUI.Disassembler)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
progress.level = disassemblerContainer.disassemblyProgress / 100.0
drawWidgets()
diff --git a/src/main/scala/li/cil/oc/client/gui/DiskDrive.scala b/src/main/scala/li/cil/oc/client/gui/DiskDrive.scala
index 87afa86b4..21e6c0e34 100644
--- a/src/main/scala/li/cil/oc/client/gui/DiskDrive.scala
+++ b/src/main/scala/li/cil/oc/client/gui/DiskDrive.scala
@@ -9,7 +9,7 @@ class DiskDrive(playerInventory: InventoryPlayer, val drive: tileentity.DiskDriv
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) = {
super.drawGuiContainerForegroundLayer(mouseX, mouseY)
fontRendererObj.drawString(
- Localization.localizeImmediately(drive.getInventoryName),
+ Localization.localizeImmediately(drive.getName),
8, 6, 0x404040)
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Drone.scala b/src/main/scala/li/cil/oc/client/gui/Drone.scala
index 63967af22..202e3bfd5 100644
--- a/src/main/scala/li/cil/oc/client/gui/Drone.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Drone.scala
@@ -69,7 +69,7 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D
override def initGui() {
super.initGui()
- powerButton = new ImageButton(0, guiLeft + 7, guiTop + 45, 18, 18, Textures.guiButtonPower, canToggle = true)
+ powerButton = new ImageButton(0, guiLeft + 7, guiTop + 45, 18, 18, Textures.GUI.ButtonPower, canToggle = true)
add(buttonList, powerButton)
}
@@ -90,7 +90,7 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D
override protected def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) {
drawBufferLayer()
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch.
- if (func_146978_c(power.x, power.y, power.width, power.height, mouseX, mouseY)) {
+ if (isPointInRegion(power.x, power.y, power.width, power.height, mouseX, mouseY)) {
val tooltip = new java.util.ArrayList[String]
val format = Localization.Computer.Power + ": %d%% (%d/%d)"
tooltip.add(format.format(
@@ -99,7 +99,7 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D
drone.globalBufferSize))
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
}
- if (powerButton.func_146115_a) {
+ if (powerButton.isMouseOver) {
val tooltip = new java.util.ArrayList[String]
tooltip.add(if (drone.isRunning) Localization.Computer.TurnOff else Localization.Computer.TurnOn)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
@@ -109,7 +109,7 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D
override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
GL11.glColor3f(1, 1, 1) // Required under Linux.
- mc.renderEngine.bindTexture(Textures.guiDrone)
+ mc.renderEngine.bindTexture(Textures.GUI.Drone)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
power.level = drone.globalBuffer.toDouble / math.max(drone.globalBufferSize.toDouble, 1.0)
drawWidgets()
@@ -139,18 +139,19 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D
val slot = drone.selectedSlot
if (slot >= 0 && slot < 16) {
RenderState.makeItBlend()
- Minecraft.getMinecraft.renderEngine.bindTexture(Textures.guiRobotSelection)
+ Minecraft.getMinecraft.renderEngine.bindTexture(Textures.GUI.RobotSelection)
val now = System.currentTimeMillis() / 1000.0
val offsetV = ((now - now.toInt) * selectionsStates).toInt * selectionStepV
val x = guiLeft + inventoryX - 1 + (slot % 4) * (selectionSize - 2)
val y = guiTop + inventoryY - 1 + (slot / 4) * (selectionSize - 2)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(x, y, zLevel, 0, offsetV)
- t.addVertexWithUV(x, y + selectionSize, zLevel, 0, offsetV + selectionStepV)
- t.addVertexWithUV(x + selectionSize, y + selectionSize, zLevel, 1, offsetV + selectionStepV)
- t.addVertexWithUV(x + selectionSize, y, zLevel, 1, offsetV)
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ r.startDrawingQuads()
+ r.addVertexWithUV(x, y, zLevel, 0, offsetV)
+ r.addVertexWithUV(x, y + selectionSize, zLevel, 0, offsetV + selectionStepV)
+ r.addVertexWithUV(x + selectionSize, y + selectionSize, zLevel, 1, offsetV + selectionStepV)
+ r.addVertexWithUV(x + selectionSize, y, zLevel, 1, offsetV)
t.draw()
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala b/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala
index 3328ce944..7e7a55611 100644
--- a/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala
+++ b/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala
@@ -7,12 +7,12 @@ import li.cil.oc.common.container.ComponentSlot
import li.cil.oc.common.container.Player
import li.cil.oc.integration.util.NEI
import li.cil.oc.util.RenderState
+import net.minecraft.client.gui.Gui
+import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.inventory.Container
import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
-import net.minecraft.util.IIcon
import org.lwjgl.opengl.GL11
import scala.collection.convert.WrapAsScala._
@@ -32,7 +32,7 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai
override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
GL11.glColor4f(1, 1, 1, 1)
- mc.renderEngine.bindTexture(Textures.guiBackground)
+ mc.renderEngine.bindTexture(Textures.GUI.Background)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
drawSecondaryBackgroundLayer()
@@ -73,13 +73,19 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai
if (!isInPlayerInventory(slot)) {
drawSlotBackground(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1)
}
- if (!slot.getHasStack) slot match {
- case component: ComponentSlot if component.tierIcon != null =>
- mc.getTextureManager.bindTexture(TextureMap.locationItemsTexture)
- GL11.glDisable(GL11.GL_DEPTH_TEST)
- drawTexturedModelRectFromIcon(slot.xDisplayPosition, slot.yDisplayPosition, component.tierIcon, 16, 16)
- GL11.glEnable(GL11.GL_DEPTH_TEST)
- case _ =>
+ if (!slot.getHasStack) {
+ slot match {
+ case component: ComponentSlot =>
+ GL11.glDisable(GL11.GL_DEPTH_TEST)
+ if (component.tierIcon != null) {
+ mc.getTextureManager.bindTexture(component.tierIcon)
+ Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16)
+ }
+ mc.getTextureManager.bindTexture(slot.getBackgroundLocation)
+ Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16)
+ GL11.glEnable(GL11.GL_DEPTH_TEST)
+ case _ =>
+ }
}
}
}
@@ -102,10 +108,10 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai
}
}
if (drawHighlight) {
+ GlStateManager.disableLighting()
GL11.glDisable(GL11.GL_DEPTH_TEST)
- GL11.glDisable(GL11.GL_LIGHTING)
drawGradientRect(slot.xDisplayPosition, slot.yDisplayPosition, slot.xDisplayPosition + 16, slot.yDisplayPosition + 16, 0x80FFFFFF, 0x80FFFFFF)
- GL11.glEnable(GL11.GL_LIGHTING)
+ GlStateManager.enableLighting()
GL11.glEnable(GL11.GL_DEPTH_TEST)
}
}
@@ -119,23 +125,24 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai
protected def drawDisabledSlot(slot: ComponentSlot) {
GL11.glColor4f(1, 1, 1, 1)
- mc.getTextureManager.bindTexture(TextureMap.locationItemsTexture)
+ mc.getTextureManager.bindTexture(slot.tierIcon)
GL11.glDisable(GL11.GL_DEPTH_TEST)
GL11.glDisable(GL11.GL_LIGHTING)
- drawTexturedModelRectFromIcon(slot.xDisplayPosition, slot.yDisplayPosition, slot.tierIcon, 16, 16)
+ Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16)
GL11.glEnable(GL11.GL_LIGHTING)
GL11.glEnable(GL11.GL_DEPTH_TEST)
}
protected def drawSlotBackground(x: Int, y: Int) {
GL11.glColor4f(1, 1, 1, 1)
- mc.getTextureManager.bindTexture(Textures.guiSlot)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(x, y + 18, zLevel + 1, 0, 1)
- t.addVertexWithUV(x + 18, y + 18, zLevel + 1, 1, 1)
- t.addVertexWithUV(x + 18, y, zLevel + 1, 1, 0)
- t.addVertexWithUV(x, y, zLevel + 1, 0, 0)
+ mc.getTextureManager.bindTexture(Textures.GUI.Slot)
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ r.startDrawingQuads()
+ r.addVertexWithUV(x, y + 18, zLevel + 1, 0, 1)
+ r.addVertexWithUV(x + 18, y + 18, zLevel + 1, 1, 1)
+ r.addVertexWithUV(x + 18, y, zLevel + 1, 1, 0)
+ r.addVertexWithUV(x, y, zLevel + 1, 0, 0)
t.draw()
}
@@ -145,15 +152,6 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai
GL11.glDisable(GL11.GL_LIGHTING)
}
- override def drawTexturedModelRectFromIcon(x: Int, y: Int, icon: IIcon, width: Int, height: Int) {
- GL11.glColor4f(1, 1, 1, 1)
- RenderState.makeItBlend()
- GL11.glDisable(GL11.GL_LIGHTING)
- super.drawTexturedModelRectFromIcon(x, y, icon, width, height)
- }
-
- private def isPointInRegion(rx: Int, ry: Int, rw: Int, rh: Int, px: Int, py: Int) = func_146978_c(rx, ry, rw, rh, px, py)
-
private def isInPlayerInventory(slot: Slot) = container match {
case player: Player => slot.inventory == player.playerInventory
case _ => false
diff --git a/src/main/scala/li/cil/oc/client/gui/Icons.scala b/src/main/scala/li/cil/oc/client/gui/Icons.scala
deleted file mode 100644
index 7c9ea3adc..000000000
--- a/src/main/scala/li/cil/oc/client/gui/Icons.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-package li.cil.oc.client.gui
-
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import li.cil.oc.Settings
-import li.cil.oc.common.Slot
-import li.cil.oc.common.Tier
-import net.minecraft.util.IIcon
-import net.minecraftforge.client.event.TextureStitchEvent
-
-import scala.collection.mutable
-
-object Icons {
- private val bySlotType = mutable.Map.empty[String, IIcon]
-
- private val byTier = mutable.Map.empty[Int, IIcon]
-
- @SubscribeEvent
- def onItemIconRegister(e: TextureStitchEvent) {
- val iconRegister = e.map
- if (iconRegister.getTextureType == 1) {
- for (name <- Slot.All) {
- bySlotType += name -> iconRegister.registerIcon(Settings.resourceDomain + ":icons/" + name)
- }
-
- byTier += Tier.None -> iconRegister.registerIcon(Settings.resourceDomain + ":icons/na")
- for (tier <- Tier.One to Tier.Three) {
- byTier += tier -> iconRegister.registerIcon(Settings.resourceDomain + ":icons/tier" + tier)
- }
- }
- }
-
- def get(slotType: String) = bySlotType.get(slotType).orNull
-
- def get(tier: Int) = byTier.get(tier).orNull
-}
diff --git a/src/main/scala/li/cil/oc/client/gui/ImageButton.scala b/src/main/scala/li/cil/oc/client/gui/ImageButton.scala
index cd8fd06cf..fd0d263e5 100644
--- a/src/main/scala/li/cil/oc/client/gui/ImageButton.scala
+++ b/src/main/scala/li/cil/oc/client/gui/ImageButton.scala
@@ -1,7 +1,7 @@
package li.cil.oc.client.gui
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.renderer.Tessellator
@@ -25,7 +25,7 @@ class ImageButton(id: Int, x: Int, y: Int, w: Int, h: Int,
if (visible) {
mc.renderEngine.bindTexture(image)
GL11.glColor4f(1, 1, 1, 1)
- field_146123_n = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height
+ hovered = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height
val x0 = xPosition
val x1 = xPosition + width
@@ -34,24 +34,25 @@ class ImageButton(id: Int, x: Int, y: Int, w: Int, h: Int,
val u0 = if (toggled) 0.5 else 0
val u1 = u0 + (if (canToggle) 0.5 else 1)
- val v0 = if (hoverOverride || getHoverState(field_146123_n) == 2) 0.5 else 0
+ val v0 = if (hoverOverride || getHoverState(hovered) == 2) 0.5 else 0
val v1 = v0 + 0.5
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(x0, y1, zLevel, u0, v1)
- t.addVertexWithUV(x1, y1, zLevel, u1, v1)
- t.addVertexWithUV(x1, y0, zLevel, u1, v0)
- t.addVertexWithUV(x0, y0, zLevel, u0, v0)
+ val t = Tessellator.getInstance
+ var r = t.getWorldRenderer
+ r.startDrawingQuads()
+ r.addVertexWithUV(x0, y1, zLevel, u0, v1)
+ r.addVertexWithUV(x1, y1, zLevel, u1, v1)
+ r.addVertexWithUV(x1, y0, zLevel, u1, v0)
+ r.addVertexWithUV(x0, y0, zLevel, u0, v0)
t.draw()
if (displayString != null) {
val color =
if (!enabled) textDisabledColor
- else if (hoverOverride || field_146123_n) textHoverColor
+ else if (hoverOverride || hovered) textHoverColor
else textColor
- if (textIndent >= 0) drawString(mc.fontRenderer, displayString, textIndent + xPosition, yPosition + (height - 8) / 2, color)
- else drawCenteredString(mc.fontRenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, color)
+ if (textIndent >= 0) drawString(mc.fontRendererObj, displayString, textIndent + xPosition, yPosition + (height - 8) / 2, color)
+ else drawCenteredString(mc.fontRendererObj, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, color)
}
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Raid.scala b/src/main/scala/li/cil/oc/client/gui/Raid.scala
index 5d5fb2f56..496bb6b0f 100644
--- a/src/main/scala/li/cil/oc/client/gui/Raid.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Raid.scala
@@ -11,7 +11,7 @@ class Raid(playerInventory: InventoryPlayer, val raid: tileentity.Raid) extends
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) = {
super.drawGuiContainerForegroundLayer(mouseX, mouseY)
fontRendererObj.drawString(
- Localization.localizeImmediately(raid.getInventoryName),
+ Localization.localizeImmediately(raid.getName),
8, 6, 0x404040)
fontRendererObj.drawSplitString(
@@ -22,7 +22,7 @@ class Raid(playerInventory: InventoryPlayer, val raid: tileentity.Raid) extends
override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
GL11.glColor3f(1, 1, 1) // Required under Linux.
super.drawGuiContainerBackgroundLayer(dt, mouseX, mouseY)
- mc.renderEngine.bindTexture(Textures.guiRaid)
+ mc.renderEngine.bindTexture(Textures.GUI.Raid)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Robot.scala b/src/main/scala/li/cil/oc/client/gui/Robot.scala
index e111465b2..30e6b227e 100644
--- a/src/main/scala/li/cil/oc/client/gui/Robot.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Robot.scala
@@ -97,8 +97,8 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
override def initGui() {
super.initGui()
- powerButton = new ImageButton(0, guiLeft + 5, guiTop + 153 - deltaY, 18, 18, Textures.guiButtonPower, canToggle = true)
- scrollButton = new ImageButton(1, guiLeft + scrollX + 1, guiTop + scrollY + 1, 6, 13, Textures.guiButtonScroll)
+ powerButton = new ImageButton(0, guiLeft + 5, guiTop + 153 - deltaY, 18, 18, Textures.GUI.ButtonPower, canToggle = true)
+ scrollButton = new ImageButton(1, guiLeft + scrollX + 1, guiTop + scrollY + 1, 6, 13, Textures.GUI.ButtonScroll)
add(buttonList, powerButton)
add(buttonList, scrollButton)
}
@@ -131,7 +131,7 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
override protected def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) {
drawBufferLayer()
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch.
- if (func_146978_c(power.x, power.y, power.width, power.height, mouseX, mouseY)) {
+ if (isPointInRegion(power.x, power.y, power.width, power.height, mouseX, mouseY)) {
val tooltip = new java.util.ArrayList[String]
val format = Localization.Computer.Power + ": %d%% (%d/%d)"
tooltip.add(format.format(
@@ -140,7 +140,7 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
robot.globalBufferSize.toInt))
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
}
- if (powerButton.func_146115_a) {
+ if (powerButton.isMouseOver) {
val tooltip = new java.util.ArrayList[String]
tooltip.add(if (robot.isRunning) Localization.Computer.TurnOff else Localization.Computer.TurnOn)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
@@ -150,8 +150,8 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
GL11.glColor3f(1, 1, 1) // Required under Linux.
- if (buffer != null) mc.renderEngine.bindTexture(Textures.guiRobot)
- else mc.renderEngine.bindTexture(Textures.guiRobotNoScreen)
+ if (buffer != null) mc.renderEngine.bindTexture(Textures.GUI.Robot)
+ else mc.renderEngine.bindTexture(Textures.GUI.RobotNoScreen)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
power.level = robot.globalBuffer / robot.globalBufferSize
drawWidgets()
@@ -191,8 +191,8 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
}
}
- override protected def mouseMovedOrUp(mouseX: Int, mouseY: Int, button: Int) {
- super.mouseMovedOrUp(mouseX, mouseY, button)
+ override protected def mouseReleased(mouseX: Int, mouseY: Int, button: Int) {
+ super.mouseReleased(mouseX, mouseY, button)
if (button == 0) {
isDragging = false
}
@@ -272,18 +272,19 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
val slot = robot.selectedSlot - robot.actualSlot(0) - inventoryOffset * 4
if (slot >= 0 && slot < 16) {
RenderState.makeItBlend()
- Minecraft.getMinecraft.renderEngine.bindTexture(Textures.guiRobotSelection)
+ Minecraft.getMinecraft.renderEngine.bindTexture(Textures.GUI.RobotSelection)
val now = System.currentTimeMillis() / 1000.0
val offsetV = ((now - now.toInt) * selectionsStates).toInt * selectionStepV
val x = guiLeft + inventoryX - 1 + (slot % 4) * (selectionSize - 2)
val y = guiTop + inventoryY - 1 + (slot / 4) * (selectionSize - 2)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(x, y, zLevel, 0, offsetV)
- t.addVertexWithUV(x, y + selectionSize, zLevel, 0, offsetV + selectionStepV)
- t.addVertexWithUV(x + selectionSize, y + selectionSize, zLevel, 1, offsetV + selectionStepV)
- t.addVertexWithUV(x + selectionSize, y, zLevel, 1, offsetV)
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ r.startDrawingQuads()
+ r.addVertexWithUV(x, y, zLevel, 0, offsetV)
+ r.addVertexWithUV(x, y + selectionSize, zLevel, 0, offsetV + selectionStepV)
+ r.addVertexWithUV(x + selectionSize, y + selectionSize, zLevel, 1, offsetV + selectionStepV)
+ r.addVertexWithUV(x + selectionSize, y, zLevel, 1, offsetV)
t.draw()
}
}
diff --git a/src/main/scala/li/cil/oc/client/gui/Screen.scala b/src/main/scala/li/cil/oc/client/gui/Screen.scala
index 3b69326ca..984e57fe5 100644
--- a/src/main/scala/li/cil/oc/client/gui/Screen.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Screen.scala
@@ -56,8 +56,8 @@ class Screen(val buffer: api.component.TextBuffer, val hasMouse: Boolean, val ha
}
}
- protected override def mouseMovedOrUp(mouseX: Int, mouseY: Int, button: Int) {
- super.mouseMovedOrUp(mouseX, mouseY, button)
+ override protected def mouseReleased(mouseX: Int, mouseY: Int, button: Int) {
+ super.mouseReleased(mouseX, mouseY, button)
if (hasMouse && button >= 0) {
if (didDrag) {
val bx = ((mouseX - x - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderWidth).toInt + 1
diff --git a/src/main/scala/li/cil/oc/client/gui/Server.scala b/src/main/scala/li/cil/oc/client/gui/Server.scala
index 0146a06b4..d455e2b2d 100644
--- a/src/main/scala/li/cil/oc/client/gui/Server.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Server.scala
@@ -12,13 +12,13 @@ class Server(playerInventory: InventoryPlayer, serverInventory: ServerInventory)
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY)
fontRendererObj.drawString(
- Localization.localizeImmediately(serverInventory.getInventoryName),
+ Localization.localizeImmediately(serverInventory.getName),
8, 6, 0x404040)
}
override def drawSecondaryBackgroundLayer() {
GL11.glColor3f(1, 1, 1) // Required under Linux.
- mc.renderEngine.bindTexture(Textures.guiServer)
+ mc.renderEngine.bindTexture(Textures.GUI.Server)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
}
diff --git a/src/main/scala/li/cil/oc/client/gui/ServerRack.scala b/src/main/scala/li/cil/oc/client/gui/ServerRack.scala
index f38694c99..396bfc359 100644
--- a/src/main/scala/li/cil/oc/client/gui/ServerRack.scala
+++ b/src/main/scala/li/cil/oc/client/gui/ServerRack.scala
@@ -12,7 +12,7 @@ import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.renderer.Tessellator
import net.minecraft.entity.player.InventoryPlayer
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRack) extends DynamicGuiContainer(new container.ServerRack(playerInventory, rack)) {
@@ -25,11 +25,11 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa
protected var rangeButtons = new Array[GuiButton](2)
def sideName(number: Int) = rack.sides(number) match {
- case Some(ForgeDirection.UP) => Localization.ServerRack.Top
- case Some(ForgeDirection.DOWN) => Localization.ServerRack.Bottom
- case Some(ForgeDirection.EAST) => Localization.ServerRack.Left
- case Some(ForgeDirection.WEST) => Localization.ServerRack.Right
- case Some(ForgeDirection.NORTH) => Localization.ServerRack.Back
+ case Some(EnumFacing.UP) => Localization.ServerRack.Top
+ case Some(EnumFacing.DOWN) => Localization.ServerRack.Bottom
+ case Some(EnumFacing.EAST) => Localization.ServerRack.Left
+ case Some(EnumFacing.WEST) => Localization.ServerRack.Right
+ case Some(EnumFacing.NORTH) => Localization.ServerRack.Back
case _ => Localization.ServerRack.None
}
@@ -41,10 +41,10 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa
}
if (button.id >= 4 && button.id <= 7) {
val number = button.id - 4
- val sides = ForgeDirection.VALID_DIRECTIONS.map(Option(_)) ++ Seq(None)
+ val sides = EnumFacing.values.map(Option(_)) ++ Seq(None)
val currentSide = sides.indexOf(rack.sides(number))
val searchSides = sides.drop(currentSide + 1) ++ sides.take(currentSide + 1)
- val nextSide = searchSides.find(side => side != Option(ForgeDirection.SOUTH) && (!rack.sides.contains(side) || side == None)) match {
+ val nextSide = searchSides.find(side => side != Option(EnumFacing.SOUTH) && (!rack.sides.contains(side) || side == None)) match {
case Some(side) => side
case _ => None
}
@@ -79,18 +79,18 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa
override def initGui() {
super.initGui()
for (i <- 0 to 3) {
- powerButtons(i) = new ImageButton(i, guiLeft + 84, guiTop + 7 + i * 18, 18, 18, Textures.guiButtonPower, canToggle = true)
+ powerButtons(i) = new ImageButton(i, guiLeft + 84, guiTop + 7 + i * 18, 18, 18, Textures.GUI.ButtonPower, canToggle = true)
add(buttonList, powerButtons(i))
}
for (i <- 0 to 3) {
- sideButtons(i) = new ImageButton(4 + i, guiLeft + 126, guiTop + 7 + i * 18, 42, 18, Textures.guiButtonSide, sideName(i))
+ sideButtons(i) = new ImageButton(4 + i, guiLeft + 126, guiTop + 7 + i * 18, 42, 18, Textures.GUI.ButtonSide, sideName(i))
add(buttonList, sideButtons(i))
}
for (i <- 0 to 1) {
- rangeButtons(i) = new ImageButton(8 + i, guiLeft + 8 + i * 48, guiTop + 50, 16, 18, Textures.guiButtonRange, if (i == 0) "-" else "+")
+ rangeButtons(i) = new ImageButton(8 + i, guiLeft + 8 + i * 48, guiTop + 50, 16, 18, Textures.GUI.ButtonRange, if (i == 0) "-" else "+")
add(buttonList, rangeButtons(i))
}
- switchButton = new ImageButton(10, guiLeft + 8, guiTop + 17, 64, 18, Textures.guiButtonSwitch, Localization.ServerRack.SwitchExternal, textIndent = 18)
+ switchButton = new ImageButton(10, guiLeft + 8, guiTop + 17, 64, 18, Textures.GUI.ButtonSwitch, Localization.ServerRack.SwitchExternal, textIndent = 18)
add(buttonList, switchButton)
}
@@ -99,7 +99,7 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Prevents NEI render glitch.
fontRendererObj.drawString(
- Localization.localizeImmediately(rack.getInventoryName),
+ Localization.localizeImmediately(rack.getName),
8, 6, 0x404040)
val rangeY = 39
@@ -111,15 +111,16 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa
val ty = 50
val w = 30
val h = 18
- val t = Tessellator.instance
- mc.getTextureManager.bindTexture(Textures.guiRange)
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ mc.getTextureManager.bindTexture(Textures.GUI.Range)
GL11.glColor3f(1, 1, 1)
GL11.glDepthMask(false)
- t.startDrawingQuads()
- t.addVertexWithUV(tx, ty + h, zLevel, 0, 1)
- t.addVertexWithUV(tx + w, ty + h, zLevel, 1, 1)
- t.addVertexWithUV(tx + w, ty, zLevel, 1, 0)
- t.addVertexWithUV(tx, ty, zLevel, 0, 0)
+ r.startDrawingQuads()
+ r.addVertexWithUV(tx, ty + h, zLevel, 0, 1)
+ r.addVertexWithUV(tx + w, ty + h, zLevel, 1, 1)
+ r.addVertexWithUV(tx + w, ty, zLevel, 1, 0)
+ r.addVertexWithUV(tx, ty, zLevel, 0, 0)
t.draw()
GL11.glDepthMask(true)
}
@@ -128,7 +129,7 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa
rack.range.toString,
40, 56, 0xFFFFFF)
- for (i <- 0 to 3 if powerButtons(i).func_146115_a) {
+ for (i <- 0 to 3 if powerButtons(i).isMouseOver) {
val tooltip = new java.util.ArrayList[String]
tooltip.add(if (rack.isRunning(i)) Localization.Computer.TurnOff else Localization.Computer.TurnOn)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
diff --git a/src/main/scala/li/cil/oc/client/gui/Switch.scala b/src/main/scala/li/cil/oc/client/gui/Switch.scala
index c15b274a8..ac3938225 100644
--- a/src/main/scala/li/cil/oc/client/gui/Switch.scala
+++ b/src/main/scala/li/cil/oc/client/gui/Switch.scala
@@ -14,7 +14,7 @@ class Switch(playerInventory: InventoryPlayer, val switch: tileentity.Switch) ex
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) = {
super.drawGuiContainerForegroundLayer(mouseX, mouseY)
fontRendererObj.drawString(
- Localization.localizeImmediately(switch.getInventoryName),
+ Localization.localizeImmediately(switch.getName),
8, 6, 0x404040)
fontRendererObj.drawString(
diff --git a/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala b/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala
index ce51835b1..83ff2884c 100644
--- a/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala
+++ b/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala
@@ -37,17 +37,21 @@ trait InputBuffer extends DisplayBuffer {
super.drawBufferLayer()
if (System.currentTimeMillis() - showKeyboardMissing < 1000) {
- Minecraft.getMinecraft.getTextureManager.bindTexture(Textures.guiKeyboardMissing)
+ Minecraft.getMinecraft.getTextureManager.bindTexture(Textures.GUI.KeyboardMissing)
GL11.glDisable(GL11.GL_DEPTH_TEST)
- val t = Tessellator.instance
- t.startDrawingQuads()
+
val x = bufferX + buffer.renderWidth - 16
val y = bufferY + buffer.renderHeight - 16
- t.addVertexWithUV(x, y + 16, 0, 0, 1)
- t.addVertexWithUV(x + 16, y + 16, 0, 1, 1)
- t.addVertexWithUV(x + 16, y, 0, 1, 0)
- t.addVertexWithUV(x, y, 0, 0, 0)
+
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ r.startDrawingQuads()
+ r.addVertexWithUV(x, y + 16, 0, 0, 1)
+ r.addVertexWithUV(x + 16, y + 16, 0, 1, 1)
+ r.addVertexWithUV(x + 16, y, 0, 1, 0)
+ r.addVertexWithUV(x, y, 0, 0, 0)
t.draw()
+
GL11.glEnable(GL11.GL_DEPTH_TEST)
RenderState.checkError(getClass.getName + ".drawBufferLayer: keyboard icon")
diff --git a/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala b/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala
index 7f9beb31e..ade4f23c2 100644
--- a/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala
+++ b/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala
@@ -21,13 +21,14 @@ class ProgressBar(val x: Int, val y: Int) extends Widget {
val ty = owner.windowY + y
val w = width * level
- Minecraft.getMinecraft.renderEngine.bindTexture(Textures.guiBar)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(tx, ty, owner.windowZ, u0, v0)
- t.addVertexWithUV(tx, ty + height, owner.windowZ, u0, v1)
- t.addVertexWithUV(tx + w, ty + height, owner.windowZ, u1, v1)
- t.addVertexWithUV(tx + w, ty, owner.windowZ, u1, v0)
+ Minecraft.getMinecraft.renderEngine.bindTexture(Textures.GUI.Bar)
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ r.startDrawingQuads()
+ r.addVertexWithUV(tx, ty, owner.windowZ, u0, v0)
+ r.addVertexWithUV(tx, ty + height, owner.windowZ, u0, v1)
+ r.addVertexWithUV(tx + w, ty + height, owner.windowZ, u1, v1)
+ r.addVertexWithUV(tx + w, ty, owner.windowZ, u1, v0)
t.draw()
}
}
diff --git a/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala
index 52388f872..094b8b2d0 100644
--- a/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala
@@ -4,9 +4,9 @@ import java.util.concurrent.Callable
import java.util.concurrent.TimeUnit
import com.google.common.cache.CacheBuilder
-import cpw.mods.fml.common.eventhandler.EventPriority
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import li.cil.oc.api.event.RobotRenderEvent
import li.cil.oc.client.renderer.tileentity.RobotRenderer
import net.minecraft.client.Minecraft
@@ -37,7 +37,7 @@ object PetRenderer {
@SubscribeEvent
def onPlayerRender(e: RenderPlayerEvent.Pre) {
- val name = e.entityPlayer.getCommandSenderName
+ val name = e.entityPlayer.getName
if (hidden.contains(name) || !entitledPlayers.contains(name)) return
rendering = Some(entitledPlayers(name))
@@ -53,8 +53,8 @@ object PetRenderer {
GL11.glPushMatrix()
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS)
if (e.entityPlayer != Minecraft.getMinecraft.thePlayer) {
- val localPos = Minecraft.getMinecraft.thePlayer.getPosition(e.partialRenderTick)
- val playerPos = e.entityPlayer.getPosition(e.partialRenderTick)
+ val localPos = Minecraft.getMinecraft.thePlayer.getPositionEyes(e.partialRenderTick)
+ val playerPos = e.entityPlayer.getPositionEyes(e.partialRenderTick)
val correction = 1.62 - (if (e.entityPlayer.isSneaking) 0.125 else 0)
GL11.glTranslated(
playerPos.xCoord - localPos.xCoord,
diff --git a/src/main/scala/li/cil/oc/client/renderer/TextBufferRenderCache.scala b/src/main/scala/li/cil/oc/client/renderer/TextBufferRenderCache.scala
index ff8fd67e6..4b9e268b3 100644
--- a/src/main/scala/li/cil/oc/client/renderer/TextBufferRenderCache.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/TextBufferRenderCache.scala
@@ -6,8 +6,8 @@ import java.util.concurrent.TimeUnit
import com.google.common.cache.CacheBuilder
import com.google.common.cache.RemovalListener
import com.google.common.cache.RemovalNotification
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import li.cil.oc.Settings
import li.cil.oc.client.renderer.font.TextBufferRenderData
import li.cil.oc.util.RenderState
diff --git a/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala
index a92bccabc..6a66203e5 100644
--- a/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala
@@ -1,7 +1,7 @@
package li.cil.oc.client.renderer
-import cpw.mods.fml.common.ObfuscationReflectionHelper
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.ObfuscationReflectionHelper
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.Settings
import li.cil.oc.server.network.WirelessNetwork
import li.cil.oc.util.RenderState
@@ -19,7 +19,7 @@ object WirelessNetworkDebugRenderer {
RenderState.checkError(getClass.getName + ".onRenderWorldLastEvent: entering (aka: wasntme)")
val world = ObfuscationReflectionHelper.getPrivateValue(classOf[net.minecraft.client.renderer.RenderGlobal], e.context, "theWorld", "field_72769_h", "r").asInstanceOf[World]
- WirelessNetwork.dimensions.get(world.provider.dimensionId) match {
+ WirelessNetwork.dimensions.get(world.provider.getDimensionId) match {
case Some(tree) =>
val mc = Minecraft.getMinecraft
val player = mc.thePlayer
diff --git a/src/main/scala/li/cil/oc/client/renderer/block/Assembler.scala b/src/main/scala/li/cil/oc/client/renderer/block/Assembler.scala
index c2509c521..568f61a90 100644
--- a/src/main/scala/li/cil/oc/client/renderer/block/Assembler.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/block/Assembler.scala
@@ -1,76 +1,76 @@
-package li.cil.oc.client.renderer.block
-
-import li.cil.oc.client.Textures
-import li.cil.oc.util.RenderState
-import net.minecraft.block.Block
-import net.minecraft.client.renderer.RenderBlocks
-import org.lwjgl.opengl.GL11
-
-object Assembler {
- def render(block: Block, metadata: Int, x: Int, y: Int, z: Int, renderer: RenderBlocks) {
- val previousRenderAllFaces = renderer.renderAllFaces
- renderer.renderAllFaces = true
-
- // Bottom.
- renderer.setRenderBounds(0, 0, 0, 1, 7 / 16f, 1)
- renderer.renderStandardBlock(block, x, y, z)
- // Middle.
- renderer.setRenderBounds(2 / 16f, 7 / 16f, 2 / 16f, 14 / 16f, 9 / 16f, 14 / 16f)
- renderer.renderStandardBlock(block, x, y, z)
- // Top.
- renderer.setRenderBounds(0, 9 / 16f, 0, 1, 1, 1)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.renderAllFaces = previousRenderAllFaces
- }
-
- def render(block: Block, metadata: Int, renderer: RenderBlocks) {
- // Bottom.
- renderer.setRenderBounds(0, 0, 0, 1, 7 / 16f, 1)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceYNeg(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
-
- // Middle.
- val previousRenderAllFaces = renderer.renderAllFaces
- renderer.renderAllFaces = true
- renderer.setRenderBounds(2 / 16f, 7 / 16f, 2 / 16f, 14 / 16f, 9 / 16f, 14 / 16f)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
- renderer.renderAllFaces = previousRenderAllFaces
-
- // Top.
- renderer.setRenderBounds(0, 9 / 16f, 0, 1, 1, 1)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceYNeg(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
-
- GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS)
- RenderState.makeItBlend()
- RenderState.disableLighting()
-
- renderer.setOverrideBlockTexture(Textures.Assembler.iconTopOn)
- renderer.setRenderBounds(0, 0, 0, 1, 1.05, 1)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
-
- renderer.setOverrideBlockTexture(Textures.Assembler.iconSideOn)
- renderer.setRenderBounds(-0.005, 0, 0, 1.005, 1, 1)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- renderer.setRenderBounds(0, 0, -0.005, 1, 1, 1.005)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
-
- renderer.clearOverrideBlockTexture()
- RenderState.enableLighting()
- GL11.glPopAttrib()
- }
-}
+//package li.cil.oc.client.renderer.block
+//
+//import li.cil.oc.client.Textures
+//import li.cil.oc.util.RenderState
+//import net.minecraft.block.Block
+//import net.minecraft.client.renderer.RenderBlocks
+//import org.lwjgl.opengl.GL11
+//
+//object Assembler {
+// def render(block: Block, metadata: Int, x: Int, y: Int, z: Int, renderer: RenderBlocks) {
+// val previousRenderAllFaces = renderer.renderAllFaces
+// renderer.renderAllFaces = true
+//
+// // Bottom.
+// renderer.setRenderBounds(0, 0, 0, 1, 7 / 16f, 1)
+// renderer.renderStandardBlock(block, x, y, z)
+// // Middle.
+// renderer.setRenderBounds(2 / 16f, 7 / 16f, 2 / 16f, 14 / 16f, 9 / 16f, 14 / 16f)
+// renderer.renderStandardBlock(block, x, y, z)
+// // Top.
+// renderer.setRenderBounds(0, 9 / 16f, 0, 1, 1, 1)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.renderAllFaces = previousRenderAllFaces
+// }
+//
+// def render(block: Block, metadata: Int, renderer: RenderBlocks) {
+// // Bottom.
+// renderer.setRenderBounds(0, 0, 0, 1, 7 / 16f, 1)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceYNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+//
+// // Middle.
+// val previousRenderAllFaces = renderer.renderAllFaces
+// renderer.renderAllFaces = true
+// renderer.setRenderBounds(2 / 16f, 7 / 16f, 2 / 16f, 14 / 16f, 9 / 16f, 14 / 16f)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+// renderer.renderAllFaces = previousRenderAllFaces
+//
+// // Top.
+// renderer.setRenderBounds(0, 9 / 16f, 0, 1, 1, 1)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceYNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+//
+// GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS)
+// RenderState.makeItBlend()
+// RenderState.disableLighting()
+//
+// renderer.setOverrideBlockTexture(Textures.Assembler.iconTopOn)
+// renderer.setRenderBounds(0, 0, 0, 1, 1.05, 1)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+//
+// renderer.setOverrideBlockTexture(Textures.Assembler.iconSideOn)
+// renderer.setRenderBounds(-0.005, 0, 0, 1.005, 1, 1)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// renderer.setRenderBounds(0, 0, -0.005, 1, 1, 1.005)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+//
+// renderer.clearOverrideBlockTexture()
+// RenderState.enableLighting()
+// GL11.glPopAttrib()
+// }
+//}
diff --git a/src/main/scala/li/cil/oc/client/renderer/block/BlockRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/block/BlockRenderer.scala
index 0f1f2b9f6..d77e7ec28 100644
--- a/src/main/scala/li/cil/oc/client/renderer/block/BlockRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/block/BlockRenderer.scala
@@ -1,268 +1,268 @@
-package li.cil.oc.client.renderer.block
-
-import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler
-import cpw.mods.fml.common.Loader
-import li.cil.oc.Settings
-import li.cil.oc.client.Textures
-import li.cil.oc.client.renderer.tileentity.RobotRenderer
-import li.cil.oc.common.block._
-import li.cil.oc.common.tileentity
-import li.cil.oc.util.RenderState
-import net.minecraft.block.Block
-import net.minecraft.client.renderer.RenderBlocks
-import net.minecraft.client.renderer.Tessellator
-import net.minecraft.util.IIcon
-import net.minecraft.world.IBlockAccess
-import net.minecraftforge.common.util.ForgeDirection
-import org.lwjgl.opengl.GL11
-
-object BlockRenderer extends ISimpleBlockRenderingHandler {
- def getRenderId = Settings.blockRenderId
-
- override def shouldRender3DInInventory(modelID: Int) = true
-
- override def renderInventoryBlock(block: Block, metadata: Int, modelID: Int, renderer: RenderBlocks) {
- RenderState.checkError(getClass.getName + ".renderInventoryBlock: entering (aka: wasntme)")
-
- GL11.glPushMatrix()
- block match {
- case cable: Cable =>
- GL11.glScalef(1.6f, 1.6f, 1.6f)
- GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- Tessellator.instance.startDrawingQuads()
- Cable.render(block, metadata, renderer)
- Tessellator.instance.draw()
-
- RenderState.checkError(getClass.getName + ".renderInventoryBlock: cable")
- case proxy@(_: RobotProxy | _: RobotAfterimage) =>
- GL11.glScalef(1.5f, 1.5f, 1.5f)
- GL11.glTranslatef(-0.5f, -0.45f, -0.5f)
- RobotRenderer.renderChassis()
-
- RenderState.checkError(getClass.getName + ".renderInventoryBlock: robot")
- case assembler: Assembler =>
- GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- Tessellator.instance.startDrawingQuads()
- Assembler.render(block, metadata, renderer)
- Tessellator.instance.draw()
-
- RenderState.checkError(getClass.getName + ".renderInventoryBlock: assembler")
- case hologram: Hologram =>
- GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- Tessellator.instance.startDrawingQuads()
- Hologram.render(block, metadata, renderer)
- Tessellator.instance.draw()
-
- RenderState.checkError(getClass.getName + ".renderInventoryBlock: hologram")
- case _ =>
- block match {
- case simple: SimpleBlock =>
- simple.setBlockBoundsForItemRender(metadata)
- simple.preItemRender(metadata)
- case _ => block.setBlockBoundsForItemRender()
- }
- renderer.setRenderBoundsFromBlock(block)
- GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- Tessellator.instance.startDrawingQuads()
- renderFaceYNeg(block, metadata, renderer)
- renderFaceYPos(block, metadata, renderer)
- renderFaceZNeg(block, metadata, renderer)
- renderFaceZPos(block, metadata, renderer)
- renderFaceXNeg(block, metadata, renderer)
- renderFaceXPos(block, metadata, renderer)
- Tessellator.instance.draw()
-
- RenderState.checkError(getClass.getName + ".renderInventoryBlock: standard block")
- }
- GL11.glPopMatrix()
-
- RenderState.checkError(getClass.getName + ".renderInventoryBlock: leaving")
- }
-
- override def renderWorldBlock(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, modelId: Int, realRenderer: RenderBlocks) = {
- RenderState.checkError(getClass.getName + ".renderWorldBlock: entering (aka: wasntme)")
-
- val renderer = patchedRenderer(realRenderer)
- world.getTileEntity(x, y, z) match {
- case cable: tileentity.Cable =>
- Cable.render(world, x, y, z, block, renderer)
-
- RenderState.checkError(getClass.getName + ".renderWorldBlock: cable")
-
- true
- case keyboard: tileentity.Keyboard =>
- if (keyboard.facing == ForgeDirection.UP || keyboard.facing == ForgeDirection.DOWN) {
- keyboard.yaw match {
- case ForgeDirection.NORTH =>
- renderer.uvRotateTop = 0
- renderer.uvRotateBottom = 0
- case ForgeDirection.SOUTH =>
- renderer.uvRotateTop = 3
- renderer.uvRotateBottom = 3
- case ForgeDirection.WEST =>
- renderer.uvRotateTop = 2
- renderer.uvRotateBottom = 1
- case ForgeDirection.EAST =>
- renderer.uvRotateTop = 1
- renderer.uvRotateBottom = 2
- case _ => throw new AssertionError("Impossible yaw value on keyboard.")
- }
- if (keyboard.facing == ForgeDirection.DOWN) {
- renderer.flipTexture = true
- }
- }
- val result = renderer.renderStandardBlock(block, x, y, z)
- renderer.uvRotateTop = 0
- renderer.uvRotateBottom = 0
- renderer.flipTexture = false
-
- RenderState.checkError(getClass.getName + ".renderWorldBlock: keyboard")
-
- result
- case rack: tileentity.ServerRack =>
- val previousRenderAllFaces = renderer.renderAllFaces
- val u1 = 1 / 16f
- val u2 = 15 / 16f
- val v1 = 2 / 16f
- val v2 = 14 / 16f
- val fs = 3 / 16f
-
- // Top and bottom.
- renderer.renderAllFaces = true
- renderer.setRenderBounds(0, 0, 0, 1, v1, 1)
- renderer.renderStandardBlock(block, x, y, z)
- renderer.setRenderBounds(0, v2, 0, 1, 1, 1)
- renderer.renderStandardBlock(block, x, y, z)
-
- // Sides.
- val front = rack.facing
- def renderSide(side: ForgeDirection, lx: Double, lz: Double, hx: Double, hz: Double) {
- if (side == front) {
- for (i <- 0 until 4 if rack.isPresent(i).isDefined) {
- side match {
- case ForgeDirection.WEST =>
- renderer.setRenderBounds(lx, v2 - (i + 1) * fs, lz + u1, u2, v2 - i * fs, hz - u1)
- case ForgeDirection.EAST =>
- renderer.setRenderBounds(u1, v2 - (i + 1) * fs, lz + u1, hx, v2 - i * fs, hz - u1)
- case ForgeDirection.NORTH =>
- renderer.setRenderBounds(lx + u1, v2 - (i + 1) * fs, lz, hx - u1, v2 - i * fs, u2)
- case ForgeDirection.SOUTH =>
- renderer.setRenderBounds(lx + u1, v2 - (i + 1) * fs, u1, hx - u1, v2 - i * fs, hz)
- case _ =>
- }
- renderer.renderStandardBlock(block, x, y, z)
- }
- }
- else {
- val isBack = front == side.getOpposite
- if (isBack) {
- renderer.setOverrideBlockTexture(Textures.ServerRack.icons(ForgeDirection.NORTH.ordinal))
- }
- renderer.setRenderBounds(lx, v1, lz, hx, v2, hz)
- renderer.renderStandardBlock(block, x, y, z)
- renderer.clearOverrideBlockTexture()
- }
- }
-
- renderSide(ForgeDirection.WEST, 0, 0, u1, 1)
- renderSide(ForgeDirection.EAST, u2, 0, 1, 1)
- renderSide(ForgeDirection.NORTH, 0, 0, 1, u1)
- renderSide(ForgeDirection.SOUTH, 0, u2, 1, 1)
-
- renderer.renderAllFaces = previousRenderAllFaces
-
- RenderState.checkError(getClass.getName + ".renderWorldBlock: rack")
-
- true
- case assembler: tileentity.Assembler =>
- Assembler.render(assembler.block, assembler.getBlockMetadata, x, y, z, renderer)
-
- RenderState.checkError(getClass.getName + ".renderWorldBlock: assembler")
-
- true
- case hologram: tileentity.Hologram =>
- Hologram.render(hologram.block, hologram.getBlockMetadata, x, y, z, renderer)
-
- RenderState.checkError(getClass.getName + ".renderWorldBlock: hologram")
-
- true
- case _ =>
- val result = renderer.renderStandardBlock(block, x, y, z)
-
- RenderState.checkError(getClass.getName + ".renderWorldBlock: standard block")
-
- result
- }
- }
-
- val isOneSevenTwo = Loader.instance.getMinecraftModContainer.getVersion == "1.7.2"
-
- def patchedRenderer(renderer: RenderBlocks) = if (isOneSevenTwo) {
- PatchedRenderBlocks.blockAccess = renderer.blockAccess
- PatchedRenderBlocks.overrideBlockTexture = renderer.overrideBlockTexture
- PatchedRenderBlocks.flipTexture = renderer.flipTexture
- PatchedRenderBlocks.renderAllFaces = renderer.renderAllFaces
- PatchedRenderBlocks.useInventoryTint = renderer.useInventoryTint
- PatchedRenderBlocks.renderFromInside = renderer.renderFromInside
- PatchedRenderBlocks.renderMinX = renderer.renderMinX
- PatchedRenderBlocks.renderMaxX = renderer.renderMaxX
- PatchedRenderBlocks.renderMinY = renderer.renderMinY
- PatchedRenderBlocks.renderMaxY = renderer.renderMaxY
- PatchedRenderBlocks.renderMinZ = renderer.renderMinZ
- PatchedRenderBlocks.renderMaxZ = renderer.renderMaxZ
- PatchedRenderBlocks.lockBlockBounds = renderer.lockBlockBounds
- PatchedRenderBlocks.partialRenderBounds = renderer.partialRenderBounds
- PatchedRenderBlocks.uvRotateEast = renderer.uvRotateEast
- PatchedRenderBlocks.uvRotateWest = renderer.uvRotateWest
- PatchedRenderBlocks.uvRotateSouth = renderer.uvRotateSouth
- PatchedRenderBlocks.uvRotateNorth = renderer.uvRotateNorth
- PatchedRenderBlocks.uvRotateTop = renderer.uvRotateTop
- PatchedRenderBlocks.uvRotateBottom = renderer.uvRotateBottom
- PatchedRenderBlocks
- }
- else renderer
-
- object PatchedRenderBlocks extends RenderBlocks {
- override def renderFaceXPos(block: Block, x: Double, y: Double, z: Double, texture: IIcon) {
- flipTexture = !flipTexture
- super.renderFaceXPos(block, x, y, z, texture)
- flipTexture = !flipTexture
- }
-
- override def renderFaceZNeg(block: Block, x: Double, y: Double, z: Double, texture: IIcon) {
- flipTexture = !flipTexture
- super.renderFaceZNeg(block, x, y, z, texture)
- flipTexture = !flipTexture
- }
- }
-
- def renderFaceXPos(block: Block, metadata: Int, renderer: RenderBlocks) {
- Tessellator.instance.setNormal(1, 0, 0)
- renderer.renderFaceXPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, ForgeDirection.EAST.ordinal, metadata))
- }
-
- def renderFaceXNeg(block: Block, metadata: Int, renderer: RenderBlocks) {
- Tessellator.instance.setNormal(-1, 0, 0)
- renderer.renderFaceXNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, ForgeDirection.WEST.ordinal, metadata))
- }
-
- def renderFaceYPos(block: Block, metadata: Int, renderer: RenderBlocks) {
- Tessellator.instance.setNormal(0, 1, 0)
- renderer.renderFaceYPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, ForgeDirection.UP.ordinal, metadata))
- }
-
- def renderFaceYNeg(block: Block, metadata: Int, renderer: RenderBlocks) {
- Tessellator.instance.setNormal(0, -1, 0)
- renderer.renderFaceYNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, ForgeDirection.DOWN.ordinal, metadata))
- }
-
- def renderFaceZPos(block: Block, metadata: Int, renderer: RenderBlocks) {
- Tessellator.instance.setNormal(0, 0, 1)
- renderer.renderFaceZPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, ForgeDirection.SOUTH.ordinal, metadata))
- }
-
- def renderFaceZNeg(block: Block, metadata: Int, renderer: RenderBlocks) {
- Tessellator.instance.setNormal(0, 0, -1)
- renderer.renderFaceZNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, ForgeDirection.NORTH.ordinal, metadata))
- }
-}
+//package li.cil.oc.client.renderer.block
+//
+//import net.minecraftforge.fml.client.registry.ISimpleBlockRenderingHandler
+//import net.minecraftforge.fml.common.Loader
+//import li.cil.oc.Settings
+//import li.cil.oc.client.Textures
+//import li.cil.oc.client.renderer.tileentity.RobotRenderer
+//import li.cil.oc.common.block._
+//import li.cil.oc.common.tileentity
+//import li.cil.oc.util.RenderState
+//import net.minecraft.block.Block
+//import net.minecraft.client.renderer.RenderBlocks
+//import net.minecraft.client.renderer.Tessellator
+//import net.minecraft.util.IIcon
+//import net.minecraft.world.IBlockAccess
+//import net.minecraft.util.EnumFacing
+//import org.lwjgl.opengl.GL11
+//
+//object BlockRenderer extends ISimpleBlockRenderingHandler {
+// def getRenderId = Settings.blockRenderId
+//
+// override def shouldRender3DInInventory(modelID: Int) = true
+//
+// override def renderInventoryBlock(block: Block, metadata: Int, modelID: Int, renderer: RenderBlocks) {
+// RenderState.checkError(getClass.getName + ".renderInventoryBlock: entering (aka: wasntme)")
+//
+// GL11.glPushMatrix()
+// block match {
+// case cable: Cable =>
+// GL11.glScalef(1.6f, 1.6f, 1.6f)
+// GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
+// Tessellator.getInstance.startDrawingQuads()
+// Cable.render(block, metadata, renderer)
+// Tessellator.getInstance.draw()
+//
+// RenderState.checkError(getClass.getName + ".renderInventoryBlock: cable")
+// case proxy@(_: RobotProxy | _: RobotAfterimage) =>
+// GL11.glScalef(1.5f, 1.5f, 1.5f)
+// GL11.glTranslatef(-0.5f, -0.45f, -0.5f)
+// RobotRenderer.renderChassis()
+//
+// RenderState.checkError(getClass.getName + ".renderInventoryBlock: robot")
+// case assembler: Assembler =>
+// GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
+// Tessellator.getInstance.startDrawingQuads()
+// Assembler.render(block, metadata, renderer)
+// Tessellator.getInstance.draw()
+//
+// RenderState.checkError(getClass.getName + ".renderInventoryBlock: assembler")
+// case hologram: Hologram =>
+// GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
+// Tessellator.getInstance.startDrawingQuads()
+// Hologram.render(block, metadata, renderer)
+// Tessellator.getInstance.draw()
+//
+// RenderState.checkError(getClass.getName + ".renderInventoryBlock: hologram")
+// case _ =>
+// block match {
+// case simple: SimpleBlock =>
+// simple.setBlockBoundsForItemRender(metadata)
+// simple.preItemRender(metadata)
+// case _ => block.setBlockBoundsForItemRender()
+// }
+// renderer.setRenderBoundsFromBlock(block)
+// GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
+// Tessellator.getInstance.startDrawingQuads()
+// renderFaceYNeg(block, metadata, renderer)
+// renderFaceYPos(block, metadata, renderer)
+// renderFaceZNeg(block, metadata, renderer)
+// renderFaceZPos(block, metadata, renderer)
+// renderFaceXNeg(block, metadata, renderer)
+// renderFaceXPos(block, metadata, renderer)
+// Tessellator.getInstance.draw()
+//
+// RenderState.checkError(getClass.getName + ".renderInventoryBlock: standard block")
+// }
+// GL11.glPopMatrix()
+//
+// RenderState.checkError(getClass.getName + ".renderInventoryBlock: leaving")
+// }
+//
+// override def renderWorldBlock(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, modelId: Int, realRenderer: RenderBlocks) = {
+// RenderState.checkError(getClass.getName + ".renderWorldBlock: entering (aka: wasntme)")
+//
+// val renderer = patchedRenderer(realRenderer)
+// world.getTileEntity(x, y, z) match {
+// case cable: tileentity.Cable =>
+// Cable.render(world, x, y, z, block, renderer)
+//
+// RenderState.checkError(getClass.getName + ".renderWorldBlock: cable")
+//
+// true
+// case keyboard: tileentity.Keyboard =>
+// if (keyboard.facing == EnumFacing.UP || keyboard.facing == EnumFacing.DOWN) {
+// keyboard.yaw match {
+// case EnumFacing.NORTH =>
+// renderer.uvRotateTop = 0
+// renderer.uvRotateBottom = 0
+// case EnumFacing.SOUTH =>
+// renderer.uvRotateTop = 3
+// renderer.uvRotateBottom = 3
+// case EnumFacing.WEST =>
+// renderer.uvRotateTop = 2
+// renderer.uvRotateBottom = 1
+// case EnumFacing.EAST =>
+// renderer.uvRotateTop = 1
+// renderer.uvRotateBottom = 2
+// case _ => throw new AssertionError("Impossible yaw value on keyboard.")
+// }
+// if (keyboard.facing == EnumFacing.DOWN) {
+// renderer.flipTexture = true
+// }
+// }
+// val result = renderer.renderStandardBlock(block, x, y, z)
+// renderer.uvRotateTop = 0
+// renderer.uvRotateBottom = 0
+// renderer.flipTexture = false
+//
+// RenderState.checkError(getClass.getName + ".renderWorldBlock: keyboard")
+//
+// result
+// case rack: tileentity.ServerRack =>
+// val previousRenderAllFaces = renderer.renderAllFaces
+// val u1 = 1 / 16f
+// val u2 = 15 / 16f
+// val v1 = 2 / 16f
+// val v2 = 14 / 16f
+// val fs = 3 / 16f
+//
+// // Top and bottom.
+// renderer.renderAllFaces = true
+// renderer.setRenderBounds(0, 0, 0, 1, v1, 1)
+// renderer.renderStandardBlock(block, x, y, z)
+// renderer.setRenderBounds(0, v2, 0, 1, 1, 1)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// // Sides.
+// val front = rack.facing
+// def renderSide(side: EnumFacing, lx: Double, lz: Double, hx: Double, hz: Double) {
+// if (side == front) {
+// for (i <- 0 until 4 if rack.isPresent(i).isDefined) {
+// side match {
+// case EnumFacing.WEST =>
+// renderer.setRenderBounds(lx, v2 - (i + 1) * fs, lz + u1, u2, v2 - i * fs, hz - u1)
+// case EnumFacing.EAST =>
+// renderer.setRenderBounds(u1, v2 - (i + 1) * fs, lz + u1, hx, v2 - i * fs, hz - u1)
+// case EnumFacing.NORTH =>
+// renderer.setRenderBounds(lx + u1, v2 - (i + 1) * fs, lz, hx - u1, v2 - i * fs, u2)
+// case EnumFacing.SOUTH =>
+// renderer.setRenderBounds(lx + u1, v2 - (i + 1) * fs, u1, hx - u1, v2 - i * fs, hz)
+// case _ =>
+// }
+// renderer.renderStandardBlock(block, x, y, z)
+// }
+// }
+// else {
+// val isBack = front == side.getOpposite
+// if (isBack) {
+// renderer.setOverrideBlockTexture(Textures.ServerRack.icons(EnumFacing.NORTH.ordinal))
+// }
+// renderer.setRenderBounds(lx, v1, lz, hx, v2, hz)
+// renderer.renderStandardBlock(block, x, y, z)
+// renderer.clearOverrideBlockTexture()
+// }
+// }
+//
+// renderSide(EnumFacing.WEST, 0, 0, u1, 1)
+// renderSide(EnumFacing.EAST, u2, 0, 1, 1)
+// renderSide(EnumFacing.NORTH, 0, 0, 1, u1)
+// renderSide(EnumFacing.SOUTH, 0, u2, 1, 1)
+//
+// renderer.renderAllFaces = previousRenderAllFaces
+//
+// RenderState.checkError(getClass.getName + ".renderWorldBlock: rack")
+//
+// true
+// case assembler: tileentity.Assembler =>
+// Assembler.render(assembler.block, assembler.getBlockMetadata, x, y, z, renderer)
+//
+// RenderState.checkError(getClass.getName + ".renderWorldBlock: assembler")
+//
+// true
+// case hologram: tileentity.Hologram =>
+// Hologram.render(hologram.block, hologram.getBlockMetadata, x, y, z, renderer)
+//
+// RenderState.checkError(getClass.getName + ".renderWorldBlock: hologram")
+//
+// true
+// case _ =>
+// val result = renderer.renderStandardBlock(block, x, y, z)
+//
+// RenderState.checkError(getClass.getName + ".renderWorldBlock: standard block")
+//
+// result
+// }
+// }
+//
+// val isOneSevenTwo = Loader.instance.getMinecraftModContainer.getVersion == "1.7.2"
+//
+// def patchedRenderer(renderer: RenderBlocks) = if (isOneSevenTwo) {
+// PatchedRenderBlocks.blockAccess = renderer.blockAccess
+// PatchedRenderBlocks.overrideBlockTexture = renderer.overrideBlockTexture
+// PatchedRenderBlocks.flipTexture = renderer.flipTexture
+// PatchedRenderBlocks.renderAllFaces = renderer.renderAllFaces
+// PatchedRenderBlocks.useInventoryTint = renderer.useInventoryTint
+// PatchedRenderBlocks.renderFromInside = renderer.renderFromInside
+// PatchedRenderBlocks.renderMinX = renderer.renderMinX
+// PatchedRenderBlocks.renderMaxX = renderer.renderMaxX
+// PatchedRenderBlocks.renderMinY = renderer.renderMinY
+// PatchedRenderBlocks.renderMaxY = renderer.renderMaxY
+// PatchedRenderBlocks.renderMinZ = renderer.renderMinZ
+// PatchedRenderBlocks.renderMaxZ = renderer.renderMaxZ
+// PatchedRenderBlocks.lockBlockBounds = renderer.lockBlockBounds
+// PatchedRenderBlocks.partialRenderBounds = renderer.partialRenderBounds
+// PatchedRenderBlocks.uvRotateEast = renderer.uvRotateEast
+// PatchedRenderBlocks.uvRotateWest = renderer.uvRotateWest
+// PatchedRenderBlocks.uvRotateSouth = renderer.uvRotateSouth
+// PatchedRenderBlocks.uvRotateNorth = renderer.uvRotateNorth
+// PatchedRenderBlocks.uvRotateTop = renderer.uvRotateTop
+// PatchedRenderBlocks.uvRotateBottom = renderer.uvRotateBottom
+// PatchedRenderBlocks
+// }
+// else renderer
+//
+// object PatchedRenderBlocks extends RenderBlocks {
+// override def renderFaceXPos(block: Block, x: Double, y: Double, z: Double, texture: IIcon) {
+// flipTexture = !flipTexture
+// super.renderFaceXPos(block, x, y, z, texture)
+// flipTexture = !flipTexture
+// }
+//
+// override def renderFaceZNeg(block: Block, x: Double, y: Double, z: Double, texture: IIcon) {
+// flipTexture = !flipTexture
+// super.renderFaceZNeg(block, x, y, z, texture)
+// flipTexture = !flipTexture
+// }
+// }
+//
+// def renderFaceXPos(block: Block, metadata: Int, renderer: RenderBlocks) {
+// Tessellator.getInstance.setNormal(1, 0, 0)
+// renderer.renderFaceXPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, EnumFacing.EAST.ordinal, metadata))
+// }
+//
+// def renderFaceXNeg(block: Block, metadata: Int, renderer: RenderBlocks) {
+// Tessellator.getInstance.setNormal(-1, 0, 0)
+// renderer.renderFaceXNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, EnumFacing.WEST.ordinal, metadata))
+// }
+//
+// def renderFaceYPos(block: Block, metadata: Int, renderer: RenderBlocks) {
+// Tessellator.getInstance.setNormal(0, 1, 0)
+// renderer.renderFaceYPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, EnumFacing.UP.ordinal, metadata))
+// }
+//
+// def renderFaceYNeg(block: Block, metadata: Int, renderer: RenderBlocks) {
+// Tessellator.getInstance.setNormal(0, -1, 0)
+// renderer.renderFaceYNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, EnumFacing.DOWN.ordinal, metadata))
+// }
+//
+// def renderFaceZPos(block: Block, metadata: Int, renderer: RenderBlocks) {
+// Tessellator.getInstance.setNormal(0, 0, 1)
+// renderer.renderFaceZPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, EnumFacing.SOUTH.ordinal, metadata))
+// }
+//
+// def renderFaceZNeg(block: Block, metadata: Int, renderer: RenderBlocks) {
+// Tessellator.getInstance.setNormal(0, 0, -1)
+// renderer.renderFaceZNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, EnumFacing.NORTH.ordinal, metadata))
+// }
+//}
diff --git a/src/main/scala/li/cil/oc/client/renderer/block/Cable.scala b/src/main/scala/li/cil/oc/client/renderer/block/Cable.scala
index 7e928146f..9e96875ac 100644
--- a/src/main/scala/li/cil/oc/client/renderer/block/Cable.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/block/Cable.scala
@@ -1,127 +1,134 @@
-package li.cil.oc.client.renderer.block
-
-import codechicken.multipart.TileMultipart
-import li.cil.oc.client.Textures
-import li.cil.oc.common
-import li.cil.oc.integration.Mods
-import net.minecraft.block.Block
-import net.minecraft.client.renderer.RenderBlocks
-import net.minecraft.tileentity.TileEntity
-import net.minecraft.util.AxisAlignedBB
-import net.minecraft.world.IBlockAccess
-import net.minecraftforge.common.util.ForgeDirection
-
-object Cable {
- private val baseSize = 4.0 / 16.0 / 2.0
-
- private val plugSize = 6.0 / 16.0 / 2.0 - 10e-5
-
- def render(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, renderer: RenderBlocks) {
- // Center part.
- val bounds = AxisAlignedBB.getBoundingBox(-baseSize, -baseSize, -baseSize, baseSize, baseSize, baseSize)
- bounds.offset(0.5, 0.5, 0.5)
- renderer.setRenderBounds(bounds.minX, bounds.minY, bounds.minZ, bounds.maxX, bounds.maxY, bounds.maxZ)
- renderer.renderStandardBlock(block, x, y, z)
-
- // Connections.
- def renderPart(side: ForgeDirection, size: Double, boundSetter: (AxisAlignedBB, ForgeDirection) => Unit) {
- bounds.setBounds(-size, -size, -size, size, size, size)
- bounds.offset(side.offsetX * 0.25, side.offsetY * 0.25, side.offsetZ * 0.25)
- boundSetter(bounds, side)
- bounds.offset(0.5, 0.5, 0.5)
- renderer.setRenderBounds(bounds.minX, bounds.minY, bounds.minZ, bounds.maxX, bounds.maxY, bounds.maxZ)
- renderer.partialRenderBounds = false
- renderer.renderStandardBlock(block, x, y, z)
- }
-
- val mask = common.block.Cable.neighbors(world, x, y, z)
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
- if ((side.flag & mask) != 0) {
- renderPart(side, baseSize, setConnectedBounds)
- }
- renderer.overrideBlockTexture = Textures.Cable.iconCap
- if ((side.flag & mask) != 0 && !isCable(world, x + side.offsetX, y + side.offsetY, z + side.offsetZ)) {
- utilForTrickingTheRendererIntoUsingUnclampedTextureCoordinates(renderer, 1)
- renderPart(side, plugSize, setPlugBounds)
- utilForTrickingTheRendererIntoUsingUnclampedTextureCoordinates(renderer, 0)
- }
- else if ((side.getOpposite.flag & mask) == mask || mask == 0) {
- renderPart(side, baseSize, setUnconnectedBounds)
- }
- renderer.clearOverrideBlockTexture()
- }
- }
-
- def render(block: Block, metadata: Int, renderer: RenderBlocks) {
- val previousRenderAllFaces = renderer.renderAllFaces
- renderer.renderAllFaces = true
-
- renderer.setRenderBounds(0.375, 3 / 16f, 0.375, 0.625, 13 / 16f, 0.625)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
-
- renderer.overrideBlockTexture = Textures.Cable.iconCap
- renderer.setRenderBounds(0.375, 2 / 16f, 0.375, 0.625, 3 / 16f, 0.625)
- BlockRenderer.renderFaceYNeg(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
- renderer.setRenderBounds(0.375, 13 / 16f, 0.375, 0.625, 14 / 16f, 0.625)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
- renderer.clearOverrideBlockTexture()
-
- renderer.renderAllFaces = previousRenderAllFaces
- }
-
- private def isCable(world: IBlockAccess, x: Int, y: Int, z: Int) = {
- val tileEntity = world.getTileEntity(x, y, z)
- tileEntity.isInstanceOf[common.tileentity.Cable] || (Mods.ForgeMultipart.isAvailable && isCableFMP(tileEntity))
- }
-
- private def isCableFMP(tileEntity: TileEntity) = {
- tileEntity.isInstanceOf[TileMultipart]
- }
-
- private def utilForTrickingTheRendererIntoUsingUnclampedTextureCoordinates(renderer: RenderBlocks, value: Int) {
- renderer.uvRotateBottom = value
- renderer.uvRotateEast = value
- renderer.uvRotateNorth = value
- renderer.uvRotateSouth = value
- renderer.uvRotateTop = value
- renderer.uvRotateWest = value
- }
-
- private def setConnectedBounds(bounds: AxisAlignedBB, side: ForgeDirection) {
- bounds.minX = math.min(bounds.minX, side.offsetX * 0.5)
- bounds.maxX = math.max(bounds.maxX, side.offsetX * 0.5)
- bounds.minY = math.min(bounds.minY, side.offsetY * 0.5)
- bounds.maxY = math.max(bounds.maxY, side.offsetY * 0.5)
- bounds.minZ = math.min(bounds.minZ, side.offsetZ * 0.5)
- bounds.maxZ = math.max(bounds.maxZ, side.offsetZ * 0.5)
- }
-
- private def setPlugBounds(bounds: AxisAlignedBB, side: ForgeDirection) {
- bounds.minX = math.max(math.min(bounds.minX + side.offsetX * 10.0 / 16.0, 7.0 / 16.0), -0.5 - 10e-5)
- bounds.maxX = math.min(math.max(bounds.maxX + side.offsetX * 10.0 / 16.0, -7.0 / 16.0), 0.5 + 10e-5)
- bounds.minY = math.max(math.min(bounds.minY + side.offsetY * 10.0 / 16.0, 7.0 / 16.0), -0.5 - 10e-5)
- bounds.maxY = math.min(math.max(bounds.maxY + side.offsetY * 10.0 / 16.0, -7.0 / 16.0), 0.5 + 10e-5)
- bounds.minZ = math.max(math.min(bounds.minZ + side.offsetZ * 10.0 / 16.0, 7.0 / 16.0), -0.5 - 10e-5)
- bounds.maxZ = math.min(math.max(bounds.maxZ + side.offsetZ * 10.0 / 16.0, -7.0 / 16.0), 0.5 + 10e-5)
- }
-
- private def setUnconnectedBounds(bounds: AxisAlignedBB, side: ForgeDirection) {
- bounds.minX = math.max(bounds.minX, -plugSize)
- bounds.maxX = math.min(bounds.maxX, plugSize)
- bounds.minY = math.max(bounds.minY, -plugSize)
- bounds.maxY = math.min(bounds.maxY, plugSize)
- bounds.minZ = math.max(bounds.minZ, -plugSize)
- bounds.maxZ = math.min(bounds.maxZ, plugSize)
- }
-}
+//package li.cil.oc.client.renderer.block
+//
+///* TODO FMP
+//import codechicken.multipart.TileMultipart
+//*/
+//import li.cil.oc.client.Textures
+//import li.cil.oc.common
+//import li.cil.oc.integration.Mods
+//import net.minecraft.block.Block
+//import net.minecraft.client.renderer.RenderBlocks
+//import net.minecraft.tileentity.TileEntity
+//import net.minecraft.util.AxisAlignedBB
+//import net.minecraft.world.IBlockAccess
+//import net.minecraft.util.EnumFacing
+//
+//object Cable {
+// private val baseSize = 4.0 / 16.0 / 2.0
+//
+// private val plugSize = 6.0 / 16.0 / 2.0 - 10e-5
+//
+// def render(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, renderer: RenderBlocks) {
+// // Center part.
+// val bounds = AxisAlignedBB.fromBounds(-baseSize, -baseSize, -baseSize, baseSize, baseSize, baseSize)
+// bounds.offset(0.5, 0.5, 0.5)
+// renderer.setRenderBounds(bounds.minX, bounds.minY, bounds.minZ, bounds.maxX, bounds.maxY, bounds.maxZ)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// // Connections.
+// def renderPart(side: EnumFacing, size: Double, boundSetter: (AxisAlignedBB, EnumFacing) => AxisAlignedBB) {
+// val baseBounds = AxisAlignedBB.fromBounds(-size, -size, -size, size, size, size).offset(side.getFrontOffsetX * 0.25, side.getFrontOffsetY * 0.25, side.getFrontOffsetZ * 0.25)
+// val realBounds = boundSetter(baseBounds, side).offset(0.5, 0.5, 0.5)
+// renderer.setRenderBounds(realBounds.minX, realBounds.minY, realBounds.minZ, realBounds.maxX, realBounds.maxY, realBounds.maxZ)
+// renderer.partialRenderBounds = false
+// renderer.renderStandardBlock(block, x, y, z)
+// }
+//
+// val mask = common.block.Cable.neighbors(world, x, y, z)
+// for (side <- EnumFacing.values) {
+// if ((side.flag & mask) != 0) {
+// renderPart(side, baseSize, setConnectedBounds)
+// }
+// renderer.overrideBlockTexture = Textures.Cable.iconCap
+// if ((side.flag & mask) != 0 && !isCable(world, x + side.getFrontOffsetX, y + side.getFrontOffsetY, z + side.getFrontOffsetZ)) {
+// utilForTrickingTheRendererIntoUsingUnclampedTextureCoordinates(renderer, 1)
+// renderPart(side, plugSize, setPlugBounds)
+// utilForTrickingTheRendererIntoUsingUnclampedTextureCoordinates(renderer, 0)
+// }
+// else if ((side.getOpposite.flag & mask) == mask || mask == 0) {
+// renderPart(side, baseSize, setUnconnectedBounds)
+// }
+// renderer.clearOverrideBlockTexture()
+// }
+// }
+//
+// def render(block: Block, metadata: Int, renderer: RenderBlocks) {
+// val previousRenderAllFaces = renderer.renderAllFaces
+// renderer.renderAllFaces = true
+//
+// renderer.setRenderBounds(0.375, 3 / 16f, 0.375, 0.625, 13 / 16f, 0.625)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+//
+// renderer.overrideBlockTexture = Textures.Cable.iconCap
+// renderer.setRenderBounds(0.375, 2 / 16f, 0.375, 0.625, 3 / 16f, 0.625)
+// BlockRenderer.renderFaceYNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+// renderer.setRenderBounds(0.375, 13 / 16f, 0.375, 0.625, 14 / 16f, 0.625)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+// renderer.clearOverrideBlockTexture()
+//
+// renderer.renderAllFaces = previousRenderAllFaces
+// }
+//
+// private def isCable(world: IBlockAccess, x: Int, y: Int, z: Int) = {
+// val tileEntity = world.getTileEntity(x, y, z)
+// tileEntity.isInstanceOf[common.tileentity.Cable] || (Mods.ForgeMultipart.isAvailable && isCableFMP(tileEntity))
+// }
+//
+// private def isCableFMP(tileEntity: TileEntity) = false
+// /* TODO FMP
+// tileEntity.isInstanceOf[TileMultipart]
+// */
+//
+// private def utilForTrickingTheRendererIntoUsingUnclampedTextureCoordinates(renderer: RenderBlocks, value: Int) {
+// renderer.uvRotateBottom = value
+// renderer.uvRotateEast = value
+// renderer.uvRotateNorth = value
+// renderer.uvRotateSouth = value
+// renderer.uvRotateTop = value
+// renderer.uvRotateWest = value
+// }
+//
+// private def setConnectedBounds(bounds: AxisAlignedBB, side: EnumFacing) = {
+// AxisAlignedBB.fromBounds(
+// math.min(bounds.minX, side.getFrontOffsetX * 0.5),
+// math.max(bounds.maxX, side.getFrontOffsetX * 0.5),
+// math.min(bounds.minY, side.getFrontOffsetY * 0.5),
+// math.max(bounds.maxY, side.getFrontOffsetY * 0.5),
+// math.min(bounds.minZ, side.getFrontOffsetZ * 0.5),
+// math.max(bounds.maxZ, side.getFrontOffsetZ * 0.5)
+// )
+// }
+//
+// private def setPlugBounds(bounds: AxisAlignedBB, side: EnumFacing) = {
+// AxisAlignedBB.fromBounds(
+// math.max(math.min(bounds.minX + side.getFrontOffsetX * 10.0 / 16.0, 7.0 / 16.0), -0.5 - 10e-5),
+// math.min(math.max(bounds.maxX + side.getFrontOffsetX * 10.0 / 16.0, -7.0 / 16.0), 0.5 + 10e-5),
+// math.max(math.min(bounds.minY + side.getFrontOffsetY * 10.0 / 16.0, 7.0 / 16.0), -0.5 - 10e-5),
+// math.min(math.max(bounds.maxY + side.getFrontOffsetY * 10.0 / 16.0, -7.0 / 16.0), 0.5 + 10e-5),
+// math.max(math.min(bounds.minZ + side.getFrontOffsetZ * 10.0 / 16.0, 7.0 / 16.0), -0.5 - 10e-5),
+// math.min(math.max(bounds.maxZ + side.getFrontOffsetZ * 10.0 / 16.0, -7.0 / 16.0), 0.5 + 10e-5)
+// )
+// }
+//
+// private def setUnconnectedBounds(bounds: AxisAlignedBB, side: EnumFacing) = {
+// AxisAlignedBB.fromBounds(
+// math.max(bounds.minX, -plugSize),
+// math.min(bounds.maxX, plugSize),
+// math.max(bounds.minY, -plugSize),
+// math.min(bounds.maxY, plugSize),
+// math.max(bounds.minZ, -plugSize),
+// math.min(bounds.maxZ, plugSize)
+// )
+// }
+//}
diff --git a/src/main/scala/li/cil/oc/client/renderer/block/Hologram.scala b/src/main/scala/li/cil/oc/client/renderer/block/Hologram.scala
index 310bb9f73..336911386 100644
--- a/src/main/scala/li/cil/oc/client/renderer/block/Hologram.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/block/Hologram.scala
@@ -1,95 +1,95 @@
-package li.cil.oc.client.renderer.block
-
-import net.minecraft.block.Block
-import net.minecraft.client.renderer.RenderBlocks
-
-object Hologram {
- def render(block: Block, metadata: Int, x: Int, y: Int, z: Int, renderer: RenderBlocks) {
- // Center.
- renderer.setRenderBounds(4 / 16f, 0, 4 / 16f, 12 / 16f, 3 / 16f, 12 / 16f)
- renderer.renderStandardBlock(block, x, y, z)
-
- val previousRenderAllFaces = renderer.renderAllFaces
- renderer.renderAllFaces = true
-
- // Walls.
- renderer.setRenderBounds(0, 0, 0, 2 / 16f, 7 / 16f, 1)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.setRenderBounds(14 / 16f, 0, 0, 1, 7 / 16f, 1)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.setRenderBounds(2 / 16f, 0, 0, 14 / 16f, 7 / 16f, 2 / 16f)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.setRenderBounds(2 / 16f, 0, 14 / 16f, 14 / 16f, 7 / 16f, 1)
- renderer.renderStandardBlock(block, x, y, z)
-
- // Inner.
- renderer.setRenderBounds(2 / 16f, 2 / 16f, 2 / 16f, 4 / 16f, 5 / 16f, 14 / 16f)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.setRenderBounds(12 / 16f, 2 / 16f, 2 / 16f, 14 / 16f, 5 / 16f, 14 / 16f)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.setRenderBounds(4 / 16f, 2 / 16f, 2 / 16f, 12 / 16f, 5 / 16f, 4 / 16f)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.setRenderBounds(4 / 16f, 2 / 16f, 12 / 16f, 12 / 16f, 5 / 16f, 14 / 16f)
- renderer.renderStandardBlock(block, x, y, z)
-
- renderer.renderAllFaces = previousRenderAllFaces
- }
-
- def render(block: Block, metadata: Int, renderer: RenderBlocks) {
- val previousRenderAllFaces = renderer.renderAllFaces
- renderer.renderAllFaces = true
-
- // Base and walls.
- renderer.setRenderBounds(4 / 16f, 0, 4 / 16f, 12 / 16f, 3 / 16f, 12 / 16f)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
-
- renderer.setRenderBounds(0, 0, 0, 1, 7 / 16f, 1)
- BlockRenderer.renderFaceYNeg(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
-
- // Layer 1.
- renderer.setRenderBounds(2 / 16f, 3 / 16f, 2 / 16f, 4 / 16f, 5 / 16f, 14 / 16f)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
-
- renderer.setRenderBounds(12 / 16f, 3 / 16f, 2 / 16f, 14 / 16f, 5 / 16f, 14 / 16f)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
-
- renderer.setRenderBounds(4 / 16f, 3 / 16f, 2 / 16f, 12 / 16f, 5 / 16f, 4 / 16f)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
-
- renderer.setRenderBounds(4 / 16f, 3 / 16f, 12 / 16f, 12 / 16f, 5 / 16f, 14 / 16f)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
-
- // Layer 2.
- renderer.setRenderBounds(0, 3 / 16f, 0, 2 / 16f, 7 / 16f, 1)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceXPos(block, metadata, renderer)
-
- renderer.setRenderBounds(14 / 16f, 3 / 16f, 0, 1, 7 / 16f, 1)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceXNeg(block, metadata, renderer)
-
- renderer.setRenderBounds(2 / 16f, 3 / 16f, 0, 14 / 16f, 7 / 16f, 2 / 16f)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceZPos(block, metadata, renderer)
-
- renderer.setRenderBounds(2 / 16f, 3 / 16f, 14 / 16f, 14 / 16f, 7 / 16f, 1)
- BlockRenderer.renderFaceYPos(block, metadata, renderer)
- BlockRenderer.renderFaceZNeg(block, metadata, renderer)
-
- renderer.renderAllFaces = previousRenderAllFaces
- }
-}
+//package li.cil.oc.client.renderer.block
+//
+//import net.minecraft.block.Block
+//import net.minecraft.client.renderer.RenderBlocks
+//
+//object Hologram {
+// def render(block: Block, metadata: Int, x: Int, y: Int, z: Int, renderer: RenderBlocks) {
+// // Center.
+// renderer.setRenderBounds(4 / 16f, 0, 4 / 16f, 12 / 16f, 3 / 16f, 12 / 16f)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// val previousRenderAllFaces = renderer.renderAllFaces
+// renderer.renderAllFaces = true
+//
+// // Walls.
+// renderer.setRenderBounds(0, 0, 0, 2 / 16f, 7 / 16f, 1)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.setRenderBounds(14 / 16f, 0, 0, 1, 7 / 16f, 1)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.setRenderBounds(2 / 16f, 0, 0, 14 / 16f, 7 / 16f, 2 / 16f)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.setRenderBounds(2 / 16f, 0, 14 / 16f, 14 / 16f, 7 / 16f, 1)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// // Inner.
+// renderer.setRenderBounds(2 / 16f, 2 / 16f, 2 / 16f, 4 / 16f, 5 / 16f, 14 / 16f)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.setRenderBounds(12 / 16f, 2 / 16f, 2 / 16f, 14 / 16f, 5 / 16f, 14 / 16f)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.setRenderBounds(4 / 16f, 2 / 16f, 2 / 16f, 12 / 16f, 5 / 16f, 4 / 16f)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.setRenderBounds(4 / 16f, 2 / 16f, 12 / 16f, 12 / 16f, 5 / 16f, 14 / 16f)
+// renderer.renderStandardBlock(block, x, y, z)
+//
+// renderer.renderAllFaces = previousRenderAllFaces
+// }
+//
+// def render(block: Block, metadata: Int, renderer: RenderBlocks) {
+// val previousRenderAllFaces = renderer.renderAllFaces
+// renderer.renderAllFaces = true
+//
+// // Base and walls.
+// renderer.setRenderBounds(4 / 16f, 0, 4 / 16f, 12 / 16f, 3 / 16f, 12 / 16f)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+//
+// renderer.setRenderBounds(0, 0, 0, 1, 7 / 16f, 1)
+// BlockRenderer.renderFaceYNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+//
+// // Layer 1.
+// renderer.setRenderBounds(2 / 16f, 3 / 16f, 2 / 16f, 4 / 16f, 5 / 16f, 14 / 16f)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+//
+// renderer.setRenderBounds(12 / 16f, 3 / 16f, 2 / 16f, 14 / 16f, 5 / 16f, 14 / 16f)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+//
+// renderer.setRenderBounds(4 / 16f, 3 / 16f, 2 / 16f, 12 / 16f, 5 / 16f, 4 / 16f)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+//
+// renderer.setRenderBounds(4 / 16f, 3 / 16f, 12 / 16f, 12 / 16f, 5 / 16f, 14 / 16f)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+//
+// // Layer 2.
+// renderer.setRenderBounds(0, 3 / 16f, 0, 2 / 16f, 7 / 16f, 1)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXPos(block, metadata, renderer)
+//
+// renderer.setRenderBounds(14 / 16f, 3 / 16f, 0, 1, 7 / 16f, 1)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceXNeg(block, metadata, renderer)
+//
+// renderer.setRenderBounds(2 / 16f, 3 / 16f, 0, 14 / 16f, 7 / 16f, 2 / 16f)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZPos(block, metadata, renderer)
+//
+// renderer.setRenderBounds(2 / 16f, 3 / 16f, 14 / 16f, 14 / 16f, 7 / 16f, 1)
+// BlockRenderer.renderFaceYPos(block, metadata, renderer)
+// BlockRenderer.renderFaceZNeg(block, metadata, renderer)
+//
+// renderer.renderAllFaces = previousRenderAllFaces
+// }
+//}
diff --git a/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala
index 854026467..2fa361d03 100644
--- a/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala
@@ -1,10 +1,11 @@
package li.cil.oc.client.renderer.entity
+import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.entity.Render
import net.minecraft.entity.Entity
import org.lwjgl.opengl.GL11
-object DroneRenderer extends Render {
+object DroneRenderer extends Render(Minecraft.getMinecraft.getRenderManager) {
val model = new ModelQuadcopter()
override def doRender(entity: Entity, x: Double, y: Double, z: Double, yaw: Float, dt: Float) {
diff --git a/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala b/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala
index cf43b1653..c1cd175fa 100644
--- a/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala
@@ -61,7 +61,7 @@ final class ModelQuadcopter extends ModelBase {
light3.addBox("flap3", -7, 0, -7, 6, 1, 6)
private val scale = 1 / 16f
- private val up = Vec3.createVectorHelper(0, 1, 0)
+ private val up = new Vec3(0, 1, 0)
private def doRender(drone: Drone, dt: Float) {
if (drone.isRunning) {
@@ -69,7 +69,7 @@ final class ModelQuadcopter extends ModelBase {
GL11.glTranslatef(0, (math.sin(timeJitter + (drone.worldObj.getTotalWorldTime + dt) / 20.0) * (1 / 16f)).toFloat, 0)
}
- val velocity = Vec3.createVectorHelper(drone.motionX, drone.motionY, drone.motionZ)
+ val velocity = new Vec3(drone.motionX, drone.motionY, drone.motionZ)
val direction = velocity.normalize()
if (direction.dotProduct(up) < 0.99) {
// Flying sideways.
diff --git a/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala
index 5e7cf6583..0ef30077e 100644
--- a/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala
@@ -23,7 +23,6 @@ object BufferRenderer {
displayLists = GLAllocation.generateDisplayLists(2)
RenderState.checkError(getClass.getName + ".displayLists: leaving")
- Textures.init(tm)
})
def compileBackground(bufferWidth: Int, bufferHeight: Int, forRobot: Boolean = false) =
@@ -35,7 +34,7 @@ object BufferRenderer {
GL11.glNewList(displayLists, GL11.GL_COMPILE)
- textureManager.get.bindTexture(Textures.guiBorders)
+ textureManager.get.bindTexture(Textures.GUI.Borders)
GL11.glBegin(GL11.GL_QUADS)
diff --git a/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala
index 9dfd28137..155fc3dd1 100644
--- a/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala
@@ -22,8 +22,7 @@ import org.lwjgl.opengl.GL11
import scala.collection.convert.WrapAsScala._
object ItemRenderer extends IItemRenderer {
- val renderItem = new RenderItem()
- renderItem.setRenderManager(RenderManager.instance)
+ val itemRenderer = Minecraft.getMinecraft.getRenderItem
lazy val craftingUpgrade = api.Items.get("craftingUpgrade")
lazy val generatorUpgrade = api.Items.get("generatorUpgrade")
@@ -34,7 +33,7 @@ object ItemRenderer extends IItemRenderer {
lazy val lootDisk = api.Items.get("lootDisk")
lazy val openOS = api.Items.get("openOS")
- def bounds = AxisAlignedBB.getBoundingBox(-0.1, -0.1, -0.1, 0.1, 0.1, 0.1)
+ def bounds = AxisAlignedBB.fromBounds(-0.1, -0.1, -0.1, 0.1, 0.1, 0.1)
def isUpgrade(descriptor: ItemInfo) =
descriptor == craftingUpgrade ||
@@ -71,21 +70,21 @@ object ItemRenderer extends IItemRenderer {
GL11.glTranslatef(0.5f, 0.5f, 0.5f)
if (descriptor == api.Items.get("craftingUpgrade")) {
- tm.bindTexture(Textures.upgradeCrafting)
+ tm.bindTexture(Textures.Model.UpgradeCrafting)
drawSimpleBlock()
RenderState.checkError(getClass.getName + ".renderItem: crafting upgrade")
}
else if (descriptor == api.Items.get("generatorUpgrade")) {
- tm.bindTexture(Textures.upgradeGenerator)
+ tm.bindTexture(Textures.Model.UpgradeGenerator)
drawSimpleBlock(if (Item.dataTag(stack).getInteger("remainingTicks") > 0) 0.5f else 0)
RenderState.checkError(getClass.getName + ".renderItem: generator upgrade")
}
else if (descriptor == api.Items.get("inventoryUpgrade")) {
- tm.bindTexture(Textures.upgradeInventory)
+ tm.bindTexture(Textures.Model.UpgradeInventory)
drawSimpleBlock()
RenderState.checkError(getClass.getName + ".renderItem: inventory upgrade")
@@ -94,9 +93,9 @@ object ItemRenderer extends IItemRenderer {
else if (isFloppy(descriptor)) {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS)
- renderItem.renderItemIntoGUI(null, tm, stack, 0, 0)
+ itemRenderer.renderItemIntoGUI(stack, 0, 0)
val res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight)
- val fontRenderer = renderItem.getFontRendererFromRenderManager
+ val fontRenderer = Minecraft.getMinecraft.fontRendererObj
if (fontRenderer != null && res.getScaleFactor > 1) {
GL11.glPushMatrix()
GL11.glTranslatef(4f + 2f / res.getScaleFactor, 9f + 2f / res.getScaleFactor, 0)
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala
index 1acd25e0b..97cdc86da 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala
@@ -4,13 +4,13 @@ import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity.Assembler
import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import org.lwjgl.opengl.GL11
object AssemblerRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val assembler = tileEntity.asInstanceOf[Assembler]
@@ -24,45 +24,45 @@ object AssemblerRenderer extends TileEntitySpecialRenderer {
GL11.glPushMatrix()
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
- bindTexture(TextureMap.locationBlocksTexture)
- val t = Tessellator.instance
- t.startDrawingQuads()
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+
+ Textures.Block.bind()
+ r.startDrawingQuads()
{
- val icon = Textures.Assembler.iconTopOn
- t.addVertexWithUV(-0.5, 0.55, 0.5, icon.getMinU, icon.getMaxV)
- t.addVertexWithUV(0.5, 0.55, 0.5, icon.getMaxU, icon.getMaxV)
- t.addVertexWithUV(0.5, 0.55, -0.5, icon.getMaxU, icon.getMinV)
- t.addVertexWithUV(-0.5, 0.55, -0.5, icon.getMinU, icon.getMinV)
+ val icon = Textures.Block.getSprite(Textures.Block.AssemblerTopOn)
+ r.addVertexWithUV(-0.5, 0.55, 0.5, icon.getMinU, icon.getMaxV)
+ r.addVertexWithUV(0.5, 0.55, 0.5, icon.getMaxU, icon.getMaxV)
+ r.addVertexWithUV(0.5, 0.55, -0.5, icon.getMaxU, icon.getMinV)
+ r.addVertexWithUV(-0.5, 0.55, -0.5, icon.getMinU, icon.getMinV)
}
- t.draw()
-
val indent = 6 / 16f + 0.005
for (i <- 0 until 4) {
- t.startDrawingQuads()
if (assembler.isAssembling) {
- val icon = Textures.Assembler.iconSideAssembling
- t.addVertexWithUV(indent, 0.5, -indent, icon.getInterpolatedU((0.5 - indent) * 16), icon.getMaxV)
- t.addVertexWithUV(indent, 0.5, indent, icon.getInterpolatedU((0.5 + indent) * 16), icon.getMaxV)
- t.addVertexWithUV(indent, -0.5, indent, icon.getInterpolatedU((0.5 + indent) * 16), icon.getMinV)
- t.addVertexWithUV(indent, -0.5, -indent, icon.getInterpolatedU((0.5 - indent) * 16), icon.getMinV)
+ val icon = Textures.Block.getSprite(Textures.Block.AssemblerSideAssembling)
+ r.addVertexWithUV(indent, 0.5, -indent, icon.getInterpolatedU((0.5 - indent) * 16), icon.getMaxV)
+ r.addVertexWithUV(indent, 0.5, indent, icon.getInterpolatedU((0.5 + indent) * 16), icon.getMaxV)
+ r.addVertexWithUV(indent, -0.5, indent, icon.getInterpolatedU((0.5 + indent) * 16), icon.getMinV)
+ r.addVertexWithUV(indent, -0.5, -indent, icon.getInterpolatedU((0.5 - indent) * 16), icon.getMinV)
}
{
- val icon = Textures.Assembler.iconSideOn
- t.addVertexWithUV(0.5005, 0.5, -0.5, icon.getMinU, icon.getMaxV)
- t.addVertexWithUV(0.5005, 0.5, 0.5, icon.getMaxU, icon.getMaxV)
- t.addVertexWithUV(0.5005, -0.5, 0.5, icon.getMaxU, icon.getMinV)
- t.addVertexWithUV(0.5005, -0.5, -0.5, icon.getMinU, icon.getMinV)
+ val icon = Textures.Block.getSprite(Textures.Block.AssemblerSideOn)
+ r.addVertexWithUV(0.5005, 0.5, -0.5, icon.getMinU, icon.getMaxV)
+ r.addVertexWithUV(0.5005, 0.5, 0.5, icon.getMaxU, icon.getMaxV)
+ r.addVertexWithUV(0.5005, -0.5, 0.5, icon.getMaxU, icon.getMinV)
+ r.addVertexWithUV(0.5005, -0.5, -0.5, icon.getMinU, icon.getMinV)
}
- t.draw()
-
GL11.glRotatef(90, 0, 1, 0)
}
+ t.draw()
+ Textures.Block.unbind()
+
GL11.glPopMatrix()
GL11.glPopAttrib()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala
index e676e492d..e76f4701e 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala
@@ -6,11 +6,11 @@ import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
object CaseRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z : Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val computer = tileEntity.asInstanceOf[Case]
@@ -25,9 +25,9 @@ object CaseRenderer extends TileEntitySpecialRenderer {
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
computer.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
@@ -35,25 +35,30 @@ object CaseRenderer extends TileEntitySpecialRenderer {
GL11.glScalef(1, -1, 1)
if (computer.isRunning) {
- bindTexture(Textures.blockCaseFrontOn)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, 1, 0, 0, 1)
- t.addVertexWithUV(1, 1, 0, 1, 1)
- t.addVertexWithUV(1, 0, 0, 1, 0)
- t.addVertexWithUV(0, 0, 0, 0, 0)
- t.draw()
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+
+ Textures.Block.bind()
+ r.startDrawingQuads()
+
+ {
+ val power = Textures.Block.getSprite(Textures.Block.CaseFrontOn)
+ r.addVertexWithUV(0, 1, 0, power.getMinU, power.getMaxV)
+ r.addVertexWithUV(1, 1, 0, power.getMaxU, power.getMaxV)
+ r.addVertexWithUV(1, 0, 0, power.getMaxU, power.getMinV)
+ r.addVertexWithUV(0, 0, 0, power.getMinU, power.getMinV)
+ }
if (System.currentTimeMillis() - computer.lastAccess < 400 && computer.world.rand.nextDouble() > 0.1) {
- bindTexture(Textures.blockCaseFrontActivity)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, 1, 0, 0, 1)
- t.addVertexWithUV(1, 1, 0, 1, 1)
- t.addVertexWithUV(1, 0, 0, 1, 0)
- t.addVertexWithUV(0, 0, 0, 0, 0)
- t.draw()
+ val activity = Textures.Block.getSprite(Textures.Block.CaseFrontActivity)
+ r.addVertexWithUV(0, 1, 0, activity.getMinU, activity.getMaxV)
+ r.addVertexWithUV(1, 1, 0, activity.getMaxU, activity.getMaxV)
+ r.addVertexWithUV(1, 0, 0, activity.getMaxU, activity.getMinV)
+ r.addVertexWithUV(0, 0, 0, activity.getMinU, activity.getMinV)
}
+
+ t.draw()
+ Textures.Block.unbind()
}
GL11.glPopMatrix()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala
index a7de7265a..5c00236d9 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala
@@ -4,14 +4,13 @@ import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity.Charger
import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
object ChargerRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val charger = tileEntity.asInstanceOf[Charger]
@@ -27,46 +26,52 @@ object ChargerRenderer extends TileEntitySpecialRenderer {
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
charger.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
GL11.glTranslatef(-0.5f, 0.5f, 0.5f)
GL11.glScalef(1, -1, 1)
- val t = Tessellator.instance
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
- val frontIcon = Textures.Charger.iconFrontCharging
- bindTexture(TextureMap.locationBlocksTexture)
- t.startDrawingQuads()
+ Textures.Block.bind()
+ r.startDrawingQuads()
- val inverse = 1 - charger.chargeSpeed
- t.addVertexWithUV(0, 1, 0.005, frontIcon.getMinU, frontIcon.getMaxV)
- t.addVertexWithUV(1, 1, 0.005, frontIcon.getMaxU, frontIcon.getMaxV)
- t.addVertexWithUV(1, inverse, 0.005, frontIcon.getMaxU, frontIcon.getInterpolatedV(inverse * 16))
- t.addVertexWithUV(0, inverse, 0.005, frontIcon.getMinU, frontIcon.getInterpolatedV(inverse * 16))
+ {
+ val inverse = 1 - charger.chargeSpeed
+ val frontIcon = Textures.Block.getSprite(Textures.Block.ChargerFrontOn)
+ r.addVertexWithUV(0, 1, 0.005, frontIcon.getMinU, frontIcon.getMaxV)
+ r.addVertexWithUV(1, 1, 0.005, frontIcon.getMaxU, frontIcon.getMaxV)
+ r.addVertexWithUV(1, inverse, 0.005, frontIcon.getMaxU, frontIcon.getInterpolatedV(inverse * 16))
+ r.addVertexWithUV(0, inverse, 0.005, frontIcon.getMinU, frontIcon.getInterpolatedV(inverse * 16))
+ }
if (charger.hasPower) {
- val sideIcon = Textures.Charger.iconSideCharging
- t.addVertexWithUV(-0.005, 1, -1, sideIcon.getMinU, sideIcon.getMaxV)
- t.addVertexWithUV(-0.005, 1, 0, sideIcon.getMaxU, sideIcon.getMaxV)
- t.addVertexWithUV(-0.005, 0, 0, sideIcon.getMaxU, sideIcon.getMinV)
- t.addVertexWithUV(-0.005, 0, -1, sideIcon.getMinU, sideIcon.getMinV)
+ val sideIcon = Textures.Block.getSprite(Textures.Block.ChargerSideOn)
+ r.startDrawingQuads()
- t.addVertexWithUV(1, 1, -1.005, sideIcon.getMinU, sideIcon.getMaxV)
- t.addVertexWithUV(0, 1, -1.005, sideIcon.getMaxU, sideIcon.getMaxV)
- t.addVertexWithUV(0, 0, -1.005, sideIcon.getMaxU, sideIcon.getMinV)
- t.addVertexWithUV(1, 0, -1.005, sideIcon.getMinU, sideIcon.getMinV)
+ r.addVertexWithUV(-0.005, 1, -1, sideIcon.getMinU, sideIcon.getMaxV)
+ r.addVertexWithUV(-0.005, 1, 0, sideIcon.getMaxU, sideIcon.getMaxV)
+ r.addVertexWithUV(-0.005, 0, 0, sideIcon.getMaxU, sideIcon.getMinV)
+ r.addVertexWithUV(-0.005, 0, -1, sideIcon.getMinU, sideIcon.getMinV)
- t.addVertexWithUV(1.005, 1, 0, sideIcon.getMinU, sideIcon.getMaxV)
- t.addVertexWithUV(1.005, 1, -1, sideIcon.getMaxU, sideIcon.getMaxV)
- t.addVertexWithUV(1.005, 0, -1, sideIcon.getMaxU, sideIcon.getMinV)
- t.addVertexWithUV(1.005, 0, 0, sideIcon.getMinU, sideIcon.getMinV)
+ r.addVertexWithUV(1, 1, -1.005, sideIcon.getMinU, sideIcon.getMaxV)
+ r.addVertexWithUV(0, 1, -1.005, sideIcon.getMaxU, sideIcon.getMaxV)
+ r.addVertexWithUV(0, 0, -1.005, sideIcon.getMaxU, sideIcon.getMinV)
+ r.addVertexWithUV(1, 0, -1.005, sideIcon.getMinU, sideIcon.getMinV)
+
+ r.addVertexWithUV(1.005, 1, 0, sideIcon.getMinU, sideIcon.getMaxV)
+ r.addVertexWithUV(1.005, 1, -1, sideIcon.getMaxU, sideIcon.getMaxV)
+ r.addVertexWithUV(1.005, 0, -1, sideIcon.getMaxU, sideIcon.getMinV)
+ r.addVertexWithUV(1.005, 0, 0, sideIcon.getMinU, sideIcon.getMinV)
}
t.draw()
+ Textures.Block.unbind()
GL11.glPopMatrix()
GL11.glPopAttrib()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala
index 325fd37f8..eaeb9a50c 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala
@@ -4,13 +4,12 @@ import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity
import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import org.lwjgl.opengl.GL11
object DisassemblerRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val disassembler = tileEntity.asInstanceOf[tileentity.Disassembler]
@@ -26,38 +25,42 @@ object DisassemblerRenderer extends TileEntitySpecialRenderer {
GL11.glScaled(1.0025, -1.0025, 1.0025)
GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- bindTexture(TextureMap.locationBlocksTexture)
- val t = Tessellator.instance
- t.startDrawingQuads()
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ Textures.Block.bind()
+ r.startDrawingQuads()
- val topOn = Textures.Disassembler.iconTopOn
- t.addVertexWithUV(0, 0, 1, topOn.getMinU, topOn.getMaxV)
- t.addVertexWithUV(1, 0, 1, topOn.getMaxU, topOn.getMaxV)
- t.addVertexWithUV(1, 0, 0, topOn.getMaxU, topOn.getMinV)
- t.addVertexWithUV(0, 0, 0, topOn.getMinU, topOn.getMinV)
+ {
+ val topOn = Textures.Block.getSprite(Textures.Block.DisassemblerTopOn)
+ r.addVertexWithUV(0, 0, 1, topOn.getMinU, topOn.getMaxV)
+ r.addVertexWithUV(1, 0, 1, topOn.getMaxU, topOn.getMaxV)
+ r.addVertexWithUV(1, 0, 0, topOn.getMaxU, topOn.getMinV)
+ r.addVertexWithUV(0, 0, 0, topOn.getMinU, topOn.getMinV)
+ }
- val sideOn = Textures.Disassembler.iconSideOn
- t.addVertexWithUV(1, 1, 0, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(0, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(0, 0, 0, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(1, 0, 0, sideOn.getMinU, sideOn.getMinV)
+ val sideOn = Textures.Block.getSprite(Textures.Block.DisassemblerSideOn)
+ r.addVertexWithUV(1, 1, 0, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 0, 0, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(1, 0, 0, sideOn.getMinU, sideOn.getMinV)
- t.addVertexWithUV(0, 1, 1, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(1, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(1, 0, 1, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(0, 0, 1, sideOn.getMinU, sideOn.getMinV)
+ r.addVertexWithUV(0, 1, 1, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 0, 1, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(0, 0, 1, sideOn.getMinU, sideOn.getMinV)
- t.addVertexWithUV(1, 1, 1, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(1, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(1, 0, 0, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(1, 0, 1, sideOn.getMinU, sideOn.getMinV)
+ r.addVertexWithUV(1, 1, 1, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 0, 0, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(1, 0, 1, sideOn.getMinU, sideOn.getMinV)
- t.addVertexWithUV(0, 1, 0, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(0, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(0, 0, 1, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(0, 0, 0, sideOn.getMinU, sideOn.getMinV)
+ r.addVertexWithUV(0, 1, 0, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 0, 1, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(0, 0, 0, sideOn.getMinU, sideOn.getMinV)
t.draw()
+ Textures.Block.unbind()
GL11.glPopMatrix()
GL11.glPopAttrib()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala
index 7c048fa39..200109a48 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala
@@ -3,18 +3,17 @@ package li.cil.oc.client.renderer.tileentity
import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity.DiskDrive
import li.cil.oc.util.RenderState
+import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.OpenGlHelper
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.entity.RenderItem
-import net.minecraft.client.renderer.entity.RenderManager
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.entity.item.EntityItem
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
object DiskDriveRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z : Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val drive = tileEntity.asInstanceOf[DiskDrive]
@@ -25,9 +24,9 @@ object DiskDriveRenderer extends TileEntitySpecialRenderer {
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
drive.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
@@ -37,15 +36,14 @@ object DiskDriveRenderer extends TileEntitySpecialRenderer {
GL11.glTranslatef(0, 3.5f / 16, 9 / 16f)
GL11.glRotatef(90, -1, 0, 0)
- val brightness = drive.world.getLightBrightnessForSkyBlocks(drive.x + drive.facing.offsetX, drive.y + drive.facing.offsetY, drive.z + drive.facing.offsetZ, 0)
+ val brightness = drive.world.getCombinedLight(drive.getPos.offset(drive.facing), 0)
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightness % 65536, brightness / 65536)
// This is very 'meh', but item frames do it like this, too!
val entity = new EntityItem(drive.world, 0, 0, 0, stack)
entity.hoverStart = 0
- RenderItem.renderInFrame = true
- RenderManager.instance.renderEntityWithPosYaw(entity, 0, 0, 0, 0, 0)
- RenderItem.renderInFrame = false
+ val rm = Minecraft.getMinecraft.getRenderManager
+ rm.renderEntityWithPosYaw(entity, 0, 0, 0, 0, 0)
GL11.glPopMatrix()
case _ =>
}
@@ -58,14 +56,20 @@ object DiskDriveRenderer extends TileEntitySpecialRenderer {
RenderState.makeItBlend()
RenderState.setBlendAlpha(1)
- bindTexture(Textures.blockDiskDriveFrontActivity)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, 1, 0, 0, 1)
- t.addVertexWithUV(1, 1, 0, 1, 1)
- t.addVertexWithUV(1, 0, 0, 1, 0)
- t.addVertexWithUV(0, 0, 0, 0, 0)
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+
+ Textures.Block.bind()
+ r.startDrawingQuads()
+
+ val activity = Textures.Block.getSprite(Textures.Block.DiskDriveFrontActivity)
+ r.addVertexWithUV(0, 1, 0, activity.getMinU, activity.getMaxV)
+ r.addVertexWithUV(1, 1, 0, activity.getMaxU, activity.getMaxV)
+ r.addVertexWithUV(1, 0, 0, activity.getMaxU, activity.getMinV)
+ r.addVertexWithUV(0, 0, 0, activity.getMinU, activity.getMinV)
+
t.draw()
+ Textures.Block.unbind()
}
GL11.glPopMatrix()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala
index e11c7e3f5..6035097d9 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala
@@ -2,17 +2,18 @@ package li.cil.oc.client.renderer.tileentity
import li.cil.oc.client.Textures
import li.cil.oc.util.RenderState
+import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import org.lwjgl.opengl.GL11
object GeolyzerRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS)
+ GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS)
RenderState.disableLighting()
RenderState.makeItBlend()
@@ -24,20 +25,24 @@ object GeolyzerRenderer extends TileEntitySpecialRenderer {
GL11.glScaled(1.0025, -1.0025, 1.0025)
GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- bindTexture(TextureMap.locationBlocksTexture)
- val t = Tessellator.instance
- t.startDrawingQuads()
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
- val topOn = Textures.Geolyzer.iconTopOn
- t.addVertexWithUV(0, 0, 1, topOn.getMinU, topOn.getMaxV)
- t.addVertexWithUV(1, 0, 1, topOn.getMaxU, topOn.getMaxV)
- t.addVertexWithUV(1, 0, 0, topOn.getMaxU, topOn.getMinV)
- t.addVertexWithUV(0, 0, 0, topOn.getMinU, topOn.getMinV)
+ Textures.Block.bind()
+ r.startDrawingQuads()
+
+ val topOn = Textures.Block.getSprite(Textures.Block.GeolyzerTopOn)
+ r.addVertexWithUV(0, 0, 1, topOn.getMinU, topOn.getMaxV)
+ r.addVertexWithUV(1, 0, 1, topOn.getMaxU, topOn.getMaxV)
+ r.addVertexWithUV(1, 0, 0, topOn.getMaxU, topOn.getMinV)
+ r.addVertexWithUV(0, 0, 0, topOn.getMinU, topOn.getMinV)
t.draw()
+ Textures.Block.unbind()
GL11.glPopMatrix()
GL11.glPopAttrib()
+ GL11.glPopClientAttrib()
RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving")
}
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala
index 989dc8a97..022cbd73b 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala
@@ -7,15 +7,15 @@ import java.util.concurrent.TimeUnit
import com.google.common.cache.CacheBuilder
import com.google.common.cache.RemovalListener
import com.google.common.cache.RemovalNotification
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import li.cil.oc.Settings
import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity.Hologram
import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.BufferUtils
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL15
@@ -57,10 +57,10 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit
/** Used to pass the current screen along to call(). */
private var hologram: Hologram = null
- override def renderTileEntityAt(te: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z : Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
- hologram = te.asInstanceOf[Hologram]
+ hologram = tileEntity.asInstanceOf[Hologram]
if (!hologram.hasPower) return
GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS)
@@ -77,14 +77,14 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
hologram.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
hologram.pitch match {
- case ForgeDirection.DOWN => GL11.glRotatef(90, 1, 0, 0)
- case ForgeDirection.UP => GL11.glRotatef(-90, 1, 0, 0)
+ case EnumFacing.DOWN => GL11.glRotatef(90, 1, 0, 0)
+ case EnumFacing.UP => GL11.glRotatef(-90, 1, 0, 0)
case _ => // No pitch.
}
@@ -103,7 +103,7 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit
// After the below scaling, hologram is drawn inside a [0..48]x[0..32]x[0..48] box
GL11.glScaled(hologram.scale / 16f, hologram.scale / 16f, hologram.scale / 16f)
- bindTexture(Textures.blockHologram)
+ bindTexture(Textures.Model.HologramEffect)
// Normalize normals (yes, glScale scales them too).
GL11.glEnable(GL11.GL_NORMALIZE)
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRendererFallback.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRendererFallback.scala
index 794ea08ca..ad85c5358 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRendererFallback.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRendererFallback.scala
@@ -9,10 +9,10 @@ import org.lwjgl.opengl.GL11
object HologramRendererFallback extends TileEntitySpecialRenderer {
val text = "Requires OpenGL 1.5"
- override def renderTileEntityAt(te: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z : Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
- val fontRenderer = Minecraft.getMinecraft.fontRenderer
+ val fontRenderer = Minecraft.getMinecraft.fontRendererObj
GL11.glPushMatrix()
GL11.glTranslated(x + 0.5, y + 0.75, z + 0.5)
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala
index 2323f8ac3..120c0e9dc 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala
@@ -6,11 +6,11 @@ import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
object MicrocontrollerRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z : Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val mcu = tileEntity.asInstanceOf[Microcontroller]
@@ -25,35 +25,41 @@ object MicrocontrollerRenderer extends TileEntitySpecialRenderer {
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
mcu.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
GL11.glTranslated(-0.5, 0.5, 0.505)
GL11.glScalef(1, -1, 1)
- bindTexture(Textures.blockMicrocontrollerFrontLight)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, 1, 0, 0, 1)
- t.addVertexWithUV(1, 1, 0, 1, 1)
- t.addVertexWithUV(1, 0, 0, 1, 0)
- t.addVertexWithUV(0, 0, 0, 0, 0)
- t.draw()
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+
+ Textures.Block.bind()
+ r.startDrawingQuads()
+
+ {
+ val icon = Textures.Block.getSprite(Textures.Block.MicrocontrollerFrontLight)
+ r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
+ r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
+ r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
+ r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
+ }
if (mcu.isRunning) {
- bindTexture(Textures.blockMicrocontrollerFrontOn)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, 1, 0, 0, 1)
- t.addVertexWithUV(1, 1, 0, 1, 1)
- t.addVertexWithUV(1, 0, 0, 1, 0)
- t.addVertexWithUV(0, 0, 0, 0, 0)
- t.draw()
+ val icon = Textures.Block.getSprite(Textures.Block.MicrocontrollerFrontOn)
+ r.startDrawingQuads()
+ r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
+ r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
+ r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
+ r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
}
+ t.draw()
+ Textures.Block.unbind()
+
GL11.glPopMatrix()
GL11.glPopAttrib()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala
index 0471a727e..cfcfa01de 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala
@@ -4,13 +4,12 @@ import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity
import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import org.lwjgl.opengl.GL11
object PowerDistributorRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val distributor = tileEntity.asInstanceOf[tileentity.PowerDistributor]
@@ -27,38 +26,42 @@ object PowerDistributorRenderer extends TileEntitySpecialRenderer {
GL11.glScaled(1.0025, -1.0025, 1.0025)
GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- bindTexture(TextureMap.locationBlocksTexture)
- val t = Tessellator.instance
- t.startDrawingQuads()
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
- val topOn = Textures.PowerDistributor.iconTopOn
- t.addVertexWithUV(0, 0, 1, topOn.getMinU, topOn.getMaxV)
- t.addVertexWithUV(1, 0, 1, topOn.getMaxU, topOn.getMaxV)
- t.addVertexWithUV(1, 0, 0, topOn.getMaxU, topOn.getMinV)
- t.addVertexWithUV(0, 0, 0, topOn.getMinU, topOn.getMinV)
+ Textures.Block.bind()
+ r.startDrawingQuads()
- val sideOn = Textures.PowerDistributor.iconSideOn
- t.addVertexWithUV(1, 1, 0, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(0, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(0, 0, 0, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(1, 0, 0, sideOn.getMinU, sideOn.getMinV)
+ val topOn = Textures.Block.getSprite(Textures.Block.PowerDistributorTopOn)
+ r.addVertexWithUV(0, 0, 1, topOn.getMinU, topOn.getMaxV)
+ r.addVertexWithUV(1, 0, 1, topOn.getMaxU, topOn.getMaxV)
+ r.addVertexWithUV(1, 0, 0, topOn.getMaxU, topOn.getMinV)
+ r.addVertexWithUV(0, 0, 0, topOn.getMinU, topOn.getMinV)
- t.addVertexWithUV(0, 1, 1, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(1, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(1, 0, 1, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(0, 0, 1, sideOn.getMinU, sideOn.getMinV)
+ val sideOn = Textures.Block.getSprite(Textures.Block.PowerDistributorSideOn)
+ r.startDrawingQuads()
+ r.addVertexWithUV(1, 1, 0, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 0, 0, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(1, 0, 0, sideOn.getMinU, sideOn.getMinV)
- t.addVertexWithUV(1, 1, 1, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(1, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(1, 0, 0, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(1, 0, 1, sideOn.getMinU, sideOn.getMinV)
+ r.addVertexWithUV(0, 1, 1, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 0, 1, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(0, 0, 1, sideOn.getMinU, sideOn.getMinV)
- t.addVertexWithUV(0, 1, 0, sideOn.getMinU, sideOn.getMaxV)
- t.addVertexWithUV(0, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
- t.addVertexWithUV(0, 0, 1, sideOn.getMaxU, sideOn.getMinV)
- t.addVertexWithUV(0, 0, 0, sideOn.getMinU, sideOn.getMinV)
+ r.addVertexWithUV(1, 1, 1, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(1, 0, 0, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(1, 0, 1, sideOn.getMinU, sideOn.getMinV)
+
+ r.addVertexWithUV(0, 1, 0, sideOn.getMinU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
+ r.addVertexWithUV(0, 0, 1, sideOn.getMaxU, sideOn.getMinV)
+ r.addVertexWithUV(0, 0, 0, sideOn.getMinU, sideOn.getMinV)
t.draw()
+ Textures.Block.unbind()
GL11.glPopMatrix()
GL11.glPopAttrib()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala
index 5d5f9cac1..855601f82 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala
@@ -4,13 +4,15 @@ import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity.Raid
import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
+import net.minecraft.client.renderer.WorldRenderer
+import net.minecraft.client.renderer.texture.TextureAtlasSprite
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
object RaidRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) = {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val raid = tileEntity.asInstanceOf[Raid]
@@ -24,27 +26,33 @@ object RaidRenderer extends TileEntitySpecialRenderer {
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
raid.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
GL11.glTranslated(-0.5, 0.5, 0.505)
GL11.glScalef(1, -1, 1)
- for (slot <- 0 until raid.getSizeInventory) {
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ Textures.Block.bind()
+ r.startDrawingQuads()
+
+ for (slot <- 0 until raid.getSizeInventory) {
if (!raid.presence(slot)) {
- bindTexture(Textures.blockRaidFrontError)
- renderSlot(slot)
+ renderSlot(r, slot, Textures.Block.getSprite(Textures.Block.RaidFrontError))
}
else if (System.currentTimeMillis() - raid.lastAccess < 400 && raid.world.rand.nextDouble() > 0.1 && slot == raid.lastAccess % raid.getSizeInventory) {
- bindTexture(Textures.blockRaidFrontActivity)
- renderSlot(slot)
+ renderSlot(r, slot, Textures.Block.getSprite(Textures.Block.RaidFrontActivity))
}
}
+ t.draw()
+ Textures.Block.unbind()
+
GL11.glPopMatrix()
GL11.glPopAttrib()
@@ -54,15 +62,12 @@ object RaidRenderer extends TileEntitySpecialRenderer {
private val u1 = 2 / 16f
private val fs = 4 / 16f
- private def renderSlot(slot: Int) {
+ private def renderSlot(r: WorldRenderer, slot: Int, icon: TextureAtlasSprite) {
val l = u1 + slot * fs
val h = u1 + (slot + 1) * fs
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(l, 1, 0, l, 1)
- t.addVertexWithUV(h, 1, 0, h, 1)
- t.addVertexWithUV(h, 0, 0, h, 0)
- t.addVertexWithUV(l, 0, 0, l, 0)
- t.draw()
+ r.addVertexWithUV(l, 1, 0, icon.getInterpolatedU(l), icon.getMaxV)
+ r.addVertexWithUV(h, 1, 0, icon.getInterpolatedU(h), icon.getMaxV)
+ r.addVertexWithUV(h, 0, 0, icon.getInterpolatedU(h), icon.getMinV)
+ r.addVertexWithUV(l, 0, 0, icon.getInterpolatedU(l), icon.getMinV)
}
}
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala
index b5fa59b9e..df54f17e1 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala
@@ -7,24 +7,18 @@ import li.cil.oc.api.event.RobotRenderEvent
import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity
import li.cil.oc.util.RenderState
-import net.minecraft.block.Block
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GLAllocation
-import net.minecraft.client.renderer.RenderBlocks
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.entity.RenderManager
+import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType
import net.minecraft.client.renderer.entity.RendererLivingEntity
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
-import net.minecraft.init.Items
-import net.minecraft.item.ItemBlock
import net.minecraft.tileentity.TileEntity
+import net.minecraft.util.EnumFacing
import net.minecraft.util.Vec3
import net.minecraftforge.client.IItemRenderer.ItemRenderType
-import net.minecraftforge.client.IItemRenderer.ItemRenderType._
-import net.minecraftforge.client.IItemRenderer.ItemRendererHelper._
import net.minecraftforge.client.MinecraftForgeClient
import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL12
@@ -43,7 +37,8 @@ object RobotRenderer extends TileEntitySpecialRenderer {
}
def compileList() {
- val t = Tessellator.instance
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
val size = 0.4f
val l = 0.5f - size
@@ -56,26 +51,26 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glVertex3f(0.5f, 1, 0.5f)
GL11.glTexCoord2f(0, 0.5f)
GL11.glVertex3f(l, gt, h)
- normal(Vec3.createVectorHelper(0, 0.2, 1))
+ normal(new Vec3(0, 0.2, 1))
GL11.glTexCoord2f(0.5f, 0.5f)
GL11.glVertex3f(h, gt, h)
- normal(Vec3.createVectorHelper(1, 0.2, 0))
+ normal(new Vec3(1, 0.2, 0))
GL11.glTexCoord2f(0.5f, 0)
GL11.glVertex3f(h, gt, l)
- normal(Vec3.createVectorHelper(0, 0.2, -1))
+ normal(new Vec3(0, 0.2, -1))
GL11.glTexCoord2f(0, 0)
GL11.glVertex3f(l, gt, l)
- normal(Vec3.createVectorHelper(-1, 0.2, 0))
+ normal(new Vec3(-1, 0.2, 0))
GL11.glTexCoord2f(0, 0.5f)
GL11.glVertex3f(l, gt, h)
GL11.glEnd()
- t.startDrawingQuads()
- t.setNormal(0, -1, 0)
- t.addVertexWithUV(l, gt, h, 0, 1)
- t.addVertexWithUV(l, gt, l, 0, 0.5)
- t.addVertexWithUV(h, gt, l, 0.5, 0.5)
- t.addVertexWithUV(h, gt, h, 0.5, 1)
+ r.startDrawingQuads()
+ r.setNormal(0, -1, 0)
+ r.addVertexWithUV(l, gt, h, 0, 1)
+ r.addVertexWithUV(l, gt, l, 0, 0.5)
+ r.addVertexWithUV(h, gt, l, 0.5, 0.5)
+ r.addVertexWithUV(h, gt, h, 0.5, 1)
t.draw()
GL11.glEndList()
@@ -87,26 +82,26 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glVertex3f(0.5f, 0.03f, 0.5f)
GL11.glTexCoord2f(0.5f, 0)
GL11.glVertex3f(l, gb, l)
- normal(Vec3.createVectorHelper(0, -0.2, 1))
+ normal(new Vec3(0, -0.2, 1))
GL11.glTexCoord2f(1, 0)
GL11.glVertex3f(h, gb, l)
- normal(Vec3.createVectorHelper(1, -0.2, 0))
+ normal(new Vec3(1, -0.2, 0))
GL11.glTexCoord2f(1, 0.5f)
GL11.glVertex3f(h, gb, h)
- normal(Vec3.createVectorHelper(0, -0.2, -1))
+ normal(new Vec3(0, -0.2, -1))
GL11.glTexCoord2f(0.5f, 0.5f)
GL11.glVertex3f(l, gb, h)
- normal(Vec3.createVectorHelper(-1, -0.2, 0))
+ normal(new Vec3(-1, -0.2, 0))
GL11.glTexCoord2f(0.5f, 0)
GL11.glVertex3f(l, gb, l)
GL11.glEnd()
- t.startDrawingQuads()
- t.setNormal(0, 1, 0)
- t.addVertexWithUV(l, gb, l, 0, 0.5)
- t.addVertexWithUV(l, gb, h, 0, 1)
- t.addVertexWithUV(h, gb, h, 0.5, 1)
- t.addVertexWithUV(h, gb, l, 0.5, 0.5)
+ r.startDrawingQuads()
+ r.setNormal(0, 1, 0)
+ r.addVertexWithUV(l, gb, l, 0, 0.5)
+ r.addVertexWithUV(l, gb, h, 0, 1)
+ r.addVertexWithUV(h, gb, h, 0.5, 1)
+ r.addVertexWithUV(h, gb, l, 0.5, 0.5)
t.draw()
GL11.glEndList()
@@ -198,7 +193,7 @@ object RobotRenderer extends TileEntitySpecialRenderer {
val event = new RobotRenderEvent(robot, mountPoints)
MinecraftForge.EVENT_BUS.post(event)
if (!event.isCanceled) {
- bindTexture(Textures.blockRobot)
+ bindTexture(Textures.Model.Robot)
if (!isRunning) {
GL11.glTranslatef(0, -2 * gap, 0)
}
@@ -214,27 +209,28 @@ object RobotRenderer extends TileEntitySpecialRenderer {
RenderState.disableLighting()
}
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(l, gt, l, u0, v0)
- t.addVertexWithUV(l, gb, l, u0, v1)
- t.addVertexWithUV(l, gb, h, u1, v1)
- t.addVertexWithUV(l, gt, h, u1, v0)
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ r.startDrawingQuads()
+ r.addVertexWithUV(l, gt, l, u0, v0)
+ r.addVertexWithUV(l, gb, l, u0, v1)
+ r.addVertexWithUV(l, gb, h, u1, v1)
+ r.addVertexWithUV(l, gt, h, u1, v0)
- t.addVertexWithUV(l, gt, h, u0, v0)
- t.addVertexWithUV(l, gb, h, u0, v1)
- t.addVertexWithUV(h, gb, h, u1, v1)
- t.addVertexWithUV(h, gt, h, u1, v0)
+ r.addVertexWithUV(l, gt, h, u0, v0)
+ r.addVertexWithUV(l, gb, h, u0, v1)
+ r.addVertexWithUV(h, gb, h, u1, v1)
+ r.addVertexWithUV(h, gt, h, u1, v0)
- t.addVertexWithUV(h, gt, h, u0, v0)
- t.addVertexWithUV(h, gb, h, u0, v1)
- t.addVertexWithUV(h, gb, l, u1, v1)
- t.addVertexWithUV(h, gt, l, u1, v0)
+ r.addVertexWithUV(h, gt, h, u0, v0)
+ r.addVertexWithUV(h, gb, h, u0, v1)
+ r.addVertexWithUV(h, gb, l, u1, v1)
+ r.addVertexWithUV(h, gt, l, u1, v0)
- t.addVertexWithUV(h, gt, l, u0, v0)
- t.addVertexWithUV(h, gb, l, u0, v1)
- t.addVertexWithUV(l, gb, l, u1, v1)
- t.addVertexWithUV(l, gt, l, u1, v0)
+ r.addVertexWithUV(h, gt, l, u0, v0)
+ r.addVertexWithUV(h, gb, l, u0, v1)
+ r.addVertexWithUV(l, gb, l, u1, v1)
+ r.addVertexWithUV(l, gt, l, u1, v0)
t.draw()
if (MinecraftForgeClient.getRenderPass == 0) {
@@ -244,12 +240,12 @@ object RobotRenderer extends TileEntitySpecialRenderer {
}
}
- override def renderTileEntityAt(entity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
- val proxy = entity.asInstanceOf[tileentity.RobotProxy]
+ val proxy = tileEntity.asInstanceOf[tileentity.RobotProxy]
val robot = proxy.robot
- val worldTime = entity.getWorldObj.getTotalWorldTime + f
+ val worldTime = tileEntity.getWorld.getTotalWorldTime + f
GL11.glPushMatrix()
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
@@ -263,10 +259,8 @@ object RobotRenderer extends TileEntitySpecialRenderer {
if (robot.isAnimatingMove) {
val remaining = (robot.animationTicksLeft - f) / robot.animationTicksTotal.toDouble
- val dx = robot.moveFromX - robot.x
- val dy = robot.moveFromY - robot.y
- val dz = robot.moveFromZ - robot.z
- GL11.glTranslated(dx * remaining, dy * remaining, dz * remaining)
+ val delta = robot.moveFrom.get.subtract(robot.getPos)
+ GL11.glTranslated(delta.getX * remaining, delta.getY * remaining, delta.getZ * remaining)
}
val timeJitter = robot.hashCode ^ 0xFF
@@ -288,9 +282,9 @@ object RobotRenderer extends TileEntitySpecialRenderer {
}
robot.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
@@ -302,9 +296,9 @@ object RobotRenderer extends TileEntitySpecialRenderer {
}
if (!robot.renderingErrored && x * x + y * y + z * z < 24 * 24) {
+ val itemRenderer = Minecraft.getMinecraft.getItemRenderer
Option(robot.getStackInSlot(0)) match {
case Some(stack) =>
- val itemRenderer = RenderManager.instance.itemRenderer
GL11.glPushMatrix()
try {
@@ -322,62 +316,65 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glRotatef((Math.sin(remaining * Math.PI) * 45).toFloat, 1, 0, 0)
}
- val customRenderer = MinecraftForgeClient.getItemRenderer(stack, EQUIPPED)
- val is3D = customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, stack, BLOCK_3D)
+ itemRenderer.renderItem(Minecraft.getMinecraft.thePlayer, stack, TransformType.NONE)
- if (is3D || (stack.getItem.isInstanceOf[ItemBlock] && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem).getRenderType))) {
- val scale = 0.375f
- GL11.glTranslatef(0, 0.1875f, -0.3125f)
- GL11.glRotatef(20, 1, 0, 0)
- GL11.glRotatef(45, 0, 1, 0)
- GL11.glScalef(-scale, -scale, scale)
- }
- else if (stack.getItem == Items.bow) {
- val scale = 0.375f
- GL11.glTranslatef(0, 0.2f, -0.2f)
- GL11.glRotatef(-10, 0, 1, 0)
- GL11.glScalef(scale, -scale, scale)
- GL11.glRotatef(-20, 1, 0, 0)
- GL11.glRotatef(45, 0, 1, 0)
- }
- else if (stack.getItem.isFull3D) {
- val scale = 0.375f
- if (stack.getItem.shouldRotateAroundWhenRendering) {
- GL11.glRotatef(180, 0, 0, 1)
- GL11.glTranslatef(0, -0.125f, 0)
- }
- GL11.glTranslatef(0, 0.1f, 0)
- GL11.glScalef(scale, -scale, scale)
- GL11.glRotatef(-100, 1, 0, 0)
- GL11.glRotatef(45, 0, 1, 0)
- }
- else {
- val scale = 0.375f
- GL11.glTranslatef(0.25f, 0.1875f, -0.1875f)
- GL11.glScalef(scale, scale, scale)
- GL11.glRotatef(60, 0, 0, 1)
- GL11.glRotatef(-90, 1, 0, 0)
- GL11.glRotatef(20, 0, 0, 1)
- }
-
- if (stack.getItem.requiresMultipleRenderPasses) {
- for (pass <- 0 until stack.getItem.getRenderPasses(stack.getItemDamage)) {
- val tint = stack.getItem.getColorFromItemStack(stack, pass)
- val r = ((tint >> 16) & 0xFF) / 255f
- val g = ((tint >> 8) & 0xFF) / 255f
- val b = ((tint >> 0) & 0xFF) / 255f
- GL11.glColor4f(r, g, b, 1)
- itemRenderer.renderItem(Minecraft.getMinecraft.thePlayer, stack, pass)
- }
- }
- else {
- val tint = stack.getItem.getColorFromItemStack(stack, 0)
- val r = ((tint >> 16) & 0xFF) / 255f
- val g = ((tint >> 8) & 0xFF) / 255f
- val b = ((tint >> 0) & 0xFF) / 255f
- GL11.glColor4f(r, g, b, 1)
- itemRenderer.renderItem(Minecraft.getMinecraft.thePlayer, stack, 0)
- }
+ // TODO remove
+ // val customRenderer = MinecraftForgeClient.getItemRenderer(stack, EQUIPPED)
+ // val is3D = customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, stack, BLOCK_3D)
+ //
+ // if (is3D || (stack.getItem.isInstanceOf[ItemBlock] && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem).getRenderType))) {
+ // val scale = 0.375f
+ // GL11.glTranslatef(0, 0.1875f, -0.3125f)
+ // GL11.glRotatef(20, 1, 0, 0)
+ // GL11.glRotatef(45, 0, 1, 0)
+ // GL11.glScalef(-scale, -scale, scale)
+ // }
+ // else if (stack.getItem == Items.bow) {
+ // val scale = 0.375f
+ // GL11.glTranslatef(0, 0.2f, -0.2f)
+ // GL11.glRotatef(-10, 0, 1, 0)
+ // GL11.glScalef(scale, -scale, scale)
+ // GL11.glRotatef(-20, 1, 0, 0)
+ // GL11.glRotatef(45, 0, 1, 0)
+ // }
+ // else if (stack.getItem.isFull3D) {
+ // val scale = 0.375f
+ // if (stack.getItem.shouldRotateAroundWhenRendering) {
+ // GL11.glRotatef(180, 0, 0, 1)
+ // GL11.glTranslatef(0, -0.125f, 0)
+ // }
+ // GL11.glTranslatef(0, 0.1f, 0)
+ // GL11.glScalef(scale, -scale, scale)
+ // GL11.glRotatef(-100, 1, 0, 0)
+ // GL11.glRotatef(45, 0, 1, 0)
+ // }
+ // else {
+ // val scale = 0.375f
+ // GL11.glTranslatef(0.25f, 0.1875f, -0.1875f)
+ // GL11.glScalef(scale, scale, scale)
+ // GL11.glRotatef(60, 0, 0, 1)
+ // GL11.glRotatef(-90, 1, 0, 0)
+ // GL11.glRotatef(20, 0, 0, 1)
+ // }
+ //
+ // if (stack.getItem.requiresMultipleRenderPasses) {
+ // for (pass <- 0 until stack.getItem.getRenderPasses(stack.getItemDamage)) {
+ // val tint = stack.getItem.getColorFromItemStack(stack, pass)
+ // val r = ((tint >> 16) & 0xFF) / 255f
+ // val g = ((tint >> 8) & 0xFF) / 255f
+ // val b = ((tint >> 0) & 0xFF) / 255f
+ // GL11.glColor4f(r, g, b, 1)
+ // itemRenderer.renderItem(Minecraft.getMinecraft.thePlayer, stack, pass)
+ // }
+ // }
+ // else {
+ // val tint = stack.getItem.getColorFromItemStack(stack, 0)
+ // val r = ((tint >> 16) & 0xFF) / 255f
+ // val g = ((tint >> 8) & 0xFF) / 255f
+ // val b = ((tint >> 0) & 0xFF) / 255f
+ // GL11.glColor4f(r, g, b, 1)
+ // itemRenderer.renderItem(Minecraft.getMinecraft.thePlayer, stack, TransformType.NONE)
+ // }
}
catch {
case e: Throwable =>
@@ -393,7 +390,7 @@ object RobotRenderer extends TileEntitySpecialRenderer {
val stacks = (robot.componentSlots ++ robot.containerSlots).map(robot.getStackInSlot).filter(stack => stack != null && MinecraftForgeClient.getItemRenderer(stack, ItemRenderType.EQUIPPED) != null).padTo(mountPoints.length, null).take(mountPoints.length)
for ((stack, mountPoint) <- stacks.zip(mountPoints)) {
try {
- if (stack != null && (stack.getItem.requiresMultipleRenderPasses() || MinecraftForgeClient.getRenderPass == 0)) {
+ if (stack != null /* && (stack.getItem.requiresMultipleRenderPasses() || MinecraftForgeClient.getRenderPass == 0) TODO remove? */ ) {
val tint = stack.getItem.getColorFromItemStack(stack, MinecraftForgeClient.getRenderPass)
val r = ((tint >> 16) & 0xFF) / 255f
val g = ((tint >> 8) & 0xFF) / 255f
@@ -403,7 +400,7 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glTranslatef(0.5f, 0.5f, 0.5f)
GL11.glRotatef(mountPoint.rotation.getW, mountPoint.rotation.getX, mountPoint.rotation.getY, mountPoint.rotation.getZ)
GL11.glTranslatef(mountPoint.offset.getX, mountPoint.offset.getY, mountPoint.offset.getZ)
- RenderManager.instance.itemRenderer.renderItem(Minecraft.getMinecraft.thePlayer, stack, MinecraftForgeClient.getRenderPass)
+ itemRenderer.renderItem(Minecraft.getMinecraft.thePlayer, stack, TransformType.NONE)
GL11.glPopMatrix()
}
}
@@ -421,8 +418,9 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glPushMatrix()
// This is pretty much copy-pasta from the entity's label renderer.
- val t = Tessellator.instance
- val f = func_147498_b
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+ val f = getFontRenderer
val scale = 1.6f / 60f
val width = f.getStringWidth(name)
val halfWidth = width / 2
@@ -431,8 +429,8 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glNormal3f(0, 1, 0)
GL11.glColor3f(1, 1, 1)
- GL11.glRotatef(-field_147501_a.field_147562_h, 0, 1, 0)
- GL11.glRotatef(field_147501_a.field_147563_i, 1, 0, 0)
+ GL11.glRotatef(-rendererDispatcher.entityYaw, 0, 1, 0)
+ GL11.glRotatef(rendererDispatcher.entityPitch, 1, 0, 0)
GL11.glScalef(-scale, -scale, scale)
RenderState.makeItBlend()
@@ -440,12 +438,12 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glDisable(GL11.GL_LIGHTING)
GL11.glDisable(GL11.GL_TEXTURE_2D)
- t.startDrawingQuads()
- t.setColorRGBA_F(0, 0, 0, 0.25f)
- t.addVertex(-halfWidth - 1, -1, 0)
- t.addVertex(-halfWidth - 1, 8, 0)
- t.addVertex(halfWidth + 1, 8, 0)
- t.addVertex(halfWidth + 1, -1, 0)
+ r.startDrawingQuads()
+ r.setColorRGBA_F(0, 0, 0, 0.25f)
+ r.addVertex(-halfWidth - 1, -1, 0)
+ r.addVertex(-halfWidth - 1, 8, 0)
+ r.addVertex(halfWidth + 1, 8, 0)
+ r.addVertex(halfWidth + 1, -1, 0)
t.draw
GL11.glEnable(GL11.GL_TEXTURE_2D) // For the font.
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala
index 61fbb212c..ba715a5f9 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala
@@ -10,7 +10,7 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
object ScreenRenderer extends TileEntitySpecialRenderer {
@@ -28,10 +28,10 @@ object ScreenRenderer extends TileEntitySpecialRenderer {
// Rendering
// ----------------------------------------------------------------------- //
- override def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z : Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
- screen = t.asInstanceOf[Screen]
+ screen = tileEntity.asInstanceOf[Screen]
if (!screen.isOrigin) {
return
}
@@ -44,7 +44,7 @@ object ScreenRenderer extends TileEntitySpecialRenderer {
// Crude check whether screen text can be seen by the local player based
// on the player's position -> angle relative to screen.
val screenFacing = screen.facing.getOpposite
- if (screenFacing.offsetX * (x + 0.5) + screenFacing.offsetY * (y + 0.5) + screenFacing.offsetZ * (z + 0.5) < 0) {
+ if (screenFacing.getFrontOffsetX * (x + 0.5) + screenFacing.getFrontOffsetY * (y + 0.5) + screenFacing.getFrontOffsetZ * (z + 0.5) < 0) {
return
}
@@ -83,14 +83,14 @@ object ScreenRenderer extends TileEntitySpecialRenderer {
private def transform() {
screen.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
screen.pitch match {
- case ForgeDirection.DOWN => GL11.glRotatef(90, 1, 0, 0)
- case ForgeDirection.UP => GL11.glRotatef(-90, 1, 0, 0)
+ case EnumFacing.DOWN => GL11.glRotatef(90, 1, 0, 0)
+ case EnumFacing.UP => GL11.glRotatef(-90, 1, 0, 0)
case _ => // No pitch.
}
@@ -102,23 +102,31 @@ object ScreenRenderer extends TileEntitySpecialRenderer {
GL11.glScalef(1, -1, 1)
}
- private def drawOverlay() = if (screen.facing == ForgeDirection.UP || screen.facing == ForgeDirection.DOWN) {
+ private def drawOverlay() = if (screen.facing == EnumFacing.UP || screen.facing == EnumFacing.DOWN) {
// Show up vector overlay when holding same screen block.
val stack = Minecraft.getMinecraft.thePlayer.getHeldItem
if (stack != null) {
- if (Wrench.holdsApplicableWrench(Minecraft.getMinecraft.thePlayer, screen.position) || screens.contains(api.Items.get(stack))) {
+ if (Wrench.holdsApplicableWrench(Minecraft.getMinecraft.thePlayer, screen.getPos) || screens.contains(api.Items.get(stack))) {
GL11.glPushMatrix()
transform()
- bindTexture(Textures.blockScreenUpIndicator)
GL11.glDepthMask(false)
GL11.glTranslatef(screen.width / 2f - 0.5f, screen.height / 2f - 0.5f, 0.05f)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, 1, 0, 0, 1)
- t.addVertexWithUV(1, 1, 0, 1, 1)
- t.addVertexWithUV(1, 0, 0, 1, 0)
- t.addVertexWithUV(0, 0, 0, 0, 0)
+
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+
+ Textures.Block.bind()
+ r.startDrawingQuads()
+
+ val icon = Textures.Block.getSprite(Textures.Block.ScreenUpIndicator)
+ r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
+ r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
+ r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
+ r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
+
t.draw()
+ Textures.Block.unbind()
+
GL11.glDepthMask(true)
GL11.glPopMatrix()
}
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala
index b7f728a79..dd535d544 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala
@@ -6,11 +6,11 @@ import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.opengl.GL11
object ServerRackRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) = {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z : Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val rack = tileEntity.asInstanceOf[ServerRack]
@@ -24,9 +24,9 @@ object ServerRackRenderer extends TileEntitySpecialRenderer {
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
rack.yaw match {
- case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
- case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
- case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
+ case EnumFacing.WEST => GL11.glRotatef(-90, 0, 1, 0)
+ case EnumFacing.NORTH => GL11.glRotatef(180, 0, 1, 0)
+ case EnumFacing.EAST => GL11.glRotatef(90, 0, 1, 0)
case _ => // No yaw.
}
@@ -34,32 +34,43 @@ object ServerRackRenderer extends TileEntitySpecialRenderer {
GL11.glScalef(1, -1, 1)
if (rack.anyRunning) {
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
+
+ Textures.Block.bind()
+ r.startDrawingQuads()
+
val v1 = 2 / 16f
val fs = 3 / 16f
- for (i <- 0 until 4 if rack.isRunning(i)) {
- val l = v1 + i * fs
- val h = v1 + (i + 1) * fs
- bindTexture(Textures.blockRackFrontOn)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, h, 0, 0, h)
- t.addVertexWithUV(1, h, 0, 1, h)
- t.addVertexWithUV(1, l, 0, 1, l)
- t.addVertexWithUV(0, l, 0, 0, l)
- t.draw()
+
+ {
+ val icon = Textures.Block.getSprite(Textures.Block.RackFrontOn)
+ for (i <- 0 until 4 if rack.isRunning(i)) {
+ val l = v1 + i * fs
+ val h = v1 + (i + 1) * fs
+ r.addVertexWithUV(0, h, 0, icon.getMinU, icon.getInterpolatedV(h))
+ r.addVertexWithUV(1, h, 0, icon.getMaxU, icon.getInterpolatedV(h))
+ r.addVertexWithUV(1, l, 0, icon.getMaxU, icon.getInterpolatedV(l))
+ r.addVertexWithUV(0, l, 0, icon.getMinU, icon.getInterpolatedV(l))
+ }
}
- for (i <- 0 until 4 if System.currentTimeMillis() - rack.lastAccess(i) < 400 && rack.world.rand.nextDouble() > 0.1) {
- val l = v1 + i * fs
- val h = v1 + (i + 1) * fs
- bindTexture(Textures.blockRackFrontActivity)
- val t = Tessellator.instance
- t.startDrawingQuads()
- t.addVertexWithUV(0, h, 0, 0, h)
- t.addVertexWithUV(1, h, 0, 1, h)
- t.addVertexWithUV(1, l, 0, 1, l)
- t.addVertexWithUV(0, l, 0, 0, l)
- t.draw()
+
+ {
+ val icon = Textures.Block.getSprite(Textures.Block.RackFrontActivity)
+ for (i <- 0 until 4 if System.currentTimeMillis() - rack.lastAccess(i) < 400 && rack.world.rand.nextDouble() > 0.1) {
+ val l = v1 + i * fs
+ val h = v1 + (i + 1) * fs
+
+ bindTexture(Textures.Block.RackFrontActivity)
+ r.addVertexWithUV(0, h, 0, icon.getMinU, icon.getInterpolatedV(h))
+ r.addVertexWithUV(1, h, 0, icon.getMaxU, icon.getInterpolatedV(h))
+ r.addVertexWithUV(1, l, 0, icon.getMaxU, icon.getInterpolatedV(l))
+ r.addVertexWithUV(0, l, 0, icon.getMinU, icon.getInterpolatedV(l))
+ }
}
+
+ t.draw()
+ Textures.Block.unbind()
}
GL11.glPopMatrix()
diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala
index b8cff8794..af1c47f80 100644
--- a/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala
+++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala
@@ -4,13 +4,12 @@ import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity
import li.cil.oc.util.RenderState
import net.minecraft.client.renderer.Tessellator
-import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import org.lwjgl.opengl.GL11
object SwitchRenderer extends TileEntitySpecialRenderer {
- override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
+ override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
val switch = tileEntity.asInstanceOf[tileentity.Switch]
@@ -28,32 +27,35 @@ object SwitchRenderer extends TileEntitySpecialRenderer {
GL11.glScaled(1.0025, -1.0025, 1.0025)
GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
- bindTexture(TextureMap.locationBlocksTexture)
- val t = Tessellator.instance
- t.startDrawingQuads()
+ val t = Tessellator.getInstance
+ val r = t.getWorldRenderer
- val sideActivity = Textures.Switch.iconSideActivity
- t.addVertexWithUV(1, 1, 0, sideActivity.getMinU, sideActivity.getMaxV)
- t.addVertexWithUV(0, 1, 0, sideActivity.getMaxU, sideActivity.getMaxV)
- t.addVertexWithUV(0, 0, 0, sideActivity.getMaxU, sideActivity.getMinV)
- t.addVertexWithUV(1, 0, 0, sideActivity.getMinU, sideActivity.getMinV)
+ Textures.Block.bind()
+ r.startDrawingQuads()
- t.addVertexWithUV(0, 1, 1, sideActivity.getMinU, sideActivity.getMaxV)
- t.addVertexWithUV(1, 1, 1, sideActivity.getMaxU, sideActivity.getMaxV)
- t.addVertexWithUV(1, 0, 1, sideActivity.getMaxU, sideActivity.getMinV)
- t.addVertexWithUV(0, 0, 1, sideActivity.getMinU, sideActivity.getMinV)
+ val sideActivity = Textures.Block.getSprite(Textures.Block.SwitchSideOn)
+ r.addVertexWithUV(1, 1, 0, sideActivity.getMinU, sideActivity.getMaxV)
+ r.addVertexWithUV(0, 1, 0, sideActivity.getMaxU, sideActivity.getMaxV)
+ r.addVertexWithUV(0, 0, 0, sideActivity.getMaxU, sideActivity.getMinV)
+ r.addVertexWithUV(1, 0, 0, sideActivity.getMinU, sideActivity.getMinV)
- t.addVertexWithUV(1, 1, 1, sideActivity.getMinU, sideActivity.getMaxV)
- t.addVertexWithUV(1, 1, 0, sideActivity.getMaxU, sideActivity.getMaxV)
- t.addVertexWithUV(1, 0, 0, sideActivity.getMaxU, sideActivity.getMinV)
- t.addVertexWithUV(1, 0, 1, sideActivity.getMinU, sideActivity.getMinV)
+ r.addVertexWithUV(0, 1, 1, sideActivity.getMinU, sideActivity.getMaxV)
+ r.addVertexWithUV(1, 1, 1, sideActivity.getMaxU, sideActivity.getMaxV)
+ r.addVertexWithUV(1, 0, 1, sideActivity.getMaxU, sideActivity.getMinV)
+ r.addVertexWithUV(0, 0, 1, sideActivity.getMinU, sideActivity.getMinV)
- t.addVertexWithUV(0, 1, 0, sideActivity.getMinU, sideActivity.getMaxV)
- t.addVertexWithUV(0, 1, 1, sideActivity.getMaxU, sideActivity.getMaxV)
- t.addVertexWithUV(0, 0, 1, sideActivity.getMaxU, sideActivity.getMinV)
- t.addVertexWithUV(0, 0, 0, sideActivity.getMinU, sideActivity.getMinV)
+ r.addVertexWithUV(1, 1, 1, sideActivity.getMinU, sideActivity.getMaxV)
+ r.addVertexWithUV(1, 1, 0, sideActivity.getMaxU, sideActivity.getMaxV)
+ r.addVertexWithUV(1, 0, 0, sideActivity.getMaxU, sideActivity.getMinV)
+ r.addVertexWithUV(1, 0, 1, sideActivity.getMinU, sideActivity.getMinV)
+
+ r.addVertexWithUV(0, 1, 0, sideActivity.getMinU, sideActivity.getMaxV)
+ r.addVertexWithUV(0, 1, 1, sideActivity.getMaxU, sideActivity.getMaxV)
+ r.addVertexWithUV(0, 0, 1, sideActivity.getMaxU, sideActivity.getMinV)
+ r.addVertexWithUV(0, 0, 0, sideActivity.getMinU, sideActivity.getMinV)
t.draw()
+ Textures.Block.unbind()
GL11.glPopMatrix()
GL11.glPopAttrib()
diff --git a/src/main/scala/li/cil/oc/common/ComponentTracker.scala b/src/main/scala/li/cil/oc/common/ComponentTracker.scala
index eb329e47c..a62cc9df2 100644
--- a/src/main/scala/li/cil/oc/common/ComponentTracker.scala
+++ b/src/main/scala/li/cil/oc/common/ComponentTracker.scala
@@ -2,7 +2,7 @@ package li.cil.oc.common
import com.google.common.cache.Cache
import com.google.common.cache.CacheBuilder
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.api.network.ManagedEnvironment
import net.minecraft.world.World
import net.minecraftforge.event.world.WorldEvent
@@ -18,7 +18,7 @@ abstract class ComponentTracker {
private val worlds = mutable.Map.empty[Int, Cache[String, ManagedEnvironment]]
private def components(world: World) = {
- worlds.getOrElseUpdate(world.provider.dimensionId,
+ worlds.getOrElseUpdate(world.provider.getDimensionId,
com.google.common.cache.CacheBuilder.newBuilder().
weakValues().
asInstanceOf[CacheBuilder[String, ManagedEnvironment]].
diff --git a/src/main/scala/li/cil/oc/common/EventHandler.scala b/src/main/scala/li/cil/oc/common/EventHandler.scala
index 38bafb33b..99defdc35 100644
--- a/src/main/scala/li/cil/oc/common/EventHandler.scala
+++ b/src/main/scala/li/cil/oc/common/EventHandler.scala
@@ -2,12 +2,12 @@ package li.cil.oc.common
import java.util.Calendar
-import cpw.mods.fml.common.Optional
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.gameevent.PlayerEvent._
-import cpw.mods.fml.common.gameevent.TickEvent
-import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent
-import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent
+import net.minecraftforge.fml.common.Optional
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.PlayerEvent._
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ServerTickEvent
+import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent
import li.cil.oc._
import li.cil.oc.api.Network
import li.cil.oc.api.detail.ItemInfo
@@ -25,7 +25,7 @@ import net.minecraft.server.MinecraftServer
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.FakePlayer
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.event.world.WorldEvent
import scala.collection.mutable
@@ -47,42 +47,6 @@ object EventHandler {
}
}
- @Optional.Method(modid = Mods.IDs.ForgeMultipart)
- def scheduleFMP(tileEntity: () => TileEntity) {
- if (SideTracker.isServer) pending.synchronized {
- pending += (() => Network.joinOrCreateNetwork(tileEntity()))
- }
- }
-
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- def scheduleAE2Add(tileEntity: power.AppliedEnergistics2) {
- if (SideTracker.isServer) pending.synchronized {
- pending += (() => if (!tileEntity.isInvalid) {
- tileEntity.getGridNode(ForgeDirection.UNKNOWN).updateState()
- })
- }
- }
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
- def scheduleIC2Add(tileEntity: power.IndustrialCraft2Experimental) {
- if (SideTracker.isServer) pending.synchronized {
- pending += (() => if (!tileEntity.addedToIC2PowerGrid && !tileEntity.isInvalid) {
- MinecraftForge.EVENT_BUS.post(new ic2.api.energy.event.EnergyTileLoadEvent(tileEntity.asInstanceOf[ic2.api.energy.tile.IEnergyTile]))
- tileEntity.addedToIC2PowerGrid = true
- })
- }
- }
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
- def scheduleIC2Add(tileEntity: power.IndustrialCraft2Classic) {
- if (SideTracker.isServer) pending.synchronized {
- pending += (() => if (!tileEntity.addedToIC2PowerGrid && !tileEntity.isInvalid) {
- MinecraftForge.EVENT_BUS.post(new ic2classic.api.energy.event.EnergyTileLoadEvent(tileEntity.asInstanceOf[ic2classic.api.energy.tile.IEnergyTile]))
- tileEntity.addedToIC2PowerGrid = true
- })
- }
- }
-
def scheduleWirelessRedstone(rs: server.component.RedstoneWireless) {
if (SideTracker.isServer) pending.synchronized {
pending += (() => if (!rs.owner.isInvalid) {
@@ -117,7 +81,7 @@ object EventHandler {
}
ServerPacketSender.sendPetVisibility(None, Some(player))
// Do update check in local games and for OPs.
- if (!Mods.VersionChecker.isAvailable && (!MinecraftServer.getServer.isDedicatedServer || MinecraftServer.getServer.getConfigurationManager.func_152596_g(player.getGameProfile))) {
+ if (!Mods.VersionChecker.isAvailable && (!MinecraftServer.getServer.isDedicatedServer || MinecraftServer.getServer.getConfigurationManager.canSendCommands(player.getGameProfile))) {
Future {
UpdateCheck.info onSuccess {
case Some(release) => player.addChatMessage(Localization.Chat.InfoNewVersion(release.tag_name))
@@ -132,7 +96,7 @@ object EventHandler {
def clientLoggedIn(e: ClientConnectedToServerEvent) {
PetRenderer.hidden.clear()
if (Settings.get.hideOwnPet) {
- PetRenderer.hidden += Minecraft.getMinecraft.thePlayer.getCommandSenderName
+ PetRenderer.hidden += Minecraft.getMinecraft.thePlayer.getName
}
ClientPacketSender.sendPetVisibility()
}
@@ -195,7 +159,7 @@ object EventHandler {
// On the 12th day of Christmas, my robot brought to me~
(month == Calendar.DECEMBER && dayOfMonth > 24) || (month == Calendar.JANUARY && dayOfMonth < 7) ||
// OC's release-birthday!
- (month == Calendar.DECEMBER && dayOfMonth == 14) || true
+ (month == Calendar.DECEMBER && dayOfMonth == 14)
}
private def recraft(e: ItemCraftedEvent, item: ItemInfo, callback: ItemStack => Option[ItemStack]): Boolean = {
diff --git a/src/main/scala/li/cil/oc/common/GuiHandler.scala b/src/main/scala/li/cil/oc/common/GuiHandler.scala
index 38b21432b..50c70ab45 100644
--- a/src/main/scala/li/cil/oc/common/GuiHandler.scala
+++ b/src/main/scala/li/cil/oc/common/GuiHandler.scala
@@ -1,17 +1,19 @@
package li.cil.oc.common
-import cpw.mods.fml.common.network.IGuiHandler
import li.cil.oc.common.init.Items
import li.cil.oc.common.inventory.DatabaseInventory
import li.cil.oc.common.inventory.ServerInventory
+import li.cil.oc.util.BlockPosition
+import li.cil.oc.util.ExtendedWorld._
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.world.World
+import net.minecraftforge.fml.common.network.IGuiHandler
abstract class GuiHandler extends IGuiHandler {
override def getServerGuiElement(id: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef = {
GuiType.Categories.get(id) match {
case Some(GuiType.Category.Block) =>
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(BlockPosition(x, y, z)) match {
case t: tileentity.Adapter if id == GuiType.Adapter.id =>
new container.Adapter(player.inventory, t)
case t: tileentity.Assembler if id == GuiType.Assembler.id =>
diff --git a/src/main/scala/li/cil/oc/common/IMC.scala b/src/main/scala/li/cil/oc/common/IMC.scala
index 3e3fe7654..0ac846897 100644
--- a/src/main/scala/li/cil/oc/common/IMC.scala
+++ b/src/main/scala/li/cil/oc/common/IMC.scala
@@ -4,7 +4,7 @@ import java.lang.reflect.Method
import java.lang.reflect.Modifier
import com.typesafe.config.Config
-import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent
+import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.common.template.AssemblerTemplates
diff --git a/src/main/scala/li/cil/oc/common/Loot.scala b/src/main/scala/li/cil/oc/common/Loot.scala
index 3614e4359..5b812ee4e 100644
--- a/src/main/scala/li/cil/oc/common/Loot.scala
+++ b/src/main/scala/li/cil/oc/common/Loot.scala
@@ -3,7 +3,7 @@ package li.cil.oc.common
import java.io
import java.util.Random
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api
diff --git a/src/main/scala/li/cil/oc/common/PacketBuilder.scala b/src/main/scala/li/cil/oc/common/PacketBuilder.scala
index 46cbad78c..0cbd7d46b 100644
--- a/src/main/scala/li/cil/oc/common/PacketBuilder.scala
+++ b/src/main/scala/li/cil/oc/common/PacketBuilder.scala
@@ -5,8 +5,9 @@ import java.io.DataOutputStream
import java.io.OutputStream
import java.util.zip.GZIPOutputStream
-import cpw.mods.fml.common.FMLCommonHandler
-import cpw.mods.fml.common.network.internal.FMLProxyPacket
+import net.minecraft.network.PacketBuffer
+import net.minecraftforge.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.network.internal.FMLProxyPacket
import io.netty.buffer.Unpooled
import li.cil.oc.OpenComputers
import li.cil.oc.api.driver.EnvironmentHost
@@ -17,24 +18,24 @@ import net.minecraft.nbt.CompressedStreamTools
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.convert.WrapAsScala._
abstract class PacketBuilder(stream: OutputStream) extends DataOutputStream(stream) {
def writeTileEntity(t: TileEntity) {
- writeInt(t.getWorldObj.provider.dimensionId)
- writeInt(t.xCoord)
- writeInt(t.yCoord)
- writeInt(t.zCoord)
+ writeInt(t.getWorld.provider.getDimensionId)
+ writeInt(t.getPos.getX)
+ writeInt(t.getPos.getY)
+ writeInt(t.getPos.getZ)
}
def writeEntity(e: Entity) {
- writeInt(e.worldObj.provider.dimensionId)
+ writeInt(e.worldObj.provider.getDimensionId)
writeInt(e.getEntityId)
}
- def writeDirection(d: Option[ForgeDirection]) = d match {
+ def writeDirection(d: Option[EnumFacing]) = d match {
case Some(side) => writeByte(side.ordinal.toByte)
case _ => writeByte(-1: Byte)
}
@@ -53,12 +54,12 @@ abstract class PacketBuilder(stream: OutputStream) extends DataOutputStream(stre
def sendToAllPlayers() = OpenComputers.channel.sendToAll(packet)
- def sendToPlayersNearTileEntity(t: TileEntity, range: Option[Double] = None): Unit = sendToNearbyPlayers(t.getWorldObj, t.xCoord + 0.5, t.yCoord + 0.5, t.zCoord + 0.5, range)
+ def sendToPlayersNearTileEntity(t: TileEntity, range: Option[Double] = None): Unit = sendToNearbyPlayers(t.getWorld, t.getPos.getX + 0.5, t.getPos.getY + 0.5, t.getPos.getZ + 0.5, range)
def sendToPlayersNearHost(host: EnvironmentHost, range: Option[Double] = None): Unit = sendToNearbyPlayers(host.world, host.xPosition, host.yPosition, host.zPosition, range)
def sendToNearbyPlayers(world: World, x: Double, y: Double, z: Double, range: Option[Double]) {
- val dimension = world.provider.dimensionId
+ val dimension = world.provider.getDimensionId
val server = FMLCommonHandler.instance.getMinecraftServerInstance
val manager = server.getConfigurationManager
for (player <- manager.playerEntityList.map(_.asInstanceOf[EntityPlayerMP]) if player.dimension == dimension) {
@@ -84,7 +85,7 @@ class SimplePacketBuilder(packetType: PacketType.Value) extends PacketBuilderBas
writeByte(packetType.id)
override protected def packet = {
- new FMLProxyPacket(Unpooled.wrappedBuffer(stream.toByteArray), "OpenComputers")
+ new FMLProxyPacket(new PacketBuffer(Unpooled.wrappedBuffer(stream.toByteArray)), "OpenComputers")
}
}
@@ -93,7 +94,7 @@ class CompressedPacketBuilder(packetType: PacketType.Value, private val data: By
override protected def packet = {
stream.finish()
- new FMLProxyPacket(Unpooled.wrappedBuffer(data.toByteArray), "OpenComputers")
+ new FMLProxyPacket(new PacketBuffer(Unpooled.wrappedBuffer(data.toByteArray)), "OpenComputers")
}
}
diff --git a/src/main/scala/li/cil/oc/common/PacketHandler.scala b/src/main/scala/li/cil/oc/common/PacketHandler.scala
index cff654487..228ed7ee3 100644
--- a/src/main/scala/li/cil/oc/common/PacketHandler.scala
+++ b/src/main/scala/li/cil/oc/common/PacketHandler.scala
@@ -9,11 +9,14 @@ import io.netty.buffer.ByteBufInputStream
import li.cil.oc.OpenComputers
import li.cil.oc.api
import li.cil.oc.common.block.RobotAfterimage
+import li.cil.oc.util.BlockPosition
+import li.cil.oc.util.ExtendedWorld._
import li.cil.oc.util.ItemUtils
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt.CompressedStreamTools
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
import scala.reflect.ClassTag
import scala.reflect.classTag
@@ -43,15 +46,15 @@ abstract class PacketHandler {
*/
protected def world(player: EntityPlayer, dimension: Int): Option[World]
- protected def dispatch(p: PacketParser)
+ protected def dispatch(p: PacketParser): Unit
protected class PacketParser(stream: InputStream, val player: EntityPlayer) extends DataInputStream(stream) {
val packetType = PacketType(readByte())
def getTileEntity[T: ClassTag](dimension: Int, x: Int, y: Int, z: Int): Option[T] = {
world(player, dimension) match {
- case Some(world) if world.blockExists(x, y, z) =>
- val t = world.getTileEntity(x, y, z)
+ case Some(world) if world.blockExists(BlockPosition(x, y, z)) =>
+ val t = world.getTileEntity(BlockPosition(x, y, z))
if (t != null && classTag[T].runtimeClass.isAssignableFrom(t.getClass)) {
return Some(t.asInstanceOf[T])
}
@@ -59,7 +62,7 @@ abstract class PacketHandler {
// mostly used when the robot *starts* moving while the client sends
// a request to the server.
api.Items.get("robotAfterimage").block match {
- case afterimage: RobotAfterimage => afterimage.findMovingRobot(world, x, y, z) match {
+ case afterimage: RobotAfterimage => afterimage.findMovingRobot(world, new BlockPos(x, y, z)) match {
case Some(robot) if classTag[T].runtimeClass.isAssignableFrom(robot.proxy.getClass) =>
return Some(robot.proxy.asInstanceOf[T])
case _ =>
@@ -99,7 +102,7 @@ abstract class PacketHandler {
def readDirection() = readByte() match {
case id if id < 0 => None
- case id => Option(ForgeDirection.getOrientation(id))
+ case id => Option(EnumFacing.getFront(id))
}
def readItemStack() = {
diff --git a/src/main/scala/li/cil/oc/common/PacketType.scala b/src/main/scala/li/cil/oc/common/PacketType.scala
index fac6f4d39..f630ad09c 100644
--- a/src/main/scala/li/cil/oc/common/PacketType.scala
+++ b/src/main/scala/li/cil/oc/common/PacketType.scala
@@ -3,7 +3,6 @@ package li.cil.oc.common
object PacketType extends Enumeration {
val
// Server -> Client
- AbstractBusState,
Analyze,
ChargerState,
ColorChange,
diff --git a/src/main/scala/li/cil/oc/common/Proxy.scala b/src/main/scala/li/cil/oc/common/Proxy.scala
index 4ef4d85d3..3e50ce704 100644
--- a/src/main/scala/li/cil/oc/common/Proxy.scala
+++ b/src/main/scala/li/cil/oc/common/Proxy.scala
@@ -1,9 +1,12 @@
package li.cil.oc.common
import com.google.common.base.Strings
-import cpw.mods.fml.common.event._
-import cpw.mods.fml.common.network.NetworkRegistry
-import cpw.mods.fml.common.registry.GameRegistry
+import li.cil.oc.common.item.Delegate
+import net.minecraft.block.Block
+import net.minecraft.item.Item
+import net.minecraftforge.fml.common.event._
+import net.minecraftforge.fml.common.network.NetworkRegistry
+import net.minecraftforge.fml.common.registry.GameRegistry
import li.cil.oc._
import li.cil.oc.common.init.Blocks
import li.cil.oc.common.init.Items
@@ -63,6 +66,12 @@ class Proxy {
api.Machine.add(classOf[LuaJLuaArchitecture])
}
+ def registerModel(instance: Item, location: String): Unit = {}
+
+ def registerModel(instance: Delegate, location: String): Unit = {}
+
+ def registerModel(instance: Block, location: String): Unit = {}
+
def init(e: FMLInitializationEvent) {
OpenComputers.channel = NetworkRegistry.INSTANCE.newEventDrivenChannel("OpenComputers")
OpenComputers.channel.register(server.PacketHandler)
@@ -89,25 +98,11 @@ class Proxy {
// extend, in case that should ever be needed.
private val blockRenames = Map(
- OpenComputers.ID + ":" + Settings.namespace + "simple" -> "simple",
- OpenComputers.ID + ":" + Settings.namespace + "simple_redstone" -> "simple_redstone",
- OpenComputers.ID + ":" + Settings.namespace + "special" -> "special",
- OpenComputers.ID + ":" + Settings.namespace + "special_redstone" -> "special_redstone",
- OpenComputers.ID + ":" + Settings.namespace + "keyboard" -> "keyboard",
- OpenComputers.ID + ":rack" -> "serverRack"
+ OpenComputers.ID + ":server_rack" -> "serverRack"
)
private val itemRenames = Map(
- OpenComputers.ID + ":" + Settings.namespace + "item" -> "item",
- OpenComputers.ID + ":" + Settings.namespace + "simple" -> "simple",
- OpenComputers.ID + ":" + Settings.namespace + "simple_redstone" -> "simple_redstone",
- OpenComputers.ID + ":" + Settings.namespace + "special" -> "special",
- OpenComputers.ID + ":" + Settings.namespace + "special_redstone" -> "special_redstone",
- OpenComputers.ID + ":" + Settings.namespace + "keyboard" -> "keyboard",
- OpenComputers.ID + ":rack" -> "serverRack",
- OpenComputers.ID + ":appengTunnel" -> "", // Avoid breaking worlds for people that used the dev builds.
- OpenComputers.ID + ":microcontrollerCase" -> "microcontrollerCase1",
- OpenComputers.ID + ":droneCase" -> "droneCase1"
+ OpenComputers.ID + ":server_rack" -> "serverRack"
)
def missingMappings(e: FMLMissingMappingsEvent) {
diff --git a/src/main/scala/li/cil/oc/common/SaveHandler.scala b/src/main/scala/li/cil/oc/common/SaveHandler.scala
index b16a850d4..aed9a2352 100644
--- a/src/main/scala/li/cil/oc/common/SaveHandler.scala
+++ b/src/main/scala/li/cil/oc/common/SaveHandler.scala
@@ -5,8 +5,8 @@ import java.io._
import java.nio.file._
import java.nio.file.attribute.BasicFileAttributes
-import cpw.mods.fml.common.eventhandler.EventPriority
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api.driver.EnvironmentHost
@@ -60,7 +60,7 @@ object SaveHandler {
def scheduleSave(position: BlockPosition, nbt: NBTTagCompound, name: String, data: Array[Byte]) {
val world = position.world.get
- val dimension = world.provider.dimensionId
+ val dimension = world.provider.getDimensionId
val chunk = new ChunkCoordIntPair(position.x >> 4, position.z >> 4)
// We have to save the dimension and chunk coordinates, because they are
@@ -159,7 +159,7 @@ object SaveHandler {
@SubscribeEvent
def onChunkSave(e: ChunkDataEvent.Save) = saveData.synchronized {
val path = statePath
- val dimension = e.world.provider.dimensionId
+ val dimension = e.world.provider.getDimensionId
val chunk = e.getChunk.getChunkCoordIntPair
val dimPath = new io.File(path, dimension.toString)
val chunkPath = new io.File(dimPath, s"${chunk.chunkXPos}.${chunk.chunkZPos}")
@@ -210,7 +210,7 @@ object SaveHandler {
@SubscribeEvent(priority = EventPriority.LOWEST)
def onWorldSave(e: WorldEvent.Save) {
saveData.synchronized {
- saveData.get(e.world.provider.dimensionId) match {
+ saveData.get(e.world.provider.getDimensionId) match {
case Some(chunks) => chunks.clear()
case _ =>
}
diff --git a/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala b/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala
index 3a784cb97..defd4a4c6 100644
--- a/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala
+++ b/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.asm
-import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper
+import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper
import li.cil.oc.common.asm.template.SimpleComponentImpl
import li.cil.oc.integration.Mods
import net.minecraft.launchwrapper.IClassTransformer
diff --git a/src/main/scala/li/cil/oc/common/block/AccessPoint.scala b/src/main/scala/li/cil/oc/common/block/AccessPoint.scala
index f181c86ef..9e6c4f4f7 100644
--- a/src/main/scala/li/cil/oc/common/block/AccessPoint.scala
+++ b/src/main/scala/li/cil/oc/common/block/AccessPoint.scala
@@ -2,21 +2,11 @@ package li.cil.oc.common.block
import li.cil.oc.Settings
import li.cil.oc.common.tileentity
+import net.minecraft.block.state.IBlockState
import net.minecraft.world.World
class AccessPoint extends Switch with traits.PowerAcceptor {
- override protected def customTextures = Array(
- None,
- Some("AccessPointTop"),
- Some("SwitchSide"),
- Some("SwitchSide"),
- Some("SwitchSide"),
- Some("SwitchSide")
- )
-
- // ----------------------------------------------------------------------- //
-
override def energyThroughput = Settings.get.accessPointRate
- override def createTileEntity(world: World, metadata: Int) = new tileentity.AccessPoint()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.AccessPoint()
}
diff --git a/src/main/scala/li/cil/oc/common/block/Adapter.scala b/src/main/scala/li/cil/oc/common/block/Adapter.scala
index 57745744a..e17b8e7b5 100644
--- a/src/main/scala/li/cil/oc/common/block/Adapter.scala
+++ b/src/main/scala/li/cil/oc/common/block/Adapter.scala
@@ -4,63 +4,49 @@ import li.cil.oc.OpenComputers
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
import net.minecraft.block.Block
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class Adapter extends SimpleBlock {
- override protected def customTextures = Array(
- None,
- Some("AdapterTop"),
- Some("AdapterSide"),
- Some("AdapterSide"),
- Some("AdapterSide"),
- Some("AdapterSide")
- )
+ override def hasTileEntity(state: IBlockState) = true
+
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Adapter()
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
-
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Adapter()
-
- // ----------------------------------------------------------------------- //
-
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Adapter.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Adapter.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
else false
}
- override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) =
- world.getTileEntity(x, y, z) match {
+ override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) =
+ world.getTileEntity(pos) match {
case adapter: tileentity.Adapter => adapter.neighborChanged()
case _ => // Ignore.
}
- override def onNeighborChange(world: IBlockAccess, x: Int, y: Int, z: Int, tileX: Int, tileY: Int, tileZ: Int) =
- world.getTileEntity(x, y, z) match {
+ override def onNeighborChange(world: IBlockAccess, pos: BlockPos, neighbor: BlockPos) =
+ world.getTileEntity(pos) match {
case adapter: tileentity.Adapter =>
- val (dx, dy, dz) = (tileX - x, tileY - y, tileZ - z)
- val index = 3 + dx + dy + dy + dz + dz + dz
- if (index >= 0 && index < sides.length) {
- adapter.neighborChanged(sides(index))
- }
+ // TODO can we just pass the blockpos?
+ val side =
+ if (neighbor == pos.down()) EnumFacing.DOWN
+ else if (neighbor == pos.up()) EnumFacing.UP
+ else if (neighbor == pos.north()) EnumFacing.NORTH
+ else if (neighbor == pos.south()) EnumFacing.SOUTH
+ else if (neighbor == pos.west()) EnumFacing.WEST
+ else if (neighbor == pos.east()) EnumFacing.EAST
+ else throw new IllegalArgumentException("not a neighbor") // TODO wat
+ adapter.neighborChanged(side)
case _ => // Ignore.
}
-
- private val sides = Array(
- ForgeDirection.NORTH,
- ForgeDirection.DOWN,
- ForgeDirection.WEST,
- ForgeDirection.UNKNOWN,
- ForgeDirection.EAST,
- ForgeDirection.UP,
- ForgeDirection.SOUTH)
}
diff --git a/src/main/scala/li/cil/oc/common/block/Assembler.scala b/src/main/scala/li/cil/oc/common/block/Assembler.scala
index f90fecd44..4882aa3c3 100644
--- a/src/main/scala/li/cil/oc/common/block/Assembler.scala
+++ b/src/main/scala/li/cil/oc/common/block/Assembler.scala
@@ -2,51 +2,34 @@ package li.cil.oc.common.block
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
-import li.cil.oc.client.Textures
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class Assembler extends SimpleBlock with traits.SpecialBlock with traits.PowerAcceptor {
setLightLevel(0.34f)
- override protected def customTextures = Array(
- None,
- Some("AssemblerTop"),
- Some("AssemblerSide"),
- Some("AssemblerSide"),
- Some("AssemblerSide"),
- Some("AssemblerSide")
- )
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- Textures.Assembler.iconSideAssembling = iconRegister.registerIcon(Settings.resourceDomain + ":AssemblerSideAssembling")
- Textures.Assembler.iconSideOn = iconRegister.registerIcon(Settings.resourceDomain + ":AssemblerSideOn")
- Textures.Assembler.iconTopOn = iconRegister.registerIcon(Settings.resourceDomain + ":AssemblerTopOn")
- }
-
- override def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = side == ForgeDirection.DOWN || side == ForgeDirection.UP
+ override def isBlockSolid(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = side == EnumFacing.DOWN || side == EnumFacing.UP
// ----------------------------------------------------------------------- //
override def energyThroughput = Settings.get.assemblerRate
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Assembler()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Assembler()
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Assembler.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Assembler.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
diff --git a/src/main/scala/li/cil/oc/common/block/Cable.scala b/src/main/scala/li/cil/oc/common/block/Cable.scala
index e456b3230..0fdb261cf 100644
--- a/src/main/scala/li/cil/oc/common/block/Cable.scala
+++ b/src/main/scala/li/cil/oc/common/block/Cable.scala
@@ -1,27 +1,28 @@
package li.cil.oc.common.block
+/* TODO FMP
import codechicken.lib.vec.Cuboid6
import codechicken.multipart.JNormalOcclusion
import codechicken.multipart.NormalOcclusionTest
import codechicken.multipart.TFacePart
import codechicken.multipart.TileMultipart
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
-import li.cil.oc.Settings
+import li.cil.oc.integration.fmp.CablePart
+*/
import li.cil.oc.api.network.Environment
import li.cil.oc.api.network.SidedEnvironment
-import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity
import li.cil.oc.integration.Mods
-import li.cil.oc.integration.fmp.CablePart
-import li.cil.oc.util.Color
import net.minecraft.block.Block
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
+import net.minecraft.item.EnumDyeColor
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.AxisAlignedBB
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class Cable extends SimpleBlock with traits.SpecialBlock {
setLightOpacity(0)
@@ -32,41 +33,26 @@ class Cable extends SimpleBlock with traits.SpecialBlock {
// For FMP part coloring.
var colorMultiplierOverride: Option[Int] = None
- override protected def customTextures = Array(
- Some("CablePart"),
- Some("CablePart"),
- Some("CablePart"),
- Some("CablePart"),
- Some("CablePart"),
- Some("CablePart")
- )
+ @SideOnly(Side.CLIENT) override
+ def colorMultiplier(world: IBlockAccess, pos: BlockPos, renderPass: Int) = colorMultiplierOverride.getOrElse(super.colorMultiplier(world, pos, renderPass))
- @SideOnly(Side.CLIENT)
- override def registerBlockIcons(iconRegister: IIconRegister) {
- super.registerBlockIcons(iconRegister)
- Textures.Cable.iconCap = iconRegister.registerIcon(Settings.resourceDomain + ":CableCap")
- }
-
- override def colorMultiplier(world: IBlockAccess, x: Int, y: Int, z: Int) =
- colorMultiplierOverride.getOrElse(super.colorMultiplier(world, x, y, z))
-
- override def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = true
+ override def shouldSideBeRendered(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = true
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Cable()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Cable()
// ----------------------------------------------------------------------- //
- override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) {
- world.markBlockForUpdate(x, y, z)
- super.onNeighborBlockChange(world, x, y, z, block)
+ override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) {
+ world.markBlockForUpdate(pos)
+ super.onNeighborBlockChange(world, pos, state, neighborBlock)
}
- override protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int): Unit = {
- setBlockBounds(Cable.bounds(world, x, y, z))
+ override protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, pos: BlockPos): Unit = {
+ setBlockBounds(Cable.bounds(world, pos))
}
}
@@ -74,87 +60,97 @@ object Cable {
val cachedBounds = {
// 6 directions = 6 bits = 11111111b >> 2 = 0xFF >> 2
(0 to 0xFF >> 2).map(mask => {
- val bounds = AxisAlignedBB.getBoundingBox(-0.125, -0.125, -0.125, 0.125, 0.125, 0.125)
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
- if ((side.flag & mask) != 0) {
- if (side.offsetX < 0) bounds.minX += side.offsetX * 0.375
- else bounds.maxX += side.offsetX * 0.375
- if (side.offsetY < 0) bounds.minY += side.offsetY * 0.375
- else bounds.maxY += side.offsetY * 0.375
- if (side.offsetZ < 0) bounds.minZ += side.offsetZ * 0.375
- else bounds.maxZ += side.offsetZ * 0.375
+ var minX = -0.125
+ var minY = -0.125
+ var minZ = -0.125
+ var maxX = 0.125
+ var maxY = 0.125
+ var maxZ = 0.125
+ for (side <- EnumFacing.values) {
+ if (((1 << side.getIndex) & mask) != 0) {
+ if (side.getFrontOffsetX < 0) minX += side.getFrontOffsetX * 0.375
+ else maxX += side.getFrontOffsetX * 0.375
+ if (side.getFrontOffsetY < 0) minY += side.getFrontOffsetY * 0.375
+ else maxY += side.getFrontOffsetY * 0.375
+ if (side.getFrontOffsetZ < 0) minZ += side.getFrontOffsetZ * 0.375
+ else maxZ += side.getFrontOffsetZ * 0.375
}
}
- bounds.setBounds(
- bounds.minX + 0.5, bounds.minY + 0.5, bounds.minZ + 0.5,
- bounds.maxX + 0.5, bounds.maxY + 0.5, bounds.maxZ + 0.5)
+ AxisAlignedBB.fromBounds(
+ minX + 0.5, minY + 0.5, minZ + 0.5,
+ maxX + 0.5, maxY + 0.5, maxZ + 0.5)
}).toArray
}
- def neighbors(world: IBlockAccess, x: Int, y: Int, z: Int) = {
+ def neighbors(world: IBlockAccess, pos: BlockPos) = {
var result = 0
- val tileEntity = world.getTileEntity(x, y, z)
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
- val (tx, ty, tz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
+ val tileEntity = world.getTileEntity(pos)
+ for (side <- EnumFacing.values) {
+ val tpos = pos.offset(side)
if (world match {
- case world: World => world.blockExists(tx, ty, tz)
- case _ => !world.isAirBlock(tx, ty, tz)
+ case world: World => world.isBlockLoaded(tpos)
+ case _ => !world.isAirBlock(tpos)
}) {
- val neighborTileEntity = world.getTileEntity(tx, ty, tz)
+ val neighborTileEntity = world.getTileEntity(tpos)
val neighborHasNode = hasNetworkNode(neighborTileEntity, side.getOpposite)
val canConnectColor = canConnectBasedOnColor(tileEntity, neighborTileEntity)
val canConnectFMP = !Mods.ForgeMultipart.isAvailable ||
(canConnectFromSideFMP(tileEntity, side) && canConnectFromSideFMP(neighborTileEntity, side.getOpposite))
val canConnectIM = canConnectFromSideIM(tileEntity, side) && canConnectFromSideIM(neighborTileEntity, side.getOpposite)
if (neighborHasNode && canConnectColor && canConnectFMP && canConnectIM) {
- result |= side.flag
+ result |= (1 << side.getIndex)
}
}
}
result
}
- def bounds(world: IBlockAccess, x: Int, y: Int, z: Int) = Cable.cachedBounds(Cable.neighbors(world, x, y, z)).copy()
+ def bounds(world: IBlockAccess, pos: BlockPos) = Cable.cachedBounds(Cable.neighbors(world, pos))
- private def hasNetworkNode(tileEntity: TileEntity, side: ForgeDirection) =
+ private def hasNetworkNode(tileEntity: TileEntity, side: EnumFacing) =
tileEntity match {
case robot: tileentity.RobotProxy => false
case host: SidedEnvironment =>
- if (host.getWorldObj.isRemote) host.canConnect(side)
+ if (host.getWorld.isRemote) host.canConnect(side)
else host.sidedNode(side) != null
case host: Environment => true
case host if Mods.ForgeMultipart.isAvailable => hasMultiPartNode(tileEntity)
case _ => false
}
- private def hasMultiPartNode(tileEntity: TileEntity) =
+ private def hasMultiPartNode(tileEntity: TileEntity) = false
+ /* TODO FMP
tileEntity match {
case host: TileMultipart => host.partList.exists(_.isInstanceOf[CablePart])
case _ => false
}
+ */
private def cableColor(tileEntity: TileEntity) =
tileEntity match {
case cable: tileentity.Cable => cable.color
case _ =>
if (Mods.ForgeMultipart.isAvailable) cableColorFMP(tileEntity)
- else Color.LightGray
+ else EnumDyeColor.SILVER
}
- private def cableColorFMP(tileEntity: TileEntity) =
+ private def cableColorFMP(tileEntity: TileEntity) = EnumDyeColor.SILVER
+ /* TODO FMP
tileEntity match {
case host: TileMultipart => (host.partList collect {
case cable: CablePart => cable.color
}).headOption.getOrElse(Color.LightGray)
case _ => Color.LightGray
}
+ */
private def canConnectBasedOnColor(te1: TileEntity, te2: TileEntity) = {
val (c1, c2) = (cableColor(te1), cableColor(te2))
- c1 == c2 || c1 == Color.LightGray || c2 == Color.LightGray
+ c1 == c2 || c1 == EnumDyeColor.SILVER || c2 == EnumDyeColor.SILVER
}
- private def canConnectFromSideFMP(tileEntity: TileEntity, side: ForgeDirection) =
+ private def canConnectFromSideFMP(tileEntity: TileEntity, side: EnumFacing) = true
+ /* TODO FMP
tileEntity match {
case host: TileMultipart =>
host.partList.forall {
@@ -168,8 +164,9 @@ object Cable {
}
case _ => true
}
+ */
- private def canConnectFromSideIM(tileEntity: TileEntity, side: ForgeDirection) =
+ private def canConnectFromSideIM(tileEntity: TileEntity, side: EnumFacing) =
tileEntity match {
case im: tileentity.traits.ImmibisMicroblock => im.ImmibisMicroblocks_isSideOpen(side.ordinal)
case _ => true
diff --git a/src/main/scala/li/cil/oc/common/block/Capacitor.scala b/src/main/scala/li/cil/oc/common/block/Capacitor.scala
index b554deaf9..0a8a7eaa2 100644
--- a/src/main/scala/li/cil/oc/common/block/Capacitor.scala
+++ b/src/main/scala/li/cil/oc/common/block/Capacitor.scala
@@ -2,30 +2,23 @@ package li.cil.oc.common.block
import li.cil.oc.common.tileentity
import net.minecraft.block.Block
+import net.minecraft.block.state.IBlockState
+import net.minecraft.util.BlockPos
import net.minecraft.world.World
class Capacitor extends SimpleBlock {
setLightLevel(0.34f)
- override protected def customTextures = Array(
- None,
- Some("CapacitorTop"),
- Some("CapacitorSide"),
- Some("CapacitorSide"),
- Some("CapacitorSide"),
- Some("CapacitorSide")
- )
+ // ----------------------------------------------------------------------- //
+
+ override def hasTileEntity(state: IBlockState) = true
+
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Capacitor()
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
-
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Capacitor()
-
- // ----------------------------------------------------------------------- //
-
- override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) =
- world.getTileEntity(x, y, z) match {
+ override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) =
+ world.getTileEntity(pos) match {
case capacitor: tileentity.Capacitor => capacitor.recomputeCapacity()
case _ =>
}
diff --git a/src/main/scala/li/cil/oc/common/block/Case.scala b/src/main/scala/li/cil/oc/common/block/Case.scala
index befdbed56..fc5e138c7 100644
--- a/src/main/scala/li/cil/oc/common/block/Case.scala
+++ b/src/main/scala/li/cil/oc/common/block/Case.scala
@@ -2,61 +2,62 @@ package li.cil.oc.common.block
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
import li.cil.oc.integration.util.Wrench
-import li.cil.oc.util.BlockPosition
import li.cil.oc.util.Color
import li.cil.oc.util.Tooltip
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemStack
-import net.minecraft.util.IIcon
-import net.minecraft.world.IBlockAccess
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
-class Case(val tier: Int) extends RedstoneAware with traits.PowerAcceptor {
- private val iconsOn = new Array[IIcon](6)
+class Case(val tier: Int) extends RedstoneAware with traits.PowerAcceptor with traits.Rotatable {
+ setDefaultState(buildDefaultState())
- // ----------------------------------------------------------------------- //
-
- override protected def customTextures = Array(
- Some("CaseTop"),
- Some("CaseTop"),
- Some("CaseBack"),
- Some("CaseFront"),
- Some("CaseSide"),
- Some("CaseSide")
- )
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- System.arraycopy(icons, 0, iconsOn, 0, icons.length)
- iconsOn(ForgeDirection.NORTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":CaseBackOn")
- iconsOn(ForgeDirection.WEST.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":CaseSideOn")
- iconsOn(ForgeDirection.EAST.ordinal) = iconsOn(ForgeDirection.WEST.ordinal)
- }
-
- override def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection) = {
- if (world.getTileEntity(x, y, z) match {
- case computer: tileentity.Case => computer.isRunning
- case _ => false
- }) iconsOn(localSide.ordinal)
- else getIcon(localSide.ordinal(), 0)
- }
+ // TODO remove
+// private val iconsOn = new Array[IIcon](6)
+//
+// // ----------------------------------------------------------------------- //
+//
+// override protected def customTextures = Array(
+// Some("CaseTop"),
+// Some("CaseTop"),
+// Some("CaseBack"),
+// Some("CaseFront"),
+// Some("CaseSide"),
+// Some("CaseSide")
+// )
+//
+// override def registerBlockIcons(iconRegister: IIconRegister) = {
+// super.registerBlockIcons(iconRegister)
+// System.arraycopy(icons, 0, iconsOn, 0, icons.length)
+// iconsOn(EnumFacing.NORTH.ordinal) = iconRegister.getAtlasSprite(Settings.resourceDomain + ":CaseBackOn")
+// iconsOn(EnumFacing.WEST.ordinal) = iconRegister.getAtlasSprite(Settings.resourceDomain + ":CaseSideOn")
+// iconsOn(EnumFacing.EAST.ordinal) = iconsOn(EnumFacing.WEST.ordinal)
+// }
+//
+// override def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: EnumFacing, localSide: EnumFacing) = {
+// if (world.getTileEntity(x, y, z) match {
+// case computer: tileentity.Case => computer.isRunning
+// case _ => false
+// }) iconsOn(localSide.ordinal)
+// else getIcon(localSide.ordinal(), 0)
+// }
@SideOnly(Side.CLIENT)
- override def getRenderColor(metadata: Int) = Color.byTier(tier)
+ override def getRenderColor(state: IBlockState) = Color.rgbValues(Color.byTier(tier))
// ----------------------------------------------------------------------- //
- override def rarity = Array(EnumRarity.common, EnumRarity.uncommon, EnumRarity.rare, EnumRarity.epic).apply(tier)
+ override def rarity = Array(EnumRarity.COMMON, EnumRarity.UNCOMMON, EnumRarity.RARE, EnumRarity.EPIC).apply(tier)
override protected def tooltipBody(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
tooltip.addAll(Tooltip.get(getClass.getSimpleName, slots))
@@ -73,21 +74,20 @@ class Case(val tier: Int) extends RedstoneAware with traits.PowerAcceptor {
override def energyThroughput = Settings.get.caseRate(tier)
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Case(tier)
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Case(tier)
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
- if (!player.isSneaking && !Wrench.holdsApplicableWrench(player, BlockPosition(x, y, z))) {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
+ if (!player.isSneaking && !Wrench.holdsApplicableWrench(player, pos)) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Case.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Case.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
else if (player.getCurrentEquippedItem == null) {
if (!world.isRemote) {
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(pos) match {
case computer: tileentity.Case if !computer.machine.isRunning => computer.machine.start()
case _ =>
}
@@ -97,9 +97,9 @@ class Case(val tier: Int) extends RedstoneAware with traits.PowerAcceptor {
else false
}
- override def removedByPlayer(world: World, player: EntityPlayer, x: Int, y: Int, z: Int, willHarvest: Boolean) =
- world.getTileEntity(x, y, z) match {
- case c: tileentity.Case => c.canInteract(player.getCommandSenderName) && super.removedByPlayer(world, player, x, y, z, willHarvest)
- case _ => super.removedByPlayer(world, player, x, y, z, willHarvest)
+ override def removedByPlayer(world: World, pos: BlockPos, player: EntityPlayer, willHarvest: Boolean) =
+ world.getTileEntity(pos) match {
+ case c: tileentity.Case => c.canInteract(player.getName) && super.removedByPlayer(world, pos, player, willHarvest)
+ case _ => super.removedByPlayer(world, pos, player, willHarvest)
}
}
diff --git a/src/main/scala/li/cil/oc/common/block/Charger.scala b/src/main/scala/li/cil/oc/common/block/Charger.scala
index 2e560ffd9..6b2022de1 100644
--- a/src/main/scala/li/cil/oc/common/block/Charger.scala
+++ b/src/main/scala/li/cil/oc/common/block/Charger.scala
@@ -2,74 +2,59 @@ package li.cil.oc.common.block
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
-import li.cil.oc.client.Textures
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
import li.cil.oc.integration.util.Wrench
import li.cil.oc.server.PacketSender
import li.cil.oc.util.BlockPosition
import net.minecraft.block.Block
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
-class Charger extends RedstoneAware with traits.PowerAcceptor {
- override protected def customTextures = Array(
- None,
- None,
- Some("ChargerSide"),
- Some("ChargerFront"),
- Some("ChargerSide"),
- Some("ChargerSide")
- )
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- Textures.Charger.iconFrontCharging = iconRegister.registerIcon(Settings.resourceDomain + ":ChargerFrontOn")
- Textures.Charger.iconSideCharging = iconRegister.registerIcon(Settings.resourceDomain + ":ChargerSideOn")
- }
-
- // ----------------------------------------------------------------------- //
+class Charger extends RedstoneAware with traits.PowerAcceptor with traits.Rotatable {
+ setDefaultState(buildDefaultState())
override def energyThroughput = Settings.get.chargerRate
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Charger()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Charger()
// ----------------------------------------------------------------------- //
- override def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = true
+ override def canConnectRedstone(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = true
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) =
- world.getTileEntity(x, y, z) match {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) =
+ world.getTileEntity(pos) match {
case charger: tileentity.Charger =>
- if (Wrench.holdsApplicableWrench(player, BlockPosition(x, y, z))) {
+ if (Wrench.holdsApplicableWrench(player, pos)) {
if (!world.isRemote) {
charger.invertSignal = !charger.invertSignal
charger.chargeSpeed = 1.0 - charger.chargeSpeed
PacketSender.sendChargerState(charger)
- Wrench.wrenchUsed(player, BlockPosition(x, y, z))
+ Wrench.wrenchUsed(player, pos)
}
true
}
else if (!player.isSneaking) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Charger.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Charger.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
else false
- case _ => super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ)
+ case _ => super.localOnBlockActivated(world, pos, player, side, hitX, hitY, hitZ)
}
- override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) {
- world.getTileEntity(x, y, z) match {
+ override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) {
+ world.getTileEntity(pos) match {
case charger: tileentity.Charger => charger.onNeighborChanged()
case _ =>
}
- super.onNeighborBlockChange(world, x, y, z, block)
+ super.onNeighborBlockChange(world, pos, state, neighborBlock)
}
}
diff --git a/src/main/scala/li/cil/oc/common/block/DelegatorConverter.scala b/src/main/scala/li/cil/oc/common/block/DelegatorConverter.scala
deleted file mode 100644
index a28736bcd..000000000
--- a/src/main/scala/li/cil/oc/common/block/DelegatorConverter.scala
+++ /dev/null
@@ -1,140 +0,0 @@
-package li.cil.oc.common.block
-
-import li.cil.oc.api
-import li.cil.oc.common.tileentity
-import li.cil.oc.integration.util.NEI
-import net.minecraft.block.Block
-import net.minecraft.block.material.Material
-import net.minecraft.entity.Entity
-import net.minecraft.entity.player.EntityPlayer
-import net.minecraft.item.ItemBlock
-import net.minecraft.item.ItemStack
-import net.minecraft.nbt.NBTTagCompound
-import net.minecraft.tileentity.TileEntity
-import net.minecraft.world.World
-
-// TODO Remove in 1.5
-class DelegatorConverter extends Block(Material.rock) {
- NEI.hide(this)
-
- override def hasTileEntity(metadata: Int) = true
-
- // We don't have to register this tile entity because it'll vanish immediately anyway, so
- // it'll not be saved, therefore not be loaded, therefor no need for the mapping.
- override def createTileEntity(world: World, metadata: Int) = new tileentity.traits.TileEntity() {}
-}
-
-object DelegatorConverter {
-
- class Item(block: Block) extends ItemBlock(block) {
- override def getItemStackDisplayName(stack: ItemStack) = "Pick me up to fix me!"
-
- override def onUpdate(stack: ItemStack, world: World, entity: Entity, slot: Int, selected: Boolean) {
- entity match {
- case player: EntityPlayer => DelegatorConverter.convert(stack, this) match {
- case Some(replacement) => player.inventory.setInventorySlotContents(slot, replacement)
- case _ => // Nothing to convert.
- }
- case _ => // Can't convert.
- }
- }
- }
-
- def convert(world: World, x: Int, y: Int, z: Int, data: Option[NBTTagCompound]) {
- val block = world.getBlock(x, y, z)
- val meta = world.getBlockMetadata(x, y, z)
- getDescriptor(block, meta) match {
- case Some(descriptor) =>
- world.setBlock(x, y, z, descriptor.block())
- data.foreach(nbt => world.getTileEntity(x, y, z) match {
- case t: TileEntity => t.readFromNBT(nbt)
- case _ => // Failed.
- })
- case _ => // Nothing to convert.
- }
- }
-
- def convert(stack: ItemStack): ItemStack = {
- if (stack != null) {
- stack.getItem match {
- case item: ItemBlock =>
- convert(stack, item) match {
- case Some(newStack) => return newStack
- case _ =>
- }
- case _ =>
- }
- }
- stack
- }
-
- def convert(stack: ItemStack, item: ItemBlock): Option[ItemStack] = {
- val block = item.field_150939_a
- val meta = stack.getItemDamage
- getDescriptor(block, meta) match {
- case Some(descriptor) =>
- val newStack = descriptor.createItemStack(stack.stackSize)
- if (stack.hasTagCompound) {
- newStack.setTagCompound(stack.getTagCompound.copy().asInstanceOf[NBTTagCompound])
- }
- Option(newStack)
- case _ => None
- }
- }
-
- def getDescriptor(block: Block, meta: Int) = {
- val oldName = Block.blockRegistry.getNameForObject(block)
- val newName = if (oldName == "OpenComputers:simple") convertSimple(meta)
- else if (oldName == "OpenComputers:simple_redstone") convertSimpleRedstone(meta)
- else if (oldName == "OpenComputers:special") convertSpecial(meta)
- else if (oldName == "OpenComputers:special_redstone") convertSpecialRedstone(meta)
- else None
- newName.map(api.Items.get)
- }
-
- private def convertSimple(id: Int): Option[String] = id match {
- case 0 => Option("adapter")
- case 1 => Option("capacitor")
- case 2 => Option("diskDrive")
- case 3 => Option("powerDistributor")
- case 4 => Option("powerConverter")
- case 5 => Option("switch")
- case 6 => Option("screen1")
- case 7 => Option("screen2")
- case 8 => Option("screen3")
- case 9 => Option("accessPoint")
- case 10 => Option("geolyzer")
- case 11 => Option("disassembler")
- case 12 => Option("motionSensor")
- case _ => None
- }
-
- private def convertSimpleRedstone(id: Int): Option[String] = id match {
- case 0 => Option("case1")
- case 1 => Option("case2")
- case 2 => Option("case3")
- case 3 => Option("charger")
- case 4 => Option("redstone")
- case 5 => Option("screen1")
- case 6 => Option("screen2")
- case 7 => Option("screen3")
- case 8 => Option("caseCreative")
- case _ => None
- }
-
- private def convertSpecial(id: Int): Option[String] = id match {
- case 0 => Option("cable")
- case 1 => Option("keyboard")
- case 2 => Option("robotAfterimage")
- case 3 => Option("hologram1")
- case 4 => Option("hologram2")
- case 5 => Option("assembler")
- case _ => None
- }
-
- private def convertSpecialRedstone(id: Int): Option[String] = id match {
- case 0 => Option("robot")
- case 1 => Option("serverRack")
- case _ => None
- }
-}
\ No newline at end of file
diff --git a/src/main/scala/li/cil/oc/common/block/Disassembler.scala b/src/main/scala/li/cil/oc/common/block/Disassembler.scala
index cfcb2b496..f3956f1f7 100644
--- a/src/main/scala/li/cil/oc/common/block/Disassembler.scala
+++ b/src/main/scala/li/cil/oc/common/block/Disassembler.scala
@@ -2,34 +2,17 @@ package li.cil.oc.common.block
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
-import li.cil.oc.client.Textures
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
import li.cil.oc.util.Tooltip
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class Disassembler extends SimpleBlock with traits.PowerAcceptor {
- override protected def customTextures = Array(
- None,
- Some("DisassemblerTop"),
- Some("DisassemblerSide"),
- Some("DisassemblerSide"),
- Some("DisassemblerSide"),
- Some("DisassemblerSide")
- )
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- Textures.Disassembler.iconSideOn = iconRegister.registerIcon(Settings.resourceDomain + ":DisassemblerSideOn")
- Textures.Disassembler.iconTopOn = iconRegister.registerIcon(Settings.resourceDomain + ":DisassemblerTopOn")
- }
-
- // ----------------------------------------------------------------------- //
-
override protected def tooltipBody(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: java.util.List[String], advanced: Boolean) {
tooltip.addAll(Tooltip.get(getClass.getSimpleName, (Settings.get.disassemblerBreakChance * 100).toInt.toString))
}
@@ -38,17 +21,16 @@ class Disassembler extends SimpleBlock with traits.PowerAcceptor {
override def energyThroughput = Settings.get.disassemblerRate
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Disassembler()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Disassembler()
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Disassembler.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Disassembler.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
diff --git a/src/main/scala/li/cil/oc/common/block/DiskDrive.scala b/src/main/scala/li/cil/oc/common/block/DiskDrive.scala
index a5905dc2c..32817803c 100644
--- a/src/main/scala/li/cil/oc/common/block/DiskDrive.scala
+++ b/src/main/scala/li/cil/oc/common/block/DiskDrive.scala
@@ -5,22 +5,15 @@ import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
import li.cil.oc.integration.Mods
import li.cil.oc.util.Tooltip
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
-class DiskDrive extends SimpleBlock {
- override protected def customTextures = Array(
- None,
- None,
- Some("DiskDriveSide"),
- Some("DiskDriveFront"),
- Some("DiskDriveSide"),
- Some("DiskDriveSide")
- )
-
- // ----------------------------------------------------------------------- //
+class DiskDrive extends SimpleBlock with traits.Rotatable {
+ setDefaultState(buildDefaultState())
override protected def tooltipTail(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: java.util.List[String], advanced: Boolean) {
super.tooltipTail(metadata, stack, player, tooltip, advanced)
@@ -31,20 +24,19 @@ class DiskDrive extends SimpleBlock {
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.DiskDrive()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.DiskDrive()
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
- world.getTileEntity(x, y, z) match {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
+ world.getTileEntity(pos) match {
case drive: tileentity.DiskDrive =>
// Behavior: sneaking -> Insert[+Eject], not sneaking -> GUI.
if (!player.isSneaking) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.DiskDrive.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.DiskDrive.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
diff --git a/src/main/scala/li/cil/oc/common/block/Geolyzer.scala b/src/main/scala/li/cil/oc/common/block/Geolyzer.scala
index 03f7f4284..07c53b93c 100644
--- a/src/main/scala/li/cil/oc/common/block/Geolyzer.scala
+++ b/src/main/scala/li/cil/oc/common/block/Geolyzer.scala
@@ -1,31 +1,15 @@
package li.cil.oc.common.block
-import li.cil.oc.Settings
-import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.world.World
class Geolyzer extends SimpleBlock {
setLightLevel(0.14f)
- override protected def customTextures = Array(
- None,
- Some("GeolyzerTop"),
- Some("GeolyzerSide"),
- Some("GeolyzerSide"),
- Some("GeolyzerSide"),
- Some("GeolyzerSide")
- )
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- Textures.Geolyzer.iconTopOn = iconRegister.registerIcon(Settings.resourceDomain + ":GeolyzerTopOn")
- }
-
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Geolyzer()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Geolyzer()
}
diff --git a/src/main/scala/li/cil/oc/common/block/Hologram.scala b/src/main/scala/li/cil/oc/common/block/Hologram.scala
index 488e2e595..df9e2ff40 100644
--- a/src/main/scala/li/cil/oc/common/block/Hologram.scala
+++ b/src/main/scala/li/cil/oc/common/block/Hologram.scala
@@ -2,8 +2,10 @@ package li.cil.oc.common.block
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.block.state.IBlockState
+import net.minecraft.util.BlockPos
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.common.tileentity
import li.cil.oc.util.Tooltip
import net.minecraft.entity.player.EntityPlayer
@@ -11,7 +13,7 @@ import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemStack
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Hologram(val tier: Int) extends SimpleBlock with traits.SpecialBlock {
setLightLevel(1)
@@ -19,25 +21,16 @@ class Hologram(val tier: Int) extends SimpleBlock with traits.SpecialBlock {
// ----------------------------------------------------------------------- //
- override protected def customTextures = Array(
- None,
- Some("HologramTop" + tier),
- Some("HologramSide"),
- Some("HologramSide"),
- Some("HologramSide"),
- Some("HologramSide")
- )
-
- override def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = side == ForgeDirection.DOWN
+ override def isBlockSolid(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = side == EnumFacing.DOWN
@SideOnly(Side.CLIENT)
- override def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = {
- super.shouldSideBeRendered(world, x, y, z, side) || side == ForgeDirection.UP
+ override def shouldSideBeRendered(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = {
+ super.shouldSideBeRendered(world, pos, side) || side == EnumFacing.UP
}
// ----------------------------------------------------------------------- //
- override def rarity = Array(EnumRarity.uncommon, EnumRarity.rare).apply(tier)
+ override def rarity = Array(EnumRarity.UNCOMMON, EnumRarity.RARE).apply(tier)
override protected def tooltipBody(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
tooltip.addAll(Tooltip.get(getClass.getSimpleName + tier))
@@ -45,7 +38,7 @@ class Hologram(val tier: Int) extends SimpleBlock with traits.SpecialBlock {
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Hologram(tier)
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Hologram(tier)
}
diff --git a/src/main/scala/li/cil/oc/common/block/Item.scala b/src/main/scala/li/cil/oc/common/block/Item.scala
index c5e1a481e..a6ee5664b 100644
--- a/src/main/scala/li/cil/oc/common/block/Item.scala
+++ b/src/main/scala/li/cil/oc/common/block/Item.scala
@@ -9,20 +9,20 @@ import li.cil.oc.common.tileentity
import li.cil.oc.util.ItemCosts
import li.cil.oc.util.ItemUtils
import net.minecraft.block.Block
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemBlock
import net.minecraft.item.ItemStack
+import net.minecraft.util.BlockPos
import net.minecraft.util.StatCollector
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import org.lwjgl.input
class Item(value: Block) extends ItemBlock(value) {
setHasSubtypes(true)
- def block = field_150939_a
-
override def addInformation(stack: ItemStack, player: EntityPlayer, tooltip: util.List[_], advanced: Boolean) {
super.addInformation(stack, player, tooltip, advanced)
(block, tooltip) match {
@@ -43,7 +43,7 @@ class Item(value: Block) extends ItemBlock(value) {
override def getRarity(stack: ItemStack) = block match {
case simple: SimpleBlock => simple.rarity
- case _ => EnumRarity.common
+ case _ => EnumRarity.COMMON
}
override def getMetadata(itemDamage: Int) = itemDamage
@@ -55,22 +55,22 @@ class Item(value: Block) extends ItemBlock(value) {
override def isBookEnchantable(a: ItemStack, b: ItemStack) = false
- override def placeBlockAt(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float, metadata: Int) = {
+ override def placeBlockAt(stack: ItemStack, player: EntityPlayer, world: World, pos: BlockPos, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float, newState: IBlockState) = {
// When placing robots in creative mode, we have to copy the stack
// manually before it's placed to ensure different component addresses
// in the different robots, to avoid interference of screens e.g.
val needsCopying = player.capabilities.isCreativeMode && api.Items.get(stack) == api.Items.get("robot")
val stackToUse = if (needsCopying) new ItemUtils.RobotData(stack).copyItemStack() else stack
- if (super.placeBlockAt(stackToUse, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) {
+ if (super.placeBlockAt(stackToUse, player, world, pos, side, hitX, hitY, hitZ, newState)) {
// If it's a rotatable block try to make it face the player.
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(pos) match {
case keyboard: tileentity.Keyboard =>
keyboard.setFromEntityPitchAndYaw(player)
- keyboard.setFromFacing(ForgeDirection.getOrientation(side))
+ keyboard.setFromFacing(side)
case rotatable: tileentity.traits.Rotatable =>
rotatable.setFromEntityPitchAndYaw(player)
if (!rotatable.validFacings.contains(rotatable.pitch)) {
- rotatable.pitch = rotatable.validFacings.headOption.getOrElse(ForgeDirection.NORTH)
+ rotatable.pitch = rotatable.validFacings.headOption.getOrElse(EnumFacing.NORTH)
}
if (!rotatable.isInstanceOf[tileentity.RobotProxy]) {
rotatable.invertRotation()
diff --git a/src/main/scala/li/cil/oc/common/block/Keyboard.scala b/src/main/scala/li/cil/oc/common/block/Keyboard.scala
index 81cd285c8..f52d03bae 100644
--- a/src/main/scala/li/cil/oc/common/block/Keyboard.scala
+++ b/src/main/scala/li/cil/oc/common/block/Keyboard.scala
@@ -4,33 +4,25 @@ import java.util.Random
import li.cil.oc.api
import li.cil.oc.common.tileentity
-import li.cil.oc.util.BlockPosition
-import li.cil.oc.util.ExtendedWorld._
import net.minecraft.block.Block
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.opengl.GL11
-class Keyboard extends SimpleBlock with traits.SpecialBlock {
+class Keyboard extends SimpleBlock with traits.SpecialBlock with traits.OmniRotatable {
setLightOpacity(0)
+ setDefaultState(buildDefaultState())
// For Immibis Microblock support.
val ImmibisMicroblocks_TransformableBlockMarker = null
- override protected def customTextures = Array(
- Some("Keyboard"),
- Some("Keyboard"),
- Some("Keyboard"),
- Some("Keyboard"),
- Some("Keyboard"),
- Some("Keyboard")
- )
+ override def shouldSideBeRendered(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = true
- override def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = true
-
- override def setBlockBoundsForItemRender(metadata: Int) = setBlockBounds(ForgeDirection.NORTH, ForgeDirection.WEST)
+ override def setBlockBoundsForItemRender(metadata: Int) = setBlockBounds(EnumFacing.NORTH, EnumFacing.WEST)
override def preItemRender(metadata: Int) {
GL11.glTranslatef(-0.75f, 0, 0)
@@ -39,83 +31,83 @@ class Keyboard extends SimpleBlock with traits.SpecialBlock {
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Keyboard()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Keyboard()
// ----------------------------------------------------------------------- //
- override def updateTick(world: World, x: Int, y: Int, z: Int, rng: Random) =
- world.getTileEntity(x, y, z) match {
+ override def updateTick(world: World, pos: BlockPos, state: IBlockState, rand: Random) =
+ world.getTileEntity(pos) match {
case keyboard: tileentity.Keyboard => api.Network.joinOrCreateNetwork(keyboard)
case _ =>
}
- override def canPlaceBlockOnSide(world: World, x: Int, y: Int, z: Int, side: ForgeDirection) = {
- world.isSideSolid(x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite) &&
- (world.getTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ) match {
+ override def localCanPlaceBlockOnSide(world: World, pos: BlockPos, side: EnumFacing) = {
+ world.isSideSolid(pos.offset(side), side.getOpposite) &&
+ (world.getTileEntity(pos.offset(side)) match {
case screen: tileentity.Screen => screen.facing != side.getOpposite
case _ => true
})
}
- override protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int) =
- world.getTileEntity(x, y, z) match {
+ override protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, pos: BlockPos) =
+ world.getTileEntity(pos) match {
case keyboard: tileentity.Keyboard => setBlockBounds(keyboard.pitch, keyboard.yaw)
case _ =>
}
- private def setBlockBounds(pitch: ForgeDirection, yaw: ForgeDirection) {
+ private def setBlockBounds(pitch: EnumFacing, yaw: EnumFacing) {
val (forward, up) = pitch match {
- case side@(ForgeDirection.DOWN | ForgeDirection.UP) => (side, yaw)
- case _ => (yaw, ForgeDirection.UP)
+ case side@(EnumFacing.DOWN | EnumFacing.UP) => (side, yaw)
+ case _ => (yaw, EnumFacing.UP)
}
- val side = forward.getRotation(up)
+ val side = forward.rotateAround(up.getAxis)
val sizes = Array(7f / 16f, 4f / 16f, 7f / 16f)
- val x0 = -up.offsetX * sizes(1) - side.offsetX * sizes(2) - forward.offsetX * sizes(0)
- val x1 = up.offsetX * sizes(1) + side.offsetX * sizes(2) - forward.offsetX * 0.5f
- val y0 = -up.offsetY * sizes(1) - side.offsetY * sizes(2) - forward.offsetY * sizes(0)
- val y1 = up.offsetY * sizes(1) + side.offsetY * sizes(2) - forward.offsetY * 0.5f
- val z0 = -up.offsetZ * sizes(1) - side.offsetZ * sizes(2) - forward.offsetZ * sizes(0)
- val z1 = up.offsetZ * sizes(1) + side.offsetZ * sizes(2) - forward.offsetZ * 0.5f
+ val x0 = -up.getFrontOffsetX * sizes(1) - side.getFrontOffsetX * sizes(2) - forward.getFrontOffsetX * sizes(0)
+ val x1 = up.getFrontOffsetX * sizes(1) + side.getFrontOffsetX * sizes(2) - forward.getFrontOffsetX * 0.5f
+ val y0 = -up.getFrontOffsetY * sizes(1) - side.getFrontOffsetY * sizes(2) - forward.getFrontOffsetY * sizes(0)
+ val y1 = up.getFrontOffsetY * sizes(1) + side.getFrontOffsetY * sizes(2) - forward.getFrontOffsetY * 0.5f
+ val z0 = -up.getFrontOffsetZ * sizes(1) - side.getFrontOffsetZ * sizes(2) - forward.getFrontOffsetZ * sizes(0)
+ val z1 = up.getFrontOffsetZ * sizes(1) + side.getFrontOffsetZ * sizes(2) - forward.getFrontOffsetZ * 0.5f
setBlockBounds(
math.min(x0, x1) + 0.5f, math.min(y0, y1) + 0.5f, math.min(z0, z1) + 0.5f,
math.max(x0, x1) + 0.5f, math.max(y0, y1) + 0.5f, math.max(z0, z1) + 0.5f)
}
- override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) =
- world.getTileEntity(x, y, z) match {
- case keyboard: tileentity.Keyboard if canPlaceBlockOnSide(world, x, y, z, keyboard.facing.getOpposite) => // Can stay.
+ override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) =
+ world.getTileEntity(pos) match {
+ case keyboard: tileentity.Keyboard if localCanPlaceBlockOnSide(world, pos, keyboard.facing.getOpposite) => // Can stay.
case _ =>
- dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0)
- world.setBlockToAir(x, y, z)
+ dropBlockAsItem(world, pos, world.getBlockState(pos), 0)
+ world.setBlockToAir(pos)
}
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) =
- adjacencyInfo(world, BlockPosition(x, y, z)) match {
- case Some((keyboard, screen, position, facing)) => screen.rightClick(world, position.x, position.y, position.z, player, facing, 0, 0, 0, force = true)
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) =
+ adjacencyInfo(world, pos) match {
+ case Some((keyboard, screen, blockPos, facing)) => screen.rightClick(world, blockPos, player, facing, 0, 0, 0, force = true)
case _ => false
}
- def adjacencyInfo(world: World, position: BlockPosition) =
- world.getTileEntity(position) match {
+ def adjacencyInfo(world: World, pos: BlockPos) =
+ world.getTileEntity(pos) match {
case keyboard: tileentity.Keyboard =>
- val blockPos = position.offset(keyboard.facing.getOpposite)
- world.getBlock(blockPos) match {
+ val blockPos = pos.offset(keyboard.facing.getOpposite)
+ world.getBlockState(blockPos).getBlock match {
case screen: Screen => Some((keyboard, screen, blockPos, keyboard.facing.getOpposite))
case _ =>
// Special case #1: check for screen in front of the keyboard.
val forward = keyboard.facing match {
- case ForgeDirection.UP | ForgeDirection.DOWN => keyboard.yaw
- case _ => ForgeDirection.UP
+ case EnumFacing.UP | EnumFacing.DOWN => keyboard.yaw
+ case _ => EnumFacing.UP
}
- val blockPos = position.offset(forward)
- world.getBlock(blockPos) match {
+ val blockPos = pos.offset(forward)
+ world.getBlockState(blockPos).getBlock match {
case screen: Screen => Some((keyboard, screen, blockPos, forward))
- case _ if keyboard.facing != ForgeDirection.UP && keyboard.facing != ForgeDirection.DOWN =>
+ case _ if keyboard.facing != EnumFacing.UP && keyboard.facing != EnumFacing.DOWN =>
// Special case #2: check for screen below keyboards on walls.
- val blockPos = position.offset(forward.getOpposite)
- world.getBlock(blockPos) match {
+ val blockPos = pos.offset(forward.getOpposite)
+ world.getBlockState(blockPos).getBlock match {
case screen: Screen => Some((keyboard, screen, blockPos, forward.getOpposite))
case _ => None
}
@@ -125,5 +117,5 @@ class Keyboard extends SimpleBlock with traits.SpecialBlock {
case _ => None
}
- override def getValidRotations(world: World, x: Int, y: Int, z: Int) = null
+ override def getValidRotations(world: World, pos: BlockPos) = null
}
diff --git a/src/main/scala/li/cil/oc/common/block/Microcontroller.scala b/src/main/scala/li/cil/oc/common/block/Microcontroller.scala
index f5e6544f0..c950418e1 100644
--- a/src/main/scala/li/cil/oc/common/block/Microcontroller.scala
+++ b/src/main/scala/li/cil/oc/common/block/Microcontroller.scala
@@ -9,39 +9,34 @@ import li.cil.oc.common.tileentity
import li.cil.oc.integration.util.NEI
import li.cil.oc.integration.util.Wrench
import li.cil.oc.util.BlockPosition
+import li.cil.oc.util.InventoryUtils
import li.cil.oc.util.ItemUtils
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.util.MovingObjectPosition
+import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class Microcontroller extends RedstoneAware with traits.PowerAcceptor {
setCreativeTab(null)
NEI.hide(this)
- override protected def customTextures = Array(
- Some("MicrocontrollerTop"),
- Some("MicrocontrollerTop"),
- Some("MicrocontrollerSide"),
- Some("MicrocontrollerFront"),
- Some("MicrocontrollerSide"),
- Some("MicrocontrollerSide")
- )
-
// ----------------------------------------------------------------------- //
- override def getPickBlock(target: MovingObjectPosition, world: World, x: Int, y: Int, z: Int) =
- world.getTileEntity(x, y, z) match {
+ override def getPickBlock(target: MovingObjectPosition, world: World, pos: BlockPos) =
+ world.getTileEntity(pos) match {
case mcu: tileentity.Microcontroller => mcu.info.copyItemStack()
case _ => null
}
// Custom drop logic for NBT tagged item stack.
- override def getDrops(world: World, x: Int, y: Int, z: Int, metadata: Int, fortune: Int) = new java.util.ArrayList[ItemStack]()
+ override def getDrops(world: IBlockAccess, pos: BlockPos, state: IBlockState, fortune: Int) = new java.util.ArrayList[ItemStack]()
- override def onBlockPreDestroy(world: World, x: Int, y: Int, z: Int, metadata: Int) {}
+ override def onBlockHarvested(worldIn: World, pos: BlockPos, state: IBlockState, player: EntityPlayer) {}
// ----------------------------------------------------------------------- //
@@ -59,15 +54,14 @@ class Microcontroller extends RedstoneAware with traits.PowerAcceptor {
override def energyThroughput = Settings.get.caseRate(Tier.One)
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Microcontroller()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Microcontroller()
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
- if (!player.isSneaking && !Wrench.holdsApplicableWrench(player, BlockPosition(x, y, z))) {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
+ if (!player.isSneaking && !Wrench.holdsApplicableWrench(player, pos)) {
if (!world.isRemote) {
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(pos) match {
case mcu: tileentity.Microcontroller =>
if (mcu.machine.isRunning) mcu.machine.stop()
else mcu.machine.start()
@@ -79,9 +73,9 @@ class Microcontroller extends RedstoneAware with traits.PowerAcceptor {
else false
}
- override def onBlockPlacedBy(world: World, x: Int, y: Int, z: Int, entity: EntityLivingBase, stack: ItemStack) {
- super.onBlockPlacedBy(world, x, y, z, entity, stack)
- if (!world.isRemote) world.getTileEntity(x, y, z) match {
+ override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, placer: EntityLivingBase, stack: ItemStack) {
+ super.onBlockPlacedBy(world, pos, state, placer, stack)
+ if (!world.isRemote) world.getTileEntity(pos) match {
case mcu: tileentity.Microcontroller =>
mcu.info.load(stack)
mcu.snooperNode.changeBuffer(mcu.info.storedEnergy - mcu.snooperNode.localBuffer)
@@ -89,16 +83,16 @@ class Microcontroller extends RedstoneAware with traits.PowerAcceptor {
}
}
- override def removedByPlayer(world: World, player: EntityPlayer, x: Int, y: Int, z: Int, willHarvest: Boolean): Boolean = {
+ override def removedByPlayer(world: World, pos: BlockPos, player: EntityPlayer, willHarvest: Boolean) = {
if (!world.isRemote) {
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(pos) match {
case mcu: tileentity.Microcontroller =>
mcu.saveComponents()
mcu.info.storedEnergy = mcu.snooperNode.localBuffer.toInt
- dropBlockAsItem(world, x, y, z, mcu.info.createItemStack())
+ InventoryUtils.spawnStackInWorld(BlockPosition(pos, world), mcu.info.createItemStack())
case _ =>
}
}
- super.removedByPlayer(world, player, x, y, z, willHarvest)
+ super.removedByPlayer(world, pos, player, willHarvest)
}
}
diff --git a/src/main/scala/li/cil/oc/common/block/MotionSensor.scala b/src/main/scala/li/cil/oc/common/block/MotionSensor.scala
index fb8e99f7e..bb9bf76f5 100644
--- a/src/main/scala/li/cil/oc/common/block/MotionSensor.scala
+++ b/src/main/scala/li/cil/oc/common/block/MotionSensor.scala
@@ -1,21 +1,11 @@
package li.cil.oc.common.block
import li.cil.oc.common.tileentity
+import net.minecraft.block.state.IBlockState
import net.minecraft.world.World
class MotionSensor extends SimpleBlock {
- override protected def customTextures = Array(
- Some("MotionSensorTop"),
- Some("MotionSensorTop"),
- Some("MotionSensorSide"),
- Some("MotionSensorSide"),
- Some("MotionSensorSide"),
- Some("MotionSensorSide")
- )
+ override def hasTileEntity(state: IBlockState) = true
- // ----------------------------------------------------------------------- //
-
- override def hasTileEntity(metadata: Int) = true
-
- override def createTileEntity(world: World, metadata: Int) = new tileentity.MotionSensor()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.MotionSensor()
}
diff --git a/src/main/scala/li/cil/oc/common/block/PowerConverter.scala b/src/main/scala/li/cil/oc/common/block/PowerConverter.scala
index ffbb6fe37..73e6c697a 100644
--- a/src/main/scala/li/cil/oc/common/block/PowerConverter.scala
+++ b/src/main/scala/li/cil/oc/common/block/PowerConverter.scala
@@ -8,6 +8,7 @@ import li.cil.oc.common.tileentity
import li.cil.oc.integration.Mods
import li.cil.oc.integration.util.NEI
import li.cil.oc.util.Tooltip
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.world.World
@@ -22,17 +23,6 @@ class PowerConverter extends SimpleBlock with traits.PowerAcceptor {
// ----------------------------------------------------------------------- //
- override protected def customTextures = Array(
- None,
- None,
- Some("PowerConverterSide"),
- Some("PowerConverterSide"),
- Some("PowerConverterSide"),
- Some("PowerConverterSide")
- )
-
- // ----------------------------------------------------------------------- //
-
override protected def tooltipTail(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
super.tooltipTail(metadata, stack, player, tooltip, advanced)
@@ -67,7 +57,7 @@ class PowerConverter extends SimpleBlock with traits.PowerAcceptor {
override def energyThroughput = Settings.get.powerConverterRate
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.PowerConverter()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.PowerConverter()
}
diff --git a/src/main/scala/li/cil/oc/common/block/PowerDistributor.scala b/src/main/scala/li/cil/oc/common/block/PowerDistributor.scala
index 97f216e23..599751e42 100644
--- a/src/main/scala/li/cil/oc/common/block/PowerDistributor.scala
+++ b/src/main/scala/li/cil/oc/common/block/PowerDistributor.scala
@@ -1,33 +1,16 @@
package li.cil.oc.common.block
-import li.cil.oc.Settings
-import li.cil.oc.client.Textures
import li.cil.oc.common.tileentity
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.world.World
class PowerDistributor extends SimpleBlock {
setLightLevel(0.34f)
- override protected def customTextures = Array(
- None,
- Some("PowerDistributorTop"),
- Some("PowerDistributorSide"),
- Some("PowerDistributorSide"),
- Some("PowerDistributorSide"),
- Some("PowerDistributorSide")
- )
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- Textures.PowerDistributor.iconSideOn = iconRegister.registerIcon(Settings.resourceDomain + ":PowerDistributorSideOn")
- Textures.PowerDistributor.iconTopOn = iconRegister.registerIcon(Settings.resourceDomain + ":PowerDistributorTopOn")
- }
-
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.PowerDistributor()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.PowerDistributor()
}
diff --git a/src/main/scala/li/cil/oc/common/block/Raid.scala b/src/main/scala/li/cil/oc/common/block/Raid.scala
index 84d7c6de5..2c719ac98 100644
--- a/src/main/scala/li/cil/oc/common/block/Raid.scala
+++ b/src/main/scala/li/cil/oc/common/block/Raid.scala
@@ -3,34 +3,26 @@ package li.cil.oc.common.block
import li.cil.oc.OpenComputers
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
-class Raid extends SimpleBlock {
- override protected def customTextures = Array(
- None,
- None,
- Some("RaidSide"),
- Some("RaidFront"),
- Some("RaidSide"),
- Some("RaidSide")
- )
+class Raid extends SimpleBlock with traits.Rotatable {
+ setDefaultState(buildDefaultState())
+
+ override def hasTileEntity(state: IBlockState) = true
+
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Raid()
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
-
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Raid()
-
- // ----------------------------------------------------------------------- //
-
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
- world.getTileEntity(x, y, z) match {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
+ world.getTileEntity(pos) match {
case drive: tileentity.Raid if !player.isSneaking =>
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Raid.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Raid.id, world, pos.getX, pos.getY, pos.getZ)
}
true
case _ => false
diff --git a/src/main/scala/li/cil/oc/common/block/Redstone.scala b/src/main/scala/li/cil/oc/common/block/Redstone.scala
index 06245ab08..29f6e6932 100644
--- a/src/main/scala/li/cil/oc/common/block/Redstone.scala
+++ b/src/main/scala/li/cil/oc/common/block/Redstone.scala
@@ -5,22 +5,12 @@ import java.util
import li.cil.oc.common.tileentity
import li.cil.oc.integration.Mods
import li.cil.oc.util.Tooltip
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.world.World
class Redstone extends RedstoneAware {
- override protected def customTextures = Array(
- Some("RedstoneTop"),
- Some("RedstoneTop"),
- Some("RedstoneSide"),
- Some("RedstoneSide"),
- Some("RedstoneSide"),
- Some("RedstoneSide")
- )
-
- // ----------------------------------------------------------------------- //
-
override protected def tooltipTail(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
super.tooltipTail(metadata, stack, player, tooltip, advanced)
if (Mods.RedLogic.isAvailable) {
@@ -33,5 +23,5 @@ class Redstone extends RedstoneAware {
// ----------------------------------------------------------------------- //
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Redstone()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Redstone()
}
diff --git a/src/main/scala/li/cil/oc/common/block/RedstoneAware.scala b/src/main/scala/li/cil/oc/common/block/RedstoneAware.scala
index 3e4427ae9..50f3e9051 100644
--- a/src/main/scala/li/cil/oc/common/block/RedstoneAware.scala
+++ b/src/main/scala/li/cil/oc/common/block/RedstoneAware.scala
@@ -1,6 +1,8 @@
package li.cil.oc.common.block
-import cpw.mods.fml.common.Optional
+import net.minecraft.block.state.IBlockState
+import net.minecraft.util.BlockPos
+import net.minecraftforge.fml.common.Optional
import li.cil.oc.common.tileentity
import li.cil.oc.integration.Mods
import li.cil.oc.util.BlockPosition
@@ -8,41 +10,44 @@ import li.cil.oc.util.ExtendedWorld._
import net.minecraft.block.Block
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
+/* TODO MFR
import powercrystals.minefactoryreloaded.api.rednet.IRedNetNetworkContainer
import powercrystals.minefactoryreloaded.api.rednet.IRedNetOmniNode
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType
+*/
@Optional.Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.IRedNetOmniNode", modid = Mods.IDs.MineFactoryReloaded)
-abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
- override def hasTileEntity(metadata: Int) = true
+abstract class RedstoneAware extends SimpleBlock /* with IRedNetOmniNode TODO MFR */ {
+ override def hasTileEntity(state: IBlockState) = true
// ----------------------------------------------------------------------- //
override def canProvidePower = true
- override def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
- world.getTileEntity(x, y, z) match {
+ override def canConnectRedstone(world: IBlockAccess, pos: BlockPos, side: EnumFacing) =
+ world.getTileEntity(pos) match {
case redstone: tileentity.traits.RedstoneAware => redstone.isOutputEnabled
case _ => false
}
- override def isProvidingStrongPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
- isProvidingWeakPower(world, x, y, z, side)
+ override def isProvidingStrongPower(world: IBlockAccess, pos: BlockPos, state: IBlockState, side: EnumFacing) =
+ isProvidingWeakPower(world, pos, state, side)
- override def isProvidingWeakPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
- world.getTileEntity(x, y, z) match {
+ override def isProvidingWeakPower(world: IBlockAccess, pos: BlockPos, state: IBlockState, side: EnumFacing) =
+ world.getTileEntity(pos) match {
case redstone: tileentity.traits.RedstoneAware => math.min(math.max(redstone.output(side), 0), 15)
- case _ => super.isProvidingWeakPower(world, x, y, z, side)
+ case _ => super.isProvidingWeakPower(world, pos, state, side)
}
// ----------------------------------------------------------------------- //
- override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) {
+ override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) {
+ /* TODO MFR
if (Mods.MineFactoryReloaded.isAvailable) {
val position = BlockPosition(x, y, z)
world.getTileEntity(position) match {
- case t: tileentity.traits.BundledRedstoneAware => for (side <- ForgeDirection.VALID_DIRECTIONS) {
+ case t: tileentity.traits.BundledRedstoneAware => for (side <- EnumFacing.values) {
world.getBlock(position.offset(side)) match {
case block: IRedNetNetworkContainer =>
case _ => for (color <- 0 until 16) {
@@ -53,7 +58,8 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
case _ =>
}
}
- world.getTileEntity(x, y, z) match {
+ */
+ world.getTileEntity(pos) match {
case redstone: tileentity.traits.RedstoneAware => redstone.checkRedstoneInputChanged()
case _ => // Ignore.
}
@@ -61,27 +67,29 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
// ----------------------------------------------------------------------- //
- override def getConnectionType(world: World, x: Int, y: Int, z: Int, side: ForgeDirection) = RedNetConnectionType.CableAll
+ /* TODO MFR
+ override def getConnectionType(world: World, x: Int, y: Int, z: Int, side: EnumFacing) = RedNetConnectionType.CableAll
- override def getOutputValue(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, color: Int) =
+ override def getOutputValue(world: World, x: Int, y: Int, z: Int, side: EnumFacing, color: Int) =
world.getTileEntity(x, y, z) match {
case t: tileentity.traits.BundledRedstoneAware => t.bundledOutput(side, color)
case _ => 0
}
- override def getOutputValues(world: World, x: Int, y: Int, z: Int, side: ForgeDirection) =
+ override def getOutputValues(world: World, x: Int, y: Int, z: Int, side: EnumFacing) =
world.getTileEntity(x, y, z) match {
case t: tileentity.traits.BundledRedstoneAware => t.bundledOutput(side)
case _ => Array.fill(16)(0)
}
- override def onInputChanged(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, inputValue: Int) {}
+ override def onInputChanged(world: World, x: Int, y: Int, z: Int, side: EnumFacing, inputValue: Int) {}
- override def onInputsChanged(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, inputValues: Array[Int]) =
+ override def onInputsChanged(world: World, x: Int, y: Int, z: Int, side: EnumFacing, inputValues: Array[Int]) =
world.getTileEntity(x, y, z) match {
case t: tileentity.traits.BundledRedstoneAware => for (color <- 0 until 16) {
t.rednetInput(side, color, inputValues(color))
}
case _ =>
}
+ */
}
diff --git a/src/main/scala/li/cil/oc/common/block/RobotAfterimage.scala b/src/main/scala/li/cil/oc/common/block/RobotAfterimage.scala
index b542552a8..aad6f897e 100644
--- a/src/main/scala/li/cil/oc/common/block/RobotAfterimage.scala
+++ b/src/main/scala/li/cil/oc/common/block/RobotAfterimage.scala
@@ -2,112 +2,107 @@ package li.cil.oc.common.block
import java.util.Random
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.common.tileentity
import li.cil.oc.integration.util.NEI
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumRarity
-import net.minecraft.util.IIcon
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.util.MovingObjectPosition
+import net.minecraft.util.Vec3i
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class RobotAfterimage extends SimpleBlock with traits.SpecialBlock {
setLightOpacity(0)
setCreativeTab(null)
NEI.hide(this)
- private var icon: IIcon = _
+ // TODO remove
+// private var icon: IIcon = _
+//
+// // ----------------------------------------------------------------------- //
+//
+// @SideOnly(Side.CLIENT)
+// override def getIcon(side: EnumFacing, metadata: Int) = icon
+//
+// @SideOnly(Side.CLIENT)
+// override def registerBlockIcons(iconRegister: IIconRegister) {
+// super.registerBlockIcons(iconRegister)
+// icon = iconRegister.getAtlasSprite(Settings.resourceDomain + ":GenericTop")
+// }
- // ----------------------------------------------------------------------- //
+ override def shouldSideBeRendered(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = false
- @SideOnly(Side.CLIENT)
- override def getIcon(side: ForgeDirection, metadata: Int) = icon
+ override def isBlockSolid(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = false
- @SideOnly(Side.CLIENT)
- override def registerBlockIcons(iconRegister: IIconRegister) {
- super.registerBlockIcons(iconRegister)
- icon = iconRegister.registerIcon(Settings.resourceDomain + ":GenericTop")
- }
-
- override def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false
-
- override def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false
-
- override def getPickBlock(target: MovingObjectPosition, world: World, x: Int, y: Int, z: Int) =
- findMovingRobot(world, x, y, z) match {
+ override def getPickBlock(target: MovingObjectPosition, world: World, pos: BlockPos) =
+ findMovingRobot(world, pos) match {
case Some(robot) => robot.info.createItemStack()
case _ => null
}
// ----------------------------------------------------------------------- //
- override def rarity = EnumRarity.epic
+ override def rarity = EnumRarity.EPIC
// ----------------------------------------------------------------------- //
- override def isAir(world: IBlockAccess, x: Int, y: Int, z: Int) = true
+ override def isAir(world: IBlockAccess, pos: BlockPos) = true
// ----------------------------------------------------------------------- //
- override def onBlockAdded(world: World, x: Int, y: Int, z: Int) {
- world.scheduleBlockUpdate(x, y, z, this, math.max((Settings.get.moveDelay * 20).toInt, 1) - 1)
+ override def onBlockAdded(world: World, pos: BlockPos, state: IBlockState) {
+ world.scheduleUpdate(pos, this, math.max((Settings.get.moveDelay * 20).toInt, 1) - 1)
}
- override def updateTick(world: World, x: Int, y: Int, z: Int, rng: Random) {
- world.setBlockToAir(x, y, z)
+ override def updateTick(world: World, pos: BlockPos, state: IBlockState, rand: Random) {
+ world.setBlockToAir(pos)
}
- override def removedByPlayer(world: World, player: EntityPlayer, x: Int, y: Int, z: Int, willHarvest: Boolean) = {
- findMovingRobot(world, x, y, z) match {
- case Some(robot) if robot.isAnimatingMove &&
- robot.moveFromX == x &&
- robot.moveFromY == y &&
- robot.moveFromZ == z =>
- robot.proxy.getBlockType.removedByPlayer(world, player, robot.x, robot.y, robot.z, false)
- case _ => super.removedByPlayer(world, player, x, y, z, willHarvest) // Probably broken by the robot we represent.
+ override def removedByPlayer(world: World, pos: BlockPos, player: EntityPlayer, willHarvest: Boolean) = {
+ findMovingRobot(world, pos) match {
+ case Some(robot) if robot.isAnimatingMove && robot.moveFrom.contains(pos) =>
+ robot.proxy.getBlockType.removedByPlayer(world, pos, player, false)
+ case _ => super.removedByPlayer(world, pos, player, willHarvest) // Probably broken by the robot we represent.
}
}
- override protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int) {
- findMovingRobot(world, x, y, z) match {
+ override protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, pos: BlockPos) {
+ findMovingRobot(world, pos) match {
case Some(robot) =>
val block = robot.getBlockType
- block.setBlockBoundsBasedOnState(world, robot.x, robot.y, robot.z)
- val dx = robot.x - robot.moveFromX
- val dy = robot.y - robot.moveFromY
- val dz = robot.z - robot.moveFromZ
+ block.setBlockBoundsBasedOnState(world, robot.getPos)
+ val delta = robot.moveFrom.fold(Vec3i.NULL_VECTOR)(robot.getPos.subtract(_))
setBlockBounds(
- block.getBlockBoundsMinX.toFloat + dx,
- block.getBlockBoundsMinY.toFloat + dy,
- block.getBlockBoundsMinZ.toFloat + dz,
- block.getBlockBoundsMaxX.toFloat + dx,
- block.getBlockBoundsMaxY.toFloat + dy,
- block.getBlockBoundsMaxZ.toFloat + dz)
+ block.getBlockBoundsMinX.toFloat + delta.getX,
+ block.getBlockBoundsMinY.toFloat + delta.getY,
+ block.getBlockBoundsMinZ.toFloat + delta.getZ,
+ block.getBlockBoundsMaxX.toFloat + delta.getX,
+ block.getBlockBoundsMaxY.toFloat + delta.getY,
+ block.getBlockBoundsMaxZ.toFloat + delta.getZ)
case _ => // throw new Exception("Robot afterimage without a robot found. This is a bug!")
}
}
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
- findMovingRobot(world, x, y, z) match {
- case Some(robot) => api.Items.get("robot").block.onBlockActivated(world, robot.x, robot.y, robot.z, player, side.ordinal, hitX, hitY, hitZ)
- case _ => world.setBlockToAir(x, y, z)
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
+ findMovingRobot(world, pos) match {
+ case Some(robot) => api.Items.get("robot").block.onBlockActivated(world, robot.getPos, world.getBlockState(robot.getPos), player, side, hitX, hitY, hitZ)
+ case _ => world.setBlockToAir(pos)
}
}
- def findMovingRobot(world: IBlockAccess, x: Int, y: Int, z: Int): Option[tileentity.Robot] = {
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
- val (tx, ty, tz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
+ def findMovingRobot(world: IBlockAccess, pos: BlockPos): Option[tileentity.Robot] = {
+ for (side <- EnumFacing.values) {
+ val tpos = pos.offset(side)
if (world match {
- case world: World => world.blockExists(tx, ty, tz)
- case _ => !world.isAirBlock(tx, ty, tz)
- }) world.getTileEntity(tx, ty, tz) match {
- case proxy: tileentity.RobotProxy if proxy.robot.moveFromX == x && proxy.robot.moveFromY == y && proxy.robot.moveFromZ == z => return Some(proxy.robot)
+ case world: World => world.isBlockLoaded(tpos)
+ case _ => true
+ }) world.getTileEntity(tpos) match {
+ case proxy: tileentity.RobotProxy if proxy.robot.moveFrom.contains(pos) => return Some(proxy.robot)
case _ =>
}
}
diff --git a/src/main/scala/li/cil/oc/common/block/RobotProxy.scala b/src/main/scala/li/cil/oc/common/block/RobotProxy.scala
index ba0dad2ff..f171b3a69 100644
--- a/src/main/scala/li/cil/oc/common/block/RobotProxy.scala
+++ b/src/main/scala/li/cil/oc/common/block/RobotProxy.scala
@@ -2,8 +2,6 @@ package li.cil.oc.common.block
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api
@@ -13,21 +11,20 @@ import li.cil.oc.common.tileentity
import li.cil.oc.integration.util.NEI
import li.cil.oc.server.PacketSender
import li.cil.oc.server.component.robot
+import li.cil.oc.util.BlockPosition
+import li.cil.oc.util.InventoryUtils
import li.cil.oc.util.ItemUtils
import li.cil.oc.util.Tooltip
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemStack
-import net.minecraft.util.AxisAlignedBB
-import net.minecraft.util.IIcon
-import net.minecraft.util.MovingObjectPosition
-import net.minecraft.util.Vec3
+import net.minecraft.tileentity.TileEntity
+import net.minecraft.util._
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class RobotProxy extends RedstoneAware with traits.SpecialBlock {
setLightOpacity(0)
@@ -36,36 +33,37 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
override val getUnlocalizedName = "Robot"
- private var icon: IIcon = _
-
var moving = new ThreadLocal[Option[tileentity.Robot]] {
override protected def initialValue = None
}
// ----------------------------------------------------------------------- //
- @SideOnly(Side.CLIENT)
- override def registerBlockIcons(iconRegister: IIconRegister) {
- super.registerBlockIcons(iconRegister)
- icon = iconRegister.registerIcon(Settings.resourceDomain + ":GenericTop")
- }
+ // TODO remove
+// private var icon: IIcon = _
+//
+// @SideOnly(Side.CLIENT)
+// override def registerBlockIcons(iconRegister: IIconRegister) {
+// super.registerBlockIcons(iconRegister)
+// icon = iconRegister.getAtlasSprite(Settings.resourceDomain + ":GenericTop")
+// }
+//
+// @SideOnly(Side.CLIENT)
+// override def getIcon(side: EnumFacing, metadata: Int) = icon
- @SideOnly(Side.CLIENT)
- override def getIcon(side: ForgeDirection, metadata: Int) = icon
+ override def shouldSideBeRendered(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = false
- override def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false
+ override def isBlockSolid(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = false
- override def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false
-
- override def getPickBlock(target: MovingObjectPosition, world: World, x: Int, y: Int, z: Int) =
- world.getTileEntity(x, y, z) match {
+ override def getPickBlock(target: MovingObjectPosition, world: World, pos: BlockPos) =
+ world.getTileEntity(pos) match {
case proxy: tileentity.RobotProxy => proxy.robot.info.copyItemStack()
case _ => null
}
// ----------------------------------------------------------------------- //
- override def rarity = EnumRarity.epic
+ override def rarity = EnumRarity.EPIC
override protected def tooltipHead(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
super.tooltipHead(metadata, stack, player, tooltip, advanced)
@@ -106,7 +104,7 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
// ----------------------------------------------------------------------- //
- override def createTileEntity(world: World, metadata: Int) = {
+ override def createTileEntity(world: World, state: IBlockState) = {
moving.get match {
case Some(robot) => new tileentity.RobotProxy(robot)
case _ => new tileentity.RobotProxy()
@@ -117,7 +115,7 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
override def getExplosionResistance(entity: Entity) = 10f
- override def getDrops(world: World, x: Int, y: Int, z: Int, metadata: Int, fortune: Int) = {
+ override def getDrops(world: IBlockAccess, pos: BlockPos, state: IBlockState, fortune: Int) = {
val list = new java.util.ArrayList[ItemStack]()
// Superspecial hack... usually this will not work, because Minecraft calls
@@ -131,10 +129,10 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
// mod calls this before the block is broken *and* calls removedByPlayer
// this will lead to dupes, but in some initial testing this wasn't the
// case anywhere (TE autonomous activator, CC turtles).
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(pos) match {
case proxy: tileentity.RobotProxy =>
val robot = proxy.robot
- if (!world.isRemote) {
+ if (robot.node != null) {
// Update: even more special hack! As discussed here http://git.io/IcNAyg
// some mods call this even when they're not about to actually break the
// block... soooo we need a whitelist to know when to generate a *proper*
@@ -157,44 +155,41 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
private def gettingDropsForActualDrop = new Exception().getStackTrace.exists(element => getDropForRealDropCallers.contains(element.getClassName + "." + element.getMethodName))
- override def intersect(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) = {
- val bounds = getCollisionBoundingBoxFromPool(world, x, y, z)
- world.getTileEntity(x, y, z) match {
+ protected override def intersect(world: World, pos: BlockPos, origin: Vec3, direction: Vec3) = {
+ val bounds = getCollisionBoundingBox(world, pos, world.getBlockState(pos))
+ world.getTileEntity(pos) match {
case proxy: tileentity.RobotProxy if proxy.robot.animationTicksLeft <= 0 && bounds.isVecInside(origin) => null
- case _ => super.intersect(world, x, y, z, origin, direction)
+ case _ => super.intersect(world, pos, origin, direction)
}
}
- override def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int) {
- world.getTileEntity(x, y, z) match {
+ protected override def doSetBlockBoundsBasedOnState(world: IBlockAccess, pos: BlockPos) {
+ world.getTileEntity(pos) match {
case proxy: tileentity.RobotProxy =>
val robot = proxy.robot
- val bounds = AxisAlignedBB.getBoundingBox(0.1, 0.1, 0.1, 0.9, 0.9, 0.9)
+ val bounds = AxisAlignedBB.fromBounds(0.1, 0.1, 0.1, 0.9, 0.9, 0.9)
if (robot.isAnimatingMove) {
val remaining = robot.animationTicksLeft.toDouble / robot.animationTicksTotal.toDouble
- val dx = robot.moveFromX - robot.x
- val dy = robot.moveFromY - robot.y
- val dz = robot.moveFromZ - robot.z
- bounds.offset(dx * remaining, dy * remaining, dz * remaining)
+ val delta = robot.moveFrom.get.subtract(robot.getPos)
+ bounds.offset(delta.getX * remaining, delta.getY * remaining, delta.getZ * remaining)
}
setBlockBounds(bounds)
- case _ => super.doSetBlockBoundsBasedOnState(world, x, y, z)
+ case _ => super.doSetBlockBoundsBasedOnState(world, pos)
}
}
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {
if (!world.isRemote) {
// We only send slot changes to nearby players, so if there was no slot
// change since this player got into range he might have the wrong one,
// so we send him the current one just in case.
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(pos) match {
case proxy: tileentity.RobotProxy if proxy.robot.node.network != null =>
PacketSender.sendRobotSelectedSlotChange(proxy.robot)
- player.openGui(OpenComputers, GuiType.Robot.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Robot.id, world, pos.getX, pos.getY, pos.getZ)
case _ =>
}
}
@@ -202,7 +197,7 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
}
else if (player.getCurrentEquippedItem == null) {
if (!world.isRemote) {
- world.getTileEntity(x, y, z) match {
+ world.getTileEntity(pos) match {
case proxy: tileentity.RobotProxy if !proxy.machine.isRunning => proxy.machine.start()
case _ =>
}
@@ -212,13 +207,13 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
else false
}
- override def onBlockPlacedBy(world: World, x: Int, y: Int, z: Int, entity: EntityLivingBase, stack: ItemStack) {
- super.onBlockPlacedBy(world, x, y, z, entity, stack)
- if (!world.isRemote) ((entity, world.getTileEntity(x, y, z)) match {
+ override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, entity: EntityLivingBase, stack: ItemStack) {
+ super.onBlockPlacedBy(world, pos, state, entity, stack)
+ if (!world.isRemote) ((entity, world.getTileEntity(pos)) match {
case (player: robot.Player, proxy: tileentity.RobotProxy) =>
Some((proxy.robot, player.robot.owner, player.robot.ownerUuid))
case (player: EntityPlayer, proxy: tileentity.RobotProxy) =>
- Some((proxy.robot, player.getCommandSenderName, Option(player.getGameProfile.getId)))
+ Some((proxy.robot, player.getName, Option(player.getGameProfile.getId)))
case _ => None
}) match {
case Some((robot, owner, uuid)) =>
@@ -231,27 +226,27 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
}
}
- override def removedByPlayer(world: World, player: EntityPlayer, x: Int, y: Int, z: Int, willHarvest: Boolean): Boolean = {
- world.getTileEntity(x, y, z) match {
+ override def removedByPlayer(world: World, pos: BlockPos, player: EntityPlayer, willHarvest: Boolean): Boolean = {
+ world.getTileEntity(pos) match {
case proxy: tileentity.RobotProxy =>
val robot = proxy.robot
if (!world.isRemote) {
if (robot.player == player) return false
robot.node.remove()
robot.saveComponents()
- dropBlockAsItem(world, x, y, z, robot.info.createItemStack())
- }
- if (world.getBlock(robot.moveFromX, robot.moveFromY, robot.moveFromZ) == api.Items.get("robotAfterimage").block) {
- world.setBlock(robot.moveFromX, robot.moveFromY, robot.moveFromZ, net.minecraft.init.Blocks.air, 0, 1)
+ InventoryUtils.spawnStackInWorld(BlockPosition(pos, world), robot.info.createItemStack())
}
+ robot.moveFrom.foreach(altPos => if (world.getBlockState(altPos).getBlock == api.Items.get("robotAfterimage").block) {
+ world.setBlockState(altPos, net.minecraft.init.Blocks.air.getDefaultState, 1)
+ })
case _ =>
}
- super.removedByPlayer(world, player, x, y, z, willHarvest)
+ super.removedByPlayer(world, pos, player, willHarvest)
}
- override def onBlockPreDestroy(world: World, x: Int, y: Int, z: Int, metadata: Int) {
+ override def harvestBlock(world: World, player: EntityPlayer, pos: BlockPos, state: IBlockState, te: TileEntity): Unit = {
if (moving.get.isEmpty) {
- super.onBlockPreDestroy(world, x, y, z, metadata)
+ super.harvestBlock(world, player, pos, state, te)
}
}
}
diff --git a/src/main/scala/li/cil/oc/common/block/Screen.scala b/src/main/scala/li/cil/oc/common/block/Screen.scala
index 64df6f24b..d95f0777d 100644
--- a/src/main/scala/li/cil/oc/common/block/Screen.scala
+++ b/src/main/scala/li/cil/oc/common/block/Screen.scala
@@ -2,38 +2,37 @@ package li.cil.oc.common.block
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
import li.cil.oc.integration.util.Wrench
-import li.cil.oc.util.BlockPosition
import li.cil.oc.util.Color
import li.cil.oc.util.PackedColor
import li.cil.oc.util.Tooltip
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.projectile.EntityArrow
import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemStack
-import net.minecraft.util.IIcon
-import net.minecraft.world.IBlockAccess
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
-class Screen(val tier: Int) extends RedstoneAware {
+class Screen(val tier: Int) extends RedstoneAware with traits.OmniRotatable {
setLightLevel(0.34f)
+ setDefaultState(buildDefaultState())
@SideOnly(Side.CLIENT)
- override def getRenderColor(metadata: Int) = Color.byTier(tier)
+ override def getRenderColor(state: IBlockState) = Color.rgbValues(Color.byTier(tier))
// ----------------------------------------------------------------------- //
- override def rarity = Array(EnumRarity.common, EnumRarity.uncommon, EnumRarity.rare).apply(tier)
+ override def rarity = Array(EnumRarity.COMMON, EnumRarity.UNCOMMON, EnumRarity.RARE).apply(tier)
override protected def tooltipBody(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
val (w, h) = Settings.screenResolutionsByTier(tier)
@@ -43,304 +42,303 @@ class Screen(val tier: Int) extends RedstoneAware {
// ----------------------------------------------------------------------- //
- object Icons {
- var b, b2, bbl, bbl2, bbm, bbm2, bbr, bbr2, bhb, bhb2, bhm, bhm2, bht, bht2, bml, bmm, bmr, btl, btm, btr, bvb, bvb2, bvm, bvt, f, f2, fbl, fbl2, fbm, fbm2, fbr, fbr2, fhb, fhb2, fhm, fhm2, fht, fht2, fml, fmm, fmr, ftl, ftm, ftr, fvb, fvb2, fvm, fvt = null: IIcon
-
- def fh = Array(fht, fhm, fhb)
-
- def fv = Array(fvt, fvm, fvb)
-
- def bh = Array(bht, bhm, bhb)
-
- def bv = Array(bvt, bvm, bvb)
-
- def fth = Array(ftl, ftm, ftr)
-
- def fmh = Array(fml, fmm, fmr)
-
- def fbh = Array(fbl, fbm, fbr)
-
- def bth = Array(btl, btm, btr)
-
- def bmh = Array(bml, bmm, bmr)
-
- def bbh = Array(bbl, bbm, bbr)
-
- def ftv = Array(ftl, fml, fbl)
-
- def fmv = Array(ftm, fmm, fbm)
-
- def fbv = Array(ftr, fmr, fbr)
-
- def btv = Array(btl, bml, bbl)
-
- def bmv = Array(btm, bmm, bbm)
-
- def bbv = Array(btr, bmr, bbr)
-
- def fh2 = Array(fht2, fhm2, fhb2)
-
- def fv2 = Array(fvt, fvm, fvb2)
-
- def bh2 = Array(bht2, bhm2, bhb2)
-
- def bv2 = Array(bvt, bvm, bvb2)
-
- def fbh2 = Array(fbl2, fbm2, fbr2)
-
- def bbh2 = Array(bbl2, bbm2, bbr2)
-
- def fud = Icons.fh2 ++ Icons.fv2 ++ Icons.fth ++ Icons.fmh ++ Icons.fbh2
-
- def bud = Icons.bh2.reverse ++ Icons.bv2 ++ Icons.bth.reverse ++ Icons.bmh.reverse ++ Icons.bbh2.reverse
-
- def fsn = Icons.fh ++ Icons.fv ++ Icons.fth ++ Icons.fmh ++ Icons.fbh
-
- def few = Icons.fv ++ Icons.fh ++ Icons.ftv ++ Icons.fmv ++ Icons.fbv
-
- def bsn = Icons.bh ++ Icons.bv ++ Icons.bth ++ Icons.bmh ++ Icons.bbh
-
- def bew = Icons.bv ++ Icons.bh ++ Icons.btv ++ Icons.bmv ++ Icons.bbv
-
- def sud = Array(Icons.bvt, Icons.bvm, Icons.bvb2)
-
- def sse = Array(Icons.bhb2, Icons.bhm2, Icons.bht2)
-
- def snw = Array(Icons.bht2, Icons.bhm2, Icons.bhb2)
-
- def th = Array(Icons.bhb, Icons.bhm, Icons.bht)
-
- def tv = Array(Icons.bvb, Icons.bvm, Icons.bvt)
- }
-
- // This an ugly monstrosity, but it's still better than having to manually
- // compute ambient occlusion in a custom block renderer to keep the lighting
- // pretty... which would be even more grotesque.
- override def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection) =
- world.getTileEntity(x, y, z) match {
- case screen: tileentity.Screen if screen.width > 1 || screen.height > 1 =>
- val right = screen.width - 1
- val bottom = screen.height - 1
- val (px, py) = screen.localPosition
- val (lx, ly) = screen.pitch match {
- case ForgeDirection.NORTH => (px, py)
- case ForgeDirection.UP => screen.yaw match {
- case ForgeDirection.SOUTH =>
- (px, py)
- case ForgeDirection.NORTH =>
- (right - px, bottom - py)
- case ForgeDirection.EAST =>
- (right - px, py)
- case ForgeDirection.WEST =>
- (px, bottom - py)
- case _ => throw new AssertionError("yaw has invalid value")
- }
- case ForgeDirection.DOWN => screen.yaw match {
- case ForgeDirection.SOUTH =>
- (px, bottom - py)
- case ForgeDirection.NORTH =>
- (right - px, py)
- case ForgeDirection.EAST =>
- (right - px, bottom - py)
- case ForgeDirection.WEST =>
- (px, py)
- case _ => throw new AssertionError("yaw has invalid value")
- }
- case _ => throw new AssertionError("pitch has invalid value")
- }
- // See which face we're rendering. We can pretty much treat front and
- // back the same, except with a different texture set. Same goes for
- // left and right sides, as well as top and bottom sides.
- localSide match {
- case ForgeDirection.SOUTH | ForgeDirection.NORTH =>
- val (ud, sn, ew) =
- if (localSide == ForgeDirection.SOUTH) (Icons.fud, Icons.fsn, Icons.few)
- else (Icons.bud, Icons.bsn, Icons.bew)
- val Array(ht, hm, hb, vt, vm, vb, tl, tm, tr, ml, mm, mr, bl, bm, br) = screen.pitch match {
- case ForgeDirection.NORTH => ud
- case _ => screen.yaw match {
- case ForgeDirection.SOUTH | ForgeDirection.NORTH => sn
- case ForgeDirection.EAST | ForgeDirection.WEST => ew
- case _ => throw new AssertionError("yaw has invalid value")
- }
- }
- if (screen.height == 1) {
- if (lx == 0) ht
- else if (lx == right) hb
- else hm
- }
- else if (screen.width == 1) {
- if (ly == 0) vb
- else if (ly == bottom) vt
- else vm
- }
- else {
- if (lx == 0) {
- if (ly == 0) bl
- else if (ly == bottom) tl
- else ml
- }
- else if (lx == right) {
- if (ly == 0) br
- else if (ly == bottom) tr
- else mr
- }
- else {
- if (ly == 0) bm
- else if (ly == bottom) tm
- else mm
- }
- }
- case ForgeDirection.EAST | ForgeDirection.WEST =>
- val (ud, sn, ew) =
- if (localSide == ForgeDirection.EAST) (Icons.sud, Icons.sse, Icons.snw)
- else (Icons.sud, Icons.snw, Icons.sse)
- val Array(t, m, b) = screen.pitch match {
- case ForgeDirection.NORTH => ud
- case _ => screen.yaw match {
- case ForgeDirection.SOUTH | ForgeDirection.EAST => sn
- case ForgeDirection.NORTH | ForgeDirection.WEST => ew
- case _ => throw new AssertionError("yaw has invalid value")
- }
- }
- if (screen.height == 1) {
- Icons.b2
- }
- else {
- if (ly == 0) b
- else if (ly == bottom) t
- else m
- }
- case ForgeDirection.UP | ForgeDirection.DOWN =>
- val (sn, ew) =
- if (localSide == ForgeDirection.UP ^ screen.pitch == ForgeDirection.DOWN) (Icons.snw, Icons.sse)
- else (Icons.sse, Icons.snw)
- val Array(t, m, b) = screen.pitch match {
- case ForgeDirection.NORTH => screen.yaw match {
- case ForgeDirection.SOUTH => Icons.th
- case ForgeDirection.NORTH => Icons.bh
- case ForgeDirection.EAST => Icons.bv
- case ForgeDirection.WEST => Icons.tv
- case _ => throw new AssertionError("yaw has invalid value")
- }
- case _ => screen.yaw match {
- case ForgeDirection.SOUTH | ForgeDirection.WEST => sn
- case ForgeDirection.NORTH | ForgeDirection.EAST => ew
- case _ => throw new AssertionError("yaw has invalid value")
- }
- }
- if (screen.width == 1) {
- if (screen.pitch == ForgeDirection.NORTH) Icons.b
- else Icons.b2
- }
- else {
- if (lx == 0) b
- else if (lx == right) t
- else m
- }
- case _ => null
- }
- case screen: tileentity.Screen =>
- val (f, b, t, s) = screen.pitch match {
- case ForgeDirection.NORTH => (Icons.f2, Icons.b2, Icons.b, Icons.b2)
- case _ => (Icons.f, Icons.b, Icons.b2, Icons.b2)
- }
- localSide match {
- case ForgeDirection.SOUTH => f
- case ForgeDirection.NORTH => b
- case ForgeDirection.DOWN | ForgeDirection.UP => t
- case _ => s
- }
- case _ => getIcon(localSide, 0)
- }
-
- override def getIcon(side: ForgeDirection, metadata: Int) =
- side match {
- case ForgeDirection.SOUTH => Icons.f2
- case ForgeDirection.DOWN | ForgeDirection.UP => Icons.b
- case _ => Icons.b2
- }
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- Icons.b = iconRegister.registerIcon(Settings.resourceDomain + ":screen/b")
- Icons.b2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/b2")
- Icons.bbl = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bbl")
- Icons.bbl2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bbl2")
- Icons.bbm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bbm")
- Icons.bbm2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bbm2")
- Icons.bbr = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bbr")
- Icons.bbr2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bbr2")
- Icons.bhb = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bhb")
- Icons.bhb2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bhb2")
- Icons.bhm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bhm")
- Icons.bhm2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bhm2")
- Icons.bht = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bht")
- Icons.bht2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bht2")
- Icons.bml = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bml")
- Icons.bmm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bmm")
- Icons.bmr = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bmr")
- Icons.btl = iconRegister.registerIcon(Settings.resourceDomain + ":screen/btl")
- Icons.btm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/btm")
- Icons.btr = iconRegister.registerIcon(Settings.resourceDomain + ":screen/btr")
- Icons.bvb = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bvb")
- Icons.bvb2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bvb2")
- Icons.bvm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bvm")
- Icons.bvt = iconRegister.registerIcon(Settings.resourceDomain + ":screen/bvt")
- Icons.f = iconRegister.registerIcon(Settings.resourceDomain + ":screen/f")
- Icons.f2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/f2")
- Icons.fbl = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fbl")
- Icons.fbl2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fbl2")
- Icons.fbm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fbm")
- Icons.fbm2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fbm2")
- Icons.fbr = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fbr")
- Icons.fbr2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fbr2")
- Icons.fhb = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fhb")
- Icons.fhb2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fhb2")
- Icons.fhm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fhm")
- Icons.fhm2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fhm2")
- Icons.fht = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fht")
- Icons.fht2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fht2")
- Icons.fml = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fml")
- Icons.fmm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fmm")
- Icons.fmr = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fmr")
- Icons.ftl = iconRegister.registerIcon(Settings.resourceDomain + ":screen/ftl")
- Icons.ftm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/ftm")
- Icons.ftr = iconRegister.registerIcon(Settings.resourceDomain + ":screen/ftr")
- Icons.fvb = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fvb")
- Icons.fvb2 = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fvb2")
- Icons.fvm = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fvm")
- Icons.fvt = iconRegister.registerIcon(Settings.resourceDomain + ":screen/fvt")
- }
+ // TODO remove
+// object Icons {
+// var b, b2, bbl, bbl2, bbm, bbm2, bbr, bbr2, bhb, bhb2, bhm, bhm2, bht, bht2, bml, bmm, bmr, btl, btm, btr, bvb, bvb2, bvm, bvt, f, f2, fbl, fbl2, fbm, fbm2, fbr, fbr2, fhb, fhb2, fhm, fhm2, fht, fht2, fml, fmm, fmr, ftl, ftm, ftr, fvb, fvb2, fvm, fvt = null: IIcon
+//
+// def fh = Array(fht, fhm, fhb)
+//
+// def fv = Array(fvt, fvm, fvb)
+//
+// def bh = Array(bht, bhm, bhb)
+//
+// def bv = Array(bvt, bvm, bvb)
+//
+// def fth = Array(ftl, ftm, ftr)
+//
+// def fmh = Array(fml, fmm, fmr)
+//
+// def fbh = Array(fbl, fbm, fbr)
+//
+// def bth = Array(btl, btm, btr)
+//
+// def bmh = Array(bml, bmm, bmr)
+//
+// def bbh = Array(bbl, bbm, bbr)
+//
+// def ftv = Array(ftl, fml, fbl)
+//
+// def fmv = Array(ftm, fmm, fbm)
+//
+// def fbv = Array(ftr, fmr, fbr)
+//
+// def btv = Array(btl, bml, bbl)
+//
+// def bmv = Array(btm, bmm, bbm)
+//
+// def bbv = Array(btr, bmr, bbr)
+//
+// def fh2 = Array(fht2, fhm2, fhb2)
+//
+// def fv2 = Array(fvt, fvm, fvb2)
+//
+// def bh2 = Array(bht2, bhm2, bhb2)
+//
+// def bv2 = Array(bvt, bvm, bvb2)
+//
+// def fbh2 = Array(fbl2, fbm2, fbr2)
+//
+// def bbh2 = Array(bbl2, bbm2, bbr2)
+//
+// def fud = Icons.fh2 ++ Icons.fv2 ++ Icons.fth ++ Icons.fmh ++ Icons.fbh2
+//
+// def bud = Icons.bh2.reverse ++ Icons.bv2 ++ Icons.bth.reverse ++ Icons.bmh.reverse ++ Icons.bbh2.reverse
+//
+// def fsn = Icons.fh ++ Icons.fv ++ Icons.fth ++ Icons.fmh ++ Icons.fbh
+//
+// def few = Icons.fv ++ Icons.fh ++ Icons.ftv ++ Icons.fmv ++ Icons.fbv
+//
+// def bsn = Icons.bh ++ Icons.bv ++ Icons.bth ++ Icons.bmh ++ Icons.bbh
+//
+// def bew = Icons.bv ++ Icons.bh ++ Icons.btv ++ Icons.bmv ++ Icons.bbv
+//
+// def sud = Array(Icons.bvt, Icons.bvm, Icons.bvb2)
+//
+// def sse = Array(Icons.bhb2, Icons.bhm2, Icons.bht2)
+//
+// def snw = Array(Icons.bht2, Icons.bhm2, Icons.bhb2)
+//
+// def th = Array(Icons.bhb, Icons.bhm, Icons.bht)
+//
+// def tv = Array(Icons.bvb, Icons.bvm, Icons.bvt)
+// }
+//
+// // This an ugly monstrosity, but it's still better than having to manually
+// // compute ambient occlusion in a custom block renderer to keep the lighting
+// // pretty... which would be even more grotesque.
+// override def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: EnumFacing, localSide: EnumFacing) =
+// world.getTileEntity(x, y, z) match {
+// case screen: tileentity.Screen if screen.width > 1 || screen.height > 1 =>
+// val right = screen.width - 1
+// val bottom = screen.height - 1
+// val (px, py) = screen.localPosition
+// val (lx, ly) = screen.pitch match {
+// case EnumFacing.NORTH => (px, py)
+// case EnumFacing.UP => screen.yaw match {
+// case EnumFacing.SOUTH =>
+// (px, py)
+// case EnumFacing.NORTH =>
+// (right - px, bottom - py)
+// case EnumFacing.EAST =>
+// (right - px, py)
+// case EnumFacing.WEST =>
+// (px, bottom - py)
+// case _ => throw new AssertionError("yaw has invalid value")
+// }
+// case EnumFacing.DOWN => screen.yaw match {
+// case EnumFacing.SOUTH =>
+// (px, bottom - py)
+// case EnumFacing.NORTH =>
+// (right - px, py)
+// case EnumFacing.EAST =>
+// (right - px, bottom - py)
+// case EnumFacing.WEST =>
+// (px, py)
+// case _ => throw new AssertionError("yaw has invalid value")
+// }
+// case _ => throw new AssertionError("pitch has invalid value")
+// }
+// // See which face we're rendering. We can pretty much treat front and
+// // back the same, except with a different texture set. Same goes for
+// // left and right sides, as well as top and bottom sides.
+// localSide match {
+// case EnumFacing.SOUTH | EnumFacing.NORTH =>
+// val (ud, sn, ew) =
+// if (localSide == EnumFacing.SOUTH) (Icons.fud, Icons.fsn, Icons.few)
+// else (Icons.bud, Icons.bsn, Icons.bew)
+// val Array(ht, hm, hb, vt, vm, vb, tl, tm, tr, ml, mm, mr, bl, bm, br) = screen.pitch match {
+// case EnumFacing.NORTH => ud
+// case _ => screen.yaw match {
+// case EnumFacing.SOUTH | EnumFacing.NORTH => sn
+// case EnumFacing.EAST | EnumFacing.WEST => ew
+// case _ => throw new AssertionError("yaw has invalid value")
+// }
+// }
+// if (screen.height == 1) {
+// if (lx == 0) ht
+// else if (lx == right) hb
+// else hm
+// }
+// else if (screen.width == 1) {
+// if (ly == 0) vb
+// else if (ly == bottom) vt
+// else vm
+// }
+// else {
+// if (lx == 0) {
+// if (ly == 0) bl
+// else if (ly == bottom) tl
+// else ml
+// }
+// else if (lx == right) {
+// if (ly == 0) br
+// else if (ly == bottom) tr
+// else mr
+// }
+// else {
+// if (ly == 0) bm
+// else if (ly == bottom) tm
+// else mm
+// }
+// }
+// case EnumFacing.EAST | EnumFacing.WEST =>
+// val (ud, sn, ew) =
+// if (localSide == EnumFacing.EAST) (Icons.sud, Icons.sse, Icons.snw)
+// else (Icons.sud, Icons.snw, Icons.sse)
+// val Array(t, m, b) = screen.pitch match {
+// case EnumFacing.NORTH => ud
+// case _ => screen.yaw match {
+// case EnumFacing.SOUTH | EnumFacing.EAST => sn
+// case EnumFacing.NORTH | EnumFacing.WEST => ew
+// case _ => throw new AssertionError("yaw has invalid value")
+// }
+// }
+// if (screen.height == 1) {
+// Icons.b2
+// }
+// else {
+// if (ly == 0) b
+// else if (ly == bottom) t
+// else m
+// }
+// case EnumFacing.UP | EnumFacing.DOWN =>
+// val (sn, ew) =
+// if (localSide == EnumFacing.UP ^ screen.pitch == EnumFacing.DOWN) (Icons.snw, Icons.sse)
+// else (Icons.sse, Icons.snw)
+// val Array(t, m, b) = screen.pitch match {
+// case EnumFacing.NORTH => screen.yaw match {
+// case EnumFacing.SOUTH => Icons.th
+// case EnumFacing.NORTH => Icons.bh
+// case EnumFacing.EAST => Icons.bv
+// case EnumFacing.WEST => Icons.tv
+// case _ => throw new AssertionError("yaw has invalid value")
+// }
+// case _ => screen.yaw match {
+// case EnumFacing.SOUTH | EnumFacing.WEST => sn
+// case EnumFacing.NORTH | EnumFacing.EAST => ew
+// case _ => throw new AssertionError("yaw has invalid value")
+// }
+// }
+// if (screen.width == 1) {
+// if (screen.pitch == EnumFacing.NORTH) Icons.b
+// else Icons.b2
+// }
+// else {
+// if (lx == 0) b
+// else if (lx == right) t
+// else m
+// }
+// case _ => null
+// }
+// case screen: tileentity.Screen =>
+// val (f, b, t, s) = screen.pitch match {
+// case EnumFacing.NORTH => (Icons.f2, Icons.b2, Icons.b, Icons.b2)
+// case _ => (Icons.f, Icons.b, Icons.b2, Icons.b2)
+// }
+// localSide match {
+// case EnumFacing.SOUTH => f
+// case EnumFacing.NORTH => b
+// case EnumFacing.DOWN | EnumFacing.UP => t
+// case _ => s
+// }
+// case _ => getIcon(localSide, 0)
+// }
+//
+// override def getIcon(side: EnumFacing, metadata: Int) =
+// side match {
+// case EnumFacing.SOUTH => Icons.f2
+// case EnumFacing.DOWN | EnumFacing.UP => Icons.b
+// case _ => Icons.b2
+// }
+//
+// override def registerBlockIcons(iconRegister: IIconRegister) = {
+// Icons.b = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/b")
+// Icons.b2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/b2")
+// Icons.bbl = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bbl")
+// Icons.bbl2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bbl2")
+// Icons.bbm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bbm")
+// Icons.bbm2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bbm2")
+// Icons.bbr = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bbr")
+// Icons.bbr2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bbr2")
+// Icons.bhb = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bhb")
+// Icons.bhb2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bhb2")
+// Icons.bhm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bhm")
+// Icons.bhm2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bhm2")
+// Icons.bht = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bht")
+// Icons.bht2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bht2")
+// Icons.bml = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bml")
+// Icons.bmm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bmm")
+// Icons.bmr = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bmr")
+// Icons.btl = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/btl")
+// Icons.btm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/btm")
+// Icons.btr = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/btr")
+// Icons.bvb = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bvb")
+// Icons.bvb2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bvb2")
+// Icons.bvm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bvm")
+// Icons.bvt = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/bvt")
+// Icons.f = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/f")
+// Icons.f2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/f2")
+// Icons.fbl = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fbl")
+// Icons.fbl2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fbl2")
+// Icons.fbm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fbm")
+// Icons.fbm2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fbm2")
+// Icons.fbr = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fbr")
+// Icons.fbr2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fbr2")
+// Icons.fhb = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fhb")
+// Icons.fhb2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fhb2")
+// Icons.fhm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fhm")
+// Icons.fhm2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fhm2")
+// Icons.fht = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fht")
+// Icons.fht2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fht2")
+// Icons.fml = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fml")
+// Icons.fmm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fmm")
+// Icons.fmr = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fmr")
+// Icons.ftl = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/ftl")
+// Icons.ftm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/ftm")
+// Icons.ftr = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/ftr")
+// Icons.fvb = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fvb")
+// Icons.fvb2 = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fvb2")
+// Icons.fvm = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fvm")
+// Icons.fvt = iconRegister.getAtlasSprite(Settings.resourceDomain + ":screen/fvt")
+// }
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Screen(tier)
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Screen(tier)
// ----------------------------------------------------------------------- //
- override def onBlockPlacedBy(world: World, x: Int, y: Int, z: Int, player: EntityLivingBase, stack: ItemStack) {
- super.onBlockPlacedBy(world, x, y, z, player, stack)
- world.getTileEntity(x, y, z) match {
+ override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, placer: EntityLivingBase, stack: ItemStack) {
+ super.onBlockPlacedBy(world, pos, state, placer, stack)
+ world.getTileEntity(pos) match {
case screen: tileentity.Screen => screen.delayUntilCheckForMultiBlock = 0
case _ =>
}
}
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = rightClick(world, x, y, z, player, side, hitX, hitY, hitZ, force = false)
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = rightClick(world, pos, player, side, hitX, hitY, hitZ, force = false)
- def rightClick(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float, force: Boolean) =
- if (Wrench.holdsApplicableWrench(player, BlockPosition(x, y, z))) false
- else world.getTileEntity(x, y, z) match {
+ def rightClick(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float, force: Boolean) =
+ if (Wrench.holdsApplicableWrench(player, pos)) false
+ else world.getTileEntity(pos) match {
case screen: tileentity.Screen if screen.hasKeyboard && (force || player.isSneaking == screen.invertTouchMode) =>
// Yep, this GUI is actually purely client side. We could skip this
// if, but it is clearer this way (to trigger it from the server we
// would have to give screens a "container", which we do not want).
if (world.isRemote) {
- player.openGui(OpenComputers, GuiType.Screen.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Screen.id, world, pos.getX, pos.getY, pos.getZ)
}
true
case screen: tileentity.Screen if screen.tier > 0 && side == screen.facing =>
@@ -348,48 +346,46 @@ class Screen(val tier: Int) extends RedstoneAware {
case _ => false
}
- override def onEntityWalking(world: World, x: Int, y: Int, z: Int, entity: Entity) =
- if (!world.isRemote) world.getTileEntity(x, y, z) match {
- case screen: tileentity.Screen if screen.tier > 0 && screen.facing == ForgeDirection.UP => screen.walk(entity)
- case _ =>
- }
-
- override def onEntityCollidedWithBlock(world: World, x: Int, y: Int, z: Int, entity: Entity) =
- if (world.isRemote) (entity, world.getTileEntity(x, y, z)) match {
+ override def onEntityCollidedWithBlock(world: World, pos: BlockPos, entity: Entity) =
+ if (world.isRemote) (entity, world.getTileEntity(pos)) match {
case (arrow: EntityArrow, screen: tileentity.Screen) if screen.tier > 0 =>
- val hitX = math.max(0, math.min(1, arrow.posX - x))
- val hitY = math.max(0, math.min(1, arrow.posY - y))
- val hitZ = math.max(0, math.min(1, arrow.posZ - z))
+ val hitX = math.max(0, math.min(1, arrow.posX - pos.getX))
+ val hitY = math.max(0, math.min(1, arrow.posY - pos.getY))
+ val hitZ = math.max(0, math.min(1, arrow.posZ - pos.getZ))
val absX = math.abs(hitX - 0.5)
val absY = math.abs(hitY - 0.5)
val absZ = math.abs(hitZ - 0.5)
val side = if (absX > absY && absX > absZ) {
- if (hitX < 0.5) ForgeDirection.WEST
- else ForgeDirection.EAST
+ if (hitX < 0.5) EnumFacing.WEST
+ else EnumFacing.EAST
}
else if (absY > absZ) {
- if (hitY < 0.5) ForgeDirection.DOWN
- else ForgeDirection.UP
+ if (hitY < 0.5) EnumFacing.DOWN
+ else EnumFacing.UP
}
else {
- if (hitZ < 0.5) ForgeDirection.NORTH
- else ForgeDirection.SOUTH
+ if (hitZ < 0.5) EnumFacing.NORTH
+ else EnumFacing.SOUTH
}
if (side == screen.facing) {
screen.shot(arrow)
}
case _ =>
}
+ else world.getTileEntity(pos) match {
+ case screen: tileentity.Screen if screen.tier > 0 && screen.facing == EnumFacing.UP => screen.walk(entity)
+ case _ =>
+ }
// ----------------------------------------------------------------------- //
- override def getValidRotations(world: World, x: Int, y: Int, z: Int) =
- world.getTileEntity(x, y, z) match {
+ override def getValidRotations(world: World, pos: BlockPos) =
+ world.getTileEntity(pos) match {
case screen: tileentity.Screen =>
- if (screen.facing == ForgeDirection.UP || screen.facing == ForgeDirection.DOWN) ForgeDirection.VALID_DIRECTIONS
- else ForgeDirection.VALID_DIRECTIONS.filter {
+ if (screen.facing == EnumFacing.UP || screen.facing == EnumFacing.DOWN) EnumFacing.values
+ else EnumFacing.values.filter {
d => d != screen.facing && d != screen.facing.getOpposite
}
- case _ => super.getValidRotations(world, x, y, z)
+ case _ => super.getValidRotations(world, pos)
}
}
diff --git a/src/main/scala/li/cil/oc/common/block/ServerRack.scala b/src/main/scala/li/cil/oc/common/block/ServerRack.scala
index fce487c37..cab3f3280 100644
--- a/src/main/scala/li/cil/oc/common/block/ServerRack.scala
+++ b/src/main/scala/li/cil/oc/common/block/ServerRack.scala
@@ -1,63 +1,63 @@
package li.cil.oc.common.block
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
-import li.cil.oc.client.Textures
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class ServerRack extends RedstoneAware with traits.SpecialBlock with traits.PowerAcceptor {
- override protected def customTextures = Array(
- None,
- None,
- Some("ServerRackSide"),
- Some("ServerRackFront"),
- Some("ServerRackSide"),
- Some("ServerRackSide")
- )
-
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- System.arraycopy(icons, 0, Textures.ServerRack.icons, 0, icons.length)
- }
+ // TODO remove
+// override protected def customTextures = Array(
+// None,
+// None,
+// Some("ServerRackSide"),
+// Some("ServerRackFront"),
+// Some("ServerRackSide"),
+// Some("ServerRackSide")
+// )
+//
+// override def registerBlockIcons(iconRegister: IIconRegister) = {
+// super.registerBlockIcons(iconRegister)
+// System.arraycopy(icons, 0, Textures.ServerRack.icons, 0, icons.length)
+// }
@SideOnly(Side.CLIENT)
- override def getMixedBrightnessForBlock(world: IBlockAccess, x: Int, y: Int, z: Int) = {
- world.getTileEntity(x, y, z) match {
+ override def getMixedBrightnessForBlock(world: IBlockAccess, pos: BlockPos) = {
+ world.getTileEntity(pos) match {
case rack: tileentity.ServerRack =>
- def brightness(x: Int, y: Int, z: Int) = world.getLightBrightnessForSkyBlocks(x, y, z, getLightValue(world, x, y, z))
- val value = brightness(x + rack.facing.offsetX, y + rack.facing.offsetY, z + rack.facing.offsetZ)
+ def brightness(pos: BlockPos) = world.getCombinedLight(pos, getLightValue(world, pos))
+ val value = brightness(pos.offset(rack.facing))
val skyBrightness = (value >> 20) & 15
val blockBrightness = (value >> 4) & 15
((skyBrightness * 3 / 4) << 20) | ((blockBrightness * 3 / 4) << 4)
- case _ => super.getMixedBrightnessForBlock(world, x, y, z)
+ case _ => super.getMixedBrightnessForBlock(world, pos)
}
}
- override def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = side == ForgeDirection.SOUTH
+ override def isBlockSolid(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = side == EnumFacing.SOUTH
// ----------------------------------------------------------------------- //
override def energyThroughput = Settings.get.serverRackRate
- override def hasTileEntity(metadata: Int) = true
+ override def hasTileEntity(state: IBlockState) = true
- override def createTileEntity(world: World, metadata: Int) = new tileentity.ServerRack()
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.ServerRack()
// ----------------------------------------------------------------------- //
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Rack.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Rack.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
diff --git a/src/main/scala/li/cil/oc/common/block/SimpleBlock.scala b/src/main/scala/li/cil/oc/common/block/SimpleBlock.scala
index cbd71ad41..4282e4fdb 100644
--- a/src/main/scala/li/cil/oc/common/block/SimpleBlock.scala
+++ b/src/main/scala/li/cil/oc/common/block/SimpleBlock.scala
@@ -1,29 +1,28 @@
package li.cil.oc.common.block
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.CreativeTab
-import li.cil.oc.Settings
import li.cil.oc.common.tileentity
import li.cil.oc.common.tileentity.traits.Colored
import li.cil.oc.common.tileentity.traits.Inventory
import li.cil.oc.common.tileentity.traits.Rotatable
+import li.cil.oc.util.BlockPosition
import li.cil.oc.util.Color
import li.cil.oc.util.Tooltip
import net.minecraft.block.Block
import net.minecraft.block.material.Material
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.Entity
-import net.minecraft.entity.EnumCreatureType
+import net.minecraft.entity.EntityLiving.SpawnPlacementType
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.item.EnumDyeColor
import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemStack
-import net.minecraft.util.AxisAlignedBB
-import net.minecraft.util.IIcon
-import net.minecraft.util.Vec3
+import net.minecraft.tileentity.TileEntity
+import net.minecraft.util._
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class SimpleBlock(material: Material = Material.iron) extends Block(material) {
setHardness(2f)
@@ -31,7 +30,7 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
var showInItemList = true
- protected val validRotations_ = Array(ForgeDirection.UP, ForgeDirection.DOWN)
+ protected val validRotations_ = Array(EnumFacing.UP, EnumFacing.DOWN)
def createItemStack(amount: Int = 1) = new ItemStack(this, amount)
@@ -39,49 +38,13 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
// Rendering
// ----------------------------------------------------------------------- //
- val icons = new Array[IIcon](6)
-
- protected def customTextures = Array.fill[Option[String]](6)(None)
-
- override def getRenderType = Settings.blockRenderId
-
@SideOnly(Side.CLIENT)
- override def colorMultiplier(world: IBlockAccess, x: Int, y: Int, z: Int) =
- world.getTileEntity(x, y, z) match {
- case colored: Colored => colored.color
- case _ => getRenderColor(world.getBlockMetadata(x, y, z))
+ override def colorMultiplier(world: IBlockAccess, pos: BlockPos, renderPass: Int) =
+ world.getTileEntity(pos) match {
+ case colored: Colored => Color.rgbValues(colored.color)
+ case _ => getRenderColor(world.getBlockState(pos))
}
- @SideOnly(Side.CLIENT)
- final override def getIcon(side: Int, metadata: Int) = getIcon(ForgeDirection.getOrientation(side), metadata)
-
- @SideOnly(Side.CLIENT)
- def getIcon(side: ForgeDirection, metadata: Int) = icons(side.ordinal())
-
- @SideOnly(Side.CLIENT)
- final override def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int) = getIcon(world, x, y, z, ForgeDirection.getOrientation(side), toLocal(world, x, y, z, ForgeDirection.getOrientation(side)))
-
- @SideOnly(Side.CLIENT)
- def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, globalSide: ForgeDirection, localSide: ForgeDirection) = icons(localSide.ordinal())
-
- @SideOnly(Side.CLIENT)
- override def registerBlockIcons(iconRegister: IIconRegister) {
- icons(ForgeDirection.DOWN.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":GenericTop")
- icons(ForgeDirection.UP.ordinal) = icons(ForgeDirection.DOWN.ordinal)
- icons(ForgeDirection.NORTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":GenericSide")
- icons(ForgeDirection.SOUTH.ordinal) = icons(ForgeDirection.NORTH.ordinal)
- icons(ForgeDirection.WEST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
- icons(ForgeDirection.EAST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
-
- val custom = customTextures
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
- custom(side.ordinal) match {
- case Some(name) => icons(side.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":" + name)
- case _ =>
- }
- }
- }
-
@SideOnly(Side.CLIENT)
def preItemRender(metadata: Int) {}
@@ -89,15 +52,11 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
def setBlockBoundsForItemRender(metadata: Int) = super.setBlockBoundsForItemRender()
- final override def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int) = shouldSideBeRendered(world, x, y, z, ForgeDirection.getOrientation(side))
-
- def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = super.shouldSideBeRendered(world, x, y, z, side.ordinal())
-
// ----------------------------------------------------------------------- //
// ItemBlock
// ----------------------------------------------------------------------- //
- def rarity = EnumRarity.common
+ def rarity = EnumRarity.COMMON
@SideOnly(Side.CLIENT)
def addInformation(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: java.util.List[String], advanced: Boolean) {
@@ -120,26 +79,26 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
// Rotation
// ----------------------------------------------------------------------- //
- def getFacing(world: IBlockAccess, x: Int, y: Int, z: Int) =
- world.getTileEntity(x, y, z) match {
+ def getFacing(world: IBlockAccess, pos: BlockPos) =
+ world.getTileEntity(pos) match {
case tileEntity: Rotatable => tileEntity.facing
- case _ => ForgeDirection.UNKNOWN
+ case _ => EnumFacing.SOUTH
}
- def setFacing(world: World, x: Int, y: Int, z: Int, value: ForgeDirection) =
- world.getTileEntity(x, y, z) match {
+ def setFacing(world: World, pos: BlockPos, value: EnumFacing) =
+ world.getTileEntity(pos) match {
case rotatable: Rotatable => rotatable.setFromFacing(value); true
case _ => false
}
- def setRotationFromEntityPitchAndYaw(world: World, x: Int, y: Int, z: Int, value: Entity) =
- world.getTileEntity(x, y, z) match {
+ def setRotationFromEntityPitchAndYaw(world: World, pos: BlockPos, value: Entity) =
+ world.getTileEntity(pos) match {
case rotatable: Rotatable => rotatable.setFromEntityPitchAndYaw(value); true
case _ => false
}
- def toLocal(world: IBlockAccess, x: Int, y: Int, z: Int, value: ForgeDirection) =
- world.getTileEntity(x, y, z) match {
+ def toLocal(world: IBlockAccess, pos: BlockPos, value: EnumFacing) =
+ world.getTileEntity(pos) match {
case rotatable: Rotatable => rotatable.toLocal(value)
case _ => value
}
@@ -148,39 +107,41 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
// Block
// ----------------------------------------------------------------------- //
- override def isNormalCube(world: IBlockAccess, x: Int, y: Int, z: Int) = true
+ override def isNormalCube(world: IBlockAccess, pos: BlockPos) = true
- override def canHarvestBlock(player: EntityPlayer, meta: Int) = true
+ override def canHarvestBlock(world: IBlockAccess, pos: BlockPos, player: EntityPlayer) = true
- override def canBeReplacedByLeaves(world: IBlockAccess, x: Int, y: Int, z: Int) = false
+ override def canBeReplacedByLeaves(world: IBlockAccess, pos: BlockPos) = false
- override def canCreatureSpawn(creature: EnumCreatureType, world: IBlockAccess, x: Int, y: Int, z: Int) = false
+ override def canCreatureSpawn(world: IBlockAccess, pos: BlockPos, `type`: SpawnPlacementType) = false
- override def getValidRotations(world: World, x: Int, y: Int, z: Int) = validRotations_
+ override def getValidRotations(world: World, pos: BlockPos) = validRotations_
- override def onBlockPreDestroy(world: World, x: Int, y: Int, z: Int, metadata: Int) =
- if (!world.isRemote) world.getTileEntity(x, y, z) match {
+ override def harvestBlock(world: World, player: EntityPlayer, pos: BlockPos, state: IBlockState, te: TileEntity) = {
+ if (!world.isRemote) te match {
case inventory: Inventory => inventory.dropAllSlots()
case _ => // Ignore.
}
+ super.harvestBlock(world, player, pos, state, te)
+ }
// ----------------------------------------------------------------------- //
- override def rotateBlock(world: World, x: Int, y: Int, z: Int, axis: ForgeDirection) =
- world.getTileEntity(x, y, z) match {
+ override def rotateBlock(world: World, pos: BlockPos, axis: EnumFacing) =
+ world.getTileEntity(pos) match {
case rotatable: tileentity.traits.Rotatable if rotatable.rotate(axis) =>
- world.markBlockForUpdate(x, y, z)
+ world.markBlockForUpdate(pos)
true
case _ => false
}
- override def recolourBlock(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, colour: Int) =
- world.getTileEntity(x, y, z) match {
- case colored: Colored if colored.color != colour =>
- colored.color = colour
- world.markBlockForUpdate(x, y, z)
+ override def recolorBlock(world: World, pos: BlockPos, side: EnumFacing, color: EnumDyeColor) =
+ world.getTileEntity(pos) match {
+ case colored: Colored if colored.color != color =>
+ colored.color = color
+ world.markBlockForUpdate(pos)
false // Don't consume items.
- case _ => super.recolourBlock(world, x, y, z, side, colour)
+ case _ => super.recolorBlock(world, pos, side, color)
}
// This function can mess things up badly in single player if not
@@ -189,11 +150,11 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
// The other place where this is locked is in collisionRayTrace below,
// which seems to be the only built-in function that *logically* depends
// on the state bounds (rest is rendering which is unimportant).
- final override def setBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int) =
- this.synchronized(doSetBlockBoundsBasedOnState(world, x, y, z))
+ final override def setBlockBoundsBasedOnState(world: IBlockAccess, pos: BlockPos) =
+ this.synchronized(doSetBlockBoundsBasedOnState(world, pos))
- protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int): Unit =
- super.setBlockBoundsBasedOnState(world, x, y, z)
+ protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, pos: BlockPos): Unit =
+ super.setBlockBoundsBasedOnState(world, pos)
protected def setBlockBounds(bounds: AxisAlignedBB) {
setBlockBounds(
@@ -206,58 +167,42 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
}
// NOTE: must not be final for immibis microblocks to work.
- override def collisionRayTrace(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) =
- this.synchronized(intersect(world, x, y, z, origin, direction))
+ override def collisionRayTrace(world: World, pos: BlockPos, origin: Vec3, end: Vec3) =
+ this.synchronized(intersect(world, pos, origin, end))
- override def getCollisionBoundingBoxFromPool(world: World, x: Int, y: Int, z: Int) = this.synchronized {
- doSetBlockBoundsBasedOnState(world, x, y, z)
- super.getCollisionBoundingBoxFromPool(world, x, y, z)
+ override def getCollisionBoundingBox(world: World, pos: BlockPos, state: IBlockState) = this.synchronized {
+ doSetBlockBoundsBasedOnState(world, pos)
+ super.getCollisionBoundingBox(world, pos, state)
}
- protected def intersect(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) =
- super.collisionRayTrace(world, x, y, z, origin, direction)
+ protected def intersect(world: World, pos: BlockPos, origin: Vec3, end: Vec3) =
+ super.collisionRayTrace(world, pos, origin, end)
- final override def canPlaceBlockOnSide(world: World, x: Int, y: Int, z: Int, side: Int) =
- canPlaceBlockOnSide(world, x, y, z, toLocal(world, x, y, z, ForgeDirection.getOrientation(side).getOpposite))
+ final override def canPlaceBlockOnSide(world: World, pos: BlockPos, side: EnumFacing) =
+ localCanPlaceBlockOnSide(world, pos, toLocal(world, pos, side.getOpposite))
- def canPlaceBlockOnSide(world: World, x: Int, y: Int, z: Int, side: ForgeDirection) =
- super.canPlaceBlockOnSide(world, x, y, z, side.getOpposite.ordinal)
+ def localCanPlaceBlockOnSide(world: World, pos: BlockPos, side: EnumFacing) =
+ super.canPlaceBlockOnSide(world, BlockPosition(pos).toBlockPos, side.getOpposite)
// ----------------------------------------------------------------------- //
- final override def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int) =
- canConnectRedstone(world, x, y, z, side match {
- case -1 => ForgeDirection.UP
- case 0 => ForgeDirection.NORTH
- case 1 => ForgeDirection.EAST
- case 2 => ForgeDirection.SOUTH
- case 3 => ForgeDirection.WEST
- })
+ override def canConnectRedstone(world: IBlockAccess, pos: BlockPos, side: EnumFacing) = false
- def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false
+ override def isProvidingStrongPower(worldIn: IBlockAccess, pos: BlockPos, state: IBlockState, side: EnumFacing) = super.isProvidingWeakPower(worldIn, pos, state, side)
- final override def isProvidingStrongPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int) =
- isProvidingStrongPower(world, x, y, z, ForgeDirection.getOrientation(side).getOpposite)
-
- def isProvidingStrongPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
- isProvidingWeakPower(world, x, y, z, side)
-
- final override def isProvidingWeakPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int) =
- isProvidingWeakPower(world, x, y, z, ForgeDirection.getOrientation(side).getOpposite)
-
- def isProvidingWeakPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = 0
+ override def isProvidingWeakPower(worldIn: IBlockAccess, pos: BlockPos, state: IBlockState, side: EnumFacing) = 0
// ----------------------------------------------------------------------- //
// NOTE: must not be final for immibis microblocks to work.
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean =
- world.getTileEntity(x, y, z) match {
+ override def onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) =
+ world.getTileEntity(pos) match {
case colored: Colored if Color.isDye(player.getHeldItem) =>
colored.color = Color.dyeColor(player.getHeldItem)
- world.markBlockForUpdate(x, y, z)
+ world.markBlockForUpdate(pos)
true
- case _ => onBlockActivated(world, x, y, z, player, ForgeDirection.getOrientation(side), hitX, hitY, hitZ)
+ case _ => localOnBlockActivated(world, pos, player, side, hitX, hitY, hitZ)
}
- def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = false
+ def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = false
}
diff --git a/src/main/scala/li/cil/oc/common/block/Switch.scala b/src/main/scala/li/cil/oc/common/block/Switch.scala
index 841c047b0..8236315b4 100644
--- a/src/main/scala/li/cil/oc/common/block/Switch.scala
+++ b/src/main/scala/li/cil/oc/common/block/Switch.scala
@@ -1,45 +1,27 @@
package li.cil.oc.common.block
import li.cil.oc.OpenComputers
-import li.cil.oc.Settings
-import li.cil.oc.client.Textures
import li.cil.oc.common.GuiType
import li.cil.oc.common.tileentity
-import net.minecraft.client.renderer.texture.IIconRegister
+import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class Switch extends SimpleBlock {
- override protected def customTextures = Array(
- None,
- Some("SwitchTop"),
- Some("SwitchSide"),
- Some("SwitchSide"),
- Some("SwitchSide"),
- Some("SwitchSide")
- )
+ override def hasTileEntity(state: IBlockState) = true
- override def registerBlockIcons(iconRegister: IIconRegister) = {
- super.registerBlockIcons(iconRegister)
- Textures.Switch.iconSideActivity = iconRegister.registerIcon(Settings.resourceDomain + ":SwitchSideOn")
- }
+ override def createTileEntity(world: World, state: IBlockState) = new tileentity.Switch()
// ----------------------------------------------------------------------- //
- override def hasTileEntity(metadata: Int) = true
-
- override def createTileEntity(world: World, metadata: Int) = new tileentity.Switch()
-
- // ----------------------------------------------------------------------- //
-
- override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
- side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
- world.getTileEntity(x, y, z) match {
+ override def localOnBlockActivated(world: World, pos: BlockPos, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
+ world.getTileEntity(pos) match {
case switch: tileentity.Switch =>
if (!player.isSneaking) {
if (!world.isRemote) {
- player.openGui(OpenComputers, GuiType.Switch.id, world, x, y, z)
+ player.openGui(OpenComputers, GuiType.Switch.id, world, pos.getX, pos.getY, pos.getZ)
}
true
}
diff --git a/src/main/scala/li/cil/oc/common/block/traits/OmniRotatable.scala b/src/main/scala/li/cil/oc/common/block/traits/OmniRotatable.scala
new file mode 100644
index 000000000..5d79dc3af
--- /dev/null
+++ b/src/main/scala/li/cil/oc/common/block/traits/OmniRotatable.scala
@@ -0,0 +1,38 @@
+package li.cil.oc.common.block.traits
+
+import com.google.common.base.Predicate
+import com.google.common.base.Predicates
+import net.minecraft.block.Block
+import net.minecraft.block.properties.PropertyDirection
+import net.minecraft.block.state.BlockState
+import net.minecraft.block.state.IBlockState
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
+
+trait OmniRotatable extends Block {
+ final lazy val Facing = PropertyDirection.create("facing", Predicates.instanceOf(classOf[EnumFacing]))
+ final lazy val Up = PropertyDirection.create("up", EnumFacing.Plane.HORIZONTAL.asInstanceOf[Predicate[EnumFacing]])
+
+ protected def buildDefaultState() = getBlockState.getBaseState.withProperty(Facing, EnumFacing.NORTH).withProperty(Up, EnumFacing.NORTH)
+
+ @SideOnly(Side.CLIENT)
+ override def getStateForEntityRender(state: IBlockState) = getDefaultState.withProperty(Facing, EnumFacing.SOUTH)
+
+ override def getStateFromMeta(meta: Int) = {
+ val facing = EnumFacing.getFront(meta >>> 3)
+ val up = EnumFacing.getHorizontal(meta & 7)
+ if (up.getAxis == EnumFacing.Axis.Y)
+ getDefaultState.withProperty(Facing, facing).withProperty(Up, EnumFacing.NORTH)
+ else
+ getDefaultState.withProperty(Facing, facing).withProperty(Up, up)
+ }
+
+ override def getMetaFromState(state: IBlockState) = {
+ val facing = state.getValue(Facing).asInstanceOf[EnumFacing]
+ val up = state.getValue(Up).asInstanceOf[EnumFacing]
+ facing.getIndex << 3 | up.getHorizontalIndex
+ }
+
+ override def createBlockState() = new BlockState(this, Facing, Up)
+}
diff --git a/src/main/scala/li/cil/oc/common/block/traits/Rotatable.scala b/src/main/scala/li/cil/oc/common/block/traits/Rotatable.scala
new file mode 100644
index 000000000..a2f845295
--- /dev/null
+++ b/src/main/scala/li/cil/oc/common/block/traits/Rotatable.scala
@@ -0,0 +1,31 @@
+package li.cil.oc.common.block.traits
+
+import com.google.common.base.Predicate
+import net.minecraft.block.Block
+import net.minecraft.block.properties.PropertyDirection
+import net.minecraft.block.state.BlockState
+import net.minecraft.block.state.IBlockState
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
+
+trait Rotatable extends Block {
+ final lazy val Facing = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL.asInstanceOf[Predicate[EnumFacing]])
+
+ protected def buildDefaultState() = getBlockState.getBaseState.withProperty(Facing, EnumFacing.NORTH)
+
+ @SideOnly(Side.CLIENT)
+ override def getStateForEntityRender(state: IBlockState) = getDefaultState.withProperty(Facing, EnumFacing.SOUTH)
+
+ override def getStateFromMeta(meta: Int) = {
+ val facing = EnumFacing.getFront(meta)
+ if (facing.getAxis == EnumFacing.Axis.Y)
+ getDefaultState.withProperty(Facing, EnumFacing.NORTH)
+ else
+ getDefaultState.withProperty(Facing, facing)
+ }
+
+ override def getMetaFromState(state: IBlockState) = state.getValue(Facing).asInstanceOf[EnumFacing].getIndex
+
+ override def createBlockState() = new BlockState(this, Facing)
+}
diff --git a/src/main/scala/li/cil/oc/common/block/traits/SpecialBlock.scala b/src/main/scala/li/cil/oc/common/block/traits/SpecialBlock.scala
index 242b5a037..1e27dd69c 100644
--- a/src/main/scala/li/cil/oc/common/block/traits/SpecialBlock.scala
+++ b/src/main/scala/li/cil/oc/common/block/traits/SpecialBlock.scala
@@ -1,17 +1,14 @@
package li.cil.oc.common.block.traits
import li.cil.oc.common.block.SimpleBlock
+import net.minecraft.util.BlockPos
import net.minecraft.world.IBlockAccess
-import net.minecraftforge.common.util.ForgeDirection
trait SpecialBlock extends SimpleBlock {
- override def isNormalCube(world: IBlockAccess, x: Int, y: Int, z: Int) = false
+ override def isNormalCube(world: IBlockAccess, pos: BlockPos) = false
override def isOpaqueCube = false
- override def renderAsNormalBlock = false
-
- final override def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int) = isBlockSolid(world, x, y, z, toLocal(world, x, y, z, ForgeDirection.getOrientation(side)))
-
- def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = super.isBlockSolid(world, x, y, z, side.ordinal())
+ // TODO new equivalent?
+// override def renderAsNormalBlock = false
}
diff --git a/src/main/scala/li/cil/oc/common/component/Terminal.scala b/src/main/scala/li/cil/oc/common/component/Terminal.scala
index 6712c545d..c33e4e27a 100644
--- a/src/main/scala/li/cil/oc/common/component/Terminal.scala
+++ b/src/main/scala/li/cil/oc/common/component/Terminal.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.component
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.component.Keyboard.UsabilityChecker
@@ -68,7 +68,7 @@ class Terminal(val rack: tileentity.ServerRack, val number: Int) {
if (nbt.hasKey(Settings.namespace + "key")) {
keys += nbt.getString(Settings.namespace + "key")
}
- nbt.getTagList(Settings.namespace + "keys", NBT.TAG_STRING).foreach((tag: NBTTagString) => keys += tag.func_150285_a_())
+ nbt.getTagList(Settings.namespace + "keys", NBT.TAG_STRING).foreach((tag: NBTTagString) => keys += tag.getString)
}
def save(nbt: NBTTagCompound) {
@@ -80,7 +80,7 @@ class Terminal(val rack: tileentity.ServerRack, val number: Int) {
@SideOnly(Side.CLIENT)
def readFromNBTForClient(nbt: NBTTagCompound) {
buffer.load(nbt)
- nbt.getTagList("keys", NBT.TAG_STRING).foreach((tag: NBTTagString) => keys += tag.func_150285_a_())
+ nbt.getTagList("keys", NBT.TAG_STRING).foreach((tag: NBTTagString) => keys += tag.getString)
}
def writeToNBTForClient(nbt: NBTTagCompound) {
diff --git a/src/main/scala/li/cil/oc/common/component/TextBuffer.scala b/src/main/scala/li/cil/oc/common/component/TextBuffer.scala
index 661e21802..16b536225 100644
--- a/src/main/scala/li/cil/oc/common/component/TextBuffer.scala
+++ b/src/main/scala/li/cil/oc/common/component/TextBuffer.scala
@@ -1,9 +1,9 @@
package li.cil.oc.common.component
import com.google.common.base.Strings
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api
@@ -657,22 +657,22 @@ object TextBuffer {
}
override def mouseDown(x: Int, y: Int, button: Int, player: EntityPlayer) {
- if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "touch", Int.box(x), Int.box(y), Int.box(button), player.getCommandSenderName)
+ if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "touch", Int.box(x), Int.box(y), Int.box(button), player.getName)
else owner.node.sendToReachable("computer.checked_signal", player, "touch", Int.box(x), Int.box(y), Int.box(button))
}
override def mouseDrag(x: Int, y: Int, button: Int, player: EntityPlayer) {
- if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "drag", Int.box(x), Int.box(y), Int.box(button), player.getCommandSenderName)
+ if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "drag", Int.box(x), Int.box(y), Int.box(button), player.getName)
else owner.node.sendToReachable("computer.checked_signal", player, "drag", Int.box(x), Int.box(y), Int.box(button))
}
override def mouseUp(x: Int, y: Int, button: Int, player: EntityPlayer) {
- if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "drop", Int.box(x), Int.box(y), Int.box(button), player.getCommandSenderName)
+ if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "drop", Int.box(x), Int.box(y), Int.box(button), player.getName)
else owner.node.sendToReachable("computer.checked_signal", player, "drop", Int.box(x), Int.box(y), Int.box(button))
}
override def mouseScroll(x: Int, y: Int, delta: Int, player: EntityPlayer) {
- if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "scroll", Int.box(x), Int.box(y), Int.box(delta), player.getCommandSenderName)
+ if (Settings.get.inputUsername) owner.node.sendToReachable("computer.checked_signal", player, "scroll", Int.box(x), Int.box(y), Int.box(delta), player.getName)
else owner.node.sendToReachable("computer.checked_signal", player, "scroll", Int.box(x), Int.box(y), Int.box(delta))
}
diff --git a/src/main/scala/li/cil/oc/common/container/Assembler.scala b/src/main/scala/li/cil/oc/common/container/Assembler.scala
index 9829bbd4f..49c651488 100644
--- a/src/main/scala/li/cil/oc/common/container/Assembler.scala
+++ b/src/main/scala/li/cil/oc/common/container/Assembler.scala
@@ -1,14 +1,14 @@
package li.cil.oc.common.container
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
-import li.cil.oc.client.gui.Icons
+import li.cil.oc.client.Textures
import li.cil.oc.common
import li.cil.oc.common.InventorySlots.InventorySlot
import li.cil.oc.common.template.AssemblerTemplates
import li.cil.oc.common.tileentity
import li.cil.oc.util.SideTracker
import net.minecraft.entity.player.InventoryPlayer
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Assembler) extends Player(playerInventory, assembler) {
// Computer case.
@@ -16,9 +16,9 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse
val index = inventorySlots.size
addSlotToContainer(new StaticComponentSlot(this, otherInventory, index, 12, 12, "template", common.Tier.Any) {
@SideOnly(Side.CLIENT) override
- def func_111238_b() = !isAssembling && super.func_111238_b()
+ def canBeHovered = !isAssembling && super.canBeHovered
- override def getBackgroundIconIndex = if (isAssembling) Icons.get(common.Tier.None) else super.getBackgroundIconIndex
+ override def getBackgroundLocation = if (isAssembling) Textures.Icons.get(common.Tier.None) else super.getBackgroundLocation
})
}
diff --git a/src/main/scala/li/cil/oc/common/container/Case.scala b/src/main/scala/li/cil/oc/common/container/Case.scala
index 326323791..021324c21 100644
--- a/src/main/scala/li/cil/oc/common/container/Case.scala
+++ b/src/main/scala/li/cil/oc/common/container/Case.scala
@@ -46,5 +46,5 @@ class Case(playerInventory: InventoryPlayer, computer: tileentity.Case) extends
addPlayerInventorySlots(8, 84)
override def canInteractWith(player: EntityPlayer) =
- super.canInteractWith(player) && computer.canInteract(player.getCommandSenderName)
+ super.canInteractWith(player) && computer.canInteract(player.getName)
}
\ No newline at end of file
diff --git a/src/main/scala/li/cil/oc/common/container/ComponentSlot.scala b/src/main/scala/li/cil/oc/common/container/ComponentSlot.scala
index b7cde9ff1..c5111158e 100644
--- a/src/main/scala/li/cil/oc/common/container/ComponentSlot.scala
+++ b/src/main/scala/li/cil/oc/common/container/ComponentSlot.scala
@@ -1,12 +1,12 @@
package li.cil.oc.common.container
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.common
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
-import net.minecraft.util.IIcon
+import net.minecraft.util.ResourceLocation
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import scala.collection.convert.WrapAsScala._
@@ -17,14 +17,14 @@ trait ComponentSlot extends Slot {
def tier: Int
- def tierIcon: IIcon
+ def tierIcon: ResourceLocation
var changeListener: Option[Slot => Unit] = None
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override def func_111238_b() = slot != common.Slot.None && tier != common.Tier.None && super.func_111238_b()
+ override def canBeHovered = slot != common.Slot.None && tier != common.Tier.None && super.canBeHovered
override def isItemValid(stack: ItemStack) = inventory.isItemValidForSlot(getSlotIndex, stack)
diff --git a/src/main/scala/li/cil/oc/common/container/Disassembler.scala b/src/main/scala/li/cil/oc/common/container/Disassembler.scala
index 638de7f29..ad072ca8f 100644
--- a/src/main/scala/li/cil/oc/common/container/Disassembler.scala
+++ b/src/main/scala/li/cil/oc/common/container/Disassembler.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.container
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.common.tileentity
import li.cil.oc.util.SideTracker
import net.minecraft.entity.player.InventoryPlayer
diff --git a/src/main/scala/li/cil/oc/common/container/Drone.scala b/src/main/scala/li/cil/oc/common/container/Drone.scala
index 81c17f2cb..9b04861e9 100644
--- a/src/main/scala/li/cil/oc/common/container/Drone.scala
+++ b/src/main/scala/li/cil/oc/common/container/Drone.scala
@@ -1,12 +1,12 @@
package li.cil.oc.common.container
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
-import li.cil.oc.client.gui.Icons
+import li.cil.oc.client.Textures
import li.cil.oc.common
import li.cil.oc.common.entity
import net.minecraft.entity.player.InventoryPlayer
import net.minecraft.inventory.IInventory
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class Drone(playerInventory: InventoryPlayer, drone: entity.Drone) extends Player(playerInventory, drone.inventory) {
val deltaY = 0
@@ -24,13 +24,12 @@ class Drone(playerInventory: InventoryPlayer, drone: entity.Drone) extends Playe
class InventorySlot(container: Player, inventory: IInventory, index: Int, x: Int, y: Int) extends StaticComponentSlot(container, inventory, index, x, y, common.Slot.Any, common.Tier.Any) {
def isValid = (0 until drone.inventory.getSizeInventory).contains(getSlotIndex)
- @SideOnly(Side.CLIENT)
- override def func_111238_b() = isValid && super.func_111238_b()
+ @SideOnly(Side.CLIENT) override
+ def canBeHovered = isValid && super.canBeHovered
- override def getBackgroundIconIndex = {
- if (isValid) super.getBackgroundIconIndex
- else Icons.get(common.Tier.None)
- }
+ override def getBackgroundLocation =
+ if (isValid) super.getBackgroundLocation
+ else Textures.Icons.get(common.Tier.None)
override def getStack = {
if (isValid) super.getStack
diff --git a/src/main/scala/li/cil/oc/common/container/DynamicComponentSlot.scala b/src/main/scala/li/cil/oc/common/container/DynamicComponentSlot.scala
index 81c8e1291..6148d03a2 100644
--- a/src/main/scala/li/cil/oc/common/container/DynamicComponentSlot.scala
+++ b/src/main/scala/li/cil/oc/common/container/DynamicComponentSlot.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.container
-import li.cil.oc.client.gui.Icons
+import li.cil.oc.client.Textures
import li.cil.oc.common
import li.cil.oc.common.InventorySlots.InventorySlot
import li.cil.oc.util.SideTracker
@@ -15,7 +15,7 @@ class DynamicComponentSlot(val container: Player, inventory: IInventory, index:
else mainTier
}
- def tierIcon = Icons.get(tier)
+ def tierIcon = Textures.Icons.get(tier)
def slot = {
val mainTier = containerTierGetter()
@@ -23,7 +23,7 @@ class DynamicComponentSlot(val container: Player, inventory: IInventory, index:
else common.Slot.None
}
- override def getBackgroundIconIndex = Icons.get(slot)
+ override def getBackgroundLocation = Textures.Icons.get(slot)
override def getSlotStackLimit =
slot match {
diff --git a/src/main/scala/li/cil/oc/common/container/Robot.scala b/src/main/scala/li/cil/oc/common/container/Robot.scala
index 65ca25817..3097820ba 100644
--- a/src/main/scala/li/cil/oc/common/container/Robot.scala
+++ b/src/main/scala/li/cil/oc/common/container/Robot.scala
@@ -1,14 +1,14 @@
package li.cil.oc.common.container
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.api
-import li.cil.oc.client.gui.Icons
+import li.cil.oc.client.Textures
import li.cil.oc.common
import li.cil.oc.common.tileentity
import li.cil.oc.util.SideTracker
import net.minecraft.entity.player.InventoryPlayer
import net.minecraft.inventory.IInventory
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class Robot(playerInventory: InventoryPlayer, robot: tileentity.Robot) extends Player(playerInventory, robot) {
val hasScreen = robot.components.exists {
@@ -78,13 +78,12 @@ class Robot(playerInventory: InventoryPlayer, robot: tileentity.Robot) extends P
class InventorySlot(container: Player, inventory: IInventory, index: Int, x: Int, y: Int) extends StaticComponentSlot(container, inventory, index, x, y, common.Slot.Any, common.Tier.Any) {
def isValid = robot.isInventorySlot(getSlotIndex)
- @SideOnly(Side.CLIENT)
- override def func_111238_b() = isValid && super.func_111238_b()
+ @SideOnly(Side.CLIENT) override
+ def canBeHovered = isValid && super.canBeHovered
- override def getBackgroundIconIndex = {
- if (isValid) super.getBackgroundIconIndex
- else Icons.get(common.Tier.None)
- }
+ override def getBackgroundLocation =
+ if (isValid) super.getBackgroundLocation
+ else Textures.Icons.get(common.Tier.None)
override def getStack = {
if (isValid) super.getStack
diff --git a/src/main/scala/li/cil/oc/common/container/ServerRack.scala b/src/main/scala/li/cil/oc/common/container/ServerRack.scala
index 73ea8bacb..c974b0cd7 100644
--- a/src/main/scala/li/cil/oc/common/container/ServerRack.scala
+++ b/src/main/scala/li/cil/oc/common/container/ServerRack.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.container
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.common.tileentity
import li.cil.oc.util.SideTracker
import net.minecraft.entity.player.InventoryPlayer
diff --git a/src/main/scala/li/cil/oc/common/container/StaticComponentSlot.scala b/src/main/scala/li/cil/oc/common/container/StaticComponentSlot.scala
index 0155308b4..fd644601c 100644
--- a/src/main/scala/li/cil/oc/common/container/StaticComponentSlot.scala
+++ b/src/main/scala/li/cil/oc/common/container/StaticComponentSlot.scala
@@ -1,14 +1,14 @@
package li.cil.oc.common.container
-import li.cil.oc.client.gui.Icons
+import li.cil.oc.client.Textures
import li.cil.oc.common
import net.minecraft.inventory.IInventory
import net.minecraft.inventory.Slot
class StaticComponentSlot(val container: Player, inventory: IInventory, index: Int, x: Int, y: Int, val slot: String, val tier: Int) extends Slot(inventory, index, x, y) with ComponentSlot {
- setBackgroundIcon(Icons.get(slot))
+ setBackgroundLocation(Textures.Icons.get(slot))
- val tierIcon = Icons.get(tier)
+ val tierIcon = Textures.Icons.get(tier)
override def getSlotStackLimit =
slot match {
diff --git a/src/main/scala/li/cil/oc/common/container/Switch.scala b/src/main/scala/li/cil/oc/common/container/Switch.scala
index c90cc8d39..7d0541cfb 100644
--- a/src/main/scala/li/cil/oc/common/container/Switch.scala
+++ b/src/main/scala/li/cil/oc/common/container/Switch.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.container
-import cpw.mods.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.FMLCommonHandler
import li.cil.oc.common.Slot
import li.cil.oc.common.tileentity
import net.minecraft.entity.player.InventoryPlayer
diff --git a/src/main/scala/li/cil/oc/common/entity/Drone.scala b/src/main/scala/li/cil/oc/common/entity/Drone.scala
index 5d987e79a..c57642e3e 100644
--- a/src/main/scala/li/cil/oc/common/entity/Drone.scala
+++ b/src/main/scala/li/cil/oc/common/entity/Drone.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.entity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api
@@ -32,7 +32,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.Vec3
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.fluids.IFluidTank
class Drone(val world: World) extends Entity(world) with MachineHost with internal.Drone {
@@ -235,7 +235,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
def inventorySize_=(value: Int) = dataWatcher.updateObject(11, byte2Byte(value.toByte))
@SideOnly(Side.CLIENT)
- override def setPositionAndRotation2(x: Double, y: Double, z: Double, yaw: Float, pitch: Float, data: Int) {
+ override def func_180426_a(x: Double, y: Double, z: Double, yaw: Float, pitch: Float, data: Int, unused: Boolean) {
// Only set exact position if we're too far away from the server's
// position, otherwise keep interpolating. This removes jitter and
// is good enough for drones.
@@ -259,7 +259,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
info.storedEnergy = control.node.localBuffer.toInt
info.save(stack)
val entity = new EntityItem(world, posX, posY, posZ, stack)
- entity.delayBeforeCanPickup = 15
+ entity.setPickupDelay(15)
world.spawnEntityInWorld(entity)
InventoryUtils.dropAllSlots(BlockPosition(this: Entity), inventory)
}
@@ -326,20 +326,20 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
prevPosX = posX
prevPosY = posY
prevPosZ = posZ
- noClip = func_145771_j(posX, (boundingBox.minY + boundingBox.maxY) / 2, posZ)
+ noClip = pushOutOfBlocks(posX, (getEntityBoundingBox.minY + getEntityBoundingBox.maxY) / 2, posZ)
if (isRunning) {
- val toTarget = Vec3.createVectorHelper(targetX - posX, targetY - posY, targetZ - posZ)
+ val toTarget = new Vec3(targetX - posX, targetY - posY, targetZ - posZ)
val distance = toTarget.lengthVector()
- val velocity = Vec3.createVectorHelper(motionX, motionY, motionZ)
+ val velocity = new Vec3(motionX, motionY, motionZ)
if (distance > 0 && (distance > 0.005f || velocity.dotProduct(velocity) > 0.005f)) {
val acceleration = math.min(targetAcceleration, distance) / distance
- velocity.xCoord += toTarget.xCoord * acceleration
- velocity.yCoord += toTarget.yCoord * acceleration
- velocity.zCoord += toTarget.zCoord * acceleration
- motionX = math.max(-maxVelocity, math.min(maxVelocity, velocity.xCoord))
- motionY = math.max(-maxVelocity, math.min(maxVelocity, velocity.yCoord))
- motionZ = math.max(-maxVelocity, math.min(maxVelocity, velocity.zCoord))
+ val velocityX = velocity.xCoord + toTarget.xCoord * acceleration
+ val velocityY = velocity.yCoord + toTarget.yCoord * acceleration
+ val velocityZ = velocity.zCoord + toTarget.zCoord * acceleration
+ motionX = math.max(-maxVelocity, math.min(maxVelocity, velocityX))
+ motionY = math.max(-maxVelocity, math.min(maxVelocity, velocityY))
+ motionZ = math.max(-maxVelocity, math.min(maxVelocity, velocityZ))
}
else {
motionX = 0
@@ -364,7 +364,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
motionZ *= drag
}
else {
- val groundDrag = worldObj.getBlock(BlockPosition(this: Entity).offset(ForgeDirection.DOWN)).slipperiness * drag
+ val groundDrag = worldObj.getBlock(BlockPosition(this: Entity).offset(EnumFacing.DOWN)).slipperiness * drag
motionX *= groundDrag
motionY *= drag
motionZ *= groundDrag
@@ -376,10 +376,10 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
override def hitByEntity(entity: Entity) = {
if (isRunning) {
- val direction = Vec3.createVectorHelper(entity.posX - posX, entity.posY + entity.getEyeHeight - posY, entity.posZ - posZ).normalize()
+ val direction = new Vec3(entity.posX - posX, entity.posY + entity.getEyeHeight - posY, entity.posZ - posZ).normalize()
if (!world.isRemote) {
if (Settings.get.inputUsername)
- machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord), entity.getCommandSenderName)
+ machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord), entity.getName)
else
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord))
}
@@ -403,7 +403,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
// ----------------------------------------------------------------------- //
override def handleWaterMovement() = {
- inWater = worldObj.handleMaterialAcceleration(boundingBox, Material.water, this)
+ inWater = worldObj.handleMaterialAcceleration(getEntityBoundingBox, Material.water, this)
inWater
}
diff --git a/src/main/scala/li/cil/oc/common/event/AngelUpgradeHandler.scala b/src/main/scala/li/cil/oc/common/event/AngelUpgradeHandler.scala
index 7e0a82e21..bdb55d881 100644
--- a/src/main/scala/li/cil/oc/common/event/AngelUpgradeHandler.scala
+++ b/src/main/scala/li/cil/oc/common/event/AngelUpgradeHandler.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.event
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.api
import li.cil.oc.api.event.RobotPlaceInAirEvent
diff --git a/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala b/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala
index 785b253bc..dccc038c6 100644
--- a/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala
+++ b/src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala
@@ -2,7 +2,7 @@ package li.cil.oc.common.event
import java.util
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.api.event.RobotMoveEvent
import li.cil.oc.server.component.UpgradeChunkloader
import li.cil.oc.util.BlockPosition
diff --git a/src/main/scala/li/cil/oc/common/event/ExperienceUpgradeHandler.scala b/src/main/scala/li/cil/oc/common/event/ExperienceUpgradeHandler.scala
index 2a81f3b16..e3159290e 100644
--- a/src/main/scala/li/cil/oc/common/event/ExperienceUpgradeHandler.scala
+++ b/src/main/scala/li/cil/oc/common/event/ExperienceUpgradeHandler.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.event
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.api.event._
diff --git a/src/main/scala/li/cil/oc/common/event/FileSystemAccessHandler.scala b/src/main/scala/li/cil/oc/common/event/FileSystemAccessHandler.scala
index f9e9b2675..dd84528f7 100644
--- a/src/main/scala/li/cil/oc/common/event/FileSystemAccessHandler.scala
+++ b/src/main/scala/li/cil/oc/common/event/FileSystemAccessHandler.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.event
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.Settings
import li.cil.oc.api.event.FileSystemAccessEvent
import li.cil.oc.common.tileentity.Case
diff --git a/src/main/scala/li/cil/oc/common/event/GeolyzerHandler.scala b/src/main/scala/li/cil/oc/common/event/GeolyzerHandler.scala
index 192b706d4..68eac206a 100644
--- a/src/main/scala/li/cil/oc/common/event/GeolyzerHandler.scala
+++ b/src/main/scala/li/cil/oc/common/event/GeolyzerHandler.scala
@@ -1,12 +1,14 @@
package li.cil.oc.common.event
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.Settings
import li.cil.oc.api.event.GeolyzerEvent
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._
import net.minecraft.block.Block
+import net.minecraft.init.Blocks
+import net.minecraft.util.BlockPos
import net.minecraftforge.fluids.FluidRegistry
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import scala.collection.convert.WrapAsScala._
@@ -29,10 +31,12 @@ object GeolyzerHandler {
for (ry <- 0 until e.data.length) {
val by = blockPos.y + ry - 32
- if (!world.isAirBlock(bx, by, bz)) {
- val block = world.getBlock(bx, by, bz)
- if (block != null && (includeReplaceable || isFluid(block) || !block.isReplaceable(world, blockPos.x, blockPos.y, blockPos.z))) {
- e.data(ry) = e.data(ry) * (math.abs(ry - 32) + 1) * Settings.get.geolyzerNoise + block.getBlockHardness(world, bx, by, bz)
+ val bp = new BlockPos(bx, by, bz)
+ if (!world.isAirBlock(bp)) {
+ val state = world.getBlockState(bp)
+ val block = state.getBlock
+ if (!block.isAir(world, bp) && (includeReplaceable || !block.isReplaceable(world, bp) || isFluid(block))) {
+ e.data(ry) = e.data(ry) * (math.abs(ry - 32) + 1) * Settings.get.geolyzerNoise + block.getBlockHardness(world, bp)
}
else e.data(ry) = 0
}
@@ -43,15 +47,17 @@ object GeolyzerHandler {
@SubscribeEvent
def onGeolyzerAnalyze(e: GeolyzerEvent.Analyze) {
val world = e.host.world
- val blockPos = BlockPosition(e.host).offset(e.side)
- val block = world.getBlock(blockPos)
+ val blockPos = BlockPosition(e.host).offset(e.side).toBlockPos
+ val state = world.getBlockState(blockPos)
+ val block = state.getBlock
+ val metadata = block.getMetaFromState(state)
e.data += "name" -> Block.blockRegistry.getNameForObject(block)
- e.data += "metadata" -> int2Integer(world.getBlockMetadata(blockPos))
- e.data += "hardness" -> float2Float(world.getBlockHardness(blockPos))
- e.data += "harvestLevel" -> int2Integer(world.getBlockHarvestLevel(blockPos))
- e.data += "harvestTool" -> world.getBlockHarvestTool(blockPos)
- e.data += "color" -> int2Integer(world.getBlockMapColor(blockPos).colorValue)
+ e.data += "metadata" -> int2Integer(metadata)
+ e.data += "hardness" -> float2Float(block.getBlockHardness(world, blockPos))
+ e.data += "harvestLevel" -> int2Integer(block.getHarvestLevel(state))
+ e.data += "harvestTool" -> block.getHarvestTool(state)
+ e.data += "color" -> int2Integer(block.getMapColor(state).colorValue)
if (Settings.get.insertIdsInConverters)
e.data += "id" -> int2Integer(Block.getIdFromBlock(block))
diff --git a/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala b/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala
index c347c0140..18e3259b9 100644
--- a/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala
+++ b/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.event
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.api.event.RobotUsedToolEvent
object RobotCommonHandler {
diff --git a/src/main/scala/li/cil/oc/common/event/WirelessNetworkCardHandler.scala b/src/main/scala/li/cil/oc/common/event/WirelessNetworkCardHandler.scala
index a22c33cf9..730981c77 100644
--- a/src/main/scala/li/cil/oc/common/event/WirelessNetworkCardHandler.scala
+++ b/src/main/scala/li/cil/oc/common/event/WirelessNetworkCardHandler.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.event
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.api
import li.cil.oc.api.event.RobotMoveEvent
import li.cil.oc.server.component.WirelessNetworkCard
diff --git a/src/main/scala/li/cil/oc/common/init/Blocks.scala b/src/main/scala/li/cil/oc/common/init/Blocks.scala
index c3e57d629..ade5ca11c 100644
--- a/src/main/scala/li/cil/oc/common/init/Blocks.scala
+++ b/src/main/scala/li/cil/oc/common/init/Blocks.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.init
-import cpw.mods.fml.common.registry.GameRegistry
+import net.minecraftforge.fml.common.registry.GameRegistry
import li.cil.oc.Settings
import li.cil.oc.common.Tier
import li.cil.oc.common.block._
@@ -9,22 +9,22 @@ import li.cil.oc.common.tileentity
object Blocks {
def init() {
- GameRegistry.registerTileEntity(classOf[tileentity.AccessPoint], Settings.namespace + "access_point")
+ GameRegistry.registerTileEntity(classOf[tileentity.AccessPoint], Settings.namespace + "accessPoint")
GameRegistry.registerTileEntity(classOf[tileentity.Adapter], Settings.namespace + "adapter")
- GameRegistry.registerTileEntityWithAlternatives(classOf[tileentity.Assembler], Settings.namespace + "assembler", Settings.namespace + "robotAssembler")
+ GameRegistry.registerTileEntity(classOf[tileentity.Assembler], Settings.namespace + "assembler")
GameRegistry.registerTileEntity(classOf[tileentity.Cable], Settings.namespace + "cable")
GameRegistry.registerTileEntity(classOf[tileentity.Capacitor], Settings.namespace + "capacitor")
GameRegistry.registerTileEntity(classOf[tileentity.Case], Settings.namespace + "case")
GameRegistry.registerTileEntity(classOf[tileentity.Charger], Settings.namespace + "charger")
- GameRegistry.registerTileEntity(classOf[tileentity.DiskDrive], Settings.namespace + "disk_drive")
+ GameRegistry.registerTileEntity(classOf[tileentity.DiskDrive], Settings.namespace + "diskDrive")
GameRegistry.registerTileEntity(classOf[tileentity.Disassembler], Settings.namespace + "disassembler")
GameRegistry.registerTileEntity(classOf[tileentity.Keyboard], Settings.namespace + "keyboard")
GameRegistry.registerTileEntity(classOf[tileentity.Hologram], Settings.namespace + "hologram")
GameRegistry.registerTileEntity(classOf[tileentity.Geolyzer], Settings.namespace + "geolyzer")
GameRegistry.registerTileEntity(classOf[tileentity.Microcontroller], Settings.namespace + "microcontroller")
- GameRegistry.registerTileEntity(classOf[tileentity.MotionSensor], Settings.namespace + "motion_sensor")
- GameRegistry.registerTileEntity(classOf[tileentity.PowerConverter], Settings.namespace + "power_converter")
- GameRegistry.registerTileEntity(classOf[tileentity.PowerDistributor], Settings.namespace + "power_distributor")
+ GameRegistry.registerTileEntity(classOf[tileentity.MotionSensor], Settings.namespace + "motionSensor")
+ GameRegistry.registerTileEntity(classOf[tileentity.PowerConverter], Settings.namespace + "powerConverter")
+ GameRegistry.registerTileEntity(classOf[tileentity.PowerDistributor], Settings.namespace + "powerDistributor")
GameRegistry.registerTileEntity(classOf[tileentity.Raid], Settings.namespace + "raid")
GameRegistry.registerTileEntity(classOf[tileentity.Redstone], Settings.namespace + "redstone")
GameRegistry.registerTileEntity(classOf[tileentity.RobotProxy], Settings.namespace + "robot")
@@ -32,14 +32,6 @@ object Blocks {
GameRegistry.registerTileEntity(classOf[tileentity.Screen], Settings.namespace + "screen")
GameRegistry.registerTileEntity(classOf[tileentity.ServerRack], Settings.namespace + "serverRack")
- // These are purely for converting existing blocks in delegator format to the new,
- // one block type per block format.
- // TODO Remove in 1.5
- GameRegistry.registerBlock(new DelegatorConverter(), classOf[DelegatorConverter.Item], "simple")
- GameRegistry.registerBlock(new DelegatorConverter(), classOf[DelegatorConverter.Item], "simple_redstone")
- GameRegistry.registerBlock(new DelegatorConverter(), classOf[DelegatorConverter.Item], "special")
- GameRegistry.registerBlock(new DelegatorConverter(), classOf[DelegatorConverter.Item], "special_redstone")
-
// IMPORTANT: the multi block must come first, since the sub blocks will
// try to register with it. Also, the order the sub blocks are created in
// must not be changed since that order determines their actual IDs.
diff --git a/src/main/scala/li/cil/oc/common/init/Items.scala b/src/main/scala/li/cil/oc/common/init/Items.scala
index 3864bd76b..603509128 100644
--- a/src/main/scala/li/cil/oc/common/init/Items.scala
+++ b/src/main/scala/li/cil/oc/common/init/Items.scala
@@ -1,6 +1,5 @@
package li.cil.oc.common.init
-import cpw.mods.fml.common.registry.GameRegistry
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api.detail.ItemAPI
@@ -16,6 +15,7 @@ import li.cil.oc.common.recipe.Recipes
import li.cil.oc.integration.Mods
import li.cil.oc.util.Color
import net.minecraft.block.Block
+import net.minecraft.block.state.IBlockState
import net.minecraft.creativetab.CreativeTabs
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.Item
@@ -23,7 +23,9 @@ import net.minecraft.item.ItemBlock
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.world.World
+import net.minecraftforge.fml.common.registry.GameRegistry
+import scala.collection.convert.WrapAsScala._
import scala.collection.mutable
object Items extends ItemAPI {
@@ -41,8 +43,15 @@ object Items extends ItemAPI {
def registerBlock[T <: Block](instance: T, id: String) = {
instance match {
case simple: SimpleBlock =>
- instance.setBlockName("oc." + id)
+ instance.setUnlocalizedName("oc." + id)
GameRegistry.registerBlock(simple, classOf[common.block.Item], id)
+
+ instance.getBlockState.getValidStates.collect {
+ case state: IBlockState =>
+ val id = Block.blockRegistry.getIDForObject(instance) << 4 | instance.getMetaFromState(state)
+ Block.BLOCK_STATE_IDS.put(state, id)
+ }
+
case _ =>
}
descriptors += id -> new ItemInfo {
@@ -58,6 +67,7 @@ object Items extends ItemAPI {
}
}
names += instance -> id
+ OpenComputers.proxy.registerModel(instance, id)
instance
}
@@ -72,6 +82,7 @@ object Items extends ItemAPI {
override def createItemStack(size: Int) = delegate.createItemStack(size)
}
names += delegate -> id
+ OpenComputers.proxy.registerModel(delegate, id)
delegate
}
@@ -95,13 +106,14 @@ object Items extends ItemAPI {
}
}
names += instance -> id
+ OpenComputers.proxy.registerModel(instance, id)
instance
}
private def getBlockOrItem(stack: ItemStack): Any = if (stack == null) null
else {
multi.subItem(stack).getOrElse(stack.getItem match {
- case block: ItemBlock => block.field_150939_a
+ case block: ItemBlock => block.getBlock
case item => item
})
}
diff --git a/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala b/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala
index db4ffd005..fad585fc6 100644
--- a/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala
+++ b/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala
@@ -156,7 +156,7 @@ trait ComponentInventory extends Inventory with network.Environment {
val tag = dataTag(driver, stack)
// Clear the tag compound before saving to get the same behavior as
// in tile entities (otherwise entries have to be cleared manually).
- for (key <- tag.func_150296_c.map(_.asInstanceOf[String])) {
+ for (key <- tag.getKeySet.map(_.asInstanceOf[String])) {
tag.removeTag(key)
}
component.save(tag)
diff --git a/src/main/scala/li/cil/oc/common/inventory/Inventory.scala b/src/main/scala/li/cil/oc/common/inventory/Inventory.scala
index 1a1e677c8..9e81cb16b 100644
--- a/src/main/scala/li/cil/oc/common/inventory/Inventory.scala
+++ b/src/main/scala/li/cil/oc/common/inventory/Inventory.scala
@@ -1,8 +1,10 @@
package li.cil.oc.common.inventory
+import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.ItemUtils
+import net.minecraft.entity.player.EntityPlayer
import net.minecraft.inventory.IInventory
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
@@ -60,16 +62,26 @@ trait Inventory extends IInventory {
override def getStackInSlotOnClosing(slot: Int) = null
- override def openInventory() {}
+ override def openInventory(player: EntityPlayer) {}
- override def closeInventory() {}
+ override def closeInventory(player: EntityPlayer) {}
- override def hasCustomInventoryName = false
+ override def clear() {} // TODO implement?
- override def getInventoryName = Settings.namespace + "container." + inventoryName
+ override def getName = Settings.namespace + "container." + inventoryName
+
+ override def hasCustomName = false
+
+ override def getDisplayName = Localization.localizeLater(getName)
protected def inventoryName = getClass.getSimpleName
+ override def getField(id: Int) = 0
+
+ override def setField(id: Int, value: Int) {}
+
+ override def getFieldCount = 0
+
// ----------------------------------------------------------------------- //
def load(nbt: NBTTagCompound) {
diff --git a/src/main/scala/li/cil/oc/common/item/Analyzer.scala b/src/main/scala/li/cil/oc/common/item/Analyzer.scala
index 325071f07..23a168fc2 100644
--- a/src/main/scala/li/cil/oc/common/item/Analyzer.scala
+++ b/src/main/scala/li/cil/oc/common/item/Analyzer.scala
@@ -9,10 +9,10 @@ import li.cil.oc.util.ExtendedWorld._
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.item.ItemStack
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Analyzer(val parent: Delegator) extends Delegate {
- override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
val world = position.world.get
player match {
case realPlayer: EntityPlayerMP =>
@@ -24,7 +24,7 @@ class Analyzer(val parent: Delegator) extends Delegate {
true
case host: SidedEnvironment =>
if (!world.isRemote) {
- analyzeNodes(Array(host.sidedNode(ForgeDirection.getOrientation(side))), realPlayer)
+ analyzeNodes(Array(host.sidedNode(side)), realPlayer)
}
true
case host: Environment =>
diff --git a/src/main/scala/li/cil/oc/common/item/Debugger.scala b/src/main/scala/li/cil/oc/common/item/Debugger.scala
index 6a94f1377..abb22411e 100644
--- a/src/main/scala/li/cil/oc/common/item/Debugger.scala
+++ b/src/main/scala/li/cil/oc/common/item/Debugger.scala
@@ -8,17 +8,17 @@ import li.cil.oc.util.ExtendedWorld._
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.item.ItemStack
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Debugger(val parent: Delegator) extends Delegate {
- override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
val world = position.world.get
player match {
case realPlayer: EntityPlayerMP =>
world.getTileEntity(position) match {
case host: SidedEnvironment =>
if (!world.isRemote) {
- Debugger.reconnect(Array(host.sidedNode(ForgeDirection.getOrientation(side))))
+ Debugger.reconnect(Array(host.sidedNode(side)))
}
true
case host: Environment =>
diff --git a/src/main/scala/li/cil/oc/common/item/Delegate.scala b/src/main/scala/li/cil/oc/common/item/Delegate.scala
index eea4e184c..876a95d46 100644
--- a/src/main/scala/li/cil/oc/common/item/Delegate.scala
+++ b/src/main/scala/li/cil/oc/common/item/Delegate.scala
@@ -2,8 +2,6 @@ package li.cil.oc.common.item
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.api
@@ -15,14 +13,14 @@ import li.cil.oc.util.Tooltip
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
+import net.minecraft.util.EnumFacing
import net.minecraft.world.World
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import org.lwjgl.input
trait Delegate {
- type Icon = net.minecraft.util.IIcon
- type IconRegister = net.minecraft.client.renderer.texture.IIconRegister
-
- val parent: Delegator
+ def parent: Delegator
def unlocalizedName = getClass.getSimpleName
@@ -34,17 +32,15 @@ trait Delegate {
val itemId = parent.add(this)
- private var _icon: Option[Icon] = None
-
def maxStackSize = 64
def createItemStack(amount: Int = 1) = new ItemStack(parent, amount, itemId)
// ----------------------------------------------------------------------- //
- def onItemUseFirst(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = false
+ def onItemUseFirst(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = false
- def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = false
+ def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = false
def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
if (player.isSneaking) {
@@ -111,20 +107,6 @@ trait Delegate {
def maxDamage(stack: ItemStack) = 0
- @SideOnly(Side.CLIENT)
- def icon: Option[Icon] = _icon
-
- @SideOnly(Side.CLIENT)
- protected def icon_=(value: Icon) = _icon = Option(value)
-
- @SideOnly(Side.CLIENT)
- def icon(stack: ItemStack, pass: Int): Option[Icon] = icon
-
- @SideOnly(Side.CLIENT)
- def registerIcons(iconRegister: IconRegister) {
- icon = iconRegister.registerIcon(Settings.resourceDomain + ":" + unlocalizedName)
- }
-
// ----------------------------------------------------------------------- //
def equals(stack: ItemStack) =
diff --git a/src/main/scala/li/cil/oc/common/item/Delegator.scala b/src/main/scala/li/cil/oc/common/item/Delegator.scala
index e67c7ef08..1aa752e03 100644
--- a/src/main/scala/li/cil/oc/common/item/Delegator.scala
+++ b/src/main/scala/li/cil/oc/common/item/Delegator.scala
@@ -3,24 +3,23 @@ package li.cil.oc.common.item
import java.util
import java.util.Random
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.CreativeTab
import li.cil.oc.OpenComputers
-import li.cil.oc.Settings
import li.cil.oc.common.tileentity
import li.cil.oc.util.BlockPosition
-import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.creativetab.CreativeTabs
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumRarity
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
-import net.minecraft.util.IIcon
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.util.WeightedRandomChestContent
import net.minecraft.world.World
import net.minecraftforge.common.ChestGenHooks
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import scala.collection.mutable
@@ -28,7 +27,6 @@ class Delegator extends Item {
setHasSubtypes(true)
setCreativeTab(CreativeTab)
setUnlocalizedName("oc.multi")
- iconString = Settings.resourceDomain + ":Microchip0"
// ----------------------------------------------------------------------- //
// SubItem
@@ -84,7 +82,7 @@ class Delegator extends Item {
override def getRarity(stack: ItemStack) = subItem(stack) match {
case Some(subItem) => subItem.rarity
- case _ => EnumRarity.common
+ case _ => EnumRarity.COMMON
}
override def getColorFromItemStack(stack: ItemStack, pass: Int) =
@@ -95,25 +93,25 @@ class Delegator extends Item {
override def getChestGenBase(chest: ChestGenHooks, rnd: Random, original: WeightedRandomChestContent) = original
- override def doesSneakBypassUse(world: World, x: Int, y: Int, z: Int, player: EntityPlayer) = {
- world.getTileEntity(x, y, z) match {
+ override def doesSneakBypassUse(world: World, pos: BlockPos, player: EntityPlayer) = {
+ world.getTileEntity(pos) match {
case drive: tileentity.DiskDrive => true
- case _ => super.doesSneakBypassUse(world, x, y, z, player)
+ case _ => super.doesSneakBypassUse(world, pos, player)
}
}
// ----------------------------------------------------------------------- //
- override def onItemUseFirst(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean =
+ override def onItemUseFirst(stack: ItemStack, player: EntityPlayer, world: World, pos: BlockPos, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) =
subItem(stack) match {
- case Some(subItem) => subItem.onItemUseFirst(stack, player, BlockPosition(x, y, z, world), side, hitX, hitY, hitZ)
- case _ => super.onItemUseFirst(stack, player, world, x, y, z, side, hitX, hitY, hitZ)
+ case Some(subItem) => subItem.onItemUseFirst(stack, player, BlockPosition(pos, world), side, hitX, hitY, hitZ)
+ case _ => super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ)
}
- override def onItemUse(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean =
+ override def onItemUse(stack: ItemStack, player: EntityPlayer, world: World, pos: BlockPos, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) =
subItem(stack) match {
- case Some(subItem) => subItem.onItemUse(stack, player, BlockPosition(x, y, z, world), side, hitX, hitY, hitZ)
- case _ => super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ)
+ case Some(subItem) => subItem.onItemUse(stack, player, BlockPosition(pos, world), side, hitX, hitY, hitZ)
+ case _ => super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ)
}
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack =
@@ -146,10 +144,10 @@ class Delegator extends Item {
}
}
- override def getDisplayDamage(stack: ItemStack) =
+ override def getDurabilityForDisplay(stack: ItemStack) =
subItem(stack) match {
case Some(subItem) if subItem.isDamageable => subItem.damage(stack)
- case _ => super.getDisplayDamage(stack)
+ case _ => super.getDurabilityForDisplay(stack)
}
override def getMaxDamage(stack: ItemStack) =
@@ -170,34 +168,35 @@ class Delegator extends Item {
case _ => super.onUpdate(stack, world, player, slot, selected)
}
- @SideOnly(Side.CLIENT)
- override def getIcon(stack: ItemStack, pass: Int) =
- subItem(stack) match {
- case Some(subItem) => subItem.icon(stack, pass) match {
- case Some(icon) => icon
- case _ => super.getIcon(stack, pass)
- }
- case _ => super.getIcon(stack, pass)
- }
-
- @SideOnly(Side.CLIENT)
- override def getIconIndex(stack: ItemStack) = getIcon(stack, 0)
-
- @SideOnly(Side.CLIENT)
- override def getIconFromDamage(damage: Int): IIcon =
- subItem(damage) match {
- case Some(subItem) => subItem.icon match {
- case Some(icon) => icon
- case _ => super.getIconFromDamage(damage)
- }
- case _ => super.getIconFromDamage(damage)
- }
-
- @SideOnly(Side.CLIENT)
- override def registerIcons(iconRegister: IIconRegister) {
- super.registerIcons(iconRegister)
- subItems.foreach(_.registerIcons(iconRegister))
- }
+ // TODO remove
+// @SideOnly(Side.CLIENT)
+// override def getIcon(stack: ItemStack, pass: Int) =
+// subItem(stack) match {
+// case Some(subItem) => subItem.icon(stack, pass) match {
+// case Some(icon) => icon
+// case _ => super.getIcon(stack, pass)
+// }
+// case _ => super.getIcon(stack, pass)
+// }
+//
+// @SideOnly(Side.CLIENT)
+// override def getIconIndex(stack: ItemStack) = getIcon(stack, 0)
+//
+// @SideOnly(Side.CLIENT)
+// override def getIconFromDamage(damage: Int): IIcon =
+// subItem(damage) match {
+// case Some(subItem) => subItem.icon match {
+// case Some(icon) => icon
+// case _ => super.getIconFromDamage(damage)
+// }
+// case _ => super.getIconFromDamage(damage)
+// }
+//
+// @SideOnly(Side.CLIENT)
+// override def registerIcons(iconRegister: IIconRegister) {
+// super.getAtlasSprites(iconRegister)
+// subItems.foreach(_.getAtlasSprites(iconRegister))
+// }
override def toString = getUnlocalizedName
}
diff --git a/src/main/scala/li/cil/oc/common/item/Drone.scala b/src/main/scala/li/cil/oc/common/item/Drone.scala
index 5e30ab7ce..0e8733ba6 100644
--- a/src/main/scala/li/cil/oc/common/item/Drone.scala
+++ b/src/main/scala/li/cil/oc/common/item/Drone.scala
@@ -8,6 +8,7 @@ import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ItemUtils
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
+import net.minecraft.util.EnumFacing
class Drone(val parent: Delegator) extends Delegate {
override protected def tooltipExtended(stack: ItemStack, tooltip: util.List[String]): Unit = {
@@ -19,7 +20,7 @@ class Drone(val parent: Delegator) extends Delegate {
}
}
- override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
val world = position.world.get
if (!world.isRemote) {
val drone = new entity.Drone(world)
diff --git a/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala b/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala
index c857158e5..c3151b8ed 100644
--- a/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala
+++ b/src/main/scala/li/cil/oc/common/item/FloppyDisk.scala
@@ -2,8 +2,8 @@ package li.cil.oc.common.item
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.util.Color
import net.minecraft.entity.player.EntityPlayer
@@ -15,15 +15,6 @@ class FloppyDisk(val parent: Delegator) extends Delegate {
override protected def tooltipName = None
- val icons = Array.fill[Icon](16)(null)
-
- @SideOnly(Side.CLIENT)
- override def icon(stack: ItemStack, pass: Int) =
- if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "color"))
- Some(icons(stack.getTagCompound.getInteger(Settings.namespace + "color") max 0 min 15))
- else
- Some(icons(8))
-
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) = {
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
val nbt = stack.getTagCompound.getCompoundTag(Settings.namespace + "data")
@@ -34,11 +25,21 @@ class FloppyDisk(val parent: Delegator) extends Delegate {
super.tooltipLines(stack, player, tooltip, advanced)
}
- override def registerIcons(iconRegister: IconRegister) {
- val baseTextureName = Settings.resourceDomain + ":" + unlocalizedName + "_"
- Color.dyes.zipWithIndex.foreach {
- case (color, index) =>
- icons(index) = iconRegister.registerIcon(baseTextureName + color)
- }
- }
+ // TODO remove
+// val icons = Array.fill[Icon](16)(null)
+//
+// @SideOnly(Side.CLIENT)
+// override def icon(stack: ItemStack, pass: Int) =
+// if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "color"))
+// Some(icons(stack.getTagCompound.getInteger(Settings.namespace + "color") max 0 min 15))
+// else
+// Some(icons(8))
+//
+// override def registerIcons(iconRegister: IconRegister) {
+// val baseTextureName = Settings.resourceDomain + ":" + unlocalizedName + "_"
+// Color.dyes.zipWithIndex.foreach {
+// case (color, index) =>
+// icons(index) = iconRegister.getAtlasSprite(baseTextureName + color)
+// }
+// }
}
diff --git a/src/main/scala/li/cil/oc/common/item/ItemTier.scala b/src/main/scala/li/cil/oc/common/item/ItemTier.scala
index aa6eb4f86..60c4bb9df 100644
--- a/src/main/scala/li/cil/oc/common/item/ItemTier.scala
+++ b/src/main/scala/li/cil/oc/common/item/ItemTier.scala
@@ -2,8 +2,8 @@ package li.cil.oc.common.item
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Localization
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
diff --git a/src/main/scala/li/cil/oc/common/item/SimpleItem.scala b/src/main/scala/li/cil/oc/common/item/SimpleItem.scala
index b04576970..ae83d6dd6 100644
--- a/src/main/scala/li/cil/oc/common/item/SimpleItem.scala
+++ b/src/main/scala/li/cil/oc/common/item/SimpleItem.scala
@@ -3,8 +3,9 @@ package li.cil.oc.common.item
import java.util
import java.util.Random
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.util.BlockPos
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.CreativeTab
import li.cil.oc.Localization
import li.cil.oc.Settings
@@ -22,7 +23,9 @@ import org.lwjgl.input
class SimpleItem extends Item {
setCreativeTab(CreativeTab)
- iconString = Settings.resourceDomain + ":" + getClass.getSimpleName
+
+ // TODO remove
+// iconString = Settings.resourceDomain + ":" + getClass.getSimpleName
def createItemStack(amount: Int = 1) = new ItemStack(this, amount)
@@ -30,10 +33,11 @@ class SimpleItem extends Item {
override def getChestGenBase(chest: ChestGenHooks, rnd: Random, original: WeightedRandomChestContent) = original
- override def doesSneakBypassUse(world: World, x: Int, y: Int, z: Int, player: EntityPlayer) = {
- world.getTileEntity(x, y, z) match {
+
+ override def doesSneakBypassUse(world: World, pos: BlockPos, player: EntityPlayer) = {
+ world.getTileEntity(pos) match {
case drive: tileentity.DiskDrive => true
- case _ => super.doesSneakBypassUse(world, x, y, z, player)
+ case _ => super.doesSneakBypassUse(world, pos, player)
}
}
diff --git a/src/main/scala/li/cil/oc/common/item/Tablet.scala b/src/main/scala/li/cil/oc/common/item/Tablet.scala
index 3d6ce41bf..5a4e4c4f6 100644
--- a/src/main/scala/li/cil/oc/common/item/Tablet.scala
+++ b/src/main/scala/li/cil/oc/common/item/Tablet.scala
@@ -7,11 +7,11 @@ import java.util.concurrent.TimeUnit
import com.google.common.cache.CacheBuilder
import com.google.common.cache.RemovalListener
import com.google.common.cache.RemovalNotification
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent
-import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ServerTickEvent
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Localization
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
@@ -37,7 +37,7 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.event.world.WorldEvent
import scala.collection.convert.WrapAsJava._
@@ -49,23 +49,24 @@ class Tablet(val parent: Delegator) extends Delegate {
override def maxStackSize = 1
- private var iconOn: Option[Icon] = None
- private var iconOff: Option[Icon] = None
-
- @SideOnly(Side.CLIENT)
- override def icon(stack: ItemStack, pass: Int) = {
- if (stack.hasTagCompound) {
- val data = new ItemUtils.TabletData(stack)
- if (data.isRunning) iconOn else iconOff
- } else super.icon(stack, pass)
- }
-
- override def registerIcons(iconRegister: IconRegister) = {
- super.registerIcons(iconRegister)
-
- iconOn = Option(iconRegister.registerIcon(Settings.resourceDomain + ":TabletOn"))
- iconOff = Option(iconRegister.registerIcon(Settings.resourceDomain + ":TabletOff"))
- }
+ // TODO remove
+// private var iconOn: Option[Icon] = None
+// private var iconOff: Option[Icon] = None
+//
+// @SideOnly(Side.CLIENT)
+// override def icon(stack: ItemStack, pass: Int) = {
+// if (stack.hasTagCompound) {
+// val data = new ItemUtils.TabletData(stack)
+// if (data.isRunning) iconOn else iconOff
+// } else super.icon(stack, pass)
+// }
+//
+// override def registerIcons(iconRegister: IconRegister) = {
+// super.getAtlasSprites(iconRegister)
+//
+// iconOn = Option(iconRegister.getAtlasSprite(Settings.resourceDomain + ":TabletOn"))
+// iconOff = Option(iconRegister.getAtlasSprite(Settings.resourceDomain + ":TabletOff"))
+// }
// ----------------------------------------------------------------------- //
@@ -137,9 +138,9 @@ class TabletWrapper(var stack: ItemStack, var player: EntityPlayer) extends Comp
override def facing = RotationHelper.fromYaw(player.rotationYaw)
- override def toLocal(value: ForgeDirection) = value // TODO do we care?
+ override def toLocal(value: EnumFacing) = value // TODO do we care?
- override def toGlobal(value: ForgeDirection) = value // TODO do we care?
+ override def toGlobal(value: EnumFacing) = value // TODO do we care?
def readFromNBT() {
if (stack.hasTagCompound) {
@@ -223,7 +224,7 @@ class TabletWrapper(var stack: ItemStack, var player: EntityPlayer) extends Comp
override def isItemValidForSlot(slot: Int, stack: ItemStack) = true
- override def isUseableByPlayer(player: EntityPlayer) = machine.canInteract(player.getCommandSenderName)
+ override def isUseableByPlayer(player: EntityPlayer) = machine.canInteract(player.getName)
override def markDirty() {}
diff --git a/src/main/scala/li/cil/oc/common/item/Terminal.scala b/src/main/scala/li/cil/oc/common/item/Terminal.scala
index fc682fa2b..5157cf9dd 100644
--- a/src/main/scala/li/cil/oc/common/item/Terminal.scala
+++ b/src/main/scala/li/cil/oc/common/item/Terminal.scala
@@ -3,8 +3,9 @@ package li.cil.oc.common.item
import java.util
import java.util.UUID
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.common.GuiType
@@ -21,9 +22,6 @@ import net.minecraft.world.World
class Terminal(val parent: Delegator) extends Delegate {
override def maxStackSize = 1
- private var iconOn: Option[Icon] = None
- private var iconOff: Option[Icon] = None
-
def hasServer(stack: ItemStack) = stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "server")
@SideOnly(Side.CLIENT)
@@ -35,19 +33,23 @@ class Terminal(val parent: Delegator) extends Delegate {
}
}
- // TODO check if server is in range and running
- // Unlike in the GUI handler the result should definitely be cached here.
- @SideOnly(Side.CLIENT)
- override def icon(stack: ItemStack, pass: Int) = if (hasServer(stack)) iconOn else iconOff
+ // TODO remove
+// private var iconOn: Option[Icon] = None
+// private var iconOff: Option[Icon] = None
+//
+// // TODO check if server is in range and running
+// // Unlike in the GUI handler the result should definitely be cached here.
+// @SideOnly(Side.CLIENT)
+// override def icon(stack: ItemStack, pass: Int) = if (hasServer(stack)) iconOn else iconOff
+//
+// override def registerIcons(iconRegister: IconRegister) = {
+// super.getAtlasSprites(iconRegister)
+//
+// iconOn = Option(iconRegister.getAtlasSprite(Settings.resourceDomain + ":TerminalOn"))
+// iconOff = Option(iconRegister.getAtlasSprite(Settings.resourceDomain + ":TerminalOff"))
+// }
- override def registerIcons(iconRegister: IconRegister) = {
- super.registerIcons(iconRegister)
-
- iconOn = Option(iconRegister.registerIcon(Settings.resourceDomain + ":TerminalOn"))
- iconOff = Option(iconRegister.registerIcon(Settings.resourceDomain + ":TerminalOff"))
- }
-
- override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
val world = position.world.get
world.getTileEntity(position) match {
case rack: tileentity.ServerRack if side == rack.facing.ordinal() =>
diff --git a/src/main/scala/li/cil/oc/common/item/UpgradeTank.scala b/src/main/scala/li/cil/oc/common/item/UpgradeTank.scala
index 5a2d3c053..a5a86b899 100644
--- a/src/main/scala/li/cil/oc/common/item/UpgradeTank.scala
+++ b/src/main/scala/li/cil/oc/common/item/UpgradeTank.scala
@@ -2,8 +2,8 @@ package li.cil.oc.common.item
import java.util
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
diff --git a/src/main/scala/li/cil/oc/common/launch/TransformerLoader.scala b/src/main/scala/li/cil/oc/common/launch/TransformerLoader.scala
index cec9eca0a..b4b035de7 100644
--- a/src/main/scala/li/cil/oc/common/launch/TransformerLoader.scala
+++ b/src/main/scala/li/cil/oc/common/launch/TransformerLoader.scala
@@ -3,12 +3,12 @@ package li.cil.oc.common.launch
import java.util
import com.google.common.eventbus.EventBus
-import cpw.mods.fml.common.DummyModContainer
-import cpw.mods.fml.common.LoadController
-import cpw.mods.fml.common.ModMetadata
-import cpw.mods.fml.relauncher.IFMLLoadingPlugin
-import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion
-import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions
+import net.minecraftforge.fml.common.DummyModContainer
+import net.minecraftforge.fml.common.LoadController
+import net.minecraftforge.fml.common.ModMetadata
+import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin
+import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion
+import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions
import li.cil.oc.common.asm.ClassTransformer
@TransformerExclusions(Array("li.cil.oc.common.asm"))
diff --git a/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala b/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala
index 7568bb794..796cf8bde 100644
--- a/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala
+++ b/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala
@@ -64,7 +64,7 @@ object ExtendedRecipe {
if (stack != null) {
if (api.Items.get(stack) == floppy && stack.hasTagCompound) {
val oldData = stack.getTagCompound
- for (oldTagName <- oldData.func_150296_c().map(_.asInstanceOf[String])) {
+ for (oldTagName <- oldData.getKeySet.map(_.asInstanceOf[String])) {
nbt.setTag(oldTagName, oldData.getTag(oldTagName).copy())
}
}
diff --git a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala
index 4595b2b3c..6d0453f51 100644
--- a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala
+++ b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala
@@ -4,8 +4,8 @@ import java.io.File
import java.io.FileReader
import com.typesafe.config._
-import cpw.mods.fml.common.Loader
-import cpw.mods.fml.common.registry.GameRegistry
+import net.minecraftforge.fml.common.Loader
+import net.minecraftforge.fml.common.registry.GameRegistry
import li.cil.oc._
import li.cil.oc.common.block.SimpleBlock
import li.cil.oc.common.init.Items
@@ -156,6 +156,7 @@ object Recipes {
case "shaped" => addShapedRecipe(output, recipe)
case "shapeless" => addShapelessRecipe(output, recipe)
case "furnace" => addFurnaceRecipe(output, recipe)
+ /* TODO GregTech
case "gt_assembler" =>
if (Mods.GregTech.isAvailable) {
addGTAssemblingMachineRecipe(output, recipe)
@@ -164,6 +165,7 @@ object Recipes {
OpenComputers.log.warn(s"Skipping GregTech assembler recipe for '$name' because GregTech is not present, you will not be able to craft this item!")
hide(output)
}
+ */
case other =>
OpenComputers.log.warn(s"Failed adding recipe for '$name', you will not be able to craft this item! The error was: Invalid recipe type '$other'.")
hide(output)
@@ -228,6 +230,7 @@ object Recipes {
else hide(output)
}
+ /* TODO GregTech
private def addGTAssemblingMachineRecipe(output: ItemStack, recipe: Config) {
val inputs = (recipe.getValue("input").unwrapped() match {
case list: java.util.List[AnyRef]@unchecked => list.map(parseIngredient)
@@ -265,6 +268,7 @@ object Recipes {
}
}
}
+ */
private def addFurnaceRecipe(output: ItemStack, recipe: Config) {
val input = parseIngredient(recipe.getValue("input").unwrapped())
@@ -272,10 +276,10 @@ object Recipes {
input match {
case stack: ItemStack =>
- FurnaceRecipes.smelting.func_151394_a(stack, output, 0)
+ FurnaceRecipes.instance.addSmeltingRecipe(stack, output, 0)
case name: String =>
for (stack <- OreDictionary.getOres(name)) {
- FurnaceRecipes.smelting.func_151394_a(stack, output, 0)
+ FurnaceRecipes.instance.addSmeltingRecipe(stack, output, 0)
}
case _ =>
}
@@ -372,7 +376,7 @@ object Recipes {
Items.multi.subItem(value) match {
case Some(stack) => stack.showInItemList = false
case _ => value.getItem match {
- case itemBlock: ItemBlock => itemBlock.field_150939_a match {
+ case itemBlock: ItemBlock => itemBlock.getBlock match {
case simple: SimpleBlock =>
simple.setCreativeTab(null)
NEI.hide(simple)
diff --git a/src/main/scala/li/cil/oc/common/template/DroneTemplate.scala b/src/main/scala/li/cil/oc/common/template/DroneTemplate.scala
index 0f8c0c1a0..6e62cc748 100644
--- a/src/main/scala/li/cil/oc/common/template/DroneTemplate.scala
+++ b/src/main/scala/li/cil/oc/common/template/DroneTemplate.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.template
-import cpw.mods.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.event.FMLInterModComms
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.internal
diff --git a/src/main/scala/li/cil/oc/common/template/MicrocontrollerTemplate.scala b/src/main/scala/li/cil/oc/common/template/MicrocontrollerTemplate.scala
index d528ca100..13f177703 100644
--- a/src/main/scala/li/cil/oc/common/template/MicrocontrollerTemplate.scala
+++ b/src/main/scala/li/cil/oc/common/template/MicrocontrollerTemplate.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.template
-import cpw.mods.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.event.FMLInterModComms
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.internal
diff --git a/src/main/scala/li/cil/oc/common/template/NavigationUpgradeTemplate.scala b/src/main/scala/li/cil/oc/common/template/NavigationUpgradeTemplate.scala
index 282eac6c1..16cad3568 100644
--- a/src/main/scala/li/cil/oc/common/template/NavigationUpgradeTemplate.scala
+++ b/src/main/scala/li/cil/oc/common/template/NavigationUpgradeTemplate.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.template
-import cpw.mods.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.event.FMLInterModComms
import li.cil.oc.api
import li.cil.oc.util.ItemUtils
import net.minecraft.item.ItemStack
diff --git a/src/main/scala/li/cil/oc/common/template/RobotTemplate.scala b/src/main/scala/li/cil/oc/common/template/RobotTemplate.scala
index e4d3842fb..f9fb04e00 100644
--- a/src/main/scala/li/cil/oc/common/template/RobotTemplate.scala
+++ b/src/main/scala/li/cil/oc/common/template/RobotTemplate.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.template
-import cpw.mods.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.event.FMLInterModComms
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.internal
diff --git a/src/main/scala/li/cil/oc/common/template/ServerTemplate.scala b/src/main/scala/li/cil/oc/common/template/ServerTemplate.scala
index 557d33649..c834bc74a 100644
--- a/src/main/scala/li/cil/oc/common/template/ServerTemplate.scala
+++ b/src/main/scala/li/cil/oc/common/template/ServerTemplate.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.template
-import cpw.mods.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.event.FMLInterModComms
import li.cil.oc.api
import li.cil.oc.common.inventory.ServerInventory
import li.cil.oc.util.ItemUtils
diff --git a/src/main/scala/li/cil/oc/common/template/TabletTemplate.scala b/src/main/scala/li/cil/oc/common/template/TabletTemplate.scala
index 144962d32..e19abab3b 100644
--- a/src/main/scala/li/cil/oc/common/template/TabletTemplate.scala
+++ b/src/main/scala/li/cil/oc/common/template/TabletTemplate.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.template
-import cpw.mods.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.event.FMLInterModComms
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.internal
diff --git a/src/main/scala/li/cil/oc/common/template/TemplateBlacklist.scala b/src/main/scala/li/cil/oc/common/template/TemplateBlacklist.scala
index e27af5fc8..3deb1d6c3 100644
--- a/src/main/scala/li/cil/oc/common/template/TemplateBlacklist.scala
+++ b/src/main/scala/li/cil/oc/common/template/TemplateBlacklist.scala
@@ -1,6 +1,6 @@
package li.cil.oc.common.template
-import cpw.mods.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.event.FMLInterModComms
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import net.minecraft.item.Item
diff --git a/src/main/scala/li/cil/oc/common/tileentity/AccessPoint.scala b/src/main/scala/li/cil/oc/common/tileentity/AccessPoint.scala
index 7e6d82f5f..cc4c747e1 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/AccessPoint.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/AccessPoint.scala
@@ -1,7 +1,5 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.api
@@ -9,12 +7,13 @@ import li.cil.oc.api.machine.Arguments
import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._
-import li.cil.oc.integration.Mods
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt.NBTTagCompound
+import net.minecraft.util.EnumFacing
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import scala.collection.convert.WrapAsScala._
@@ -30,9 +29,9 @@ class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = true
+ override protected def hasConnector(side: EnumFacing) = true
- override protected def connector(side: ForgeDirection) = sidedNode(side) match {
+ override protected def connector(side: EnumFacing) = sidedNode(side) match {
case connector: Connector => Option(connector)
case _ => None
}
@@ -41,9 +40,9 @@ class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float): Array[Node] = {
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Array[Node] = {
player.addChatMessage(Localization.Analyzer.WirelessStrength(strength))
- Array(componentNodes(side))
+ Array(componentNodes(side.getIndex))
}
// ----------------------------------------------------------------------- //
@@ -70,15 +69,9 @@ class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor
override def receivePacket(packet: Packet, source: WirelessEndpoint) {
tryEnqueuePacket(None, packet)
- if (Mods.ComputerCraft.isAvailable) {
- packet.data.headOption match {
- case Some(answerPort: java.lang.Double) => queueMessage(packet.source, packet.destination, packet.port, answerPort.toInt, packet.data.drop(1))
- case _ => queueMessage(packet.source, packet.destination, packet.port, -1, packet.data)
- }
- }
}
- override protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet) {
+ override protected def relayPacket(sourceSide: Option[EnumFacing], packet: Packet) {
super.relayPacket(sourceSide, packet)
if (strength > 0 && (sourceSide != None || isRepeater)) {
val cost = Settings.get.wirelessCostPerRange
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Adapter.scala b/src/main/scala/li/cil/oc/common/tileentity/Adapter.scala
index bf1f9f9c4..132a73ce7 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Adapter.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Adapter.scala
@@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagList
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.mutable
@@ -27,7 +27,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = blocks collect {
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = blocks collect {
case Some(((environment, _))) => environment.node
}
@@ -35,8 +35,8 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
override def canUpdate = isServer
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (updatingBlocks.nonEmpty) {
for (block <- updatingBlocks) {
block.update()
@@ -44,10 +44,10 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
}
}
- def neighborChanged(d: ForgeDirection) {
+ def neighborChanged(d: EnumFacing) {
if (node != null && node.network != null) {
- val (x, y, z) = (this.x + d.offsetX, this.y + d.offsetY, this.z + d.offsetZ)
- world.getTileEntity(x, y, z) match {
+ val blockPos = getPos.offset(d)
+ world.getTileEntity(getPos) match {
case env: traits.Environment =>
// Don't provide adaption for our stuffs. This is mostly to avoid
// cables and other non-functional stuff popping up in the adapter
@@ -55,7 +55,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
// but the only 'downside' is that it can't be used to manipulate
// inventories, which I actually consider a plus :P
case _ =>
- Option(api.Driver.driverFor(world, x, y, z)) match {
+ Option(api.Driver.driverFor(world, blockPos)) match {
case Some(newDriver) => blocks(d.ordinal()) match {
case Some((oldEnvironment, driver)) =>
if (newDriver != driver) {
@@ -66,7 +66,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
node.disconnect(oldEnvironment.node)
// Then rebuild - if we have something.
- val environment = newDriver.createEnvironment(world, x, y, z)
+ val environment = newDriver.createEnvironment(world, blockPos)
if (environment != null) {
blocks(d.ordinal()) = Some((environment, newDriver))
if (environment.canUpdate) {
@@ -78,7 +78,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
} // else: the more things change, the more they stay the same.
case _ =>
// A challenger appears. Maybe.
- val environment = newDriver.createEnvironment(world, x, y, z)
+ val environment = newDriver.createEnvironment(world, blockPos)
if (environment != null) {
blocks(d.ordinal()) = Some((environment, newDriver))
if (environment.canUpdate) {
@@ -110,7 +110,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
def neighborChanged() {
if (node != null && node.network != null) {
- for (d <- ForgeDirection.VALID_DIRECTIONS) {
+ for (d <- EnumFacing.values) {
neighborChanged(d)
}
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Assembler.scala b/src/main/scala/li/cil/oc/common/tileentity/Assembler.scala
index 0babf4e81..f06485c28 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Assembler.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Assembler.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.machine.Arguments
@@ -14,7 +14,7 @@ import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.ItemUtils
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Assembler extends traits.Environment with traits.PowerAcceptor with traits.Inventory with traits.Rotatable with SidedEnvironment {
val node = api.Network.newNode(this, Visibility.Network).
@@ -31,14 +31,14 @@ class Assembler extends traits.Environment with traits.PowerAcceptor with traits
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override def canConnect(side: ForgeDirection) = side != ForgeDirection.UP
+ override def canConnect(side: EnumFacing) = side != EnumFacing.UP
- override def sidedNode(side: ForgeDirection) = if (side != ForgeDirection.UP) node else null
+ override def sidedNode(side: EnumFacing) = if (side != EnumFacing.UP) node else null
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = canConnect(side)
+ override protected def hasConnector(side: EnumFacing) = canConnect(side)
- override protected def connector(side: ForgeDirection) = Option(if (side != ForgeDirection.UP) node else null)
+ override protected def connector(side: EnumFacing) = Option(if (side != EnumFacing.UP) node else null)
override protected def energyThroughput = Settings.get.assemblerRate
@@ -96,8 +96,8 @@ class Assembler extends traits.Environment with traits.PowerAcceptor with traits
override def canUpdate = isServer
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (output.isDefined && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
val want = math.max(1, math.min(requiredEnergy, Settings.get.assemblerTickAmount * Settings.get.tickFrequency))
val success = Settings.get.ignorePower || node.tryChangeBuffer(-want)
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Cable.scala b/src/main/scala/li/cil/oc/common/tileentity/Cable.scala
index 34b54b572..779750c1a 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Cable.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Cable.scala
@@ -3,12 +3,12 @@ package li.cil.oc.common.tileentity
import li.cil.oc.api
import li.cil.oc.api.network.Visibility
import li.cil.oc.common
-import li.cil.oc.util.Color
+import net.minecraft.item.EnumDyeColor
class Cable extends traits.Environment with traits.NotAnalyzable with traits.ImmibisMicroblock with traits.Colored {
val node = api.Network.newNode(this, Visibility.None).create()
- color = Color.LightGray
+ color = EnumDyeColor.SILVER
override protected def onColorChanged() {
super.onColorChanged()
@@ -19,5 +19,5 @@ class Cable extends traits.Environment with traits.NotAnalyzable with traits.Imm
override def canUpdate = false
- override def getRenderBoundingBox = common.block.Cable.bounds(world, x, y, z).offset(x, y, z)
+ override def getRenderBoundingBox = common.block.Cable.bounds(world, getPos).offset(x, y, z)
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala b/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala
index 89645ca4b..66776e05f 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala
@@ -1,10 +1,10 @@
package li.cil.oc.common.tileentity
-import li.cil.oc.api.network.Node
-import li.cil.oc.api.network.Visibility
import li.cil.oc.Settings
import li.cil.oc.api
-import net.minecraftforge.common.util.ForgeDirection
+import li.cil.oc.api.network.Node
+import li.cil.oc.api.network.Visibility
+import net.minecraft.util.EnumFacing
class Capacitor extends traits.Environment {
// Start with maximum theoretical capacity, gets reduced after validation.
@@ -21,11 +21,10 @@ class Capacitor extends traits.Environment {
super.dispose()
if (isServer) {
indirectNeighbors.map(coordinate => {
- val (nx, ny, nz) = coordinate
- if (world.blockExists(nx, ny, nz)) world.getTileEntity(nx, ny, nz)
- else null
+ if (world.isBlockLoaded(coordinate)) Option(world.getTileEntity(coordinate))
+ else None
}).collect {
- case capacitor: Capacitor => capacitor.recomputeCapacity()
+ case Some(capacitor: Capacitor) => capacitor.recomputeCapacity()
}
}
}
@@ -42,26 +41,24 @@ class Capacitor extends traits.Environment {
def recomputeCapacity(updateSecondGradeNeighbors: Boolean = false) {
node.setLocalBufferSize(
Settings.get.bufferCapacitor +
- Settings.get.bufferCapacitorAdjacencyBonus * ForgeDirection.VALID_DIRECTIONS.count(side => {
- val (nx, ny, nz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
- world.blockExists(nx, ny, nz) && (world.getTileEntity(nx, ny, nz) match {
+ Settings.get.bufferCapacitorAdjacencyBonus * EnumFacing.values.count(side => {
+ val blockPos = getPos.offset(side)
+ world.isBlockLoaded(blockPos) && (world.getTileEntity(blockPos) match {
case capacitor: Capacitor => true
case _ => false
})
}) +
- Settings.get.bufferCapacitorAdjacencyBonus / 2 * indirectNeighbors.count {
- case (nx, ny, nz) => world.blockExists(nx, ny, nz) && (world.getTileEntity(nx, ny, nz) match {
+ Settings.get.bufferCapacitorAdjacencyBonus / 2 * indirectNeighbors.count(blockPos => world.isBlockLoaded(blockPos) && (world.getTileEntity(blockPos) match {
case capacitor: Capacitor =>
if (updateSecondGradeNeighbors) {
capacitor.recomputeCapacity()
}
true
case _ => false
- })
- })
+ })))
}
- private def indirectNeighbors = ForgeDirection.VALID_DIRECTIONS.map(side => (x + side.offsetX * 2, y + side.offsetY * 2, z + side.offsetZ * 2))
+ private def indirectNeighbors = EnumFacing.values.map(getPos.offset(_, 2))
private def maxCapacity = Settings.get.bufferCapacitor + Settings.get.bufferCapacitorAdjacencyBonus * 9
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Case.scala b/src/main/scala/li/cil/oc/common/tileentity/Case.scala
index 0b386a467..8d645a16c 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Case.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Case.scala
@@ -1,7 +1,5 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api.Driver
import li.cil.oc.api.driver.item.Memory
@@ -12,12 +10,13 @@ import li.cil.oc.common
import li.cil.oc.common.InventorySlots
import li.cil.oc.common.Slot
import li.cil.oc.common.Tier
-import li.cil.oc.common.init.Items
import li.cil.oc.util.Color
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with traits.Colored with internal.Case {
def this() = this(0)
@@ -28,14 +27,12 @@ class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with
color = Color.byTier(tier)
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = side != facing
+ override protected def hasConnector(side: EnumFacing) = side != facing
- override protected def connector(side: ForgeDirection) = Option(if (side != facing && machine != null) machine.node.asInstanceOf[Connector] else null)
+ override protected def connector(side: EnumFacing) = Option(if (side != facing && machine != null) machine.node.asInstanceOf[Connector] else null)
override protected def energyThroughput = Settings.get.caseRate(tier)
- override def getWorld = world
-
var maxComponents = 0
private def isCreativeCase = tier == Tier.Four
@@ -76,12 +73,12 @@ class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with
override def canUpdate = isServer
- override def updateEntity() {
+ override def update() {
if (isServer && isCreativeCase && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
// Creative case, make it generate power.
node.asInstanceOf[Connector].changeBuffer(Double.PositiveInfinity)
}
- super.updateEntity()
+ super.update()
}
// ----------------------------------------------------------------------- //
@@ -91,20 +88,11 @@ class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with
color = Color.byTier(tier)
super.readFromNBT(nbt)
recomputeMaxComponents()
-
- // Code for migrating from 1.4.1 -> 1.4.2, add EEPROM.
- // TODO Remove in 1.5
- if (!nbt.hasKey(Settings.namespace + "biosFlag")) {
- items(items.length - 1) = Option(Items.createLuaBios())
- }
}
override def writeToNBT(nbt: NBTTagCompound) {
nbt.setByte(Settings.namespace + "tier", tier.toByte)
super.writeToNBT(nbt)
-
- // TODO Remove in 1.5
- nbt.setBoolean(Settings.namespace + "biosFlag", true)
}
// ----------------------------------------------------------------------- //
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Charger.scala b/src/main/scala/li/cil/oc/common/tileentity/Charger.scala
index eb9d49c12..d0954ef0b 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Charger.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Charger.scala
@@ -1,7 +1,8 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.util.EnumParticleTypes
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.api
@@ -18,7 +19,7 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.Vec3
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.convert.WrapAsScala._
import scala.collection.mutable
@@ -39,13 +40,13 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = side != facing
+ override protected def hasConnector(side: EnumFacing) = side != facing
- override protected def connector(side: ForgeDirection) = Option(if (side != facing) node else null)
+ override protected def connector(side: EnumFacing) = Option(if (side != facing) node else null)
override protected def energyThroughput = Settings.get.chargerRate
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
player.addChatMessage(Localization.Analyzer.ChargerSpeed(chargeSpeed))
null
}
@@ -54,8 +55,8 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
override def canUpdate = true
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
// Offset by hashcode to avoid all chargers ticking at the same time.
if ((world.getWorldInfo.getWorldTotalTime + math.abs(hashCode())) % 20 == 0) {
@@ -105,7 +106,7 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
val dx = 0.45 * Math.sin(theta) * Math.cos(phi)
val dy = 0.45 * Math.sin(theta) * Math.sin(phi)
val dz = 0.45 * Math.cos(theta)
- world.spawnParticle("happyVillager", position.xCoord + dx, position.yCoord + dz, position.zCoord + dy, 0, 0, 0)
+ world.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, position.xCoord + dx, position.yCoord + dz, position.zCoord + dy, 0, 0, 0)
}
}
}
@@ -168,9 +169,9 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
// ----------------------------------------------------------------------- //
- override protected def updateRedstoneInput(side: ForgeDirection) {
+ override protected def updateRedstoneInput(side: EnumFacing) {
super.updateRedstoneInput(side)
- val signal = math.max(0, math.min(15, ForgeDirection.VALID_DIRECTIONS.map(input).max))
+ val signal = math.max(0, math.min(15, EnumFacing.values.map(input).max))
if (invertSignal) chargeSpeed = (15 - signal) / 15.0
else chargeSpeed = signal / 15.0
@@ -185,7 +186,7 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
}
def updateConnectors() {
- val robotConnectors = ForgeDirection.VALID_DIRECTIONS.map(side => {
+ val robotConnectors = EnumFacing.values.map(side => {
val blockPos = BlockPosition(this).offset(side)
if (world.blockExists(blockPos)) Option(world.getTileEntity(blockPos))
else None
@@ -193,7 +194,7 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
case Some(t: RobotProxy) => (BlockPosition(t).toVec3, t.robot.node.asInstanceOf[Connector])
}
val droneConnectors = world.getEntitiesWithinAABB(classOf[Drone], BlockPosition(this).bounds.expand(1, 1, 1)).collect {
- case drone: Drone => (Vec3.createVectorHelper(drone.posX, drone.posY, drone.posZ), drone.components.node.asInstanceOf[Connector])
+ case drone: Drone => (new Vec3(drone.posX, drone.posY, drone.posZ), drone.components.node.asInstanceOf[Connector])
}
connectors.clear()
connectors ++= robotConnectors
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala b/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala
index a91f564a2..d27e6f05f 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.network.Visibility
@@ -14,7 +14,7 @@ import li.cil.oc.util.ItemUtils
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.mutable
@@ -41,9 +41,9 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = side != ForgeDirection.UP
+ override protected def hasConnector(side: EnumFacing) = side != EnumFacing.UP
- override protected def connector(side: ForgeDirection) = Option(if (side != ForgeDirection.UP) node else null)
+ override protected def connector(side: EnumFacing) = Option(if (side != EnumFacing.UP) node else null)
override protected def energyThroughput = Settings.get.disassemblerRate
@@ -51,8 +51,8 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
override def canUpdate = isServer
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
if (queue.isEmpty) {
disassemble(decrStackSize(0, 1))
@@ -95,11 +95,11 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
private def drop(stack: ItemStack) {
if (stack != null) {
- for (side <- ForgeDirection.VALID_DIRECTIONS if stack.stackSize > 0) {
+ for (side <- EnumFacing.values if stack.stackSize > 0) {
InventoryUtils.insertIntoInventoryAt(stack, BlockPosition(this).offset(side), side.getOpposite)
}
if (stack.stackSize > 0) {
- spawnStackInWorld(stack, Option(ForgeDirection.UP))
+ spawnStackInWorld(stack, Option(EnumFacing.UP))
}
}
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/DiskDrive.scala b/src/main/scala/li/cil/oc/common/tileentity/DiskDrive.scala
index a3858d22f..ced41d382 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/DiskDrive.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/DiskDrive.scala
@@ -1,7 +1,8 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.api
import li.cil.oc.api.Driver
import li.cil.oc.api.network.Analyzable
@@ -30,7 +31,7 @@ class DiskDrive extends traits.Environment with traits.ComponentInventory with t
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = filesystemNode.fold(null: Array[Node])(Array(_))
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = filesystemNode.fold(null: Array[Node])(Array(_))
override def canUpdate = false
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala b/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala
index a37364bad..d184182c9 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Hologram.scala
@@ -1,7 +1,5 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.machine.Arguments
@@ -10,14 +8,14 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Analyzable
import li.cil.oc.api.network._
import li.cil.oc.common.SaveHandler
-import li.cil.oc.integration.Mods
-import li.cil.oc.integration.util.Waila
import li.cil.oc.server.{PacketSender => ServerPacketSender}
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.AxisAlignedBB
+import net.minecraft.util.EnumFacing
import net.minecraft.util.Vec3
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment with Analyzable with traits.Rotatable {
def this() = this(0)
@@ -39,7 +37,7 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
var scale = 1.0
// Projection Y position offset - consider adding X,Z later perhaps
- var translation = Vec3.createVectorHelper(0, 0, 0)
+ var translation = new Vec3(0, 0, 0)
// Relative number of lit columns (for energy cost).
var litRatio = -1.0
@@ -104,12 +102,12 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override def canConnect(side: ForgeDirection) = toLocal(side) == ForgeDirection.DOWN
+ override def canConnect(side: EnumFacing) = toLocal(side) == EnumFacing.DOWN
- override def sidedNode(side: ForgeDirection) = if (toLocal(side) == ForgeDirection.DOWN) node else null
+ override def sidedNode(side: EnumFacing) = if (toLocal(side) == EnumFacing.DOWN) node else null
// Override automatic analyzer implementation for sided environments.
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = Array(node)
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = Array(node)
// ----------------------------------------------------------------------- //
@@ -236,9 +234,7 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
val ty = math.max(0, math.min(maxTranslation * 2, args.checkDouble(1)))
val tz = math.max(-maxTranslation, math.min(maxTranslation, args.checkDouble(2)))
- translation.xCoord = tx
- translation.yCoord = ty
- translation.zCoord = tz
+ translation = new Vec3(tx, ty, tz)
ServerPacketSender.sendHologramOffset(this)
null
@@ -298,8 +294,8 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
override def canUpdate = isServer
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (isServer) {
if (dirty) {
cooldown -= 1
@@ -341,7 +337,7 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
val cz = z + 0.5
val sh = width / 16 * scale
val sv = height / 16 * scale
- AxisAlignedBB.getBoundingBox(
+ AxisAlignedBB.fromBounds(
cx + (-0.5 + translation.xCoord) * sh,
cy + translation.yCoord * sv,
cz + (-0.5 + translation.zCoord) * sh,
@@ -359,20 +355,19 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
tag.getIntArray("volume").copyToArray(volume)
tag.getIntArray("colors").map(convertColor).copyToArray(colors)
scale = nbt.getDouble(Settings.namespace + "scale")
- translation.xCoord = nbt.getDouble(Settings.namespace + "offsetX")
- translation.yCoord = nbt.getDouble(Settings.namespace + "offsetY")
- translation.zCoord = nbt.getDouble(Settings.namespace + "offsetZ")
+ val tx = nbt.getDouble(Settings.namespace + "offsetX")
+ val ty = nbt.getDouble(Settings.namespace + "offsetY")
+ val tz = nbt.getDouble(Settings.namespace + "offsetZ")
+ translation = new Vec3(tx, ty, tz)
}
override def writeToNBT(nbt: NBTTagCompound) = this.synchronized {
nbt.setByte(Settings.namespace + "tier", tier.toByte)
super.writeToNBT(nbt)
- if (!Mods.Waila.isAvailable || !Waila.isSavingForTooltip) {
- SaveHandler.scheduleSave(world, x, z, nbt, node.address + "_data", tag => {
- tag.setIntArray("volume", volume)
- tag.setIntArray("colors", colors.map(convertColor))
- })
- }
+ SaveHandler.scheduleSave(world, x, z, nbt, node.address + "_data", tag => {
+ tag.setIntArray("volume", volume)
+ tag.setIntArray("colors", colors.map(convertColor))
+ })
nbt.setDouble(Settings.namespace + "scale", scale)
nbt.setDouble(Settings.namespace + "offsetX", translation.xCoord)
nbt.setDouble(Settings.namespace + "offsetY", translation.yCoord)
@@ -386,9 +381,10 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
nbt.getIntArray("colors").copyToArray(colors)
scale = nbt.getDouble("scale")
hasPower = nbt.getBoolean("hasPower")
- translation.xCoord = nbt.getDouble("offsetX")
- translation.yCoord = nbt.getDouble("offsetY")
- translation.zCoord = nbt.getDouble("offsetZ")
+ val tx = nbt.getDouble("offsetX")
+ val ty = nbt.getDouble("offsetY")
+ val tz = nbt.getDouble("offsetZ")
+ translation = new Vec3(tx, ty, tz)
}
override def writeToNBTForClient(nbt: NBTTagCompound) {
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Keyboard.scala b/src/main/scala/li/cil/oc/common/tileentity/Keyboard.scala
index 7ac1d8993..d246482e2 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Keyboard.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Keyboard.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.network.Analyzable
@@ -9,10 +9,10 @@ import li.cil.oc.api.network.SidedEnvironment
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Keyboard extends traits.Environment with traits.Rotatable with traits.ImmibisMicroblock with SidedEnvironment with Analyzable {
- override def validFacings = ForgeDirection.VALID_DIRECTIONS
+ override def validFacings = EnumFacing.values
val keyboard = {
val keyboardItem = api.Items.get("keyboard").createItemStack(1)
@@ -21,18 +21,18 @@ class Keyboard extends traits.Environment with traits.Rotatable with traits.Immi
override def node = keyboard.node
- def hasNodeOnSide(side: ForgeDirection) =
+ def hasNodeOnSide(side: EnumFacing) =
side == facing.getOpposite || side == forward || (isOnWall && side == forward.getOpposite)
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override def canConnect(side: ForgeDirection) = hasNodeOnSide(side)
+ override def canConnect(side: EnumFacing) = hasNodeOnSide(side)
- override def sidedNode(side: ForgeDirection) = if (hasNodeOnSide(side)) node else null
+ override def sidedNode(side: EnumFacing) = if (hasNodeOnSide(side)) node else null
// Override automatic analyzer implementation for sided environments.
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = Array(node)
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = Array(node)
// ----------------------------------------------------------------------- //
@@ -54,7 +54,7 @@ class Keyboard extends traits.Environment with traits.Rotatable with traits.Immi
// ----------------------------------------------------------------------- //
- private def isOnWall = facing != ForgeDirection.UP && facing != ForgeDirection.DOWN
+ private def isOnWall = facing != EnumFacing.UP && facing != EnumFacing.DOWN
- private def forward = if (isOnWall) ForgeDirection.UP else yaw
+ private def forward = if (isOnWall) EnumFacing.UP else yaw
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Microcontroller.scala b/src/main/scala/li/cil/oc/common/tileentity/Microcontroller.scala
index 77752d978..bb2151c95 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Microcontroller.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Microcontroller.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.Driver
@@ -18,7 +18,7 @@ import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.ItemUtils
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Microcontroller extends traits.PowerAcceptor with traits.Computer with SidedEnvironment with internal.Microcontroller {
val info = new ItemUtils.MicrocontrollerData()
@@ -40,15 +40,15 @@ class Microcontroller extends traits.PowerAcceptor with traits.Computer with Sid
// ----------------------------------------------------------------------- //
- override def sidedNode(side: ForgeDirection) = if (side != facing) node else null
+ override def sidedNode(side: EnumFacing) = if (side != facing) node else null
@SideOnly(Side.CLIENT)
- override def canConnect(side: ForgeDirection) = side != facing
+ override def canConnect(side: EnumFacing) = side != facing
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = side != facing
+ override protected def hasConnector(side: EnumFacing) = side != facing
- override protected def connector(side: ForgeDirection) = Option(if (side != facing && machine != null) machine.node.asInstanceOf[Connector] else null)
+ override protected def connector(side: EnumFacing) = Option(if (side != facing && machine != null) machine.node.asInstanceOf[Connector] else null)
override protected def energyThroughput = Settings.get.caseRate(Tier.One)
@@ -102,8 +102,8 @@ class Microcontroller extends traits.PowerAcceptor with traits.Computer with Sid
override def canUpdate = isServer
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
// Pump energy into the internal network.
if (world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
diff --git a/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala b/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala
index bbd0d27bc..4bee10cc7 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala
@@ -31,8 +31,8 @@ class MotionSensor extends traits.Environment {
override def canUpdate = isServer
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (world.getTotalWorldTime % 10 == 0) {
// Get a list of all living entities we could possibly detect, using a rough
// bounding box check, then refining it using the actual distance and an
@@ -61,7 +61,7 @@ class MotionSensor extends traits.Environment {
}
}
- private def sensorBounds = AxisAlignedBB.getBoundingBox(
+ private def sensorBounds = AxisAlignedBB.fromBounds(
x + 0.5 - radius, y + 0.5 - radius, z + 0.5 - radius,
x + 0.5 + radius, y + 0.5 + radius, z + 0.5 + radius)
@@ -73,21 +73,23 @@ class MotionSensor extends traits.Environment {
// is pseudo-infrared driven (it only works for *living* entities, after
// all), so I think it makes more sense for it to work in the dark, too.
/* entity.getBrightness(0) > 0.2 && */ {
- val origin = Vec3.createVectorHelper(x + 0.5, y + 0.5, z + 0.5)
- val target = Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ)
+ var ox = x + 0.5
+ var oy = y + 0.5
+ var oz = z + 0.5
+ val target = new Vec3(entity.posX, entity.posY, entity.posZ)
// Start trace outside of this block.
- if (entity.posX < x) origin.xCoord -= 0.75
- if (entity.posX > x + 1) origin.xCoord += 0.75
- if (entity.posY < y) origin.yCoord -= 0.75
- if (entity.posY > y + 1) origin.yCoord += 0.75
- if (entity.posZ < z) origin.zCoord -= 0.75
- if (entity.posZ > z + 1) origin.zCoord += 0.75
- world.rayTraceBlocks(origin, target) == null
+ if (entity.posX < x) ox -= 0.75
+ if (entity.posX > x + 1) ox += 0.75
+ if (entity.posY < y) oy -= 0.75
+ if (entity.posY > y + 1) oy += 0.75
+ if (entity.posZ < z) oz -= 0.75
+ if (entity.posZ > z + 1) oz += 0.75
+ world.rayTraceBlocks(new Vec3(ox, oy, oz), target) == null
}
private def sendSignal(entity: EntityLivingBase) {
if (Settings.get.inputUsername) {
- node.sendToReachable("computer.signal", "motion", Double.box(entity.posX - (x + 0.5)), Double.box(entity.posY - (y + 0.5)), Double.box(entity.posZ - (z + 0.5)), entity.getCommandSenderName)
+ node.sendToReachable("computer.signal", "motion", Double.box(entity.posX - (x + 0.5)), Double.box(entity.posY - (y + 0.5)), Double.box(entity.posZ - (z + 0.5)), entity.getName)
}
else {
node.sendToReachable("computer.signal", "motion", Double.box(entity.posX - (x + 0.5)), Double.box(entity.posY - (y + 0.5)), Double.box(entity.posZ - (z + 0.5)))
diff --git a/src/main/scala/li/cil/oc/common/tileentity/PowerConverter.scala b/src/main/scala/li/cil/oc/common/tileentity/PowerConverter.scala
index 005159f84..9aeb0b6e2 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/PowerConverter.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/PowerConverter.scala
@@ -1,11 +1,11 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.network._
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class PowerConverter extends traits.PowerAcceptor with traits.Environment with traits.NotAnalyzable {
val node = api.Network.newNode(this, Visibility.Network).
@@ -13,9 +13,9 @@ class PowerConverter extends traits.PowerAcceptor with traits.Environment with t
create()
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = true
+ override protected def hasConnector(side: EnumFacing) = true
- override protected def connector(side: ForgeDirection) = Option(node)
+ override protected def connector(side: EnumFacing) = Option(node)
override protected def energyThroughput = Settings.get.powerConverterRate
diff --git a/src/main/scala/li/cil/oc/common/tileentity/PowerDistributor.scala b/src/main/scala/li/cil/oc/common/tileentity/PowerDistributor.scala
index e1eda922c..45605f25f 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/PowerDistributor.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/PowerDistributor.scala
@@ -1,14 +1,14 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.network._
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class PowerDistributor extends traits.Environment with traits.PowerBalancer with traits.NotAnalyzable {
val node = null
@@ -24,9 +24,9 @@ class PowerDistributor extends traits.Environment with traits.PowerBalancer with
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override def canConnect(side: ForgeDirection) = true
+ override def canConnect(side: EnumFacing) = true
- override def sidedNode(side: ForgeDirection) = nodes(side.ordinal)
+ override def sidedNode(side: EnumFacing) = nodes(side.ordinal)
// ----------------------------------------------------------------------- //
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Raid.scala b/src/main/scala/li/cil/oc/common/tileentity/Raid.scala
index d51ca682e..128528c35 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Raid.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Raid.scala
@@ -2,8 +2,9 @@ package li.cil.oc.common.tileentity
import java.util.UUID
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.Driver
@@ -33,7 +34,7 @@ class Raid extends traits.Environment with traits.Inventory with traits.Rotatabl
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = Array(filesystem.map(_.node).orNull)
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = Array(filesystem.map(_.node).orNull)
override def canUpdate = false
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Redstone.scala b/src/main/scala/li/cil/oc/common/tileentity/Redstone.scala
index 8dda0180d..c1c9aa7e9 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Redstone.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Redstone.scala
@@ -8,7 +8,7 @@ import li.cil.oc.integration.util.BundledRedstone
import li.cil.oc.server.component
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Redstone extends Environment with BundledRedstoneAware {
val instance = if (BundledRedstone.isAvailable) new component.Redstone[BundledRedstoneAware](this) with component.RedstoneBundled else new component.Redstone(this)
@@ -34,7 +34,7 @@ class Redstone extends Environment with BundledRedstoneAware {
// ----------------------------------------------------------------------- //
- override protected def onRedstoneInputChanged(side: ForgeDirection) {
+ override protected def onRedstoneInputChanged(side: EnumFacing) {
super.onRedstoneInputChanged(side)
node.sendToReachable("computer.signal", "redstone_changed", Int.box(side.ordinal()))
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala
index 7384576b2..e5b83059f 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala
@@ -2,8 +2,12 @@ package li.cil.oc.common.tileentity
import java.util.UUID
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import com.sun.javafx.geom.Vec3f
+import net.minecraft.init.Blocks
+import net.minecraft.util.BlockPos
+import net.minecraft.util.Vec3
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc._
import li.cil.oc.api.Driver
import li.cil.oc.api.driver.item
@@ -39,7 +43,7 @@ import net.minecraft.inventory.IInventory
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.fluids._
import scala.collection.mutable
@@ -81,17 +85,27 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
override def decrStackSize(slot: Int, amount: Int) = Robot.this.decrStackSize(actualSlot(slot), amount)
- override def getInventoryName = Robot.this.getInventoryName
+ override def getName = Robot.this.getName
- override def hasCustomInventoryName = Robot.this.hasCustomInventoryName
+ override def hasCustomName = Robot.this.hasCustomName
- override def openInventory() = Robot.this.openInventory()
+ override def openInventory(player: EntityPlayer) = Robot.this.openInventory(player)
- override def closeInventory() = Robot.this.closeInventory()
+ override def closeInventory(player: EntityPlayer) = Robot.this.closeInventory(player)
override def getStackInSlotOnClosing(slot: Int) = Robot.this.getStackInSlotOnClosing(actualSlot(slot))
override def isUseableByPlayer(player: EntityPlayer) = Robot.this.isUseableByPlayer(player)
+
+ override def getField(id: Int) = Robot.this.getField(id)
+
+ override def setField(id: Int, value: Int) = Robot.this.setField(id, value)
+
+ override def getFieldCount = Robot.this.getFieldCount
+
+ override def clear() = Robot.this.clear()
+
+ override def getDisplayName = Robot.this.getDisplayName
}
val actualInventorySize = 86
@@ -156,7 +170,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
var animationTicksTotal = 0
- var moveFromX, moveFromY, moveFromZ = Int.MaxValue
+ var moveFrom: Option[BlockPos] = None
var swingingTool = false
@@ -182,24 +196,24 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
def name = info.name
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
player.addChatMessage(Localization.Analyzer.RobotOwner(owner))
- player.addChatMessage(Localization.Analyzer.RobotName(player_.getCommandSenderName))
+ player.addChatMessage(Localization.Analyzer.RobotName(player_.getName))
MinecraftForge.EVENT_BUS.post(new RobotAnalyzeEvent(this, player))
super.onAnalyze(player, side, hitX, hitY, hitZ)
}
- def player(facing: ForgeDirection = facing, side: ForgeDirection = facing) = {
+ def player(facing: EnumFacing = facing, side: EnumFacing = facing) = {
player_.updatePositionAndRotation(facing, side)
player_
}
def actualSlot(n: Int) = n + 1 + containerCount
- def move(direction: ForgeDirection): Boolean = {
- val oldPosition = BlockPosition(this)
+ def move(direction: EnumFacing): Boolean = {
+ val oldPosition = getPos
val newPosition = oldPosition.offset(direction)
- if (!world.blockExists(newPosition)) {
+ if (!world.isBlockLoaded(newPosition)) {
return false // Don't fall off the earth.
}
@@ -212,8 +226,9 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
val blockRobotProxy = api.Items.get("robot").block.asInstanceOf[common.block.RobotProxy]
val blockRobotAfterImage = api.Items.get("robotAfterimage").block.asInstanceOf[common.block.RobotAfterimage]
val wasAir = world.isAirBlock(newPosition)
- val block = world.getBlock(newPosition)
- val metadata = world.getBlockMetadata(newPosition)
+ val state = world.getBlockState(newPosition)
+ val block = state.getBlock
+ val metadata = block.getMetaFromState(state)
try {
// Setting this will make the tile entity created via the following call
// to setBlock to re-use our "real" instance as the inner object, instead
@@ -226,13 +241,13 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
world.setBlockToAir(newPosition)
// In some cases (though I couldn't quite figure out which one) setBlock
// will return true, even though the block was not created / adjusted.
- val created = world.setBlock(newPosition, blockRobotProxy, 0, 1) &&
+ val created = world.setBlockState(newPosition, blockRobotProxy.getDefaultState, 1) &&
world.getTileEntity(newPosition) == proxy
if (created) {
- assert(BlockPosition(this) == newPosition)
- world.setBlock(oldPosition, net.minecraft.init.Blocks.air, 0, 1)
- world.setBlock(oldPosition, blockRobotAfterImage, 0, 1)
- assert(world.getBlock(oldPosition) == blockRobotAfterImage)
+ assert(getPos == newPosition)
+ world.setBlockState(oldPosition, net.minecraft.init.Blocks.air.getDefaultState, 1)
+ world.setBlockState(oldPosition, blockRobotAfterImage.getDefaultState, 1)
+ assert(world.getBlockState(oldPosition).getBlock == blockRobotAfterImage)
// Here instead of Lua callback so that it gets called on client, too.
val moveTicks = math.max((Settings.get.moveDelay * 20).toInt, 1)
setAnimateMove(oldPosition, moveTicks)
@@ -244,15 +259,17 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
else {
// If we broke some replaceable block (like grass) play its break sound.
if (!wasAir) {
- if (block != null && block != blockRobotAfterImage) {
+ if (block != Blocks.air && block != blockRobotAfterImage) {
if (FluidRegistry.lookupFluidForBlock(block) == null &&
!block.isInstanceOf[BlockFluidBase] &&
!block.isInstanceOf[BlockLiquid]) {
world.playAuxSFX(2001, newPosition, Block.getIdFromBlock(block) + (metadata << 12))
}
else {
- val soundPos = newPosition.toVec3
- world.playSound(soundPos.xCoord, soundPos.yCoord, soundPos.zCoord, "liquid.water",
+ val sx = newPosition.getX + 0.5
+ val sy = newPosition.getY + 0.5
+ val sz = newPosition.getZ + 0.5
+ world.playSound(sx, sy, sz, "liquid.water",
world.rand.nextFloat * 0.25f + 0.75f, world.rand.nextFloat * 1.0f + 0.5f, false)
}
}
@@ -274,7 +291,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
// ----------------------------------------------------------------------- //
- def isAnimatingMove = animationTicksLeft > 0 && (moveFromX != Int.MaxValue || moveFromY != Int.MaxValue || moveFromZ != Int.MaxValue)
+ def isAnimatingMove = animationTicksLeft > 0 && moveFrom.isDefined
def isAnimatingSwing = animationTicksLeft > 0 && swingingTool
@@ -290,12 +307,10 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
ServerPacketSender.sendRobotAnimateTurn(this)
}
- def setAnimateMove(fromPosition: BlockPosition, ticks: Int) {
+ def setAnimateMove(fromPosition: BlockPos, ticks: Int) {
animationTicksTotal = ticks
prepareForAnimation()
- moveFromX = fromPosition.x
- moveFromY = fromPosition.y
- moveFromZ = fromPosition.z
+ moveFrom = Some(fromPosition)
}
def setAnimateSwing(ticks: Int) {
@@ -312,9 +327,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
private def prepareForAnimation() {
animationTicksLeft = animationTicksTotal
- moveFromX = Int.MaxValue
- moveFromY = Int.MaxValue
- moveFromZ = Int.MaxValue
+ moveFrom = None
swingingTool = false
turnAxis = 0
}
@@ -324,22 +337,20 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
override def shouldRenderInPass(pass: Int) = true
override def getRenderBoundingBox =
- getBlockType.getCollisionBoundingBoxFromPool(world, x, y, z).expand(0.5, 0.5, 0.5)
+ getBlockType.getCollisionBoundingBox(world, getPos, world.getBlockState(getPos)).expand(0.5, 0.5, 0.5)
// ----------------------------------------------------------------------- //
- override def updateEntity() {
+ override def update() {
if (animationTicksLeft > 0) {
animationTicksLeft -= 1
if (animationTicksLeft == 0) {
- moveFromX = Int.MaxValue
- moveFromY = Int.MaxValue
- moveFromZ = Int.MaxValue
+ moveFrom = None
swingingTool = false
turnAxis = 0
}
}
- super.updateEntity()
+ super.update()
if (isServer) {
if (world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
if (info.tier == 3) {
@@ -404,9 +415,10 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
animationTicksTotal = nbt.getInteger(Settings.namespace + "animationTicksTotal")
animationTicksLeft = nbt.getInteger(Settings.namespace + "animationTicksLeft")
if (animationTicksLeft > 0) {
- moveFromX = nbt.getInteger(Settings.namespace + "moveFromX")
- moveFromY = nbt.getInteger(Settings.namespace + "moveFromY")
- moveFromZ = nbt.getInteger(Settings.namespace + "moveFromZ")
+ val moveFromX = nbt.getInteger(Settings.namespace + "moveFromX")
+ val moveFromY = nbt.getInteger(Settings.namespace + "moveFromY")
+ val moveFromZ = nbt.getInteger(Settings.namespace + "moveFromZ")
+ moveFrom = Some(new BlockPos(moveFromX, moveFromY, moveFromZ))
swingingTool = nbt.getBoolean(Settings.namespace + "swingingTool")
turnAxis = nbt.getByte(Settings.namespace + "turnAxis")
}
@@ -426,9 +438,9 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
if (isAnimatingMove || isAnimatingSwing || isAnimatingTurn) {
nbt.setInteger(Settings.namespace + "animationTicksTotal", animationTicksTotal)
nbt.setInteger(Settings.namespace + "animationTicksLeft", animationTicksLeft)
- nbt.setInteger(Settings.namespace + "moveFromX", moveFromX)
- nbt.setInteger(Settings.namespace + "moveFromY", moveFromY)
- nbt.setInteger(Settings.namespace + "moveFromZ", moveFromZ)
+ nbt.setInteger(Settings.namespace + "moveFromX", moveFrom.get.getX)
+ nbt.setInteger(Settings.namespace + "moveFromY", moveFrom.get.getY)
+ nbt.setInteger(Settings.namespace + "moveFromZ", moveFrom.get.getZ)
nbt.setBoolean(Settings.namespace + "swingingTool", swingingTool)
nbt.setByte(Settings.namespace + "turnAxis", turnAxis.toByte)
}
@@ -445,9 +457,10 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
selectedSlot = nbt.getInteger("selectedSlot")
animationTicksTotal = nbt.getInteger("animationTicksTotal")
animationTicksLeft = nbt.getInteger("animationTicksLeft")
- moveFromX = nbt.getInteger("moveFromX")
- moveFromY = nbt.getInteger("moveFromY")
- moveFromZ = nbt.getInteger("moveFromZ")
+ val moveFromX = nbt.getInteger("moveFromX")
+ val moveFromY = nbt.getInteger("moveFromY")
+ val moveFromZ = nbt.getInteger("moveFromZ")
+ moveFrom = Some(new BlockPos(moveFromX, moveFromY, moveFromZ))
if (animationTicksLeft > 0) {
swingingTool = nbt.getBoolean("swingingTool")
turnAxis = nbt.getByte("turnAxis")
@@ -464,9 +477,9 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
if (isAnimatingMove || isAnimatingSwing || isAnimatingTurn) {
nbt.setInteger("animationTicksTotal", animationTicksTotal)
nbt.setInteger("animationTicksLeft", animationTicksLeft)
- nbt.setInteger("moveFromX", moveFromX)
- nbt.setInteger("moveFromY", moveFromY)
- nbt.setInteger("moveFromZ", moveFromZ)
+ nbt.setInteger("moveFromX", moveFrom.get.getX)
+ nbt.setInteger("moveFromY", moveFrom.get.getY)
+ nbt.setInteger("moveFromZ", moveFrom.get.getZ)
nbt.setBoolean("swingingTool", swingingTool)
nbt.setByte("turnAxis", turnAxis.toByte)
}
@@ -509,7 +522,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
}
if (isComponentSlot(slot)) {
super.onItemAdded(slot, stack)
- world.notifyBlocksOfNeighborChange(x, y, z, getBlockType)
+ world.notifyBlocksOfNeighborChange(position, getBlockType)
}
if (isInventorySlot(slot)) {
machine.signal("inventory_changed", Int.box(slot - actualSlot(0) + 1))
@@ -534,7 +547,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
machine.signal("inventory_changed", Int.box(slot - actualSlot(0) + 1))
}
if (isComponentSlot(slot)) {
- world.notifyBlocksOfNeighborChange(x, y, z, getBlockType)
+ world.notifyBlocksOfNeighborChange(position, getBlockType)
}
}
}
@@ -704,7 +717,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
}
else super.setInventorySlotContents(slot, stack)
}
- else if (stack != null && stack.stackSize > 0) spawnStackInWorld(stack, Option(ForgeDirection.UP))
+ else if (stack != null && stack.stackSize > 0) spawnStackInWorld(stack, Option(EnumFacing.UP))
}
override def isItemValidForSlot(slot: Int, stack: ItemStack) = (slot, Option(Driver.driverFor(stack, getClass))) match {
@@ -727,7 +740,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
// ----------------------------------------------------------------------- //
- override def dropSlot(slot: Int, count: Int, direction: Option[ForgeDirection]) =
+ override def dropSlot(slot: Int, count: Int, direction: Option[EnumFacing]) =
InventoryUtils.dropSlot(BlockPosition(x, y, z, world), dynamicInventory, slot, count, direction)
override def dropAllSlots() =
@@ -735,17 +748,17 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
// ----------------------------------------------------------------------- //
- override def canExtractItem(slot: Int, stack: ItemStack, side: Int) =
- getAccessibleSlotsFromSide(side).contains(slot)
+ override def canExtractItem(slot: Int, stack: ItemStack, side: EnumFacing) =
+ getSlotsForFace(side).contains(slot)
- override def canInsertItem(slot: Int, stack: ItemStack, side: Int) =
- getAccessibleSlotsFromSide(side).contains(slot) &&
+ override def canInsertItem(slot: Int, stack: ItemStack, side: EnumFacing) =
+ getSlotsForFace(side).contains(slot) &&
isItemValidForSlot(slot, stack)
- override def getAccessibleSlotsFromSide(side: Int) =
- toLocal(ForgeDirection.getOrientation(side)) match {
- case ForgeDirection.WEST => Array(0) // Tool
- case ForgeDirection.EAST => containerSlots.toArray
+ override def getSlotsForFace(side: EnumFacing) =
+ toLocal(side) match {
+ case EnumFacing.WEST => Array(0) // Tool
+ case EnumFacing.EAST => containerSlots.toArray
case _ => inventorySlots.toArray
}
@@ -768,21 +781,21 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
// ----------------------------------------------------------------------- //
- override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean) =
+ override def fill(from: EnumFacing, resource: FluidStack, doFill: Boolean) =
tryGetTank(selectedTank) match {
case Some(t) =>
t.fill(resource, doFill)
case _ => 0
}
- override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean) =
+ override def drain(from: EnumFacing, resource: FluidStack, doDrain: Boolean) =
tryGetTank(selectedTank) match {
case Some(t) if t.getFluid != null && t.getFluid.isFluidEqual(resource) =>
t.drain(resource.amount, doDrain)
case _ => null
}
- override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean) = {
+ override def drain(from: EnumFacing, maxDrain: Int, doDrain: Boolean) = {
tryGetTank(selectedTank) match {
case Some(t) =>
t.drain(maxDrain, doDrain)
@@ -790,21 +803,21 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
}
}
- override def canFill(from: ForgeDirection, fluid: Fluid) = {
+ override def canFill(from: EnumFacing, fluid: Fluid) = {
tryGetTank(selectedTank) match {
case Some(t) => t.getFluid == null || t.getFluid.getFluid == fluid
case _ => false
}
}
- override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = {
+ override def canDrain(from: EnumFacing, fluid: Fluid): Boolean = {
tryGetTank(selectedTank) match {
case Some(t) => t.getFluid != null && t.getFluid.getFluid == fluid
case _ => false
}
}
- override def getTankInfo(from: ForgeDirection) =
+ override def getTankInfo(from: EnumFacing) =
components.collect {
case Some(t: IFluidTank) => t.getInfo
}.toArray
diff --git a/src/main/scala/li/cil/oc/common/tileentity/RobotProxy.scala b/src/main/scala/li/cil/oc/common/tileentity/RobotProxy.scala
index 6e03d691e..3e35bda2a 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/RobotProxy.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/RobotProxy.scala
@@ -1,8 +1,5 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.common.Optional
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.api
import li.cil.oc.api.internal
import li.cil.oc.api.machine.Arguments
@@ -10,14 +7,17 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._
import li.cil.oc.common.inventory.MultiTank
-import li.cil.oc.integration.Mods
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
+/* TODO RedLogic
import mods.immibis.redlogic.api.wiring.IWire
+*/
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.inventory.ISidedInventory
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.fluids.Fluid
import net.minecraftforge.fluids.FluidStack
import net.minecraftforge.fluids.IFluidHandler
@@ -91,8 +91,8 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
// ----------------------------------------------------------------------- //
- override def updateEntity() {
- robot.updateEntity()
+ override def update() {
+ robot.update()
}
override def validate() {
@@ -100,9 +100,7 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
val firstProxy = robot.proxy == null
robot.proxy = this
robot.setWorldObj(worldObj)
- robot.xCoord = xCoord
- robot.yCoord = yCoord
- robot.zCoord = zCoord
+ robot.setPos(getPos)
if (firstProxy) {
robot.validate()
}
@@ -151,7 +149,7 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = robot.onAnalyze(player, side, hitX, hitY, hitZ)
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = robot.onAnalyze(player, side, hitX, hitY, hitZ)
// ----------------------------------------------------------------------- //
@@ -171,6 +169,7 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
override def checkRedstoneInputChanged() = robot.checkRedstoneInputChanged()
+/* TORO RedLogic
@Optional.Method(modid = Mods.IDs.RedLogic)
override def connects(wire: IWire, blockFace: Int, fromDirection: Int) = robot.connects(wire, blockFace, fromDirection)
@@ -188,30 +187,31 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
@Optional.Method(modid = Mods.IDs.RedLogic)
override def onRedstoneInputChanged() = robot.onRedstoneInputChanged()
+*/
// ----------------------------------------------------------------------- //
override def pitch = robot.pitch
- override def pitch_=(value: ForgeDirection) = robot.pitch_=(value)
+ override def pitch_=(value: EnumFacing) = robot.pitch_=(value)
override def yaw = robot.yaw
- override def yaw_=(value: ForgeDirection) = robot.yaw_=(value)
+ override def yaw_=(value: EnumFacing) = robot.yaw_=(value)
override def setFromEntityPitchAndYaw(entity: Entity) = robot.setFromEntityPitchAndYaw(entity)
- override def setFromFacing(value: ForgeDirection) = robot.setFromFacing(value)
+ override def setFromFacing(value: EnumFacing) = robot.setFromFacing(value)
override def invertRotation() = robot.invertRotation()
override def facing = robot.facing
- override def rotate(axis: ForgeDirection) = robot.rotate(axis)
+ override def rotate(axis: EnumFacing) = robot.rotate(axis)
- override def toLocal(value: ForgeDirection) = robot.toLocal(value)
+ override def toLocal(value: EnumFacing) = robot.toLocal(value)
- override def toGlobal(value: ForgeDirection) = robot.toGlobal(value)
+ override def toGlobal(value: EnumFacing) = robot.toGlobal(value)
// ----------------------------------------------------------------------- //
@@ -223,15 +223,15 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
override def getStackInSlotOnClosing(slot: Int) = robot.getStackInSlotOnClosing(slot)
- override def openInventory() = robot.openInventory()
+ override def openInventory(player: EntityPlayer) = robot.openInventory(player)
- override def closeInventory() = robot.closeInventory()
+ override def closeInventory(player: EntityPlayer) = robot.closeInventory(player)
- override def hasCustomInventoryName = robot.hasCustomInventoryName
+ override def hasCustomName = robot.hasCustomName
override def isUseableByPlayer(player: EntityPlayer) = robot.isUseableByPlayer(player)
- override def dropSlot(slot: Int, count: Int, direction: Option[ForgeDirection]) = robot.dropSlot(slot, count, direction)
+ override def dropSlot(slot: Int, count: Int, direction: Option[EnumFacing]) = robot.dropSlot(slot, count, direction)
override def dropAllSlots() = robot.dropAllSlots()
@@ -243,7 +243,7 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
override def componentSlot(address: String) = robot.componentSlot(address)
- override def getInventoryName = robot.getInventoryName
+ override def getName = robot.getName
override def getSizeInventory = robot.getSizeInventory
@@ -251,11 +251,11 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
// ----------------------------------------------------------------------- //
- override def canExtractItem(slot: Int, stack: ItemStack, side: Int) = robot.canExtractItem(slot, stack, side)
+ override def canExtractItem(slot: Int, stack: ItemStack, side: EnumFacing) = robot.canExtractItem(slot, stack, side)
- override def canInsertItem(slot: Int, stack: ItemStack, side: Int) = robot.canInsertItem(slot, stack, side)
+ override def canInsertItem(slot: Int, stack: ItemStack, side: EnumFacing) = robot.canInsertItem(slot, stack, side)
- override def getAccessibleSlotsFromSide(side: Int) = robot.getAccessibleSlotsFromSide(side)
+ override def getSlotsForFace(side: EnumFacing) = robot.getSlotsForFace(side)
// ----------------------------------------------------------------------- //
@@ -275,15 +275,15 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
// ----------------------------------------------------------------------- //
- override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean) = robot.fill(from, resource, doFill)
+ override def fill(from: EnumFacing, resource: FluidStack, doFill: Boolean) = robot.fill(from, resource, doFill)
- override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean) = robot.drain(from, resource, doDrain)
+ override def drain(from: EnumFacing, resource: FluidStack, doDrain: Boolean) = robot.drain(from, resource, doDrain)
- override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean) = robot.drain(from, maxDrain, doDrain)
+ override def drain(from: EnumFacing, maxDrain: Int, doDrain: Boolean) = robot.drain(from, maxDrain, doDrain)
- override def canFill(from: ForgeDirection, fluid: Fluid) = robot.canFill(from, fluid)
+ override def canFill(from: EnumFacing, fluid: Fluid) = robot.canFill(from, fluid)
- override def canDrain(from: ForgeDirection, fluid: Fluid) = robot.canDrain(from, fluid)
+ override def canDrain(from: EnumFacing, fluid: Fluid) = robot.canDrain(from, fluid)
- override def getTankInfo(from: ForgeDirection) = robot.getTankInfo(from)
+ override def getTankInfo(from: EnumFacing) = robot.getTankInfo(from)
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Screen.scala b/src/main/scala/li/cil/oc/common/tileentity/Screen.scala
index 4812ceb8d..87d8b8723 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Screen.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Screen.scala
@@ -1,18 +1,20 @@
package li.cil.oc.common.tileentity
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api.network.Analyzable
import li.cil.oc.api.network._
+import li.cil.oc.util.BlockPosition
import li.cil.oc.util.Color
+import li.cil.oc.util.ExtendedWorld._
import net.minecraft.client.Minecraft
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.projectile.EntityArrow
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.AxisAlignedBB
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import scala.collection.mutable
import scala.language.postfixOps
@@ -23,7 +25,7 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
// Enable redstone functionality.
_isOutputEnabled = true
- override def validFacings = ForgeDirection.VALID_DIRECTIONS
+ override def validFacings = EnumFacing.values
// ----------------------------------------------------------------------- //
@@ -57,25 +59,25 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
color = Color.byTier(tier)
@SideOnly(Side.CLIENT)
- override def canConnect(side: ForgeDirection) = toLocal(side) != ForgeDirection.SOUTH
+ override def canConnect(side: EnumFacing) = toLocal(side) != EnumFacing.SOUTH
// Allow connections from front for keyboards, and keyboards only...
- override def sidedNode(side: ForgeDirection) = if (toLocal(side) != ForgeDirection.SOUTH || world.getTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ).isInstanceOf[Keyboard]) node else null
+ override def sidedNode(side: EnumFacing) = if (toLocal(side) != EnumFacing.SOUTH || world.getTileEntity(getPos.offset(side)).isInstanceOf[Keyboard]) node else null
// ----------------------------------------------------------------------- //
def isOrigin = origin == this
def localPosition = {
- val (lx, ly, _) = project(this)
- val (ox, oy, _) = project(origin)
- (lx - ox, ly - oy)
+ val lpos = project(this)
+ val opos = project(origin)
+ (lpos.x - opos.x, lpos.y - opos.y)
}
def hasKeyboard = screens.exists(screen =>
- ForgeDirection.VALID_DIRECTIONS.map(side => (side, {
- val (nx, ny, nz) = (screen.x + side.offsetX, screen.y + side.offsetY, screen.z + side.offsetZ)
- if (world.blockExists(nx, ny, nz)) world.getTileEntity(nx, ny, nz)
+ EnumFacing.values.map(side => (side, {
+ val blockPos = BlockPosition(screen).offset(side)
+ if (world.blockExists(blockPos)) world.getTileEntity(blockPos)
else null
})).exists {
case (side, keyboard: Keyboard) => keyboard.hasNodeOnSide(side.getOpposite)
@@ -95,8 +97,8 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
def click(player: EntityPlayer, hitX: Double, hitY: Double, hitZ: Double): Boolean = {
// Compute absolute position of the click on the face, measured in blocks.
- def dot(f: ForgeDirection) = f.offsetX * hitX + f.offsetY * hitY + f.offsetZ * hitZ
- val (hx, hy) = (dot(toGlobal(ForgeDirection.EAST)), dot(toGlobal(ForgeDirection.UP)))
+ def dot(f: EnumFacing) = f.getFrontOffsetX * hitX + f.getFrontOffsetY * hitY + f.getFrontOffsetZ * hitZ
+ val (hx, hy) = (dot(toGlobal(EnumFacing.EAST)), dot(toGlobal(EnumFacing.UP)))
val tx = if (hx < 0) 1 + hx else hx
val ty = 1 - (if (hy < 0) 1 + hy else hy)
val (lx, ly) = localPosition
@@ -146,7 +148,7 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
val (x, y) = localPosition
entity match {
case player: EntityPlayer if Settings.get.inputUsername =>
- origin.node.sendToReachable("computer.signal", "walk", Int.box(x + 1), Int.box(height - y), player.getCommandSenderName)
+ origin.node.sendToReachable("computer.signal", "walk", Int.box(x + 1), Int.box(height - y), player.getName)
case _ =>
origin.node.sendToReachable("computer.signal", "walk", Int.box(x + 1), Int.box(height - y))
}
@@ -160,8 +162,8 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
override def canUpdate = true
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (shouldCheckForMultiBlock && ((isClient && isClientReadyForMultiBlockCheck) || (isServer && isConnected))) {
// Make sure we merge in a deterministic order, to avoid getting
// different results on server and client due to the update order
@@ -171,10 +173,10 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
val queue = mutable.Queue(this)
while (queue.nonEmpty) {
val current = queue.dequeue()
- val (lx, ly, lz) = project(current)
+ val lpos = project(current)
def tryQueue(dx: Int, dy: Int) {
- val (nx, ny, nz) = unproject(lx + dx, ly + dy, lz)
- if (world.blockExists(nx, ny, nz)) world.getTileEntity(nx, ny, nz) match {
+ val npos = unproject(lpos.x + dx, lpos.y + dy, lpos.z)
+ if (world.blockExists(npos)) world.getTileEntity(npos) match {
case s: Screen if s.pitch == pitch && s.yaw == yaw && pending.add(s) => queue += s
case _ => // Ignore.
}
@@ -279,11 +281,13 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
@SideOnly(Side.CLIENT) override
def readFromNBTForClient(nbt: NBTTagCompound) {
+ tier = nbt.getByte("tier") max 0 min 2
super.readFromNBTForClient(nbt)
invertTouchMode = nbt.getBoolean("invertTouchMode")
}
override def writeToNBTForClient(nbt: NBTTagCompound) {
+ nbt.setByte("tier", tier.toByte)
super.writeToNBTForClient(nbt)
nbt.setBoolean("invertTouchMode", invertTouchMode)
}
@@ -296,13 +300,14 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
else cachedBounds match {
case Some(bounds) => bounds
case _ =>
- val (sx, sy, sz) = unproject(width, height, 1)
- val ox = x + (if (sx < 0) 1 else 0)
- val oy = y + (if (sy < 0) 1 else 0)
- val oz = z + (if (sz < 0) 1 else 0)
- val b = AxisAlignedBB.getBoundingBox(ox, oy, oz, ox + sx, oy + sy, oz + sz)
- b.setBounds(math.min(b.minX, b.maxX), math.min(b.minY, b.maxY), math.min(b.minZ, b.maxZ),
- math.max(b.minX, b.maxX), math.max(b.minY, b.maxY), math.max(b.minZ, b.maxZ))
+ val spos = unproject(width, height, 1)
+ val ox = x + (if (spos.x < 0) 1 else 0)
+ val oy = y + (if (spos.y < 0) 1 else 0)
+ val oz = z + (if (spos.z < 0) 1 else 0)
+ val btmp = AxisAlignedBB.fromBounds(ox, oy, oz, ox + spos.x, oy + spos.y, oz + spos.z)
+ val b = AxisAlignedBB.fromBounds(
+ math.min(btmp.minX, btmp.maxX), math.min(btmp.minY, btmp.maxY), math.min(btmp.minZ, btmp.maxZ),
+ math.max(btmp.minX, btmp.maxX), math.max(btmp.minY, btmp.maxY), math.max(btmp.minZ, btmp.maxZ))
cachedBounds = Some(b)
b
}
@@ -312,9 +317,9 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = Array(origin.node)
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = Array(origin.node)
- override protected def onRedstoneInputChanged(side: ForgeDirection) {
+ override protected def onRedstoneInputChanged(side: EnumFacing) {
super.onRedstoneInputChanged(side)
val hasRedstoneInput = screens.map(_.maxInput).max > 0
if (hasRedstoneInput != hadRedstoneInput) {
@@ -340,21 +345,21 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
// ----------------------------------------------------------------------- //
private def tryMerge() = {
- val (ox, oy, oz) = project(origin)
+ val opos = project(origin)
def tryMergeTowards(dx: Int, dy: Int) = {
- val (nx, ny, nz) = unproject(ox + dx, oy + dy, oz)
- world.blockExists(nx, ny, nz) && (world.getTileEntity(nx, ny, nz) match {
+ val npos = unproject(opos.x + dx, opos.y + dy, opos.z)
+ world.blockExists(npos) && (world.getTileEntity(npos) match {
case s: Screen if s.tier == tier && s.pitch == pitch && s.color == color && s.yaw == yaw && !screens.contains(s) =>
- val (sx, sy, _) = project(s.origin)
- val canMergeAlongX = sy == oy && s.height == height && s.width + width <= Settings.get.maxScreenWidth
- val canMergeAlongY = sx == ox && s.width == width && s.height + height <= Settings.get.maxScreenHeight
+ val spos = project(s.origin)
+ val canMergeAlongX = spos.y == opos.y && s.height == height && s.width + width <= Settings.get.maxScreenWidth
+ val canMergeAlongY = spos.x == opos.x && s.width == width && s.height + height <= Settings.get.maxScreenHeight
if (canMergeAlongX || canMergeAlongY) {
val (newOrigin) =
if (canMergeAlongX) {
- if (sx < ox) s.origin else origin
+ if (spos.x < opos.x) s.origin else origin
}
else {
- if (sy < oy) s.origin else origin
+ if (spos.y < opos.y) s.origin else origin
}
val (newWidth, newHeight) =
if (canMergeAlongX) (width + s.width, height)
@@ -377,12 +382,12 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
}
private def project(t: Screen) = {
- def dot(f: ForgeDirection, s: Screen) = f.offsetX * s.x + f.offsetY * s.y + f.offsetZ * s.z
- (dot(toGlobal(ForgeDirection.EAST), t), dot(toGlobal(ForgeDirection.UP), t), dot(toGlobal(ForgeDirection.SOUTH), t))
+ def dot(f: EnumFacing, s: Screen) = f.getFrontOffsetX * s.x + f.getFrontOffsetY * s.y + f.getFrontOffsetZ * s.z
+ BlockPosition(dot(toGlobal(EnumFacing.EAST), t), dot(toGlobal(EnumFacing.UP), t), dot(toGlobal(EnumFacing.SOUTH), t))
}
private def unproject(x: Int, y: Int, z: Int) = {
- def dot(f: ForgeDirection) = f.offsetX * x + f.offsetY * y + f.offsetZ * z
- (dot(toLocal(ForgeDirection.EAST)), dot(toLocal(ForgeDirection.UP)), dot(toLocal(ForgeDirection.SOUTH)))
+ def dot(f: EnumFacing) = f.getFrontOffsetX * x + f.getFrontOffsetY * y + f.getFrontOffsetZ * z
+ BlockPosition(dot(toLocal(EnumFacing.EAST)), dot(toLocal(EnumFacing.UP)), dot(toLocal(EnumFacing.SOUTH)))
}
}
\ No newline at end of file
diff --git a/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala b/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala
index caf9e8124..b413e15ab 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala
@@ -1,10 +1,11 @@
package li.cil.oc.common.tileentity
import com.google.common.base.Strings
-import cpw.mods.fml.common.Optional.Method
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import li.cil.oc.util.BlockPosition
+import net.minecraftforge.fml.common.Optional.Method
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc._
import li.cil.oc.api.Network
import li.cil.oc.api.internal
@@ -12,28 +13,26 @@ import li.cil.oc.api.network.Analyzable
import li.cil.oc.api.network._
import li.cil.oc.client.Sound
import li.cil.oc.common.Tier
-import li.cil.oc.common.init.Items
import li.cil.oc.integration.Mods
import li.cil.oc.integration.opencomputers.DriverRedstoneCard
-import li.cil.oc.integration.stargatetech2.DriverAbstractBusCard
-import li.cil.oc.integration.util.Waila
import li.cil.oc.server.component
import li.cil.oc.server.{PacketSender => ServerPacketSender}
import li.cil.oc.util.ExtendedNBT._
+import li.cil.oc.util.ExtendedWorld._
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagString
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.event.world.WorldEvent
import scala.collection.mutable
-class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalancer with traits.Inventory with traits.Rotatable with traits.BundledRedstoneAware with traits.AbstractBusAware with Analyzable with internal.ServerRack {
+class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalancer with traits.Inventory with traits.Rotatable with traits.BundledRedstoneAware with Analyzable with internal.ServerRack {
val servers = Array.fill(getSizeInventory)(None: Option[component.Server])
- val sides = Seq(Option(ForgeDirection.UP), Option(ForgeDirection.EAST), Option(ForgeDirection.WEST), Option(ForgeDirection.DOWN)).
+ val sides = Seq(Option(EnumFacing.UP), Option(EnumFacing.EAST), Option(EnumFacing.WEST), Option(EnumFacing.DOWN)).
padTo(servers.length, None).toArray
val terminals = (0 until servers.length).map(new common.component.Terminal(this, _)).toArray
@@ -56,9 +55,9 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
override def server(slot: Int) = servers(slot).orNull
@SideOnly(Side.CLIENT)
- override protected def hasConnector(side: ForgeDirection) = side != facing
+ override protected def hasConnector(side: EnumFacing) = side != facing
- override protected def connector(side: ForgeDirection) = Option(if (side != facing) sidedNode(side).asInstanceOf[Connector] else null)
+ override protected def connector(side: EnumFacing) = Option(if (side != facing) sidedNode(side).asInstanceOf[Connector] else null)
override protected def energyThroughput = Settings.get.serverRackRate
@@ -66,13 +65,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
// ----------------------------------------------------------------------- //
- override def canConnect(side: ForgeDirection) = side != facing
-
- @Method(modid = Mods.IDs.StargateTech2)
- override def getInterfaces(side: Int) = if (side != facing.ordinal) {
- super.getInterfaces(side)
- }
- else null
+ override def canConnect(side: EnumFacing) = side != facing
// ----------------------------------------------------------------------- //
@@ -83,7 +76,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
@SideOnly(Side.CLIENT)
def setRunning(number: Int, value: Boolean) = {
_isRunning(number) = value
- world.markBlockForUpdate(x, y, z)
+ world.markBlockForUpdate(getPos)
if (anyRunning) Sound.startLoop(this, "computer_running", 1.5f, 50 + world.rand.nextInt(50))
else Sound.stopLoop(this)
this
@@ -95,21 +88,6 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
def markForSaving() = markChunkDirty = true
- override def installedComponents = servers.flatMap {
- case Some(server) => server.inventory.components collect {
- case Some(component) => component
- }
- case _ => Iterable.empty
- }
-
- def hasAbstractBusCard = servers exists {
- case Some(server) => server.machine.isRunning && server.inventory.items.exists {
- case Some(stack) => DriverAbstractBusCard.worksWith(stack, server.getClass)
- case _ => false
- }
- case _ => false
- }
-
def hasRedstoneCard = servers exists {
case Some(server) => server.machine.isRunning && server.inventory.items.exists {
case Some(stack) => DriverRedstoneCard.worksWith(stack, server.getClass)
@@ -122,7 +100,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
sides(number) match {
case Some(serverSide) =>
val serverNode = server.machine.node
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
+ for (side <- EnumFacing.values) {
if (toLocal(side) == serverSide) sidedNode(side).connect(serverNode)
else sidedNode(side).disconnect(serverNode)
}
@@ -134,7 +112,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
override protected def distribute() = {
def node(side: Int) = sides(side) match {
- case None | Some(ForgeDirection.UNKNOWN) => servers(side).fold(null: Connector)(_.machine.node.asInstanceOf[Connector])
+ case None => servers(side).fold(null: Connector)(_.machine.node.asInstanceOf[Connector])
case _ => null
}
val nodes = (0 to 3).map(node)
@@ -164,7 +142,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
// ----------------------------------------------------------------------- //
- override protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet) {
+ override protected def relayPacket(sourceSide: Option[EnumFacing], packet: Packet) {
if (internalSwitch) {
for (slot <- 0 until servers.length) {
val side = sides(slot).map(toGlobal)
@@ -205,8 +183,8 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
- slotAt(ForgeDirection.getOrientation(side), hitX, hitY, hitZ) match {
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
+ slotAt(side, hitX, hitY, hitZ) match {
case Some(slot) => servers(slot) match {
case Some(server) =>
val computer = server.machine
@@ -223,11 +201,11 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
Array(computer.node)
case _ => null
}
- case _ => Array(sidedNode(ForgeDirection.getOrientation(side)))
+ case _ => Array(sidedNode(side))
}
}
- def slotAt(side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
+ def slotAt(side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
if (side == facing) {
val l = 2 / 16.0
val h = 14 / 16.0
@@ -241,8 +219,8 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
override def canUpdate = isServer
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (isServer && isConnected) {
val shouldUpdatePower = world.getTotalWorldTime % Settings.get.tickFrequency == 0
if (shouldUpdatePower && range > 0 && !Settings.get.ignorePower) {
@@ -252,7 +230,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
}
if (countRunning > 0) {
var cost = -(countRunning * range * Settings.get.wirelessCostPerRange * Settings.get.tickFrequency)
- for (side <- ForgeDirection.VALID_DIRECTIONS if cost < 0) {
+ for (side <- EnumFacing.values if cost < 0) {
sidedNode(side) match {
case connector: Connector => cost = connector.changeBuffer(cost)
case _ =>
@@ -271,7 +249,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
if (markChunkDirty) {
markChunkDirty = false
- world.markTileEntityChunkModified(x, y, z, this)
+ world.markChunkDirty(getPos, this)
}
for (i <- 0 until servers.length) {
@@ -282,7 +260,6 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
}
}
isOutputEnabled = hasRedstoneCard
- isAbstractBusAvailable = hasAbstractBusCard
servers collect {
case Some(server) =>
@@ -324,18 +301,12 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
try server.load(tag) catch {
case t: Throwable => OpenComputers.log.warn("Failed restoring server state. Please report this!", t)
}
-
- // Code for migrating from 1.4.1 -> 1.4.2, add EEPROM.
- // TODO Remove in 1.5
- if (!nbt.hasKey(Settings.namespace + "biosFlag")) {
- server.inventory.items(server.inventory.items.length - 1) = Option(Items.createLuaBios())
- }
case _ =>
}
case _ =>
}
val sidesNbt = nbt.getByteArray(Settings.namespace + "sides").map {
- case side if side >= 0 => Option(ForgeDirection.getOrientation(side))
+ case side if side >= 0 => Option(EnumFacing.getFront(side))
case _ => None
}
Array.copy(sidesNbt, 0, sides, 0, math.min(sidesNbt.length, sides.length))
@@ -351,19 +322,16 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
internalSwitch = nbt.getBoolean(Settings.namespace + "internalSwitch")
}
- // Side check for Waila (and other mods that may call this client side).
override def writeToNBT(nbt: NBTTagCompound) = if (isServer) {
- if (!Mods.Waila.isAvailable || !Waila.isSavingForTooltip) {
- nbt.setNewTagList(Settings.namespace + "servers", servers map {
- case Some(server) =>
- val serverNbt = new NBTTagCompound()
- try server.save(serverNbt) catch {
- case t: Throwable => OpenComputers.log.warn("Failed saving server state. Please report this!", t)
- }
- serverNbt
- case _ => new NBTTagCompound()
- })
- }
+ nbt.setNewTagList(Settings.namespace + "servers", servers map {
+ case Some(server) =>
+ val serverNbt = new NBTTagCompound()
+ try server.save(serverNbt) catch {
+ case t: Throwable => OpenComputers.log.warn("Failed saving server state. Please report this!", t)
+ }
+ serverNbt
+ case _ => new NBTTagCompound()
+ })
super.writeToNBT(nbt)
nbt.setByteArray(Settings.namespace + "sides", sides.map {
case Some(side) => side.ordinal.toByte
@@ -378,9 +346,6 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
}))
nbt.setInteger(Settings.namespace + "range", range)
nbt.setBoolean(Settings.namespace + "internalSwitch", internalSwitch)
-
- // TODO Remove in 1.5
- nbt.setBoolean(Settings.namespace + "biosFlag", true)
}
@SideOnly(Side.CLIENT)
@@ -389,12 +354,12 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
val isRunningNbt = nbt.getByteArray("isServerRunning").map(_ == 1)
Array.copy(isRunningNbt, 0, _isRunning, 0, math.min(isRunningNbt.length, _isRunning.length))
val isPresentNbt = nbt.getTagList("isPresent", NBT.TAG_STRING).map((tag: NBTTagString) => {
- val value = tag.func_150285_a_()
+ val value = tag.getString()
if (Strings.isNullOrEmpty(value)) None else Some(value)
}).toArray
Array.copy(isPresentNbt, 0, isPresent, 0, math.min(isPresentNbt.length, isPresent.length))
val sidesNbt = nbt.getByteArray("sides").map {
- case side if side >= 0 => Option(ForgeDirection.getOrientation(side))
+ case side if side >= 0 => Option(EnumFacing.getFront(side))
case _ => None
}
Array.copy(sidesNbt, 0, sides, 0, math.min(sidesNbt.length, sides.length))
@@ -475,11 +440,10 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
super.markDirty()
if (isServer) {
isOutputEnabled = hasRedstoneCard
- isAbstractBusAvailable = hasAbstractBusCard
ServerPacketSender.sendServerPresence(this)
}
else {
- world.markBlockForUpdate(x, y, z)
+ world.markBlockForUpdate(getPos)
}
}
@@ -488,14 +452,14 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
checkRedstoneInputChanged()
}
- override protected def onRedstoneInputChanged(side: ForgeDirection) {
+ override protected def onRedstoneInputChanged(side: EnumFacing) {
super.onRedstoneInputChanged(side)
servers collect {
case Some(server) => server.machine.signal("redstone_changed", server.machine.node.address, Int.box(toLocal(side).ordinal()))
}
}
- override def rotate(axis: ForgeDirection) = false
+ override def rotate(axis: EnumFacing) = false
}
object ServerRack {
diff --git a/src/main/scala/li/cil/oc/common/tileentity/Switch.scala b/src/main/scala/li/cil/oc/common/tileentity/Switch.scala
index f36482c32..7754e989a 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/Switch.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/Switch.scala
@@ -1,47 +1,24 @@
package li.cil.oc.common.tileentity
-import com.google.common.base.Charsets
-import dan200.computercraft.api.peripheral.IComputerAccess
import li.cil.oc.api.Driver
-import li.cil.oc.api.network.Message
import li.cil.oc.api.network.Packet
import li.cil.oc.common.InventorySlots
import li.cil.oc.common.Slot
import li.cil.oc.common.init.Items
import li.cil.oc.common.item
-import li.cil.oc.integration.Mods
import li.cil.oc.server.PacketSender
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
-
-import scala.collection.mutable
+import net.minecraft.util.EnumFacing
class Switch extends traits.Hub with traits.NotAnalyzable with traits.ComponentInventory {
var lastMessage = 0L
- val computers = mutable.Buffer.empty[AnyRef]
-
- val openPorts = mutable.Map.empty[AnyRef, mutable.Set[Int]]
-
override def canUpdate = isServer
// ----------------------------------------------------------------------- //
- protected def queueMessage(source: String, destination: String, port: Int, answerPort: Int, args: Array[AnyRef]) {
- for (computer <- computers.map(_.asInstanceOf[IComputerAccess])) {
- val address = s"cc${computer.getID}_${computer.getAttachmentName}"
- if (source != address && Option(destination).forall(_ == address) && openPorts(computer).contains(port))
- computer.queueEvent("modem_message", Array(Seq(computer.getAttachmentName, Int.box(port), Int.box(answerPort)) ++ args.map {
- case x: Array[Byte] => new String(x, Charsets.UTF_8)
- case x => x
- }: _*))
- }
- }
-
- // ----------------------------------------------------------------------- //
-
- override protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet) {
+ override protected def relayPacket(sourceSide: Option[EnumFacing], packet: Packet) {
super.relayPacket(sourceSide, packet)
val now = System.currentTimeMillis()
if (now - lastMessage >= (relayDelay - 1) * 50) {
@@ -50,22 +27,6 @@ class Switch extends traits.Hub with traits.NotAnalyzable with traits.ComponentI
}
}
- override protected def onPlugMessage(plug: Plug, message: Message) {
- super.onPlugMessage(plug, message)
- if (message.name == "network.message" && Mods.ComputerCraft.isAvailable) {
- message.data match {
- case Array(packet: Packet) =>
- packet.data.headOption match {
- case Some(answerPort: java.lang.Double) =>
- queueMessage(packet.source, packet.destination, packet.port, answerPort.toInt, packet.data.drop(1))
- case _ =>
- queueMessage(packet.source, packet.destination, packet.port, -1, packet.data)
- }
- case _ =>
- }
- }
- }
-
// ----------------------------------------------------------------------- //
override protected def onItemAdded(slot: Int, stack: ItemStack) {
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/AbstractBusAware.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/AbstractBusAware.scala
deleted file mode 100644
index 7a9d6b10c..000000000
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/AbstractBusAware.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-package li.cil.oc.common.tileentity.traits
-
-import cpw.mods.fml.common.Optional
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
-import li.cil.oc.api.network
-import li.cil.oc.api.network.ManagedEnvironment
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import li.cil.oc.integration.util.StargateTech2
-import li.cil.oc.server.component
-import li.cil.oc.server.{PacketSender => ServerPacketSender}
-import lordfokas.stargatetech2.api.StargateTechAPI
-import lordfokas.stargatetech2.api.bus.IBusDevice
-import lordfokas.stargatetech2.api.bus.IBusInterface
-import net.minecraft.nbt.NBTTagCompound
-
-@Injectable.Interface(value = "lordfokas.stargatetech2.api.bus.IBusDevice", modid = Mods.IDs.StargateTech2)
-trait AbstractBusAware extends TileEntity with network.Environment {
- protected var _isAbstractBusAvailable: Boolean = _
-
- protected lazy val fakeInterface = Array[AnyRef](StargateTechAPI.api.getFactory.getIBusInterface(this.asInstanceOf[IBusDevice], null))
-
- def installedComponents: Iterable[ManagedEnvironment]
-
- @Optional.Method(modid = Mods.IDs.StargateTech2)
- def getInterfaces(side: Int): Array[IBusInterface] =
- if (isAbstractBusAvailable) {
- if (isServer) {
- installedComponents.collect {
- case abstractBus: component.AbstractBusCard => abstractBus.busInterface
- }.toArray
- }
- else fakeInterface.map(_.asInstanceOf[IBusInterface])
- }
- else null
-
- def getWorld = world
-
- def getXCoord = x
-
- def getYCoord = y
-
- def getZCoord = z
-
- def isAbstractBusAvailable = _isAbstractBusAvailable
-
- def isAbstractBusAvailable_=(value: Boolean) = {
- if (value != isAbstractBusAvailable) {
- _isAbstractBusAvailable = value
- if (isServer && Mods.StargateTech2.isAvailable) {
- if (isAbstractBusAvailable) StargateTech2.addDevice(world, x, y, z)
- else StargateTech2.removeDevice(world, x, y, z)
- }
- world.notifyBlocksOfNeighborChange(x, y, z, block)
- if (isServer) ServerPacketSender.sendAbstractBusState(this)
- else world.markBlockForUpdate(x, y, z)
- }
- this
- }
-
- @SideOnly(Side.CLIENT)
- override def readFromNBTForClient(nbt: NBTTagCompound) {
- super.readFromNBTForClient(nbt)
- isAbstractBusAvailable = nbt.getBoolean("isAbstractBusAvailable")
- }
-
- override def writeToNBTForClient(nbt: NBTTagCompound) {
- super.writeToNBTForClient(nbt)
- nbt.setBoolean("isAbstractBusAvailable", isAbstractBusAvailable)
- }
-
- abstract override def onDisconnect(node: network.Node) {
- super.onDisconnect(node)
- if (node == this.node) {
- isAbstractBusAvailable = false
- }
- }
-}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/BundledRedstoneAware.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/BundledRedstoneAware.scala
index a0a3b16fb..cb641f1cc 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/BundledRedstoneAware.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/BundledRedstoneAware.scala
@@ -1,28 +1,32 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.common.Optional
import li.cil.oc.Settings
import li.cil.oc.integration.Mods
-import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedNBT._
-import li.cil.oc.util.ExtendedWorld._
+import net.minecraftforge.fml.common.Optional
+/* TODO RedLogic
import mods.immibis.redlogic.api.wiring.IBundledEmitter
import mods.immibis.redlogic.api.wiring.IBundledUpdatable
import mods.immibis.redlogic.api.wiring.IInsulatedRedstoneWire
+*/
+/* TODO Project Red
import mrtjp.projectred.api.IBundledTile
import mrtjp.projectred.api.ProjectRedAPI
+*/
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagIntArray
+import net.minecraft.util.EnumFacing
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+/* TODO MFR
import powercrystals.minefactoryreloaded.api.rednet.IRedNetNetworkContainer
+*/
@Optional.InterfaceList(Array(
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IBundledEmitter", modid = Mods.IDs.RedLogic),
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IBundledUpdatable", modid = Mods.IDs.RedLogic),
new Optional.Interface(iface = "mrtjp.projectred.api.IBundledTile", modid = Mods.IDs.ProjectRedTransmission)
))
-trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBundledUpdatable with IBundledTile {
+trait BundledRedstoneAware extends RedstoneAware /* with IBundledEmitter with IBundledUpdatable with IBundledTile TODO RedLogic, Project Red, MFR */ {
protected[tileentity] val _bundledInput = Array.fill(6)(Array.fill(16)(-1))
@@ -45,10 +49,10 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
super.isOutputEnabled_=(value)
}
- def bundledInput(side: ForgeDirection, color: Int) =
+ def bundledInput(side: EnumFacing, color: Int) =
math.max(_bundledInput(side.ordinal())(color), _rednetInput(side.ordinal())(color))
- def rednetInput(side: ForgeDirection, color: Int, value: Int) =
+ def rednetInput(side: EnumFacing, color: Int, value: Int) =
if (_rednetInput(side.ordinal())(color) != value) {
if (_rednetInput(side.ordinal())(color) != -1) {
onRedstoneInputChanged(side)
@@ -56,13 +60,14 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
_rednetInput(side.ordinal())(color) = value
}
- def bundledOutput(side: ForgeDirection) = _bundledOutput(toLocal(side).ordinal())
+ def bundledOutput(side: EnumFacing) = _bundledOutput(toLocal(side).ordinal())
- def bundledOutput(side: ForgeDirection, color: Int): Int = bundledOutput(side)(color)
+ def bundledOutput(side: EnumFacing, color: Int): Int = bundledOutput(side)(color)
- def bundledOutput(side: ForgeDirection, color: Int, value: Int): Unit = if (value != bundledOutput(side, color)) {
+ def bundledOutput(side: EnumFacing, color: Int, value: Int): Unit = if (value != bundledOutput(side, color)) {
_bundledOutput(toLocal(side).ordinal())(color) = value
+ /* TODO MFR
if (Mods.MineFactoryReloaded.isAvailable) {
val blockPos = BlockPosition(x, y, z).offset(side)
world.getBlock(blockPos) match {
@@ -70,13 +75,14 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
case _ =>
}
}
+ */
onRedstoneOutputChanged(side)
}
// ----------------------------------------------------------------------- //
- override protected def updateRedstoneInput(side: ForgeDirection) {
+ override protected def updateRedstoneInput(side: EnumFacing) {
super.updateRedstoneInput(side)
val oldBundledInput = _bundledInput(side.ordinal())
val newBundledInput = computeBundledInput(side)
@@ -98,14 +104,14 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
super.readFromNBT(nbt)
nbt.getTagList(Settings.namespace + "rs.bundledInput", NBT.TAG_INT_ARRAY).toArray[NBTTagIntArray].
- map(_.func_150302_c()).zipWithIndex.foreach {
+ map(_.getIntArray).zipWithIndex.foreach {
case (input, index) if index < _bundledInput.length =>
val safeLength = input.length min _bundledInput(index).length
input.copyToArray(_bundledInput(index), 0, safeLength)
case _ =>
}
nbt.getTagList(Settings.namespace + "rs.bundledOutput", NBT.TAG_INT_ARRAY).toArray[NBTTagIntArray].
- map(_.func_150302_c()).zipWithIndex.foreach {
+ map(_.getIntArray).zipWithIndex.foreach {
case (input, index) if index < _bundledOutput.length =>
val safeLength = input.length min _bundledOutput(index).length
input.copyToArray(_bundledOutput(index), 0, safeLength)
@@ -113,7 +119,7 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
}
nbt.getTagList(Settings.namespace + "rs.rednetInput", NBT.TAG_INT_ARRAY).toArray[NBTTagIntArray].
- map(_.func_150302_c()).zipWithIndex.foreach {
+ map(_.getIntArray).zipWithIndex.foreach {
case (input, index) if index < _rednetInput.length =>
val safeLength = input.length min _rednetInput(index).length
input.copyToArray(_rednetInput(index), 0, safeLength)
@@ -132,43 +138,53 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
// ----------------------------------------------------------------------- //
- protected def computeBundledInput(side: ForgeDirection): Array[Int] = {
- val redLogic = if (Mods.RedLogic.isAvailable) {
- val (nx, ny, nz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
- if (world.blockExists(nx, ny, nz)) world.getTileEntity(nx, ny, nz) match {
- case wire: IInsulatedRedstoneWire =>
- var strength: Array[Int] = null
- for (face <- -1 to 5 if wire.wireConnectsInDirection(face, side.ordinal()) && strength == null) {
- strength = Array.fill(16)(0)
- strength(wire.getInsulatedWireColour) = wire.getEmittedSignalStrength(face, side.ordinal())
- }
- strength
- case emitter: IBundledEmitter =>
- var strength: Array[Int] = null
- for (i <- -1 to 5 if strength == null) {
- strength = Option(emitter.getBundledCableStrength(i, side.getOpposite.ordinal())).fold(null: Array[Int])(_.map(_ & 0xFF))
- }
- strength
- case _ => null
+ protected def computeBundledInput(side: EnumFacing): Array[Int] = {
+ /* TODO RedLogic
+ val redLogic =
+ if (Mods.RedLogic.isAvailable) {
+ val (nx, ny, nz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
+ if (world.blockExists(nx, ny, nz)) world.getTileEntity(nx, ny, nz) match {
+ case wire: IInsulatedRedstoneWire =>
+ var strength: Array[Int] = null
+ for (face <- -1 to 5 if wire.wireConnectsInDirection(face, side.ordinal()) && strength == null) {
+ strength = Array.fill(16)(0)
+ strength(wire.getInsulatedWireColour) = wire.getEmittedSignalStrength(face, side.ordinal())
+ }
+ strength
+ case emitter: IBundledEmitter =>
+ var strength: Array[Int] = null
+ for (i <- -1 to 5 if strength == null) {
+ strength = Option(emitter.getBundledCableStrength(i, side.getOpposite.ordinal())).fold(null: Array[Int])(_.map(_ & 0xFF))
+ }
+ strength
+ case _ => null
+ }
+ else null
}
else null
- }
- else null
- val projectRed = if (Mods.ProjectRedTransmission.isAvailable) {
- Option(ProjectRedAPI.transmissionAPI.getBundledInput(world, x, y, z, side.ordinal)).fold(null: Array[Int])(_.map(_ & 0xFF))
- }
- else null
+ */
+ /* TODO Project Red
+ val projectRed =
+ if (Mods.ProjectRedTransmission.isAvailable) {
+ Option(ProjectRedAPI.transmissionAPI.getBundledInput(world, x, y, z, side.ordinal)).fold(null: Array[Int])(_.map(_ & 0xFF))
+ }
+ else null
+ */
+ /* TODO RedLogic or Project Red
(redLogic, projectRed) match {
case (a: Array[Int], b: Array[Int]) => (a, b).zipped.map((r1, r2) => math.max(r1, r2))
case (a: Array[Int], _) => a
case (_, b: Array[Int]) => b
case _ => null
}
+ */
+ null
}
override protected def onRedstoneOutputEnabledChanged() {
+ /* TODO MFR
if (Mods.MineFactoryReloaded.isAvailable) {
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
+ for (side <- EnumFacing.VALID_DIRECTIONS) {
val blockPos = BlockPosition(x, y, z).offset(side)
world.getBlock(blockPos) match {
case block: IRedNetNetworkContainer => block.updateNetwork(world, x, y, z, side.getOpposite)
@@ -176,22 +192,24 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
}
}
}
+ */
super.onRedstoneOutputEnabledChanged()
}
// ----------------------------------------------------------------------- //
-
+/* TODO RedLogic
@Optional.Method(modid = Mods.IDs.RedLogic)
- def getBundledCableStrength(blockFace: Int, toDirection: Int): Array[Byte] = bundledOutput(ForgeDirection.getOrientation(toDirection)).map(value => math.min(math.max(value, 0), 255).toByte)
+ def getBundledCableStrength(blockFace: Int, toDirection: Int): Array[Byte] = bundledOutput(EnumFacing.getOrientation(toDirection)).map(value => math.min(math.max(value, 0), 255).toByte)
@Optional.Method(modid = Mods.IDs.RedLogic)
def onBundledInputChanged() = checkRedstoneInputChanged()
-
+*/
// ----------------------------------------------------------------------- //
-
+/* TODO Project Red
@Optional.Method(modid = Mods.IDs.ProjectRedTransmission)
def canConnectBundled(side: Int) = isOutputEnabled
@Optional.Method(modid = Mods.IDs.ProjectRedTransmission)
- def getBundledSignal(side: Int) = bundledOutput(ForgeDirection.getOrientation(side)).map(value => math.min(math.max(value, 0), 255).toByte)
+ def getBundledSignal(side: Int) = bundledOutput(EnumFacing.getOrientation(side)).map(value => math.min(math.max(value, 0), 255).toByte)
+*/
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/Colored.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/Colored.scala
index 471185af1..d8837ee55 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/Colored.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/Colored.scala
@@ -1,25 +1,26 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.item.EnumDyeColor
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api.internal
import li.cil.oc.server.PacketSender
import net.minecraft.nbt.NBTTagCompound
trait Colored extends TileEntity with internal.Colored {
- private var _color = 0
+ private var _color = EnumDyeColor.SILVER
def color = _color
- def color_=(value: Int) = if (value != _color) {
+ def color_=(value: EnumDyeColor) = if (value != _color) {
_color = value
onColorChanged()
}
- override def getColor = color
+ override def getColor: EnumDyeColor = color
- override def setColor(value: Int) = color = value
+ override def setColor(value: EnumDyeColor) = color = value
protected def onColorChanged() {
if (world != null && isServer) {
@@ -30,23 +31,23 @@ trait Colored extends TileEntity with internal.Colored {
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
if (nbt.hasKey(Settings.namespace + "renderColor")) {
- _color = nbt.getInteger(Settings.namespace + "renderColor")
+ _color = EnumDyeColor.byMetadata(nbt.getInteger(Settings.namespace + "renderColor"))
}
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
- nbt.setInteger(Settings.namespace + "renderColor", _color)
+ nbt.setInteger(Settings.namespace + "renderColor", _color.getMetadata)
}
@SideOnly(Side.CLIENT)
override def readFromNBTForClient(nbt: NBTTagCompound) {
super.readFromNBTForClient(nbt)
- _color = nbt.getInteger("renderColor")
+ _color = EnumDyeColor.byMetadata(nbt.getInteger("renderColor"))
}
override def writeToNBTForClient(nbt: NBTTagCompound) {
super.writeToNBTForClient(nbt)
- nbt.setInteger("renderColor", _color)
+ nbt.setInteger("renderColor", _color.getMetadata)
}
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/ComponentInventory.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/ComponentInventory.scala
index df36348af..76906125f 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/ComponentInventory.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/ComponentInventory.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.api.network.Node
import li.cil.oc.common.inventory
import net.minecraft.nbt.NBTTagCompound
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/Computer.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/Computer.scala
index b53fb1dc3..0555a9590 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/Computer.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/Computer.scala
@@ -1,7 +1,5 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.api.Driver
@@ -14,21 +12,20 @@ import li.cil.oc.api.network.Node
import li.cil.oc.client.Sound
import li.cil.oc.common.Slot
import li.cil.oc.common.tileentity.RobotProxy
-import li.cil.oc.integration.Mods
import li.cil.oc.integration.opencomputers.DriverRedstoneCard
-import li.cil.oc.integration.stargatetech2.DriverAbstractBusCard
-import li.cil.oc.integration.util.Waila
import li.cil.oc.server.{PacketSender => ServerPacketSender}
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagString
+import net.minecraft.util.EnumFacing
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import scala.collection.mutable
-trait Computer extends Environment with ComponentInventory with Rotatable with BundledRedstoneAware with AbstractBusAware with Analyzable with MachineHost {
+trait Computer extends Environment with ComponentInventory with Rotatable with BundledRedstoneAware with Analyzable with MachineHost {
private lazy val _machine = if (isServer) Machine.create(this) else null
def machine = _machine
@@ -54,7 +51,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
@SideOnly(Side.CLIENT)
def setRunning(value: Boolean): Unit = if (value != _isRunning) {
_isRunning = value
- world.markBlockForUpdate(x, y, z)
+ world.markBlockForUpdate(getPos)
runSound.foreach(sound =>
if (_isRunning) Sound.startLoop(this, sound, 0.5f, 50 + world.rand.nextInt(50))
else Sound.stopLoop(this)
@@ -82,19 +79,10 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
override def markForSaving() = markChunkDirty = true
- override def installedComponents = components collect {
- case Some(component) => component
- }
-
override def onMachineConnect(node: Node) = this.onConnect(node)
override def onMachineDisconnect(node: Node) = this.onDisconnect(node)
- def hasAbstractBusCard = items.exists {
- case Some(item) => machine.isRunning && DriverAbstractBusCard.worksWith(item, getClass)
- case _ => false
- }
-
def hasRedstoneCard = items.exists {
case Some(item) => machine.isRunning && DriverRedstoneCard.worksWith(item, getClass)
case _ => false
@@ -102,7 +90,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
// ----------------------------------------------------------------------- //
- override def updateEntity() {
+ override def update() {
if (isServer && isConnected) {
// If we're not yet in a network we might have just been loaded from disk,
// meaning there may be other tile entities that also have not re-joined
@@ -113,7 +101,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
if (markChunkDirty) {
markChunkDirty = false
- world.markTileEntityChunkModified(x, y, z, this)
+ world.markChunkDirty(getPos, this)
}
if (_isRunning != machine.isRunning) {
@@ -125,7 +113,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
updateComponents()
}
- super.updateEntity()
+ super.update()
}
// ----------------------------------------------------------------------- //
@@ -136,10 +124,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
// This is required for loading auxiliary data (kernel state), because the
// coordinates in the actual robot won't be set properly, otherwise.
this match {
- case proxy: RobotProxy =>
- proxy.robot.xCoord = xCoord
- proxy.robot.yCoord = yCoord
- proxy.robot.zCoord = zCoord
+ case proxy: RobotProxy => proxy.robot.setPos(getPos)
case _ =>
}
machine.load(nbt.getCompoundTag(Settings.namespace + "computer"))
@@ -148,10 +133,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
if (machine != null) {
- if (!Mods.Waila.isAvailable || !Waila.isSavingForTooltip)
- nbt.setNewCompoundTag(Settings.namespace + "computer", machine.save)
- else if (machine.node.address != null)
- nbt.setString(Settings.namespace + "address", machine.node.address)
+ nbt.setNewCompoundTag(Settings.namespace + "computer", machine.save)
}
}
@@ -160,7 +142,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
super.readFromNBTForClient(nbt)
_isRunning = nbt.getBoolean("isRunning")
_users.clear()
- _users ++= nbt.getTagList("users", NBT.TAG_STRING).map((tag: NBTTagString) => tag.func_150285_a_())
+ _users ++= nbt.getTagList("users", NBT.TAG_STRING).map((tag: NBTTagString) => tag.getString)
if (_isRunning) runSound.foreach(sound => Sound.startLoop(this, sound, 0.5f, 1000 + world.rand.nextInt(2000)))
}
@@ -177,26 +159,25 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
if (isServer) {
machine.onHostChanged()
isOutputEnabled = hasRedstoneCard
- isAbstractBusAvailable = hasAbstractBusCard
}
}
override def isUseableByPlayer(player: EntityPlayer) =
- super.isUseableByPlayer(player) && canInteract(player.getCommandSenderName)
+ super.isUseableByPlayer(player) && canInteract(player.getName)
override protected def onRotationChanged() {
super.onRotationChanged()
checkRedstoneInputChanged()
}
- override protected def onRedstoneInputChanged(side: ForgeDirection) {
+ override protected def onRedstoneInputChanged(side: EnumFacing) {
super.onRedstoneInputChanged(side)
machine.signal("redstone_changed", machine.node.address, Int.box(toLocal(side).ordinal()))
}
// ----------------------------------------------------------------------- //
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
machine.lastError match {
case value if value != null =>
player.addChatMessage(Localization.Analyzer.LastError(value))
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/Environment.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/Environment.scala
index bec2408f6..7cce17543 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/Environment.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/Environment.scala
@@ -8,7 +8,7 @@ import li.cil.oc.api.network.SidedEnvironment
import li.cil.oc.common.EventHandler
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait Environment extends TileEntity with network.Environment with driver.EnvironmentHost {
protected var isChangeScheduled = false
@@ -19,7 +19,7 @@ trait Environment extends TileEntity with network.Environment with driver.Enviro
override def zPosition = z + 0.5
- override def markChanged() = if (canUpdate) isChangeScheduled = true else world.markTileEntityChunkModified(x, y, z, this)
+ override def markChanged() = if (canUpdate) isChangeScheduled = true else world.markChunkDirty(getPos, this)
protected def isConnected = node.address != null && node.network != null
@@ -32,10 +32,10 @@ trait Environment extends TileEntity with network.Environment with driver.Enviro
}
}
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (isChangeScheduled) {
- world.markTileEntityChunkModified(x, y, z, this)
+ world.markChunkDirty(getPos, this)
isChangeScheduled = false
}
}
@@ -45,7 +45,7 @@ trait Environment extends TileEntity with network.Environment with driver.Enviro
if (isServer) {
Option(node).foreach(_.remove)
this match {
- case sidedEnvironment: SidedEnvironment => for (side <- ForgeDirection.VALID_DIRECTIONS) {
+ case sidedEnvironment: SidedEnvironment => for (side <- EnumFacing.values) {
Option(sidedEnvironment.sidedNode(side)).foreach(_.remove())
}
case _ =>
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala
index baf95a49e..82c46390d 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.network._
@@ -10,7 +10,7 @@ import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.MovingAverage
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.mutable
@@ -19,9 +19,9 @@ trait Hub extends traits.Environment with SidedEnvironment {
override protected def isConnected = plugs.exists(plug => plug.node.address != null && plug.node.network != null)
- protected val plugs = ForgeDirection.VALID_DIRECTIONS.map(side => new Plug(side))
+ protected val plugs = EnumFacing.values.map(side => new Plug(side))
- val queue = mutable.Queue.empty[(Option[ForgeDirection], Packet)]
+ val queue = mutable.Queue.empty[(Option[EnumFacing], Packet)]
var maxQueueSize = queueBaseSize
@@ -51,14 +51,14 @@ trait Hub extends traits.Environment with SidedEnvironment {
// ----------------------------------------------------------------------- //
@SideOnly(Side.CLIENT)
- override def canConnect(side: ForgeDirection) = side != ForgeDirection.UNKNOWN
+ override def canConnect(side: EnumFacing) = true
- override def sidedNode(side: ForgeDirection) = if (side != ForgeDirection.UNKNOWN) plugs(side.ordinal()).node else null
+ override def sidedNode(side: EnumFacing) = plugs(side.ordinal).node
// ----------------------------------------------------------------------- //
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (relayCooldown > 0) {
relayCooldown -= 1
}
@@ -80,7 +80,7 @@ trait Hub extends traits.Environment with SidedEnvironment {
}
}
- def tryEnqueuePacket(sourceSide: Option[ForgeDirection], packet: Packet) = queue.synchronized {
+ def tryEnqueuePacket(sourceSide: Option[EnumFacing], packet: Packet) = queue.synchronized {
if (packet.ttl > 0 && queue.size < maxQueueSize) {
queue += sourceSide -> packet.hop()
if (relayCooldown < 0) {
@@ -91,8 +91,8 @@ trait Hub extends traits.Environment with SidedEnvironment {
else false
}
- protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet) {
- for (side <- ForgeDirection.VALID_DIRECTIONS if Option(side) != sourceSide) {
+ protected def relayPacket(sourceSide: Option[EnumFacing], packet: Packet) {
+ for (side <- EnumFacing.values if Option(side) != sourceSide) {
sidedNode(side).sendToReachable("network.message", packet)
}
}
@@ -138,7 +138,7 @@ trait Hub extends traits.Environment with SidedEnvironment {
// ----------------------------------------------------------------------- //
- protected class Plug(val side: ForgeDirection) extends api.network.Environment {
+ protected class Plug(val side: EnumFacing) extends api.network.Environment {
val node = createNode(this)
override def onMessage(message: Message) {
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/Inventory.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/Inventory.scala
index 81495f114..6fa1a0109 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/Inventory.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/Inventory.scala
@@ -6,7 +6,7 @@ import li.cil.oc.util.InventoryUtils
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait Inventory extends TileEntity with inventory.Inventory {
lazy val items = Array.fill[Option[ItemStack]](getSizeInventory)(None)
@@ -30,12 +30,12 @@ trait Inventory extends TileEntity with inventory.Inventory {
// ----------------------------------------------------------------------- //
- def dropSlot(slot: Int, count: Int = getInventoryStackLimit, direction: Option[ForgeDirection] = None) =
+ def dropSlot(slot: Int, count: Int = getInventoryStackLimit, direction: Option[EnumFacing] = None) =
InventoryUtils.dropSlot(BlockPosition(x, y, z, world), this, slot, count, direction)
def dropAllSlots() =
InventoryUtils.dropAllSlots(BlockPosition(x, y, z, world), this)
- def spawnStackInWorld(stack: ItemStack, direction: Option[ForgeDirection] = None) =
+ def spawnStackInWorld(stack: ItemStack, direction: Option[EnumFacing] = None) =
InventoryUtils.spawnStackInWorld(BlockPosition(x, y, z, world), stack, direction)
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/NotAnalyzable.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/NotAnalyzable.scala
index 73ac87226..ab04a1141 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/NotAnalyzable.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/NotAnalyzable.scala
@@ -3,7 +3,8 @@ package li.cil.oc.common.tileentity.traits
import li.cil.oc.api.network.Analyzable
import li.cil.oc.api.network.Node
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.EnumFacing
trait NotAnalyzable extends Analyzable {
- override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float): Array[Node] = null
+ override def onAnalyze(player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Array[Node] = null
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerAcceptor.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerAcceptor.scala
index 8a4fc4372..3cd4f1004 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerAcceptor.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerAcceptor.scala
@@ -2,10 +2,10 @@ package li.cil.oc.common.tileentity.traits
trait PowerAcceptor
extends power.Common
- with power.AppliedEnergistics2
- with power.Factorization
- with power.Galacticraft
- with power.IndustrialCraft2Experimental
- with power.IndustrialCraft2Classic
- with power.Mekanism
- with power.RedstoneFlux
+// with power.AppliedEnergistics2
+// with power.Factorization
+// with power.Galacticraft
+// with power.IndustrialCraft2Experimental
+// with power.IndustrialCraft2Classic
+// with power.Mekanism
+// with power.RedstoneFlux
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerBalancer.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerBalancer.scala
index cd006867d..2fa19895f 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerBalancer.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerBalancer.scala
@@ -3,15 +3,15 @@ package li.cil.oc.common.tileentity.traits
import li.cil.oc.Settings
import li.cil.oc.api.network.Connector
import li.cil.oc.api.network.SidedEnvironment
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait PowerBalancer extends PowerInformation with SidedEnvironment {
var globalBuffer, globalBufferSize = 0.0
protected def isConnected: Boolean
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (isServer && isConnected && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
val nodes = connectors
def network(connector: Connector) = if (connector != null && connector.network != null) connector.network else this
@@ -55,7 +55,7 @@ trait PowerBalancer extends PowerInformation with SidedEnvironment {
(sumBuffer, sumSize)
}
- private def connectors = ForgeDirection.VALID_DIRECTIONS.view.map(sidedNode(_) match {
+ private def connectors = EnumFacing.values.view.map(sidedNode(_) match {
case connector: Connector => connector
case _ => null
})
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala
index 017688bf9..0dce9aa57 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.server.{PacketSender => ServerPacketSender}
import net.minecraft.nbt.NBTTagCompound
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/RedstoneAware.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/RedstoneAware.scala
index 8653b1b5e..27cd6764e 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/RedstoneAware.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/RedstoneAware.scala
@@ -1,27 +1,31 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.common.Optional
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraft.block.BlockRedstoneWire
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.common.Optional
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.integration.Mods
import li.cil.oc.server.{PacketSender => ServerPacketSender}
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._
+/* TODO RedLogic
import mods.immibis.redlogic.api.wiring.IConnectable
import mods.immibis.redlogic.api.wiring.IRedstoneEmitter
import mods.immibis.redlogic.api.wiring.IRedstoneUpdatable
import mods.immibis.redlogic.api.wiring.IWire
+*/
import net.minecraft.init.Blocks
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
@Optional.InterfaceList(Array(
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IConnectable", modid = Mods.IDs.RedLogic),
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IRedstoneEmitter", modid = Mods.IDs.RedLogic),
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IRedstoneUpdatable", modid = Mods.IDs.RedLogic)
))
-trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitter with IRedstoneUpdatable {
+trait RedstoneAware extends RotationAware /* with IConnectable with IRedstoneEmitter with IRedstoneUpdatable TODO RedLogic */ {
protected[tileentity] val _input = Array.fill(6)(-1)
protected[tileentity] val _output = Array.fill(6)(0)
@@ -45,13 +49,13 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
this
}
- def input(side: ForgeDirection) = _input(side.ordinal())
+ def input(side: EnumFacing) = _input(side.ordinal())
- def maxInput = ForgeDirection.VALID_DIRECTIONS.map(input).max
+ def maxInput = EnumFacing.values.map(input).max
- def output(side: ForgeDirection) = _output(toLocal(side).ordinal())
+ def output(side: EnumFacing) = _output(toLocal(side).ordinal())
- def output(side: ForgeDirection, value: Int): Unit = if (value != output(side)) {
+ def output(side: EnumFacing, value: Int): Unit = if (value != output(side)) {
_output(toLocal(side).ordinal()) = value
onRedstoneOutputChanged(side)
@@ -63,19 +67,19 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
// ----------------------------------------------------------------------- //
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (isServer) {
if (shouldUpdateInput) {
shouldUpdateInput = false
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
+ for (side <- EnumFacing.values) {
updateRedstoneInput(side)
}
}
}
}
- protected def updateRedstoneInput(side: ForgeDirection) {
+ protected def updateRedstoneInput(side: EnumFacing) {
val oldInput = _input(side.ordinal())
val newInput = computeInput(side)
_input(side.ordinal()) = newInput
@@ -117,13 +121,15 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
// ----------------------------------------------------------------------- //
- protected def computeInput(side: ForgeDirection) = {
+ protected def computeInput(side: EnumFacing) = {
val blockPos = BlockPosition(x, y, z).offset(side)
if (!world.blockExists(blockPos)) 0
else {
// See BlockRedstoneLogic.getInputStrength() for reference.
val vanilla = math.max(world.getIndirectPowerLevelTo(blockPos, side),
- if (world.getBlock(blockPos) == Blocks.redstone_wire) world.getBlockMetadata(blockPos) else 0)
+ if (world.getBlock(blockPos) == Blocks.redstone_wire) world.getBlockMetadata(blockPos).getValue(BlockRedstoneWire.POWER).asInstanceOf[Integer].intValue() else 0)
+ val redLogic = 0
+/* TODO RedLogic
val redLogic = if (Mods.RedLogic.isAvailable) {
world.getTileEntity(blockPos) match {
case emitter: IRedstoneEmitter =>
@@ -136,11 +142,12 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
}
}
else 0
+*/
math.max(vanilla, redLogic)
}
}
- protected def onRedstoneInputChanged(side: ForgeDirection) {}
+ protected def onRedstoneInputChanged(side: EnumFacing) {}
protected def onRedstoneOutputEnabledChanged() {
world.notifyBlocksOfNeighborChange(position, block)
@@ -148,7 +155,7 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
else world.markBlockForUpdate(position)
}
- protected def onRedstoneOutputChanged(side: ForgeDirection) {
+ protected def onRedstoneOutputChanged(side: EnumFacing) {
val blockPos = position.offset(side)
world.notifyBlockOfNeighborChange(blockPos, block)
world.notifyBlocksOfNeighborChange(blockPos, world.getBlock(blockPos), side.getOpposite)
@@ -158,7 +165,7 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
}
// ----------------------------------------------------------------------- //
-
+/* TODO RedLogic
@Optional.Method(modid = Mods.IDs.RedLogic)
override def connects(wire: IWire, blockFace: Int, fromDirection: Int) = isOutputEnabled
@@ -170,4 +177,5 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
@Optional.Method(modid = Mods.IDs.RedLogic)
override def onRedstoneInputChanged() = checkRedstoneInputChanged()
+*/
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/Rotatable.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/Rotatable.scala
index aeaa62e19..9f48418fd 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/Rotatable.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/Rotatable.scala
@@ -1,14 +1,15 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api.internal
import li.cil.oc.server.{PacketSender => ServerPacketSender}
+import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._
import net.minecraft.entity.Entity
import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
/** TileEntity base class for rotatable blocks. */
trait Rotatable extends RotationAware with internal.Rotatable {
@@ -26,33 +27,33 @@ trait Rotatable extends RotationAware with internal.Rotatable {
// Pitch = Down
Array(
// Yaw = North
- Array(D.south, D.north, D.up, D.down, D.east, D.west, D.unknown),
+ Array(D.south, D.north, D.up, D.down, D.east, D.west),
// Yaw = South
- Array(D.south, D.north, D.down, D.up, D.west, D.east, D.unknown),
+ Array(D.south, D.north, D.down, D.up, D.west, D.east),
// Yaw = West
- Array(D.south, D.north, D.west, D.east, D.up, D.down, D.unknown),
+ Array(D.south, D.north, D.west, D.east, D.up, D.down),
// Yaw = East
- Array(D.south, D.north, D.east, D.west, D.down, D.up, D.unknown)),
+ Array(D.south, D.north, D.east, D.west, D.down, D.up)),
// Pitch = Up
Array(
// Yaw = North
- Array(D.north, D.south, D.down, D.up, D.east, D.west, D.unknown),
+ Array(D.north, D.south, D.down, D.up, D.east, D.west),
// Yaw = South
- Array(D.north, D.south, D.up, D.down, D.west, D.east, D.unknown),
+ Array(D.north, D.south, D.up, D.down, D.west, D.east),
// Yaw = West
- Array(D.north, D.south, D.west, D.east, D.down, D.up, D.unknown),
+ Array(D.north, D.south, D.west, D.east, D.down, D.up),
// Yaw = East
- Array(D.north, D.south, D.east, D.west, D.up, D.down, D.unknown)),
+ Array(D.north, D.south, D.east, D.west, D.up, D.down)),
// Pitch = Forward (North|East|South|West)
Array(
// Yaw = North
- Array(D.down, D.up, D.south, D.north, D.east, D.west, D.unknown),
+ Array(D.down, D.up, D.south, D.north, D.east, D.west),
// Yaw = South
- Array(D.down, D.up, D.north, D.south, D.west, D.east, D.unknown),
+ Array(D.down, D.up, D.north, D.south, D.west, D.east),
// Yaw = West
- Array(D.down, D.up, D.west, D.east, D.south, D.north, D.unknown),
+ Array(D.down, D.up, D.west, D.east, D.south, D.north),
// Yaw = East
- Array(D.down, D.up, D.east, D.west, D.north, D.south, D.unknown)))
+ Array(D.down, D.up, D.east, D.west, D.north, D.south)))
private val pitch2Direction = Array(D.up, D.north, D.down)
@@ -60,13 +61,12 @@ trait Rotatable extends RotationAware with internal.Rotatable {
/** Shortcuts for forge directions to make the above more readable. */
private object D {
- val down = ForgeDirection.DOWN
- val up = ForgeDirection.UP
- val north = ForgeDirection.NORTH
- val south = ForgeDirection.SOUTH
- val west = ForgeDirection.WEST
- val east = ForgeDirection.EAST
- val unknown = ForgeDirection.UNKNOWN
+ val down = EnumFacing.DOWN
+ val up = EnumFacing.UP
+ val north = EnumFacing.NORTH
+ val south = EnumFacing.SOUTH
+ val west = EnumFacing.WEST
+ val east = EnumFacing.EAST
}
// ----------------------------------------------------------------------- //
@@ -74,10 +74,10 @@ trait Rotatable extends RotationAware with internal.Rotatable {
// ----------------------------------------------------------------------- //
/** One of Up, Down and North (where north means forward/no pitch). */
- private var _pitch = ForgeDirection.NORTH
+ private var _pitch = EnumFacing.NORTH
/** One of the four cardinal directions. */
- private var _yaw = ForgeDirection.SOUTH
+ private var _yaw = EnumFacing.SOUTH
/** Translation for facings based on current pitch and yaw. */
private var cachedTranslation = translations(_pitch.ordinal)(_yaw.ordinal - 2)
@@ -91,17 +91,17 @@ trait Rotatable extends RotationAware with internal.Rotatable {
def pitch = _pitch
- def pitch_=(value: ForgeDirection): Unit =
+ def pitch_=(value: EnumFacing): Unit =
trySetPitchYaw(value match {
- case ForgeDirection.DOWN | ForgeDirection.UP => value
- case _ => ForgeDirection.NORTH
+ case EnumFacing.DOWN | EnumFacing.UP => value
+ case _ => EnumFacing.NORTH
}, _yaw)
def yaw = _yaw
- def yaw_=(value: ForgeDirection): Unit =
+ def yaw_=(value: EnumFacing): Unit =
trySetPitchYaw(pitch, value match {
- case ForgeDirection.DOWN | ForgeDirection.UP => _yaw
+ case EnumFacing.DOWN | EnumFacing.UP => _yaw
case _ => value
})
@@ -110,35 +110,35 @@ trait Rotatable extends RotationAware with internal.Rotatable {
pitch2Direction((entity.rotationPitch / 90).round + 1),
yaw2Direction((entity.rotationYaw / 360 * 4).round & 3))
- def setFromFacing(value: ForgeDirection) =
+ def setFromFacing(value: EnumFacing) =
value match {
- case ForgeDirection.DOWN | ForgeDirection.UP =>
+ case EnumFacing.DOWN | EnumFacing.UP =>
trySetPitchYaw(value, yaw)
case yaw =>
- trySetPitchYaw(ForgeDirection.NORTH, yaw)
+ trySetPitchYaw(EnumFacing.NORTH, yaw)
}
def invertRotation() =
trySetPitchYaw(_pitch match {
- case ForgeDirection.DOWN | ForgeDirection.UP => _pitch.getOpposite
- case _ => ForgeDirection.NORTH
+ case EnumFacing.DOWN | EnumFacing.UP => _pitch.getOpposite
+ case _ => EnumFacing.NORTH
}, _yaw.getOpposite)
override def facing = _pitch match {
- case ForgeDirection.DOWN | ForgeDirection.UP => _pitch
+ case EnumFacing.DOWN | EnumFacing.UP => _pitch
case _ => _yaw
}
- def rotate(axis: ForgeDirection) = {
+ def rotate(axis: EnumFacing) = {
val block = world.getBlock(position)
if (block != null) {
- val valid = block.getValidRotations(world, x, y, z)
+ val valid = block.getValidRotations(world, getPos)
if (valid != null && valid.contains(axis)) {
- val (newPitch, newYaw) = facing.getRotation(axis) match {
- case value@(ForgeDirection.UP | ForgeDirection.DOWN) =>
- if (value == pitch) (value, yaw.getRotation(axis))
+ val (newPitch, newYaw) = rotateAround(facing, axis) match {
+ case value@(EnumFacing.UP | EnumFacing.DOWN) =>
+ if (value == pitch) (value, rotateAround(yaw, axis))
else (value, yaw)
- case value => (ForgeDirection.NORTH, value)
+ case value => (EnumFacing.NORTH, value)
}
trySetPitchYaw(newPitch, newYaw)
}
@@ -147,11 +147,18 @@ trait Rotatable extends RotationAware with internal.Rotatable {
else false
}
- override def toLocal(value: ForgeDirection) = cachedTranslation(value.ordinal)
+ private def rotateAround(facing: EnumFacing, around: EnumFacing) = {
+ if (around.getAxisDirection == EnumFacing.AxisDirection.NEGATIVE)
+ facing.getOpposite.rotateAround(around.getAxis)
+ else
+ facing.rotateAround(around.getAxis)
+ }
- override def toGlobal(value: ForgeDirection) = cachedInverseTranslation(value.ordinal)
+ override def toLocal(value: EnumFacing) = cachedTranslation(value.ordinal)
- def validFacings = Array(ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST)
+ override def toGlobal(value: EnumFacing) = cachedInverseTranslation(value.ordinal)
+
+ def validFacings = Array(EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST)
// ----------------------------------------------------------------------- //
@@ -160,9 +167,9 @@ trait Rotatable extends RotationAware with internal.Rotatable {
ServerPacketSender.sendRotatableState(this)
}
else {
- world.markBlockForUpdate(x, y, z)
+ world.markBlockForUpdate(getPos)
}
- world.notifyBlocksOfNeighborChange(x, y, z, block)
+ world.notifyBlocksOfNeighborChange(BlockPosition(x, y, z), block)
}
// ----------------------------------------------------------------------- //
@@ -170,10 +177,10 @@ trait Rotatable extends RotationAware with internal.Rotatable {
override def readFromNBT(nbt: NBTTagCompound) = {
super.readFromNBT(nbt)
if (nbt.hasKey(Settings.namespace + "pitch")) {
- pitch = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "pitch"))
+ pitch = EnumFacing.getFront(nbt.getInteger(Settings.namespace + "pitch"))
}
if (nbt.hasKey(Settings.namespace + "yaw")) {
- yaw = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "yaw"))
+ yaw = EnumFacing.getFront(nbt.getInteger(Settings.namespace + "yaw"))
}
validatePitchAndYaw()
updateTranslation()
@@ -188,8 +195,8 @@ trait Rotatable extends RotationAware with internal.Rotatable {
@SideOnly(Side.CLIENT)
override def readFromNBTForClient(nbt: NBTTagCompound) {
super.readFromNBTForClient(nbt)
- pitch = ForgeDirection.getOrientation(nbt.getInteger("pitch"))
- yaw = ForgeDirection.getOrientation(nbt.getInteger("yaw"))
+ pitch = EnumFacing.getFront(nbt.getInteger("pitch"))
+ yaw = EnumFacing.getFront(nbt.getInteger("yaw"))
validatePitchAndYaw()
updateTranslation()
}
@@ -201,11 +208,11 @@ trait Rotatable extends RotationAware with internal.Rotatable {
}
private def validatePitchAndYaw() {
- if (!Set(ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.NORTH).contains(_pitch)) {
- _pitch = ForgeDirection.NORTH
+ if (!Set(EnumFacing.UP, EnumFacing.DOWN, EnumFacing.NORTH).contains(_pitch)) {
+ _pitch = EnumFacing.NORTH
}
- if (!Set(ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST).contains(_yaw)) {
- _yaw = ForgeDirection.SOUTH
+ if (!Set(EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST).contains(_yaw)) {
+ _yaw = EnumFacing.SOUTH
}
}
@@ -224,7 +231,7 @@ trait Rotatable extends RotationAware with internal.Rotatable {
}
/** Validates new values against the allowed rotations as set in our block. */
- private def trySetPitchYaw(pitch: ForgeDirection, yaw: ForgeDirection) = {
+ private def trySetPitchYaw(pitch: EnumFacing, yaw: EnumFacing) = {
var changed = false
if (pitch != _pitch) {
changed = true
@@ -240,6 +247,6 @@ trait Rotatable extends RotationAware with internal.Rotatable {
changed
}
- private def invert(t: Array[ForgeDirection]) =
- (0 until t.length).map(i => ForgeDirection.getOrientation(t.indexOf(ForgeDirection.getOrientation(i))))
+ private def invert(t: Array[EnumFacing]) =
+ (0 until t.length).map(i => EnumFacing.getFront(t.indexOf(EnumFacing.getFront(i))))
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/RotationAware.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/RotationAware.scala
index b4b0486a7..908f8d52d 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/RotationAware.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/RotationAware.scala
@@ -1,9 +1,9 @@
package li.cil.oc.common.tileentity.traits
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait RotationAware extends TileEntity {
- def toLocal(value: ForgeDirection) = value
+ def toLocal(value: EnumFacing) = value
- def toGlobal(value: ForgeDirection) = value
+ def toGlobal(value: EnumFacing) = value
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/TextBuffer.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/TextBuffer.scala
index b58ac044d..a009d341e 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/TextBuffer.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/TextBuffer.scala
@@ -1,7 +1,7 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api
import net.minecraft.nbt.NBTTagCompound
@@ -20,8 +20,8 @@ trait TextBuffer extends Environment {
def tier: Int
- override def updateEntity() {
- super.updateEntity()
+ override def update() {
+ super.update()
if (isClient || isConnected) {
buffer.update()
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/TileEntity.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/TileEntity.scala
index b165edc79..73d32fa04 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/TileEntity.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/TileEntity.scala
@@ -1,26 +1,26 @@
package li.cil.oc.common.tileentity.traits
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.client.Sound
-import li.cil.oc.common.EventHandler
-import li.cil.oc.common.block.DelegatorConverter
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.SideTracker
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.network.NetworkManager
import net.minecraft.network.play.server.S35PacketUpdateTileEntity
+import net.minecraft.server.gui.IUpdatePlayerListBox
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
-trait TileEntity extends net.minecraft.tileentity.TileEntity {
- def world = getWorldObj
+// TODO only implement ticking interface where needed.
+trait TileEntity extends net.minecraft.tileentity.TileEntity with IUpdatePlayerListBox {
+ def world = getWorld
- def x = xCoord
+ def x = getPos.getX
- def y = yCoord
+ def y = getPos.getY
- def z = zCoord
+ def z = getPos.getZ
def position = BlockPosition(x, y, z)
@@ -32,17 +32,17 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity {
// ----------------------------------------------------------------------- //
- override def updateEntity() {
- super.updateEntity()
- if (Settings.get.periodicallyForceLightUpdate && world.getTotalWorldTime % 40 == 0 && block.getLightValue(world, x, y, z) > 0) {
- world.markBlockForUpdate(x, y, z)
+ def canUpdate = true
+
+ override def update() {
+ if (Settings.get.periodicallyForceLightUpdate && world.getTotalWorldTime % 40 == 0 && block.getLightValue(world, getPos) > 0) {
+ world.markBlockForUpdate(getPos)
}
}
override def validate() {
super.validate()
initialize()
- EventHandler.schedule(() => DelegatorConverter.convert(world, x, y, z, None))
}
override def invalidate() {
@@ -66,11 +66,6 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity {
// ----------------------------------------------------------------------- //
- override def readFromNBT(nbt: NBTTagCompound) {
- super.readFromNBT(nbt)
- EventHandler.schedule(() => DelegatorConverter.convert(world, x, y, z, Option(nbt)))
- }
-
@SideOnly(Side.CLIENT)
def readFromNBTForClient(nbt: NBTTagCompound) {}
@@ -83,11 +78,11 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity {
try writeToNBTForClient(nbt) catch {
case e: Throwable => OpenComputers.log.warn("There was a problem writing a TileEntity description packet. Please report this if you see it!", e)
}
- if (nbt.hasNoTags) null else new S35PacketUpdateTileEntity(x, y, z, -1, nbt)
+ if (nbt.hasNoTags) null else new S35PacketUpdateTileEntity(getPos, -1, nbt)
}
override def onDataPacket(manager: NetworkManager, packet: S35PacketUpdateTileEntity) {
- try readFromNBTForClient(packet.func_148857_g()) catch {
+ try readFromNBTForClient(packet.getNbtCompound) catch {
case e: Throwable => OpenComputers.log.warn("There was a problem reading a TileEntity description packet. Please report this if you see it!", e)
}
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/AppliedEnergistics2.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/AppliedEnergistics2.scala
index e1b40c687..5b154f629 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/AppliedEnergistics2.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/AppliedEnergistics2.scala
@@ -1,135 +1,135 @@
-package li.cil.oc.common.tileentity.traits.power
-
-import java.util
-
-import appeng.api.AEApi
-import appeng.api.config.Actionable
-import appeng.api.config.PowerMultiplier
-import appeng.api.networking._
-import appeng.api.networking.energy.IEnergyGrid
-import appeng.api.util.AECableType
-import appeng.api.util.AEColor
-import appeng.api.util.DimensionalCoord
-import cpw.mods.fml.common.Optional
-import li.cil.oc.Settings
-import li.cil.oc.common.EventHandler
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.util.ForgeDirection
-
-import scala.collection.convert.WrapAsJava._
-
-@Injectable.Interface(value = "appeng.api.networking.IGridHost", modid = Mods.IDs.AppliedEnergistics2)
-trait AppliedEnergistics2 extends Common {
- private lazy val useAppliedEnergistics2Power = isServer && Mods.AppliedEnergistics2.isAvailable
-
- // 'Manual' lazy val, because lazy vals mess up the class loader, leading to class not found exceptions.
- private var node: Option[AnyRef] = None
-
- override def updateEntity() {
- super.updateEntity()
- if (useAppliedEnergistics2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
- updateEnergy()
- }
- }
-
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- private def updateEnergy() {
- tryAllSides((demand, side) => {
- val grid = getGridNode(side).getGrid
- if (grid != null) {
- val cache = grid.getCache(classOf[IEnergyGrid]).asInstanceOf[IEnergyGrid]
- if (cache != null) {
- cache.extractAEPower(demand, Actionable.MODULATE, PowerMultiplier.CONFIG)
- }
- else 0.0
- }
- else 0.0
- }, Settings.get.ratioAppliedEnergistics2)
- }
-
- override def validate() {
- super.validate()
- if (useAppliedEnergistics2Power) EventHandler.scheduleAE2Add(this)
- }
-
- override def invalidate() {
- super.invalidate()
- if (useAppliedEnergistics2Power) securityBreak()
- }
-
- override def onChunkUnload() {
- super.onChunkUnload()
- if (useAppliedEnergistics2Power) securityBreak()
- }
-
- // ----------------------------------------------------------------------- //
-
- override def readFromNBT(nbt: NBTTagCompound) {
- super.readFromNBT(nbt)
- if (useAppliedEnergistics2Power) loadNode(nbt)
- }
-
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- private def loadNode(nbt: NBTTagCompound): Unit = {
- getGridNode(ForgeDirection.UNKNOWN).loadFromNBT(Settings.namespace + "ae2power", nbt)
- }
-
- override def writeToNBT(nbt: NBTTagCompound) {
- super.writeToNBT(nbt)
- if (useAppliedEnergistics2Power) saveNode(nbt)
- }
-
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- private def saveNode(nbt: NBTTagCompound): Unit = {
- getGridNode(ForgeDirection.UNKNOWN).saveToNBT(Settings.namespace + "ae2power", nbt)
- }
-
- // ----------------------------------------------------------------------- //
-
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- def getGridNode(side: ForgeDirection) = node match {
- case Some(gridNode: IGridNode) => gridNode
- case _ =>
- val gridNode = AEApi.instance.createGridNode(new AppliedEnergistics2GridBlock(this))
- node = Option(gridNode)
- gridNode
- }
-
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- def getCableConnectionType(side: ForgeDirection) = AECableType.SMART
-
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- def securityBreak() {
- getGridNode(ForgeDirection.UNKNOWN).destroy()
- }
-}
-
-class AppliedEnergistics2GridBlock(val tileEntity: AppliedEnergistics2) extends IGridBlock {
- override def getIdlePowerUsage = 0.0
-
- override def getFlags = util.EnumSet.noneOf(classOf[GridFlags])
-
- // rv1
- def isWorldAccessable = true
-
- // rv2
- def isWorldAccessible = true
-
- override def getLocation = new DimensionalCoord(tileEntity)
-
- override def getGridColor = AEColor.Transparent
-
- override def onGridNotification(p1: GridNotification) {}
-
- override def setNetworkStatus(p1: IGrid, p2: Int) {}
-
- override def getConnectableSides = util.EnumSet.copyOf(ForgeDirection.VALID_DIRECTIONS.filter(tileEntity.canConnectPower).toList)
-
- override def getMachine = tileEntity.asInstanceOf[IGridHost]
-
- override def gridChanged() {}
-
- override def getMachineRepresentation = null
-}
\ No newline at end of file
+//package li.cil.oc.common.tileentity.traits.power
+//
+//import java.util
+//
+//import appeng.api.AEApi
+//import appeng.api.config.Actionable
+//import appeng.api.config.PowerMultiplier
+//import appeng.api.networking._
+//import appeng.api.networking.energy.IEnergyGrid
+//import appeng.api.util.AECableType
+//import appeng.api.util.AEColor
+//import appeng.api.util.DimensionalCoord
+//import net.minecraftforge.fml.common.Optional
+//import li.cil.oc.Settings
+//import li.cil.oc.common.EventHandler
+//import li.cil.oc.common.asm.Injectable
+//import li.cil.oc.integration.Mods
+//import net.minecraft.nbt.NBTTagCompound
+//import net.minecraft.util.EnumFacing
+//
+//import scala.collection.convert.WrapAsJava._
+//
+//@Injectable.Interface(value = "appeng.api.networking.IGridHost", modid = Mods.IDs.AppliedEnergistics2)
+//trait AppliedEnergistics2 extends Common {
+// private lazy val useAppliedEnergistics2Power = isServer && Mods.AppliedEnergistics2.isAvailable
+//
+// // 'Manual' lazy val, because lazy vals mess up the class loader, leading to class not found exceptions.
+// private var node: Option[AnyRef] = None
+//
+// override def updateEntity() {
+// super.updateEntity()
+// if (useAppliedEnergistics2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
+// updateEnergy()
+// }
+// }
+//
+// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
+// private def updateEnergy() {
+// tryAllSides((demand, side) => {
+// val grid = getGridNode(side).getGrid
+// if (grid != null) {
+// val cache = grid.getCache(classOf[IEnergyGrid]).asInstanceOf[IEnergyGrid]
+// if (cache != null) {
+// cache.extractAEPower(demand, Actionable.MODULATE, PowerMultiplier.CONFIG)
+// }
+// else 0.0
+// }
+// else 0.0
+// }, Settings.get.ratioAppliedEnergistics2)
+// }
+//
+// override def validate() {
+// super.validate()
+// if (useAppliedEnergistics2Power) EventHandler.scheduleAE2Add(this)
+// }
+//
+// override def invalidate() {
+// super.invalidate()
+// if (useAppliedEnergistics2Power) securityBreak()
+// }
+//
+// override def onChunkUnload() {
+// super.onChunkUnload()
+// if (useAppliedEnergistics2Power) securityBreak()
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// override def readFromNBT(nbt: NBTTagCompound) {
+// super.readFromNBT(nbt)
+// if (useAppliedEnergistics2Power) loadNode(nbt)
+// }
+//
+// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
+// private def loadNode(nbt: NBTTagCompound): Unit = {
+// getGridNode(EnumFacing.UNKNOWN).loadFromNBT(Settings.namespace + "ae2power", nbt)
+// }
+//
+// override def writeToNBT(nbt: NBTTagCompound) {
+// super.writeToNBT(nbt)
+// if (useAppliedEnergistics2Power) saveNode(nbt)
+// }
+//
+// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
+// private def saveNode(nbt: NBTTagCompound): Unit = {
+// getGridNode(EnumFacing.UNKNOWN).saveToNBT(Settings.namespace + "ae2power", nbt)
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
+// def getGridNode(side: EnumFacing) = node match {
+// case Some(gridNode: IGridNode) => gridNode
+// case _ =>
+// val gridNode = AEApi.instance.createGridNode(new AppliedEnergistics2GridBlock(this))
+// node = Option(gridNode)
+// gridNode
+// }
+//
+// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
+// def getCableConnectionType(side: EnumFacing) = AECableType.SMART
+//
+// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
+// def securityBreak() {
+// getGridNode(EnumFacing.UNKNOWN).destroy()
+// }
+//}
+//
+//class AppliedEnergistics2GridBlock(val tileEntity: AppliedEnergistics2) extends IGridBlock {
+// override def getIdlePowerUsage = 0.0
+//
+// override def getFlags = util.EnumSet.noneOf(classOf[GridFlags])
+//
+// // rv1
+// def isWorldAccessable = true
+//
+// // rv2
+// def isWorldAccessible = true
+//
+// override def getLocation = new DimensionalCoord(tileEntity)
+//
+// override def getGridColor = AEColor.Transparent
+//
+// override def onGridNotification(p1: GridNotification) {}
+//
+// override def setNetworkStatus(p1: IGrid, p2: Int) {}
+//
+// override def getConnectableSides = util.EnumSet.copyOf(EnumFacing.values.filter(tileEntity.canConnectPower).toList)
+//
+// override def getMachine = tileEntity.asInstanceOf[IGridHost]
+//
+// override def gridChanged() {}
+//
+// override def getMachineRepresentation = null
+//}
\ No newline at end of file
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Common.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Common.scala
index 98618ae27..e90394201 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Common.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Common.scala
@@ -1,27 +1,27 @@
package li.cil.oc.common.tileentity.traits.power
-import cpw.mods.fml.relauncher.Side
-import cpw.mods.fml.relauncher.SideOnly
+import net.minecraftforge.fml.relauncher.Side
+import net.minecraftforge.fml.relauncher.SideOnly
import li.cil.oc.Settings
import li.cil.oc.api.network.Connector
import li.cil.oc.common.tileentity.traits.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait Common extends TileEntity {
@SideOnly(Side.CLIENT)
- protected def hasConnector(side: ForgeDirection) = false
+ protected def hasConnector(side: EnumFacing) = false
- protected def connector(side: ForgeDirection): Option[Connector] = None
+ protected def connector(side: EnumFacing): Option[Connector] = None
// ----------------------------------------------------------------------- //
protected def energyThroughput: Double
- protected def tryAllSides(provider: (Double, ForgeDirection) => Double, ratio: Double) {
+ protected def tryAllSides(provider: (Double, EnumFacing) => Double, ratio: Double) {
// We make sure to only call this every `Settings.get.tickFrequency` ticks,
// but our throughput is per tick, so multiply this up for actual budget.
var budget = energyThroughput * Settings.get.tickFrequency
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
+ for (side <- EnumFacing.values) {
val demand = math.min(budget, globalDemand(side)) / ratio
if (demand > 1) {
val energy = provider(demand, side) * ratio
@@ -34,11 +34,10 @@ trait Common extends TileEntity {
// ----------------------------------------------------------------------- //
- def canConnectPower(side: ForgeDirection) =
- !Settings.get.ignorePower && side != null && side != ForgeDirection.UNKNOWN &&
- (if (isClient) hasConnector(side) else connector(side).isDefined)
+ def canConnectPower(side: EnumFacing) =
+ !Settings.get.ignorePower && (if (isClient) hasConnector(side) else connector(side).isDefined)
- def tryChangeBuffer(side: ForgeDirection, amount: Double, doReceive: Boolean = true) =
+ def tryChangeBuffer(side: EnumFacing, amount: Double, doReceive: Boolean = true) =
if (isClient || Settings.get.ignorePower) 0
else connector(side) match {
case Some(node) =>
@@ -48,19 +47,19 @@ trait Common extends TileEntity {
case _ => 0
}
- def globalBuffer(side: ForgeDirection) =
+ def globalBuffer(side: EnumFacing) =
if (isClient) 0
else connector(side) match {
case Some(node) => node.globalBuffer
case _ => 0
}
- def globalBufferSize(side: ForgeDirection) =
+ def globalBufferSize(side: EnumFacing) =
if (isClient) 0
else connector(side) match {
case Some(node) => node.globalBufferSize
case _ => 0
}
- def globalDemand(side: ForgeDirection) = math.max(0, math.min(energyThroughput, globalBufferSize(side) - globalBuffer(side)))
+ def globalDemand(side: EnumFacing) = math.max(0, math.min(energyThroughput, globalBufferSize(side) - globalBuffer(side)))
}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Factorization.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Factorization.scala
index c9e10e306..a0afc3ab6 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Factorization.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Factorization.scala
@@ -1,92 +1,92 @@
-package li.cil.oc.common.tileentity.traits.power
-
-import cpw.mods.fml.common.Optional
-import factorization.api.Charge
-import factorization.api.Coord
-import factorization.api.IChargeConductor
-import li.cil.oc.OpenComputers
-import li.cil.oc.Settings
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import net.minecraft.nbt.NBTTagCompound
-
-@Injectable.Interface(value = "factorization.api.IChargeConductor", modid = Mods.IDs.Factorization)
-trait Factorization extends Common {
- private lazy val useFactorizationPower = isServer && Mods.Factorization.isAvailable
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- private lazy val charge: AnyRef = this match {
- case conductor: IChargeConductor => new Charge(conductor)
- case _ =>
- OpenComputers.log.warn("Failed setting up Factorization power, which most likely means the class transformer did not run. You're probably running in an incorrectly configured development environment. Try adding `-Dfml.coreMods.load=li.cil.oc.common.launch.TransformerLoader` to the VM options of your run configuration.")
- null
- }
-
- // ----------------------------------------------------------------------- //
-
- override def updateEntity() {
- if (useFactorizationPower) updateEnergy()
- super.updateEntity()
- }
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- private def updateEnergy() {
- getCharge.update()
- if (world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
- tryAllSides((demand, _) => getCharge.deplete(demand.toInt), Settings.get.ratioFactorization)
- }
- }
-
- override def invalidate() {
- if (useFactorizationPower) invalidateCharge()
- super.invalidate()
- }
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- private def invalidateCharge() {
- getCharge.invalidate()
- }
-
- override def onChunkUnload() {
- if (useFactorizationPower) removeCharge()
- super.onChunkUnload()
- }
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- private def removeCharge() {
- if (!isInvalid) getCharge.remove()
- }
-
- // ----------------------------------------------------------------------- //
-
- override def readFromNBT(nbt: NBTTagCompound) {
- super.readFromNBT(nbt)
- if (useFactorizationPower) loadCharge(nbt)
- }
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- private def loadCharge(nbt: NBTTagCompound) {
- getCharge.readFromNBT(nbt, "fzpower")
- }
-
- override def writeToNBT(nbt: NBTTagCompound) {
- super.writeToNBT(nbt)
- if (useFactorizationPower) saveCharge(nbt)
- }
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- private def saveCharge(nbt: NBTTagCompound) {
- getCharge.writeToNBT(nbt, "fzpower")
- }
-
- // ----------------------------------------------------------------------- //
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- def getCharge = if (Mods.Factorization.isAvailable) charge.asInstanceOf[Charge] else null
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- def getInfo = ""
-
- @Optional.Method(modid = Mods.IDs.Factorization)
- def getCoord = new Coord(this)
-}
+//package li.cil.oc.common.tileentity.traits.power
+//
+//import net.minecraftforge.fml.common.Optional
+//import factorization.api.Charge
+//import factorization.api.Coord
+//import factorization.api.IChargeConductor
+//import li.cil.oc.OpenComputers
+//import li.cil.oc.Settings
+//import li.cil.oc.common.asm.Injectable
+//import li.cil.oc.integration.Mods
+//import net.minecraft.nbt.NBTTagCompound
+//
+//@Injectable.Interface(value = "factorization.api.IChargeConductor", modid = Mods.IDs.Factorization)
+//trait Factorization extends Common {
+// private lazy val useFactorizationPower = isServer && Mods.Factorization.isAvailable
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// private lazy val charge: AnyRef = this match {
+// case conductor: IChargeConductor => new Charge(conductor)
+// case _ =>
+// OpenComputers.log.warn("Failed setting up Factorization power, which most likely means the class transformer did not run. You're probably running in an incorrectly configured development environment. Try adding `-Dfml.coreMods.load=li.cil.oc.common.launch.TransformerLoader` to the VM options of your run configuration.")
+// null
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// override def updateEntity() {
+// if (useFactorizationPower) updateEnergy()
+// super.updateEntity()
+// }
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// private def updateEnergy() {
+// getCharge.update()
+// if (world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
+// tryAllSides((demand, _) => getCharge.deplete(demand.toInt), Settings.get.ratioFactorization)
+// }
+// }
+//
+// override def invalidate() {
+// if (useFactorizationPower) invalidateCharge()
+// super.invalidate()
+// }
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// private def invalidateCharge() {
+// getCharge.invalidate()
+// }
+//
+// override def onChunkUnload() {
+// if (useFactorizationPower) removeCharge()
+// super.onChunkUnload()
+// }
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// private def removeCharge() {
+// if (!isInvalid) getCharge.remove()
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// override def readFromNBT(nbt: NBTTagCompound) {
+// super.readFromNBT(nbt)
+// if (useFactorizationPower) loadCharge(nbt)
+// }
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// private def loadCharge(nbt: NBTTagCompound) {
+// getCharge.readFromNBT(nbt, "fzpower")
+// }
+//
+// override def writeToNBT(nbt: NBTTagCompound) {
+// super.writeToNBT(nbt)
+// if (useFactorizationPower) saveCharge(nbt)
+// }
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// private def saveCharge(nbt: NBTTagCompound) {
+// getCharge.writeToNBT(nbt, "fzpower")
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// def getCharge = if (Mods.Factorization.isAvailable) charge.asInstanceOf[Charge] else null
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// def getInfo = ""
+//
+// @Optional.Method(modid = Mods.IDs.Factorization)
+// def getCoord = new Coord(this)
+//}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Galacticraft.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Galacticraft.scala
index cc61126b9..627452b01 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Galacticraft.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Galacticraft.scala
@@ -1,42 +1,42 @@
-package li.cil.oc.common.tileentity.traits.power
-
-import cpw.mods.fml.common.Optional
-import li.cil.oc.Settings
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import micdoodle8.mods.galacticraft.api.power.EnergySource
-import micdoodle8.mods.galacticraft.api.transmission.NetworkType
-import net.minecraftforge.common.util.ForgeDirection
-
-import scala.language.implicitConversions
-
-@Injectable.InterfaceList(Array(
- new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.power.IEnergyHandlerGC", modid = Mods.IDs.Galacticraft),
- new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.transmission.tile.IConnector", modid = Mods.IDs.Galacticraft)
-))
-trait Galacticraft extends Common {
- private implicit def toDirection(source: EnergySource): ForgeDirection = source match {
- case adjacent: EnergySource.EnergySourceAdjacent => adjacent.direction
- case _ => ForgeDirection.UNKNOWN
- }
-
- @Optional.Method(modid = Mods.IDs.Galacticraft)
- def nodeAvailable(from: EnergySource) = Mods.Galacticraft.isAvailable && canConnectPower(from)
-
- @Optional.Method(modid = Mods.IDs.Galacticraft)
- def receiveEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) =
- if (!Mods.Galacticraft.isAvailable) 0
- else (tryChangeBuffer(from, amount * Settings.get.ratioGalacticraft, !simulate) / Settings.get.ratioGalacticraft).toFloat
-
- @Optional.Method(modid = Mods.IDs.Galacticraft)
- def getEnergyStoredGC(from: EnergySource) = (globalBuffer(from) / Settings.get.ratioGalacticraft).toFloat
-
- @Optional.Method(modid = Mods.IDs.Galacticraft)
- def getMaxEnergyStoredGC(from: EnergySource) = (globalBufferSize(from) / Settings.get.ratioGalacticraft).toFloat
-
- @Optional.Method(modid = Mods.IDs.Galacticraft)
- def extractEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) = 0f
-
- @Optional.Method(modid = Mods.IDs.Galacticraft)
- def canConnect(from: ForgeDirection, networkType: NetworkType): Boolean = networkType == NetworkType.POWER && canConnectPower(from)
-}
+//package li.cil.oc.common.tileentity.traits.power
+//
+//import net.minecraftforge.fml.common.Optional
+//import li.cil.oc.Settings
+//import li.cil.oc.common.asm.Injectable
+//import li.cil.oc.integration.Mods
+//import micdoodle8.mods.galacticraft.api.power.EnergySource
+//import micdoodle8.mods.galacticraft.api.transmission.NetworkType
+//import net.minecraft.util.EnumFacing
+//
+//import scala.language.implicitConversions
+//
+//@Injectable.InterfaceList(Array(
+// new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.power.IEnergyHandlerGC", modid = Mods.IDs.Galacticraft),
+// new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.transmission.tile.IConnector", modid = Mods.IDs.Galacticraft)
+//))
+//trait Galacticraft extends Common {
+// private implicit def toDirection(source: EnergySource): EnumFacing = source match {
+// case adjacent: EnergySource.EnergySourceAdjacent => adjacent.direction
+// case _ => EnumFacing.UNKNOWN
+// }
+//
+// @Optional.Method(modid = Mods.IDs.Galacticraft)
+// def nodeAvailable(from: EnergySource) = Mods.Galacticraft.isAvailable && canConnectPower(from)
+//
+// @Optional.Method(modid = Mods.IDs.Galacticraft)
+// def receiveEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) =
+// if (!Mods.Galacticraft.isAvailable) 0
+// else (tryChangeBuffer(from, amount * Settings.get.ratioGalacticraft, !simulate) / Settings.get.ratioGalacticraft).toFloat
+//
+// @Optional.Method(modid = Mods.IDs.Galacticraft)
+// def getEnergyStoredGC(from: EnergySource) = (globalBuffer(from) / Settings.get.ratioGalacticraft).toFloat
+//
+// @Optional.Method(modid = Mods.IDs.Galacticraft)
+// def getMaxEnergyStoredGC(from: EnergySource) = (globalBufferSize(from) / Settings.get.ratioGalacticraft).toFloat
+//
+// @Optional.Method(modid = Mods.IDs.Galacticraft)
+// def extractEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) = 0f
+//
+// @Optional.Method(modid = Mods.IDs.Galacticraft)
+// def canConnect(from: EnumFacing, networkType: NetworkType): Boolean = networkType == NetworkType.POWER && canConnectPower(from)
+//}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Classic.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Classic.scala
index d0d6bb0b6..e79135132 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Classic.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Classic.scala
@@ -1,98 +1,98 @@
-package li.cil.oc.common.tileentity.traits.power
-
-import cpw.mods.fml.common.Optional
-import cpw.mods.fml.common.eventhandler.Event
-import ic2classic.api.Direction
-import li.cil.oc.OpenComputers
-import li.cil.oc.Settings
-import li.cil.oc.common.EventHandler
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import net.minecraft.nbt.NBTTagCompound
-import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
-
-@Injectable.Interface(value = "ic2classic.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2Classic)
-trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {
- private var conversionBuffer = 0.0
-
- private lazy val useIndustrialCraft2ClassicPower = isServer && Mods.IndustrialCraft2Classic.isAvailable
-
- // ----------------------------------------------------------------------- //
-
- override def updateEntity() {
- super.updateEntity()
- if (useIndustrialCraft2ClassicPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
- updateEnergy()
- }
- }
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
- private def updateEnergy() {
- tryAllSides((demand, _) => {
- val result = math.min(demand, conversionBuffer)
- conversionBuffer -= result
- result
- }, Settings.get.ratioIndustrialCraft2)
- }
-
- override def validate() {
- super.validate()
- if (useIndustrialCraft2ClassicPower && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
- }
-
- override def invalidate() {
- super.invalidate()
- if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
- }
-
- override def onChunkUnload() {
- super.onChunkUnload()
- if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
- }
-
- private def removeFromIC2Grid() {
- try MinecraftForge.EVENT_BUS.post(Class.forName("ic2classic.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2classic.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
- case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
- }
- addedToIC2PowerGrid = false
- }
-
- // ----------------------------------------------------------------------- //
-
- override def readFromNBT(nbt: NBTTagCompound) {
- super.readFromNBT(nbt)
- conversionBuffer = nbt.getDouble(Settings.namespace + "ic2cpower")
- }
-
- override def writeToNBT(nbt: NBTTagCompound) {
- super.writeToNBT(nbt)
- nbt.setDouble(Settings.namespace + "ic2cpower", conversionBuffer)
- }
-
- // ----------------------------------------------------------------------- //
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
- def isAddedToEnergyNet: Boolean = addedToIC2PowerGrid
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
- def getMaxSafeInput: Int = Int.MaxValue
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
- def acceptsEnergyFrom(emitter: TileEntity, direction: Direction) = useIndustrialCraft2ClassicPower && canConnectPower(direction.toForgeDirection)
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
- def injectEnergy(directionFrom: Direction, amount: Int): Boolean = {
- conversionBuffer += amount
- true
- }
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
- def demandsEnergy: Int = {
- if (!useIndustrialCraft2ClassicPower) 0
- else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
- math.min(ForgeDirection.VALID_DIRECTIONS.map(globalDemand).max, energyThroughput / Settings.get.ratioIndustrialCraft2).toInt
- else 0
- }
-}
+//package li.cil.oc.common.tileentity.traits.power
+//
+//import net.minecraftforge.fml.common.Optional
+//import net.minecraftforge.fml.common.eventhandler.Event
+//import ic2classic.api.Direction
+//import li.cil.oc.OpenComputers
+//import li.cil.oc.Settings
+//import li.cil.oc.common.EventHandler
+//import li.cil.oc.common.asm.Injectable
+//import li.cil.oc.integration.Mods
+//import net.minecraft.nbt.NBTTagCompound
+//import net.minecraft.tileentity.TileEntity
+//import net.minecraftforge.common.MinecraftForge
+//import net.minecraft.util.EnumFacing
+//
+//@Injectable.Interface(value = "ic2classic.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2Classic)
+//trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {
+// private var conversionBuffer = 0.0
+//
+// private lazy val useIndustrialCraft2ClassicPower = isServer && Mods.IndustrialCraft2Classic.isAvailable
+//
+// // ----------------------------------------------------------------------- //
+//
+// override def updateEntity() {
+// super.updateEntity()
+// if (useIndustrialCraft2ClassicPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
+// updateEnergy()
+// }
+// }
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
+// private def updateEnergy() {
+// tryAllSides((demand, _) => {
+// val result = math.min(demand, conversionBuffer)
+// conversionBuffer -= result
+// result
+// }, Settings.get.ratioIndustrialCraft2)
+// }
+//
+// override def validate() {
+// super.validate()
+// if (useIndustrialCraft2ClassicPower && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
+// }
+//
+// override def invalidate() {
+// super.invalidate()
+// if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
+// }
+//
+// override def onChunkUnload() {
+// super.onChunkUnload()
+// if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
+// }
+//
+// private def removeFromIC2Grid() {
+// try MinecraftForge.EVENT_BUS.post(Class.forName("ic2classic.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2classic.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
+// case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
+// }
+// addedToIC2PowerGrid = false
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// override def readFromNBT(nbt: NBTTagCompound) {
+// super.readFromNBT(nbt)
+// conversionBuffer = nbt.getDouble(Settings.namespace + "ic2cpower")
+// }
+//
+// override def writeToNBT(nbt: NBTTagCompound) {
+// super.writeToNBT(nbt)
+// nbt.setDouble(Settings.namespace + "ic2cpower", conversionBuffer)
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
+// def isAddedToEnergyNet: Boolean = addedToIC2PowerGrid
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
+// def getMaxSafeInput: Int = Int.MaxValue
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
+// def acceptsEnergyFrom(emitter: TileEntity, direction: Direction) = useIndustrialCraft2ClassicPower && canConnectPower(direction.toEnumFacing)
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
+// def injectEnergy(directionFrom: Direction, amount: Int): Boolean = {
+// conversionBuffer += amount
+// true
+// }
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
+// def demandsEnergy: Int = {
+// if (!useIndustrialCraft2ClassicPower) 0
+// else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
+// math.min(EnumFacing.values.map(globalDemand).max, energyThroughput / Settings.get.ratioIndustrialCraft2).toInt
+// else 0
+// }
+//}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Common.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Common.scala
index 368b2ff19..1486fdd67 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Common.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Common.scala
@@ -1,5 +1,5 @@
-package li.cil.oc.common.tileentity.traits.power
-
-trait IndustrialCraft2Common {
- var addedToIC2PowerGrid = false
-}
+//package li.cil.oc.common.tileentity.traits.power
+//
+//trait IndustrialCraft2Common {
+// var addedToIC2PowerGrid = false
+//}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Experimental.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Experimental.scala
index 3352d3c2f..326a28b24 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Experimental.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/IndustrialCraft2Experimental.scala
@@ -1,93 +1,93 @@
-package li.cil.oc.common.tileentity.traits.power
-
-import cpw.mods.fml.common.Optional
-import cpw.mods.fml.common.eventhandler.Event
-import li.cil.oc.OpenComputers
-import li.cil.oc.Settings
-import li.cil.oc.common.EventHandler
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import net.minecraft.nbt.NBTTagCompound
-import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
-
-@Injectable.Interface(value = "ic2.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2)
-trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {
- private var conversionBuffer = 0.0
-
- private lazy val useIndustrialCraft2Power = isServer && Mods.IndustrialCraft2.isAvailable
-
- // ----------------------------------------------------------------------- //
-
- override def updateEntity() {
- super.updateEntity()
- if (useIndustrialCraft2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
- updateEnergy()
- }
- }
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
- private def updateEnergy() {
- tryAllSides((demand, _) => {
- val result = math.min(demand, conversionBuffer)
- conversionBuffer -= result
- result
- }, Settings.get.ratioIndustrialCraft2)
- }
-
- override def validate() {
- super.validate()
- if (useIndustrialCraft2Power && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
- }
-
- override def invalidate() {
- super.invalidate()
- if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
- }
-
- override def onChunkUnload() {
- super.onChunkUnload()
- if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
- }
-
- private def removeFromIC2Grid() {
- try MinecraftForge.EVENT_BUS.post(Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
- case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
- }
- addedToIC2PowerGrid = false
- }
-
- // ----------------------------------------------------------------------- //
-
- override def readFromNBT(nbt: NBTTagCompound) {
- super.readFromNBT(nbt)
- conversionBuffer = nbt.getDouble(Settings.namespace + "ic2power")
- }
-
- override def writeToNBT(nbt: NBTTagCompound) {
- super.writeToNBT(nbt)
- nbt.setDouble(Settings.namespace + "ic2power", conversionBuffer)
- }
-
- // ----------------------------------------------------------------------- //
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
- def getSinkTier: Int = Int.MaxValue
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
- def acceptsEnergyFrom(emitter: net.minecraft.tileentity.TileEntity, direction: ForgeDirection): Boolean = useIndustrialCraft2Power && canConnectPower(direction)
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
- def injectEnergy(directionFrom: ForgeDirection, amount: Double, voltage: Double): Double = {
- conversionBuffer += amount
- 0.0
- }
-
- @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
- def getDemandedEnergy: Double = {
- if (!useIndustrialCraft2Power) 0.0
- else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
- math.min(ForgeDirection.VALID_DIRECTIONS.map(globalDemand).max, energyThroughput / Settings.get.ratioIndustrialCraft2)
- else 0
- }
-}
+//package li.cil.oc.common.tileentity.traits.power
+//
+//import net.minecraftforge.fml.common.Optional
+//import net.minecraftforge.fml.common.eventhandler.Event
+//import li.cil.oc.OpenComputers
+//import li.cil.oc.Settings
+//import li.cil.oc.common.EventHandler
+//import li.cil.oc.common.asm.Injectable
+//import li.cil.oc.integration.Mods
+//import net.minecraft.nbt.NBTTagCompound
+//import net.minecraftforge.common.MinecraftForge
+//import net.minecraft.util.EnumFacing
+//
+//@Injectable.Interface(value = "ic2.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2)
+//trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {
+// private var conversionBuffer = 0.0
+//
+// private lazy val useIndustrialCraft2Power = isServer && Mods.IndustrialCraft2.isAvailable
+//
+// // ----------------------------------------------------------------------- //
+//
+// override def updateEntity() {
+// super.updateEntity()
+// if (useIndustrialCraft2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
+// updateEnergy()
+// }
+// }
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
+// private def updateEnergy() {
+// tryAllSides((demand, _) => {
+// val result = math.min(demand, conversionBuffer)
+// conversionBuffer -= result
+// result
+// }, Settings.get.ratioIndustrialCraft2)
+// }
+//
+// override def validate() {
+// super.validate()
+// if (useIndustrialCraft2Power && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
+// }
+//
+// override def invalidate() {
+// super.invalidate()
+// if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
+// }
+//
+// override def onChunkUnload() {
+// super.onChunkUnload()
+// if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
+// }
+//
+// private def removeFromIC2Grid() {
+// try MinecraftForge.EVENT_BUS.post(Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
+// case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
+// }
+// addedToIC2PowerGrid = false
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// override def readFromNBT(nbt: NBTTagCompound) {
+// super.readFromNBT(nbt)
+// conversionBuffer = nbt.getDouble(Settings.namespace + "ic2power")
+// }
+//
+// override def writeToNBT(nbt: NBTTagCompound) {
+// super.writeToNBT(nbt)
+// nbt.setDouble(Settings.namespace + "ic2power", conversionBuffer)
+// }
+//
+// // ----------------------------------------------------------------------- //
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
+// def getSinkTier: Int = Int.MaxValue
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
+// def acceptsEnergyFrom(emitter: net.minecraft.tileentity.TileEntity, direction: EnumFacing): Boolean = useIndustrialCraft2Power && canConnectPower(direction)
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
+// def injectEnergy(directionFrom: EnumFacing, amount: Double, voltage: Double): Double = {
+// conversionBuffer += amount
+// 0.0
+// }
+//
+// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
+// def getDemandedEnergy: Double = {
+// if (!useIndustrialCraft2Power) 0.0
+// else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
+// math.min(EnumFacing.values.map(globalDemand).max, energyThroughput / Settings.get.ratioIndustrialCraft2)
+// else 0
+// }
+//}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Mekanism.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Mekanism.scala
index d6290a4cb..396e0db5d 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/Mekanism.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/Mekanism.scala
@@ -1,27 +1,27 @@
-package li.cil.oc.common.tileentity.traits.power
-
-import cpw.mods.fml.common.Optional
-import li.cil.oc.Settings
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import net.minecraftforge.common.util.ForgeDirection
-
-@Injectable.Interface(value = "mekanism.api.energy.IStrictEnergyAcceptor", modid = Mods.IDs.Mekanism)
-trait Mekanism extends Common {
- @Optional.Method(modid = Mods.IDs.Mekanism)
- def canReceiveEnergy(side: ForgeDirection) = Mods.Mekanism.isAvailable && canConnectPower(side)
-
- @Optional.Method(modid = Mods.IDs.Mekanism)
- def transferEnergyToAcceptor(side: ForgeDirection, amount: Double) =
- if (!Mods.Mekanism.isAvailable) 0
- else amount - tryChangeBuffer(side, amount * Settings.get.ratioMekanism) / Settings.get.ratioMekanism
-
- @Optional.Method(modid = Mods.IDs.Mekanism)
- def getMaxEnergy = ForgeDirection.VALID_DIRECTIONS.map(globalBufferSize).max / Settings.get.ratioMekanism
-
- @Optional.Method(modid = Mods.IDs.Mekanism)
- def getEnergy = ForgeDirection.VALID_DIRECTIONS.map(globalBuffer).max / Settings.get.ratioMekanism
-
- @Optional.Method(modid = Mods.IDs.Mekanism)
- def setEnergy(energy: Double) {}
-}
+//package li.cil.oc.common.tileentity.traits.power
+//
+//import net.minecraftforge.fml.common.Optional
+//import li.cil.oc.Settings
+//import li.cil.oc.common.asm.Injectable
+//import li.cil.oc.integration.Mods
+//import net.minecraft.util.EnumFacing
+//
+//@Injectable.Interface(value = "mekanism.api.energy.IStrictEnergyAcceptor", modid = Mods.IDs.Mekanism)
+//trait Mekanism extends Common {
+// @Optional.Method(modid = Mods.IDs.Mekanism)
+// def canReceiveEnergy(side: EnumFacing) = Mods.Mekanism.isAvailable && canConnectPower(side)
+//
+// @Optional.Method(modid = Mods.IDs.Mekanism)
+// def transferEnergyToAcceptor(side: EnumFacing, amount: Double) =
+// if (!Mods.Mekanism.isAvailable) 0
+// else amount - tryChangeBuffer(side, amount * Settings.get.ratioMekanism) / Settings.get.ratioMekanism
+//
+// @Optional.Method(modid = Mods.IDs.Mekanism)
+// def getMaxEnergy = EnumFacing.values.map(globalBufferSize).max / Settings.get.ratioMekanism
+//
+// @Optional.Method(modid = Mods.IDs.Mekanism)
+// def getEnergy = EnumFacing.values.map(globalBuffer).max / Settings.get.ratioMekanism
+//
+// @Optional.Method(modid = Mods.IDs.Mekanism)
+// def setEnergy(energy: Double) {}
+//}
diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/power/RedstoneFlux.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/power/RedstoneFlux.scala
index a29af1a46..266902946 100644
--- a/src/main/scala/li/cil/oc/common/tileentity/traits/power/RedstoneFlux.scala
+++ b/src/main/scala/li/cil/oc/common/tileentity/traits/power/RedstoneFlux.scala
@@ -1,27 +1,27 @@
-package li.cil.oc.common.tileentity.traits.power
-
-import cpw.mods.fml.common.Optional
-import li.cil.oc.Settings
-import li.cil.oc.common.asm.Injectable
-import li.cil.oc.integration.Mods
-import net.minecraftforge.common.util.ForgeDirection
-
-@Injectable.Interface(value = "cofh.api.energy.IEnergyHandler", modid = Mods.IDs.CoFHEnergy)
-trait RedstoneFlux extends Common {
- @Optional.Method(modid = Mods.IDs.CoFHEnergy)
- def canConnectEnergy(from: ForgeDirection) = Mods.CoFHEnergy.isAvailable && canConnectPower(from)
-
- @Optional.Method(modid = Mods.IDs.CoFHEnergy)
- def receiveEnergy(from: ForgeDirection, maxReceive: Int, simulate: Boolean) =
- if (!Mods.CoFHEnergy.isAvailable) 0
- else (tryChangeBuffer(from, maxReceive * Settings.get.ratioRedstoneFlux, !simulate) / Settings.get.ratioRedstoneFlux).toInt
-
- @Optional.Method(modid = Mods.IDs.CoFHEnergy)
- def getEnergyStored(from: ForgeDirection) = (globalBuffer(from) / Settings.get.ratioRedstoneFlux).toInt
-
- @Optional.Method(modid = Mods.IDs.CoFHEnergy)
- def getMaxEnergyStored(from: ForgeDirection) = (globalBufferSize(from) / Settings.get.ratioRedstoneFlux).toInt
-
- @Optional.Method(modid = Mods.IDs.CoFHEnergy)
- def extractEnergy(from: ForgeDirection, maxExtract: Int, simulate: Boolean) = 0
-}
+//package li.cil.oc.common.tileentity.traits.power
+//
+//import net.minecraftforge.fml.common.Optional
+//import li.cil.oc.Settings
+//import li.cil.oc.common.asm.Injectable
+//import li.cil.oc.integration.Mods
+//import net.minecraft.util.EnumFacing
+//
+//@Injectable.Interface(value = "cofh.api.energy.IEnergyHandler", modid = Mods.IDs.CoFHEnergy)
+//trait RedstoneFlux extends Common {
+// @Optional.Method(modid = Mods.IDs.CoFHEnergy)
+// def canConnectEnergy(from: EnumFacing) = Mods.CoFHEnergy.isAvailable && canConnectPower(from)
+//
+// @Optional.Method(modid = Mods.IDs.CoFHEnergy)
+// def receiveEnergy(from: EnumFacing, maxReceive: Int, simulate: Boolean) =
+// if (!Mods.CoFHEnergy.isAvailable) 0
+// else (tryChangeBuffer(from, maxReceive * Settings.get.ratioRedstoneFlux, !simulate) / Settings.get.ratioRedstoneFlux).toInt
+//
+// @Optional.Method(modid = Mods.IDs.CoFHEnergy)
+// def getEnergyStored(from: EnumFacing) = (globalBuffer(from) / Settings.get.ratioRedstoneFlux).toInt
+//
+// @Optional.Method(modid = Mods.IDs.CoFHEnergy)
+// def getMaxEnergyStored(from: EnumFacing) = (globalBufferSize(from) / Settings.get.ratioRedstoneFlux).toInt
+//
+// @Optional.Method(modid = Mods.IDs.CoFHEnergy)
+// def extractEnergy(from: EnumFacing, maxExtract: Int, simulate: Boolean) = 0
+//}
diff --git a/src/main/scala/li/cil/oc/integration/Mods.scala b/src/main/scala/li/cil/oc/integration/Mods.scala
index 710f4fdd2..945f8e086 100644
--- a/src/main/scala/li/cil/oc/integration/Mods.scala
+++ b/src/main/scala/li/cil/oc/integration/Mods.scala
@@ -1,8 +1,8 @@
package li.cil.oc.integration
-import cpw.mods.fml.common.Loader
-import cpw.mods.fml.common.ModAPIManager
-import cpw.mods.fml.common.versioning.VersionParser
+import net.minecraftforge.fml.common.Loader
+import net.minecraftforge.fml.common.ModAPIManager
+import net.minecraftforge.fml.common.versioning.VersionParser
import li.cil.oc.Settings
import li.cil.oc.integration
@@ -71,37 +71,37 @@ object Mods {
// ----------------------------------------------------------------------- //
def init() {
- tryInit(integration.appeng.ModAppEng)
- tryInit(integration.buildcraft.tools.ModBuildCraftAPITools)
- tryInit(integration.buildcraft.tiles.ModBuildCraftAPITiles)
- tryInit(integration.buildcraft.transport.ModBuildCraftAPITransport)
- tryInit(integration.cofh.energy.ModCoFHEnergy)
- tryInit(integration.cofh.item.ModCoFHItem)
- tryInit(integration.cofh.tileentity.ModCoFHTileEntity)
- tryInit(integration.cofh.transport.ModCoFHTransport)
- tryInit(integration.enderstorage.ModEnderStorage)
- tryInit(integration.forestry.ModForestry)
- tryInit(integration.fmp.ModForgeMultipart)
- tryInit(integration.gregtech.ModGregtech)
- tryInit(integration.ic2.ModIndustrialCraft2)
- tryInit(integration.mfr.ModMineFactoryReloaded)
- tryInit(integration.mystcraft.ModMystcraft)
+// tryInit(integration.appeng.ModAppEng)
+// tryInit(integration.buildcraft.tools.ModBuildCraftAPITools)
+// tryInit(integration.buildcraft.tiles.ModBuildCraftAPITiles)
+// tryInit(integration.buildcraft.transport.ModBuildCraftAPITransport)
+// tryInit(integration.cofh.energy.ModCoFHEnergy)
+// tryInit(integration.cofh.item.ModCoFHItem)
+// tryInit(integration.cofh.tileentity.ModCoFHTileEntity)
+// tryInit(integration.cofh.transport.ModCoFHTransport)
+// tryInit(integration.enderstorage.ModEnderStorage)
+// tryInit(integration.forestry.ModForestry)
+// tryInit(integration.fmp.ModForgeMultipart)
+// tryInit(integration.gregtech.ModGregtech)
+// tryInit(integration.ic2.ModIndustrialCraft2)
+// tryInit(integration.mfr.ModMineFactoryReloaded)
+// tryInit(integration.mystcraft.ModMystcraft)
tryInit(integration.opencomputers.ModOpenComputers)
- tryInit(integration.railcraft.ModRailcraft)
- tryInit(integration.stargatetech2.ModStargateTech2)
- tryInit(integration.thaumcraft.ModThaumcraft)
- tryInit(integration.thermalexpansion.ModThermalExpansion)
- tryInit(integration.tcon.ModTinkersConstruct)
- tryInit(integration.tmechworks.ModTMechworks)
+// tryInit(integration.railcraft.ModRailcraft)
+// tryInit(integration.stargatetech2.ModStargateTech2)
+// tryInit(integration.thaumcraft.ModThaumcraft)
+// tryInit(integration.thermalexpansion.ModThermalExpansion)
+// tryInit(integration.tcon.ModTinkersConstruct)
+// tryInit(integration.tmechworks.ModTMechworks)
tryInit(integration.vanilla.ModVanilla)
- tryInit(integration.versionchecker.ModVersionChecker)
- tryInit(integration.waila.ModWaila)
- tryInit(integration.wrcbe.ModWRCBE)
- tryInit(integration.wrsve.ModWRSVE)
-
- // Register the general IPeripheral driver last, if at all, to avoid it
- // being used rather than other more concrete implementations.
- tryInit(integration.computercraft.ModComputerCraft)
+// tryInit(integration.versionchecker.ModVersionChecker)
+// tryInit(integration.waila.ModWaila)
+// tryInit(integration.wrcbe.ModWRCBE)
+// tryInit(integration.wrsve.ModWRSVE)
+//
+// // Register the general IPeripheral driver last, if at all, to avoid it
+// // being used rather than other more concrete implementations.
+// tryInit(integration.computercraft.ModComputerCraft)
}
private def tryInit(mod: ModProxy) {
diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/DriverBlockEnvironments.scala b/src/main/scala/li/cil/oc/integration/opencomputers/DriverBlockEnvironments.scala
index e61c816da..b23366b07 100644
--- a/src/main/scala/li/cil/oc/integration/opencomputers/DriverBlockEnvironments.scala
+++ b/src/main/scala/li/cil/oc/integration/opencomputers/DriverBlockEnvironments.scala
@@ -12,6 +12,7 @@ import li.cil.oc.server.machine.Machine
import net.minecraft.block.Block
import net.minecraft.item.ItemBlock
import net.minecraft.item.ItemStack
+import net.minecraft.util.BlockPos
import net.minecraft.world.World
/**
@@ -21,22 +22,22 @@ import net.minecraft.world.World
* and therefore have item drivers.
*/
object DriverBlockEnvironments extends driver.Block with EnvironmentAware {
- override def worksWith(world: World, x: Int, y: Int, z: Int) = false
+ override def worksWith(world: World, pos: BlockPos) = false
- override def createEnvironment(world: World, x: Int, y: Int, z: Int) = null
+ override def createEnvironment(world: World, pos: BlockPos) = null
override def providedEnvironment(stack: ItemStack): Class[_ <: Environment] = stack.getItem match {
- case block: ItemBlock if block.field_150939_a != null =>
- if (isOneOf(block.field_150939_a, "accessPoint")) classOf[tileentity.AccessPoint]
- else if (isOneOf(block.field_150939_a, "assembler")) classOf[tileentity.Assembler]
- else if (isOneOf(block.field_150939_a, "case1", "case2", "case3", "caseCreative", "microcontroller")) classOf[Machine]
- else if (isOneOf(block.field_150939_a, "hologram1", "hologram2")) classOf[tileentity.Hologram]
- else if (isOneOf(block.field_150939_a, "motionSensor")) classOf[tileentity.MotionSensor]
- else if (isOneOf(block.field_150939_a, "redstone")) if (BundledRedstone.isAvailable) classOf[component.Redstone.Bundled] else classOf[component.Redstone.Simple]
- else if (isOneOf(block.field_150939_a, "screen1")) classOf[common.component.TextBuffer].asInstanceOf[Class[_ <: Environment]]
- else if (isOneOf(block.field_150939_a, "screen2", "screen3")) classOf[common.component.Screen]
- else if (isOneOf(block.field_150939_a, "robot")) classOf[component.robot.Robot].asInstanceOf[Class[_ <: Environment]]
- else if (isOneOf(block.field_150939_a, "drone")) classOf[component.Drone].asInstanceOf[Class[_ <: Environment]]
+ case block: ItemBlock if block.getBlock != null =>
+ if (isOneOf(block.getBlock, "accessPoint")) classOf[tileentity.AccessPoint]
+ else if (isOneOf(block.getBlock, "assembler")) classOf[tileentity.Assembler]
+ else if (isOneOf(block.getBlock, "case1", "case2", "case3", "caseCreative", "microcontroller")) classOf[Machine]
+ else if (isOneOf(block.getBlock, "hologram1", "hologram2")) classOf[tileentity.Hologram]
+ else if (isOneOf(block.getBlock, "motionSensor")) classOf[tileentity.MotionSensor]
+ else if (isOneOf(block.getBlock, "redstone")) if (BundledRedstone.isAvailable) classOf[component.Redstone.Bundled] else classOf[component.Redstone.Simple]
+ else if (isOneOf(block.getBlock, "screen1")) classOf[common.component.TextBuffer].asInstanceOf[Class[_ <: Environment]]
+ else if (isOneOf(block.getBlock, "screen2", "screen3")) classOf[common.component.Screen]
+ else if (isOneOf(block.getBlock, "robot")) classOf[component.robot.Robot].asInstanceOf[Class[_ <: Environment]]
+ else if (isOneOf(block.getBlock, "drone")) classOf[component.Drone].asInstanceOf[Class[_ <: Environment]]
else null
case _ => null
}
diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala
index 02df8e723..3e1c1660a 100644
--- a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala
+++ b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala
@@ -1,8 +1,8 @@
package li.cil.oc.integration.opencomputers
-import cpw.mods.fml.common.FMLCommonHandler
-import cpw.mods.fml.common.event.FMLInterModComms
-import cpw.mods.fml.common.registry.EntityRegistry
+import net.minecraftforge.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.event.FMLInterModComms
+import net.minecraftforge.fml.common.registry.EntityRegistry
import li.cil.oc.OpenComputers
import li.cil.oc.api
import li.cil.oc.api.internal
@@ -130,6 +130,7 @@ object ModOpenComputers extends ModProxy {
"keyboard",
"lanCard",
"redstoneCard1",
+ "redstoneCard2", // TODO Move back down to wireless section once wireless redstone can work on its own.
"screen1",
"angelUpgrade",
"craftingUpgrade",
@@ -176,7 +177,6 @@ object ModOpenComputers extends ModProxy {
"leashUpgrade")
if (!WirelessRedstone.isAvailable) {
- blacklistHost(classOf[internal.Drone], "redstoneCard2")
blacklistHost(classOf[internal.Tablet], "redstoneCard2")
}
}
diff --git a/src/main/scala/li/cil/oc/integration/util/NEI.scala b/src/main/scala/li/cil/oc/integration/util/NEI.scala
index 45fe97deb..f2204bc7c 100644
--- a/src/main/scala/li/cil/oc/integration/util/NEI.scala
+++ b/src/main/scala/li/cil/oc/integration/util/NEI.scala
@@ -1,6 +1,8 @@
package li.cil.oc.integration.util
+/* TODO NEI
import codechicken.nei.LayoutManager
+*/
import li.cil.oc.integration.Mods
import net.minecraft.block.Block
import net.minecraft.client.gui.inventory.GuiContainer
@@ -11,19 +13,24 @@ import scala.collection.mutable
object NEI {
val hiddenBlocks = mutable.Set.empty[Block]
- def isInputFocused = Mods.NotEnoughItems.isAvailable && (try isInputFocused0 catch {
- case _: Throwable => false
- })
+ def isInputFocused = false
+ /* TODO NEI
+ Mods.NotEnoughItems.isAvailable && (try isInputFocused0 catch {
+ case _: Throwable => false
+ })
private def isInputFocused0 = LayoutManager.getInputFocused != null
+ */
- def hoveredStack(container: GuiContainer, mouseX: Int, mouseY: Int): Option[ItemStack] =
+ def hoveredStack(container: GuiContainer, mouseX: Int, mouseY: Int): Option[ItemStack] = None
+ /* TODO NEI
if (Mods.NotEnoughItems.isAvailable) try Option(hoveredStack0(container, mouseX, mouseY)) catch {
case t: Throwable => None
}
else None
private def hoveredStack0(container: GuiContainer, mouseX: Int, mouseY: Int) = LayoutManager.instance.getStackUnderMouse(container, mouseX, mouseY)
+ */
def hide(block: Block): Unit = if (Mods.NotEnoughItems.isAvailable) hiddenBlocks += block
}
diff --git a/src/main/scala/li/cil/oc/integration/util/StargateTech2.scala b/src/main/scala/li/cil/oc/integration/util/StargateTech2.scala
deleted file mode 100644
index 79dead922..000000000
--- a/src/main/scala/li/cil/oc/integration/util/StargateTech2.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-package li.cil.oc.integration.util
-
-import lordfokas.stargatetech2.api.bus.BusEvent.AddToNetwork
-import lordfokas.stargatetech2.api.bus.BusEvent.RemoveFromNetwork
-import net.minecraft.world.World
-import net.minecraftforge.common.MinecraftForge
-
-object StargateTech2 {
- def addDevice(world: World, x: Int, y: Int, z: Int) = MinecraftForge.EVENT_BUS.post(new AddToNetwork(world, x, y, z))
-
- def removeDevice(world: World, x: Int, y: Int, z: Int) = MinecraftForge.EVENT_BUS.post(new RemoveFromNetwork(world, x, y, z))
-}
\ No newline at end of file
diff --git a/src/main/scala/li/cil/oc/integration/util/Waila.scala b/src/main/scala/li/cil/oc/integration/util/Waila.scala
deleted file mode 100644
index 1810730b4..000000000
--- a/src/main/scala/li/cil/oc/integration/util/Waila.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package li.cil.oc.integration.util
-
-import cpw.mods.fml.common.Loader
-import cpw.mods.fml.common.ModContainer
-import cpw.mods.fml.common.versioning.VersionRange
-import li.cil.oc.integration.Mods
-
-object Waila {
- private val oldVersion = VersionRange.createFromVersionSpec("[,1.5.6)")
-
- // This is used to check if certain data actually has to be saved in
- // writeToNBT calls. For some stuff we write lots of data (e.g. computer
- // state), and we want to avoid that when Waila is calling us.
- def isSavingForTooltip = {
- Loader.instance.getIndexedModList.get(Mods.IDs.Waila) match {
- case mod: ModContainer if oldVersion.containsVersion(mod.getProcessedVersion) =>
- // Old version of Waila where we actually have to check.
- new Exception().getStackTrace.exists(_.getClassName.startsWith("mcp.mobius.waila"))
- case _ =>
- // Waila is not present or new enough so we don't care.
- false
- }
- }
-}
diff --git a/src/main/scala/li/cil/oc/integration/util/Wrench.scala b/src/main/scala/li/cil/oc/integration/util/Wrench.scala
index 8ac1af5f3..750e8704a 100644
--- a/src/main/scala/li/cil/oc/integration/util/Wrench.scala
+++ b/src/main/scala/li/cil/oc/integration/util/Wrench.scala
@@ -5,6 +5,7 @@ import java.lang.reflect.Method
import li.cil.oc.common.IMC
import li.cil.oc.util.BlockPosition
import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.util.BlockPos
import scala.collection.mutable
@@ -13,9 +14,9 @@ object Wrench {
def add(wrench: Method): Unit = wrenches += wrench
- def holdsApplicableWrench(player: EntityPlayer, position: BlockPosition): Boolean =
- player.getCurrentEquippedItem != null && wrenches.exists(IMC.tryInvokeStatic(_, player, int2Integer(position.x), int2Integer(position.y), int2Integer(position.z), boolean2Boolean(false))(false))
+ def holdsApplicableWrench(player: EntityPlayer, position: BlockPos): Boolean =
+ player.getCurrentEquippedItem != null && wrenches.exists(IMC.tryInvokeStatic(_, player, int2Integer(position.getX), int2Integer(position.getY), int2Integer(position.getZ), boolean2Boolean(false))(false))
- def wrenchUsed(player: EntityPlayer, position: BlockPosition): Unit =
- if (player.getCurrentEquippedItem != null) wrenches.foreach(IMC.tryInvokeStaticVoid(_, player, int2Integer(position.x), int2Integer(position.y), int2Integer(position.z), boolean2Boolean(true)))
+ def wrenchUsed(player: EntityPlayer, position: BlockPos): Unit =
+ if (player.getCurrentEquippedItem != null) wrenches.foreach(IMC.tryInvokeStaticVoid(_, player, int2Integer(position.getX), int2Integer(position.getY), int2Integer(position.getZ), boolean2Boolean(true)))
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/ConverterItemStack.scala b/src/main/scala/li/cil/oc/integration/vanilla/ConverterItemStack.scala
index 0dc02d9e7..830ca82ea 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/ConverterItemStack.scala
+++ b/src/main/scala/li/cil/oc/integration/vanilla/ConverterItemStack.scala
@@ -4,9 +4,11 @@ import java.util
import li.cil.oc.Settings
import li.cil.oc.api
+import li.cil.oc.util.ItemUtils
import net.minecraft.item
import net.minecraft.item.Item
import net.minecraft.nbt.CompressedStreamTools
+import net.minecraft.nbt.NBTBase
import scala.collection.convert.WrapAsScala._
@@ -26,7 +28,7 @@ object ConverterItemStack extends api.driver.Converter {
output += "label" -> stack.getDisplayName
if (stack.hasTagCompound && Settings.get.allowItemStackNBTTags) {
- output += "tag" -> CompressedStreamTools.compress(stack.getTagCompound)
+ output += "tag" -> ItemUtils.saveTag(stack.getTagCompound)
}
case _ =>
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverBeacon.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverBeacon.java
index 60cb6aa69..b3f5eeed1 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverBeacon.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverBeacon.java
@@ -13,6 +13,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.tileentity.TileEntityBeacon;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverBeacon extends DriverTileEntity implements EnvironmentAware {
@@ -22,8 +23,8 @@ public final class DriverBeacon extends DriverTileEntity implements EnvironmentA
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((TileEntityBeacon) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((TileEntityBeacon) world.getTileEntity(pos));
}
@Override
@@ -50,17 +51,17 @@ public final class DriverBeacon extends DriverTileEntity implements EnvironmentA
@Callback(doc = "function():number -- Get the number of levels for this beacon.")
public Object[] getLevels(final Context context, final Arguments args) {
- return new Object[]{tileEntity.getLevels()};
+ return new Object[]{tileEntity.getField(0)};
}
@Callback(doc = "function():string -- Get the name of the active primary effect.")
public Object[] getPrimaryEffect(final Context context, final Arguments args) {
- return new Object[]{getEffectName(tileEntity.getPrimaryEffect())};
+ return new Object[]{getEffectName(tileEntity.getField(1))};
}
@Callback(doc = "function():string -- Get the name of the active secondary effect.")
public Object[] getSecondaryEffect(final Context context, final Arguments args) {
- return new Object[]{getEffectName(tileEntity.getSecondaryEffect())};
+ return new Object[]{getEffectName(tileEntity.getField(2))};
}
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverBrewingStand.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverBrewingStand.java
index 36e46f673..d5d1d627b 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverBrewingStand.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverBrewingStand.java
@@ -11,6 +11,7 @@ import li.cil.oc.integration.ManagedTileEntityEnvironment;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityBrewingStand;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverBrewingStand extends DriverTileEntity implements EnvironmentAware {
@@ -20,8 +21,8 @@ public final class DriverBrewingStand extends DriverTileEntity implements Enviro
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((TileEntityBrewingStand) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((TileEntityBrewingStand) world.getTileEntity(pos));
}
@Override
@@ -48,7 +49,7 @@ public final class DriverBrewingStand extends DriverTileEntity implements Enviro
@Callback(doc = "function():number -- Get the number of ticks remaining of the current brewing operation.")
public Object[] getBrewTime(final Context context, final Arguments args) {
- return new Object[]{tileEntity.getBrewTime()};
+ return new Object[]{tileEntity.getField(0)};
}
}
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.java
index 7e1921aa4..8a4d086fb 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.java
@@ -12,6 +12,7 @@ import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityCommandBlock;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverCommandBlock extends DriverTileEntity implements EnvironmentAware {
@@ -21,8 +22,8 @@ public final class DriverCommandBlock extends DriverTileEntity implements Enviro
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((TileEntityCommandBlock) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((TileEntityCommandBlock) world.getTileEntity(pos));
}
@Override
@@ -49,20 +50,20 @@ public final class DriverCommandBlock extends DriverTileEntity implements Enviro
@Callback(direct = true, doc = "function():string -- Get the command currently set in this command block.")
public Object[] getCommand(final Context context, final Arguments args) {
- return new Object[]{tileEntity.func_145993_a().func_145753_i()};
+ return new Object[]{tileEntity.getCommandBlockLogic().getCustomName()};
}
@Callback(doc = "function(value:string) -- Set the specified command for the command block.")
public Object[] setCommand(final Context context, final Arguments args) {
- tileEntity.func_145993_a().func_145752_a(args.checkString(0));
- tileEntity.getWorldObj().markBlockForUpdate(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
+ tileEntity.getCommandBlockLogic().setCommand(args.checkString(0));
+ tileEntity.getWorld().markBlockForUpdate(tileEntity.getPos());
return new Object[]{true};
}
@Callback(doc = "function():number -- Execute the currently set command. This has a slight delay to allow the command block to properly update.")
public Object[] executeCommand(final Context context, final Arguments args) {
context.pause(0.1); // Make sure the command block has time to do its thing.
- tileEntity.func_145993_a().func_145755_a(tileEntity.getWorldObj());
+ tileEntity.getCommandBlockLogic().trigger(tileEntity.getWorld());
return new Object[]{true};
}
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverComparator.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverComparator.java
index 570d9e60a..44f932a0b 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverComparator.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverComparator.java
@@ -11,6 +11,7 @@ import li.cil.oc.integration.ManagedTileEntityEnvironment;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityComparator;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverComparator extends DriverTileEntity implements EnvironmentAware {
@@ -20,8 +21,8 @@ public final class DriverComparator extends DriverTileEntity implements Environm
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((TileEntityComparator) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((TileEntityComparator) world.getTileEntity(pos));
}
@Override
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidHandler.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidHandler.java
index c636b1753..6cc56aad9 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidHandler.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidHandler.java
@@ -6,8 +6,9 @@ import li.cil.oc.api.machine.Context;
import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.prefab.DriverTileEntity;
import li.cil.oc.integration.ManagedTileEntityEnvironment;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.IFluidHandler;
public final class DriverFluidHandler extends DriverTileEntity {
@@ -17,8 +18,8 @@ public final class DriverFluidHandler extends DriverTileEntity {
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((IFluidHandler) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((IFluidHandler) world.getTileEntity(pos));
}
public static final class Environment extends ManagedTileEntityEnvironment {
@@ -28,7 +29,7 @@ public final class DriverFluidHandler extends DriverTileEntity {
@Callback(doc = "function([side:number=6]):table -- Get some information about the tank accessible from the specified side.")
public Object[] getTankInfo(final Context context, final Arguments args) {
- ForgeDirection side = args.count() > 0 ? ForgeDirection.getOrientation(args.checkInteger(0)) : ForgeDirection.UNKNOWN;
+ EnumFacing side = args.count() > 0 ? EnumFacing.getFront(args.checkInteger(0)) : EnumFacing.DOWN;
return tileEntity.getTankInfo(side);
}
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidTank.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidTank.java
index 2c302edb6..0203216e1 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidTank.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverFluidTank.java
@@ -6,6 +6,7 @@ import li.cil.oc.api.machine.Context;
import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.prefab.DriverTileEntity;
import li.cil.oc.integration.ManagedTileEntityEnvironment;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidTank;
@@ -16,8 +17,8 @@ public final class DriverFluidTank extends DriverTileEntity {
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((IFluidTank) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((IFluidTank) world.getTileEntity(pos));
}
public static final class Environment extends ManagedTileEntityEnvironment {
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverFurnace.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverFurnace.java
index 14a036fe9..bfd108cd1 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverFurnace.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverFurnace.java
@@ -12,6 +12,7 @@ import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverFurnace extends DriverTileEntity implements EnvironmentAware {
@@ -21,8 +22,8 @@ public final class DriverFurnace extends DriverTileEntity implements Environment
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((TileEntityFurnace) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((TileEntityFurnace) world.getTileEntity(pos));
}
@Override
@@ -49,17 +50,17 @@ public final class DriverFurnace extends DriverTileEntity implements Environment
@Callback(doc = "function():number -- The number of ticks that the furnace will keep burning from the last consumed fuel.")
public Object[] getBurnTime(final Context context, final Arguments args) {
- return new Object[]{tileEntity.furnaceBurnTime};
+ return new Object[]{tileEntity.getField(0)};
}
@Callback(doc = "function():number -- The number of ticks that the current item has been cooking for.")
public Object[] getCookTime(final Context context, final Arguments args) {
- return new Object[]{tileEntity.furnaceCookTime};
+ return new Object[]{tileEntity.getField(2)};
}
@Callback(doc = "function():number -- The number of ticks that the currently burning fuel lasts in total.")
public Object[] getCurrentItemBurnTime(final Context context, final Arguments args) {
- return new Object[]{tileEntity.currentItemBurnTime};
+ return new Object[]{tileEntity.getField(1)};
}
@Callback(doc = "function():boolean -- Get whether the furnace is currently active.")
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverInventory.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverInventory.java
index 4431fc8b6..4734190cf 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverInventory.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverInventory.java
@@ -11,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@@ -23,8 +24,8 @@ public final class DriverInventory extends DriverTileEntity {
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment(world.getTileEntity(x, y, z), world);
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment(world.getTileEntity(pos), world);
}
public static final class Environment extends ManagedTileEntityEnvironment {
@@ -34,13 +35,13 @@ public final class DriverInventory extends DriverTileEntity {
public Environment(final TileEntity tileEntity, final World world) {
super((IInventory) tileEntity, "inventory");
fakePlayer = FakePlayerFactory.get((WorldServer) world, Settings.get().fakePlayerProfile());
- position = Vec3.createVectorHelper(tileEntity.xCoord + 0.5, tileEntity.yCoord + 0.5, tileEntity.zCoord + 0.5);
+ position = new Vec3(tileEntity.getPos().getX() + 0.5, tileEntity.getPos().getY() + 0.5, tileEntity.getPos().getZ() + 0.5);
}
@Callback(doc = "function():string -- Get the name of this inventory.")
public Object[] getInventoryName(final Context context, final Arguments args) {
if (notPermitted()) return new Object[]{null, "permission denied"};
- return new Object[]{tileEntity.getInventoryName()};
+ return new Object[]{tileEntity.getName()};
}
@Callback(doc = "function():number -- Get the number of slots in this inventory.")
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverMobSpawner.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverMobSpawner.java
index e7f6cbceb..8dd631a88 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverMobSpawner.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverMobSpawner.java
@@ -11,7 +11,9 @@ import li.cil.oc.integration.ManagedTileEntityEnvironment;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityMobSpawner;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverMobSpawner extends DriverTileEntity implements EnvironmentAware {
@@ -21,8 +23,8 @@ public final class DriverMobSpawner extends DriverTileEntity implements Environm
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((TileEntityMobSpawner) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((TileEntityMobSpawner) world.getTileEntity(pos));
}
@Override
@@ -49,7 +51,9 @@ public final class DriverMobSpawner extends DriverTileEntity implements Environm
@Callback(doc = "function():string -- Get the name of the entity that is being spawned by this spawner.")
public Object[] getSpawningMobName(final Context context, final Arguments args) {
- return new Object[]{tileEntity.func_145881_a().getEntityNameToSpawn()};
+ final NBTTagCompound tag = new NBTTagCompound();
+ tileEntity.writeToNBT(tag);
+ return new Object[]{tag.getString("EntityId")};
}
}
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverNoteBlock.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverNoteBlock.java
index e0935e126..74527fbe5 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverNoteBlock.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverNoteBlock.java
@@ -13,6 +13,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityNote;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverNoteBlock extends DriverTileEntity implements EnvironmentAware {
@@ -22,8 +23,8 @@ public final class DriverNoteBlock extends DriverTileEntity implements Environme
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((TileEntityNote) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((TileEntityNote) world.getTileEntity(pos));
}
@Override
@@ -65,14 +66,11 @@ public final class DriverNoteBlock extends DriverTileEntity implements Environme
setPitch(args.checkInteger(0));
}
- final World world = tileEntity.getWorldObj();
- final int x = tileEntity.xCoord;
- final int y = tileEntity.yCoord;
- final int z = tileEntity.zCoord;
- final Material material = world.getBlock(x, y + 1, z).getMaterial();
+ final World world = tileEntity.getWorld();
+ final Material material = world.getBlockState(tileEntity.getPos().up()).getBlock().getMaterial();
final boolean canTrigger = material == Material.air;
- tileEntity.triggerNote(world, x, y, z);
+ tileEntity.triggerNote(world, tileEntity.getPos());
return new Object[]{canTrigger};
}
diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverRecordPlayer.java b/src/main/scala/li/cil/oc/integration/vanilla/DriverRecordPlayer.java
index f058ac891..c93796c2e 100644
--- a/src/main/scala/li/cil/oc/integration/vanilla/DriverRecordPlayer.java
+++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverRecordPlayer.java
@@ -13,6 +13,7 @@ import net.minecraft.block.BlockJukebox;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public final class DriverRecordPlayer extends DriverTileEntity implements EnvironmentAware {
@@ -22,8 +23,8 @@ public final class DriverRecordPlayer extends DriverTileEntity implements Enviro
}
@Override
- public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
- return new Environment((BlockJukebox.TileEntityJukebox) world.getTileEntity(x, y, z));
+ public ManagedEnvironment createEnvironment(final World world, final BlockPos pos) {
+ return new Environment((BlockJukebox.TileEntityJukebox) world.getTileEntity(pos));
}
@Override
@@ -50,7 +51,7 @@ public final class DriverRecordPlayer extends DriverTileEntity implements Enviro
@Callback(doc = "function():string -- Get the title of the record currently in the jukebox.")
public Object[] getRecord(final Context context, final Arguments args) {
- final ItemStack record = tileEntity.func_145856_a();
+ final ItemStack record = tileEntity.getRecord();
if (record == null || !(record.getItem() instanceof ItemRecord)) {
return null;
}
diff --git a/src/main/scala/li/cil/oc/server/CommandHandler.scala b/src/main/scala/li/cil/oc/server/CommandHandler.scala
index 18c7dce3c..8a2926ffd 100644
--- a/src/main/scala/li/cil/oc/server/CommandHandler.scala
+++ b/src/main/scala/li/cil/oc/server/CommandHandler.scala
@@ -1,6 +1,7 @@
package li.cil.oc.server
-import cpw.mods.fml.common.event.FMLServerStartingEvent
+import net.minecraft.util.BlockPos
+import net.minecraftforge.fml.common.event.FMLServerStartingEvent
import li.cil.oc.Settings
import net.minecraft.command.CommandBase
import net.minecraft.command.ICommandSender
@@ -24,10 +25,10 @@ object CommandHandler {
override def getCommandUsage(source: ICommandSender) = name + " "
- override def processCommand(source: ICommandSender, command: Array[String]) {
+ override def execute(sender: ICommandSender, command: Array[String]) {
Settings.rTreeDebugRenderer =
if (command != null && command.length > 0)
- CommandBase.parseBoolean(source, command(0))
+ CommandBase.parseBoolean(command(0))
else
!Settings.rTreeDebugRenderer
}
@@ -38,15 +39,15 @@ object CommandHandler {
abstract class SimpleCommand(val name: String) extends CommandBase {
protected var aliases = mutable.ListBuffer.empty[String]
- override def getCommandName = name
+ override def getName = name
- override def getCommandAliases = aliases
+ override def getAliases = aliases
- override def canCommandSenderUseCommand(source: ICommandSender) = true
+ override def canCommandSenderUse(sender: ICommandSender) = true
+
+ override def addTabCompletionOptions(sender: ICommandSender, args: Array[String], pos: BlockPos) = List.empty[AnyRef]
override def isUsernameIndex(command: Array[String], i: Int) = false
-
- override def addTabCompletionOptions(source: ICommandSender, command: Array[String]) = List.empty[AnyRef]
}
}
diff --git a/src/main/scala/li/cil/oc/server/PacketHandler.scala b/src/main/scala/li/cil/oc/server/PacketHandler.scala
index 87582c526..0537dabb5 100644
--- a/src/main/scala/li/cil/oc/server/PacketHandler.scala
+++ b/src/main/scala/li/cil/oc/server/PacketHandler.scala
@@ -1,7 +1,7 @@
package li.cil.oc.server
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent
import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.api
@@ -13,13 +13,15 @@ import li.cil.oc.common.tileentity._
import li.cil.oc.common.tileentity.traits.Computer
import li.cil.oc.common.tileentity.traits.TileEntity
import li.cil.oc.common.{PacketHandler => CommonPacketHandler}
+/* TODO FMP
import li.cil.oc.integration.fmp.EventHandler
+*/
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.network.NetHandlerPlayServer
import net.minecraftforge.common.DimensionManager
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
object PacketHandler extends CommonPacketHandler {
@SubscribeEvent
@@ -39,7 +41,9 @@ object PacketHandler extends CommonPacketHandler {
case PacketType.MouseClickOrDrag => onMouseClick(p)
case PacketType.MouseScroll => onMouseScroll(p)
case PacketType.MouseUp => onMouseUp(p)
+ /* TODO FMP
case PacketType.MultiPartPlace => onMultiPartPlace(p)
+ */
case PacketType.PetVisibility => onPetVisibility(p)
case PacketType.RobotAssemblerStart => onRobotAssemblerStart(p)
case PacketType.RobotStateRequest => onRobotStateRequest(p)
@@ -82,7 +86,7 @@ object PacketHandler extends CommonPacketHandler {
}
private def trySetComputerPower(computer: Machine, value: Boolean, player: EntityPlayerMP) {
- if (computer.canInteract(player.getCommandSenderName)) {
+ if (computer.canInteract(player.getName)) {
if (value) {
if (!computer.isPaused) {
computer.start()
@@ -144,24 +148,26 @@ object PacketHandler extends CommonPacketHandler {
}
}
+ /* TODO FMP
def onMultiPartPlace(p: PacketParser) {
p.player match {
case player: EntityPlayerMP => EventHandler.place(player)
case _ => // Invalid packet.
}
}
+ */
def onPetVisibility(p: PacketParser) {
p.player match {
case player: EntityPlayerMP =>
if (if (p.readBoolean()) {
- PetVisibility.hidden.remove(player.getCommandSenderName)
+ PetVisibility.hidden.remove(player.getName)
}
else {
- PetVisibility.hidden.add(player.getCommandSenderName)
+ PetVisibility.hidden.add(player.getName)
}) {
// Something changed.
- PacketSender.sendPetVisibility(Some(player.getCommandSenderName))
+ PacketSender.sendPetVisibility(Some(player.getName))
}
case _ => // Invalid packet.
}
@@ -178,7 +184,7 @@ object PacketHandler extends CommonPacketHandler {
def onRobotStateRequest(p: PacketParser) =
p.readTileEntity[RobotProxy]() match {
- case Some(proxy) => proxy.world.markBlockForUpdate(proxy.x, proxy.y, proxy.z)
+ case Some(proxy) => proxy.world.markBlockForUpdate(proxy.getPos)
case _ => // Invalid packet.
}
@@ -199,7 +205,7 @@ object PacketHandler extends CommonPacketHandler {
case player: EntityPlayerMP if rack.isUseableByPlayer(player) =>
val number = p.readInt()
val side = p.readDirection()
- if (rack.sides(number) != side && side != Option(ForgeDirection.SOUTH) && (!rack.sides.contains(side) || side == None)) {
+ if (rack.sides(number) != side && side != Option(EnumFacing.SOUTH) && (!rack.sides.contains(side) || side == None)) {
rack.sides(number) = side
rack.servers(number) match {
case Some(server) => rack.reconnectServer(number, server)
diff --git a/src/main/scala/li/cil/oc/server/PacketSender.scala b/src/main/scala/li/cil/oc/server/PacketSender.scala
index f3a09a749..7167fd3b0 100644
--- a/src/main/scala/li/cil/oc/server/PacketSender.scala
+++ b/src/main/scala/li/cil/oc/server/PacketSender.scala
@@ -12,22 +12,14 @@ import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.item.ItemStack
import net.minecraft.nbt.CompressedStreamTools
import net.minecraft.nbt.NBTTagCompound
+import net.minecraft.util.BlockPos
import net.minecraft.world.World
import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.mutable
object PacketSender {
- def sendAbstractBusState(t: AbstractBusAware) {
- val pb = new SimplePacketBuilder(PacketType.AbstractBusState)
-
- pb.writeTileEntity(t)
- pb.writeBoolean(t.isAbstractBusAvailable)
-
- pb.sendToPlayersNearTileEntity(t)
- }
-
def sendAnalyze(address: String, player: EntityPlayerMP) {
val pb = new SimplePacketBuilder(PacketType.Analyze)
@@ -50,7 +42,7 @@ object PacketSender {
val pb = new SimplePacketBuilder(PacketType.ColorChange)
pb.writeTileEntity(t)
- pb.writeInt(t.color)
+ pb.writeInt(t.color.getMetadata)
pb.sendToPlayersNearTileEntity(t)
}
@@ -108,7 +100,7 @@ object PacketSender {
pb.writeTileEntity(t)
case _ =>
pb.writeBoolean(false)
- pb.writeInt(event.getWorld.provider.dimensionId)
+ pb.writeInt(event.getWorld.provider.getDimensionId)
pb.writeDouble(event.getX)
pb.writeDouble(event.getY)
pb.writeDouble(event.getZ)
@@ -242,7 +234,7 @@ object PacketSender {
pb.writeTileEntity(t)
pb.writeBoolean(t.isOutputEnabled)
- for (d <- ForgeDirection.VALID_DIRECTIONS) {
+ for (d <- EnumFacing.values) {
pb.writeByte(t.output(d))
}
@@ -258,14 +250,14 @@ object PacketSender {
pb.sendToPlayersNearHost(t)
}
- def sendRobotMove(t: tileentity.Robot, position: BlockPosition, direction: ForgeDirection) {
+ def sendRobotMove(t: tileentity.Robot, position: BlockPos, direction: EnumFacing) {
val pb = new SimplePacketBuilder(PacketType.RobotMove)
// Custom pb.writeTileEntity() with fake coordinates (valid for the client).
- pb.writeInt(t.proxy.world.provider.dimensionId)
- pb.writeInt(position.x)
- pb.writeInt(position.y)
- pb.writeInt(position.z)
+ pb.writeInt(t.proxy.world.provider.getDimensionId)
+ pb.writeInt(position.getX)
+ pb.writeInt(position.getY)
+ pb.writeInt(position.getZ)
pb.writeDirection(Option(direction))
pb.sendToPlayersNearTileEntity(t)
@@ -461,7 +453,7 @@ object PacketSender {
val pb = new SimplePacketBuilder(PacketType.Sound)
val blockPos = BlockPosition(x, y, z)
- pb.writeInt(world.provider.dimensionId)
+ pb.writeInt(world.provider.getDimensionId)
pb.writeInt(blockPos.x)
pb.writeInt(blockPos.y)
pb.writeInt(blockPos.z)
@@ -475,7 +467,7 @@ object PacketSender {
val pb = new SimplePacketBuilder(PacketType.SoundPattern)
val blockPos = BlockPosition(x, y, z)
- pb.writeInt(world.provider.dimensionId)
+ pb.writeInt(world.provider.getDimensionId)
pb.writeInt(blockPos.x)
pb.writeInt(blockPos.y)
pb.writeInt(blockPos.z)
diff --git a/src/main/scala/li/cil/oc/server/Proxy.scala b/src/main/scala/li/cil/oc/server/Proxy.scala
index d3f6eb835..579da911b 100644
--- a/src/main/scala/li/cil/oc/server/Proxy.scala
+++ b/src/main/scala/li/cil/oc/server/Proxy.scala
@@ -1,7 +1,7 @@
package li.cil.oc.server
-import cpw.mods.fml.common.event.FMLInitializationEvent
-import cpw.mods.fml.common.network.NetworkRegistry
+import net.minecraftforge.fml.common.event.FMLInitializationEvent
+import net.minecraftforge.fml.common.network.NetworkRegistry
import li.cil.oc.OpenComputers
import li.cil.oc.common.{Proxy => CommonProxy}
diff --git a/src/main/scala/li/cil/oc/server/component/AbstractBusCard.scala b/src/main/scala/li/cil/oc/server/component/AbstractBusCard.scala
deleted file mode 100644
index 4b9db3561..000000000
--- a/src/main/scala/li/cil/oc/server/component/AbstractBusCard.scala
+++ /dev/null
@@ -1,153 +0,0 @@
-package li.cil.oc.server.component
-
-import li.cil.oc.Settings
-import li.cil.oc.api.Network
-import li.cil.oc.api.machine.Arguments
-import li.cil.oc.api.machine.Callback
-import li.cil.oc.api.machine.Context
-import li.cil.oc.api.network._
-import li.cil.oc.api.prefab
-import lordfokas.stargatetech2.api.StargateTechAPI
-import lordfokas.stargatetech2.api.bus._
-import net.minecraft.nbt.NBTTagCompound
-
-import scala.collection.convert.WrapAsScala._
-
-class AbstractBusCard(val device: IBusDevice) extends prefab.ManagedEnvironment with IBusDriver {
- override val node = Network.newNode(this, Visibility.Neighbors).
- withComponent("abstract_bus").
- withConnector().
- create()
-
- val busInterface: IBusInterface = StargateTechAPI.api.getFactory.getIBusInterface(device, this)
-
- protected var isEnabled = true
-
- protected var address = 0
-
- protected var sendQueue: Option[BusPacket[_]] = None
-
- protected var owner: Option[Context] = None
-
- // ----------------------------------------------------------------------- //
-
- 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[_]) {
- 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)
- owner.foreach(_.signal("bus_message", Int.box(packet.getProtocolID), Int.box(packet.getSender), Int.box(packet.getTarget), data, metadata))
- }
-
- override def getNextPacketToSend = this.synchronized {
- val packet = sendQueue.orNull
- sendQueue = None
- packet
- }
-
- override def isInterfaceEnabled = isEnabled
-
- override def getInterfaceAddress = address.toShort
-
- // ----------------------------------------------------------------------- //
-
- @Callback(doc = """function():boolean -- Whether the local bus interface is enabled.""")
- def getEnabled(context: Context, args: Arguments): Array[AnyRef] = result(isEnabled)
-
- @Callback(doc = """function(enabled:boolean):boolean -- Sets whether the local bus interface should be enabled.""")
- def setEnabled(context: Context, args: Arguments): Array[AnyRef] = {
- isEnabled = args.checkBoolean(0)
- result(isEnabled)
- }
-
- @Callback(doc = """function():number -- Get the local interface address.""")
- def getAddress(context: Context, args: Arguments): Array[AnyRef] = result(address)
-
- @Callback(doc = """function(address:number):number -- Sets the local interface address.""")
- def setAddress(context: Context, args: Arguments): Array[AnyRef] = {
- address = args.checkInteger(0) & 0xFFFF
- result(address)
- }
-
- @Callback(doc = """function(address:number, data:table):table -- Sends data across the abstract bus.""")
- def send(context: Context, args: Arguments): Array[AnyRef] = this.synchronized {
- val target = args.checkInteger(0) & 0xFFFF
- val data = args.checkTable(1)
- if (node.tryChangeBuffer(-Settings.get.abstractBusPacketCost)) {
- val packet = new BusPacketLIP(address.toShort, target.toShort)
- var size = 0
- def checkSize(add: Int) {
- size += add
- if (size > Settings.get.maxNetworkPacketSize) {
- throw new IllegalArgumentException("packet too big (max " + Settings.get.maxNetworkPacketSize + ")")
- }
- }
- for ((key, value) <- data) {
- val keyAsString = key.toString
- checkSize(keyAsString.length)
- val valueAsString = value.toString
- checkSize(valueAsString.length)
- packet.set(keyAsString, valueAsString)
- }
- packet.setMetadata(new BusPacketLIP.LIPMetadata("OpenComputers", node.address, null))
- packet.finish()
- sendQueue = Some(packet)
- busInterface.sendAllPackets()
- result(packet.getResponses.toArray)
- }
- else result(Unit, "not enough energy")
- }
-
- @Callback(doc = """function(mask:number):table -- Scans the network for other devices.""")
- def scan(context: Context, args: Arguments): Array[AnyRef] = this.synchronized {
- val mask = (args.checkInteger(0) & 0xFFFF).toShort
- if (node.tryChangeBuffer(-Settings.get.abstractBusPacketCost)) {
- val packet = new BusPacketNetScan(mask)
- sendQueue = Some(packet)
- busInterface.sendAllPackets()
- Array(packet.getDevices.toArray)
- }
- else Array(Unit, "not enough energy")
- }
-
- @Callback(direct = true, doc = """function():number -- The maximum packet size that can be sent over the bus.""")
- def maxPacketSize(context: Context, args: Arguments): Array[AnyRef] = result(Settings.get.maxNetworkPacketSize)
-
- // ----------------------------------------------------------------------- //
-
- override def onConnect(node: Node) {
- super.onConnect(node)
- if (owner.isEmpty && node.host.isInstanceOf[Context]) {
- owner = Some(node.host.asInstanceOf[Context])
- }
- }
-
- override def onDisconnect(node: Node) {
- super.onDisconnect(node)
- if (owner.isDefined && node.host.isInstanceOf[Context] && (node.host.asInstanceOf[Context] == owner.get)) {
- owner = None
- }
- }
-
- override def load(nbt: NBTTagCompound) {
- super.load(nbt)
- busInterface.readFromNBT(nbt, "bus")
- // Don't default to false.
- if (nbt.hasKey("enabled")) {
- isEnabled = nbt.getBoolean("enabled")
- }
- address = nbt.getInteger("address") & 0xFFFF
- }
-
- override def save(nbt: NBTTagCompound) {
- super.save(nbt)
- busInterface.writeToNBT(nbt, "bus")
- nbt.setBoolean("enabled", isEnabled)
- nbt.setInteger("address", address)
- }
-}
diff --git a/src/main/scala/li/cil/oc/server/component/DebugCard.scala b/src/main/scala/li/cil/oc/server/component/DebugCard.scala
index 245a1de5d..142f80752 100644
--- a/src/main/scala/li/cil/oc/server/component/DebugCard.scala
+++ b/src/main/scala/li/cil/oc/server/component/DebugCard.scala
@@ -14,6 +14,7 @@ import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.InventoryUtils
import net.minecraft.block.Block
+import net.minecraft.command.CommandResultStats.Type
import net.minecraft.command.ICommandSender
import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.item.Item
@@ -22,13 +23,14 @@ import net.minecraft.nbt.JsonToNBT
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.server.MinecraftServer
import net.minecraft.server.management.UserListOpsEntry
+import net.minecraft.util.BlockPos
+import net.minecraft.util.EnumFacing
import net.minecraft.util.IChatComponent
import net.minecraft.world.World
import net.minecraft.world.WorldServer
import net.minecraft.world.WorldSettings.GameType
import net.minecraftforge.common.DimensionManager
import net.minecraftforge.common.util.FakePlayerFactory
-import net.minecraftforge.common.util.ForgeDirection
class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment {
override val node = Network.newNode(this, Visibility.Neighbors).
@@ -98,7 +100,7 @@ object DebugCard {
def withPlayer(f: (EntityPlayerMP) => Array[AnyRef]) = {
checkEnabled()
- MinecraftServer.getServer.getConfigurationManager.func_152612_a(name) match {
+ MinecraftServer.getServer.getConfigurationManager.getPlayerByUsername(name) match {
case player: EntityPlayerMP => f(player)
case _ => result(Unit, "player is offline")
}
@@ -167,7 +169,7 @@ object DebugCard {
@Callback(doc = """function():number -- Gets the numeric id of the current dimension.""")
def getDimensionId(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- result(world.provider.dimensionId)
+ result(world.provider.getDimensionId)
}
@Callback(doc = """function():string -- Gets the name of the current dimension.""")
@@ -230,7 +232,7 @@ object DebugCard {
@Callback(doc = """function(x:number, y:number, z:number) -- Set the spawn point coordinates.""")
def setSpawnPoint(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- world.getWorldInfo.setSpawnPosition(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
+ world.getWorldInfo.setSpawn(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
null
}
@@ -239,45 +241,45 @@ object DebugCard {
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the ID of the block at the specified coordinates.""")
def getBlockId(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- result(Block.getIdFromBlock(world.getBlock(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))))
+ result(Block.getIdFromBlock(world.getBlockState(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))).getBlock))
}
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the metadata of the block at the specified coordinates.""")
def getMetadata(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- result(world.getBlockMetadata(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
+ result(world.getBlockState(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))))
}
@Callback(doc = """function(x:number, y:number, z:number):number -- Check whether the block at the specified coordinates is loaded.""")
def isLoaded(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- result(world.blockExists(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
+ result(world.isBlockLoaded(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))))
}
@Callback(doc = """function(x:number, y:number, z:number):number -- Check whether the block at the specified coordinates has a tile entity.""")
def hasTileEntity(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- val (x, y, z) = (args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
- val block = world.getBlock(x, y, z)
- result(block != null && block.hasTileEntity(world.getBlockMetadata(x, y, z)))
+ val blockPos = new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
+ val state = world.getBlockState(blockPos)
+ result(state.getBlock.hasTileEntity(state))
}
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the light opacity of the block at the specified coordinates.""")
def getLightOpacity(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- result(world.getBlockLightOpacity(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
+ result(world.getBlockLightOpacity(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))))
}
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the light value (emission) of the block at the specified coordinates.""")
def getLightValue(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- result(world.getBlockLightValue(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
+ result(world.getLight(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)), false))
}
@Callback(doc = """function(x:number, y:number, z:number):number -- Get whether the block at the specified coordinates is directly under the sky.""")
def canSeeSky(context: Context, args: Arguments): Array[AnyRef] = {
checkEnabled()
- result(world.canBlockSeeTheSky(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
+ result(world.canBlockSeeSky(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))))
}
@Callback(doc = """function(x:number, y:number, z:number, id:number or string, meta:number):number -- Set the block at the specified coordinates.""")
@@ -285,7 +287,7 @@ object DebugCard {
checkEnabled()
val block = if (args.isInteger(3)) Block.getBlockById(args.checkInteger(3)) else Block.getBlockFromName(args.checkString(3))
val metadata = args.checkInteger(4)
- result(world.setBlock(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2), block, metadata, 3))
+ result(world.setBlockState(new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)), block.getStateFromMeta(metadata)))
}
@Callback(doc = """function(x1:number, y1:number, z1:number, x2:number, y2:number, z2:number, id:number or string, meta:number):number -- Set all blocks in the area defined by the two corner points (x1, y1, z1) and (x2, y2, z2).""")
@@ -298,7 +300,7 @@ object DebugCard {
for (x <- math.min(xMin, xMax) to math.max(xMin, xMax)) {
for (y <- math.min(yMin, yMax) to math.max(yMin, yMax)) {
for (z <- math.min(zMin, zMax) to math.max(zMin, zMax)) {
- world.setBlock(x, y, z, block, metadata, 3)
+ world.setBlockState(new BlockPos(x, y, z), block.getStateFromMeta(metadata))
}
}
}
@@ -317,9 +319,9 @@ object DebugCard {
val count = args.checkInteger(1)
val damage = args.checkInteger(2)
val tagJson = args.checkString(3)
- val tag = if (Strings.isNullOrEmpty(tagJson)) null else JsonToNBT.func_150315_a(tagJson).asInstanceOf[NBTTagCompound]
+ val tag = if (Strings.isNullOrEmpty(tagJson)) null else JsonToNBT.func_180713_a(tagJson)
val position = BlockPosition(args.checkDouble(4), args.checkDouble(5), args.checkDouble(6), world)
- val side = args.checkSide(7, ForgeDirection.VALID_DIRECTIONS: _*)
+ val side = args.checkSide(7, EnumFacing.values: _*)
InventoryUtils.inventoryAt(position) match {
case Some(inventory) =>
val stack = new ItemStack(item, count, damage)
@@ -338,7 +340,7 @@ object DebugCard {
override def save(nbt: NBTTagCompound) {
super.save(nbt)
- nbt.setInteger("dimension", world.provider.dimensionId)
+ nbt.setInteger("dimension", world.provider.getDimensionId)
}
}
@@ -347,7 +349,7 @@ object DebugCard {
var messages: Option[String] = None
- override def getCommandSenderName = fakePlayer.getCommandSenderName
+ override def getName = fakePlayer.getName
override def getEntityWorld = host.world
@@ -355,18 +357,26 @@ object DebugCard {
messages = Option(messages.getOrElse("") + message.getUnformattedText)
}
- override def canCommandSenderUseCommand(level: Int, command: String) = {
+ override def getDisplayName = fakePlayer.getDisplayName
+
+ override def setCommandStat(`type`: Type, amount: Int) = fakePlayer.setCommandStat(`type`, amount)
+
+ override def getPosition = fakePlayer.getPosition
+
+ override def canUseCommand(level: Int, commandName: String) = {
val profile = fakePlayer.getGameProfile
val server = fakePlayer.mcServer
val config = server.getConfigurationManager
- server.isSinglePlayer || (config.func_152596_g(profile) && (config.func_152603_m.func_152683_b(profile) match {
- case entry: UserListOpsEntry => entry.func_152644_a >= level
+ server.isSinglePlayer || (config.canSendCommands(profile) && (config.getOppedPlayers.getEntry(profile) match {
+ case entry: UserListOpsEntry => entry.getPermissionLevel >= level
case _ => server.getOpPermissionLevel >= level
}))
}
- override def getPlayerCoordinates = BlockPosition(host).toChunkCoordinates
+ override def getCommandSenderEntity = fakePlayer
- override def func_145748_c_() = fakePlayer.func_145748_c_()
+ override def getPositionVector = fakePlayer.getPositionVector
+
+ override def sendCommandFeedback() = fakePlayer.sendCommandFeedback()
}
}
diff --git a/src/main/scala/li/cil/oc/server/component/Drone.scala b/src/main/scala/li/cil/oc/server/component/Drone.scala
index ae01c8237..800278c73 100644
--- a/src/main/scala/li/cil/oc/server/component/Drone.scala
+++ b/src/main/scala/li/cil/oc/server/component/Drone.scala
@@ -13,7 +13,7 @@ import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.InventoryUtils
import net.minecraft.entity.Entity
import net.minecraft.entity.item.EntityItem
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with traits.WorldControl with traits.InventoryControl with traits.InventoryWorldControl with traits.TankAware with traits.TankControl with traits.TankWorldControl {
override val node = Network.newNode(this, Visibility.Network).
@@ -36,9 +36,9 @@ class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with trait
override def selectedTank_=(value: Int) = host.selectedTank = value
override protected def checkSideForAction(args: Arguments, n: Int) =
- args.checkSide(n, ForgeDirection.VALID_DIRECTIONS: _*)
+ args.checkSide(n, EnumFacing.values: _*)
- override protected def suckableItems(side: ForgeDirection) = entitiesInBlock(position) ++ super.suckableItems(side)
+ override protected def suckableItems(side: EnumFacing) = entitiesInBlock(position) ++ super.suckableItems(side)
override protected def onSuckCollect(entity: EntityItem) = {
if (InventoryUtils.insertIntoInventory(entity.getEntityItem, inventory, slots = Option(insertionSlots))) {
diff --git a/src/main/scala/li/cil/oc/server/component/Geolyzer.scala b/src/main/scala/li/cil/oc/server/component/Geolyzer.scala
index 5dc708c2f..2266cd5a7 100644
--- a/src/main/scala/li/cil/oc/server/component/Geolyzer.scala
+++ b/src/main/scala/li/cil/oc/server/component/Geolyzer.scala
@@ -18,7 +18,7 @@ import li.cil.oc.util.ExtendedWorld._
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.convert.WrapAsJava._
@@ -49,7 +49,7 @@ class Geolyzer(val host: EnvironmentHost) extends prefab.ManagedEnvironment {
@Callback(doc = """function(side:number[,options:table]):table -- Get some information on a directly adjacent block.""")
def analyze(computer: Context, args: Arguments): Array[AnyRef] = if (Settings.get.allowItemStackInspection) {
- val side = args.checkSide(0, ForgeDirection.VALID_DIRECTIONS: _*)
+ val side = args.checkSide(0, EnumFacing.values: _*)
val globalSide = host match {
case rotatable: Rotatable => rotatable.toGlobal(side)
case _ => side
@@ -68,7 +68,7 @@ class Geolyzer(val host: EnvironmentHost) extends prefab.ManagedEnvironment {
@Callback(doc = """function(side:number, dbAddress:string, dbSlot:number):boolean -- Store an item stack representation of the block on the specified side in a database component.""")
def store(computer: Context, args: Arguments): Array[AnyRef] = {
- val side = args.checkSide(0, ForgeDirection.VALID_DIRECTIONS: _*)
+ val side = args.checkSide(0, EnumFacing.values: _*)
val globalSide = host match {
case rotatable: Rotatable => rotatable.toGlobal(side)
case _ => side
diff --git a/src/main/scala/li/cil/oc/server/component/Keyboard.scala b/src/main/scala/li/cil/oc/server/component/Keyboard.scala
index cc1072cc8..7800bf945 100644
--- a/src/main/scala/li/cil/oc/server/component/Keyboard.scala
+++ b/src/main/scala/li/cil/oc/server/component/Keyboard.scala
@@ -1,10 +1,10 @@
package li.cil.oc.server.component
-import cpw.mods.fml.common.FMLCommonHandler
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent
-import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent
-import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent
+import net.minecraftforge.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent
+import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent
+import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.Network
@@ -54,7 +54,7 @@ class Keyboard(val host: EnvironmentHost) extends prefab.ManagedEnvironment with
pressedKeys.get(player) match {
case Some(keys) => for ((code, char) <- keys) {
if (Settings.get.inputUsername) {
- signal(player, "key_up", char, code, player.getCommandSenderName)
+ signal(player, "key_up", char, code, player.getName)
}
else {
signal(player, "key_up", char, code)
@@ -94,7 +94,7 @@ class Keyboard(val host: EnvironmentHost) extends prefab.ManagedEnvironment with
if (isUseableByPlayer(p)) {
pressedKeys.getOrElseUpdate(p, mutable.Map.empty[Integer, Character]) += code -> char
if (Settings.get.inputUsername) {
- signal(p, "key_down", char, code, p.getCommandSenderName)
+ signal(p, "key_down", char, code, p.getName)
}
else {
signal(p, "key_down", char, code)
@@ -105,7 +105,7 @@ class Keyboard(val host: EnvironmentHost) extends prefab.ManagedEnvironment with
case Some(keys) if keys.contains(code) =>
keys -= code
if (Settings.get.inputUsername) {
- signal(p, "key_up", char, code, p.getCommandSenderName)
+ signal(p, "key_up", char, code, p.getName)
}
else {
signal(p, "key_up", char, code)
@@ -116,7 +116,7 @@ class Keyboard(val host: EnvironmentHost) extends prefab.ManagedEnvironment with
if (isUseableByPlayer(p)) {
for (line <- value.linesWithSeparators) {
if (Settings.get.inputUsername) {
- signal(p, "clipboard", line, p.getCommandSenderName)
+ signal(p, "clipboard", line, p.getName)
}
else {
signal(p, "clipboard", line)
diff --git a/src/main/scala/li/cil/oc/server/component/Redstone.scala b/src/main/scala/li/cil/oc/server/component/Redstone.scala
index 1d1908613..6d90fa9c0 100644
--- a/src/main/scala/li/cil/oc/server/component/Redstone.scala
+++ b/src/main/scala/li/cil/oc/server/component/Redstone.scala
@@ -9,7 +9,7 @@ import li.cil.oc.api.prefab
import li.cil.oc.common.tileentity.traits.BundledRedstoneAware
import li.cil.oc.common.tileentity.traits.RedstoneAware
import li.cil.oc.server.component
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class Redstone[+Owner <: RedstoneAware](val owner: Owner) extends prefab.ManagedEnvironment {
override val node = Network.newNode(this, Visibility.Network).
@@ -45,7 +45,7 @@ class Redstone[+Owner <: RedstoneAware](val owner: Owner) extends prefab.Managed
val side = args.checkInteger(index)
if (side < 0 || side > 5)
throw new IllegalArgumentException("invalid side")
- owner.toGlobal(ForgeDirection.getOrientation(side))
+ owner.toGlobal(EnumFacing.getFront(side))
}
}
diff --git a/src/main/scala/li/cil/oc/server/component/RedstoneWireless.scala b/src/main/scala/li/cil/oc/server/component/RedstoneWireless.scala
index 546ab1bb4..cf02a9f05 100644
--- a/src/main/scala/li/cil/oc/server/component/RedstoneWireless.scala
+++ b/src/main/scala/li/cil/oc/server/component/RedstoneWireless.scala
@@ -1,9 +1,11 @@
package li.cil.oc.server.component
+/* TODO WRCBE
import codechicken.lib.vec.Vector3
import codechicken.wirelessredstone.core.WirelessReceivingDevice
import codechicken.wirelessredstone.core.WirelessTransmittingDevice
-import cpw.mods.fml.common.Optional
+*/
+import net.minecraftforge.fml.common.Optional
import li.cil.oc.api.machine.Arguments
import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
@@ -18,7 +20,7 @@ import net.minecraft.nbt.NBTTagCompound
new Optional.Interface(iface = "codechicken.wirelessredstone.core.WirelessReceivingDevice", modid = Mods.IDs.WirelessRedstoneCBE),
new Optional.Interface(iface = "codechicken.wirelessredstone.core.WirelessTransmittingDevice", modid = Mods.IDs.WirelessRedstoneCBE)
))
-trait RedstoneWireless extends Redstone[RedstoneAware] with WirelessReceivingDevice with WirelessTransmittingDevice {
+trait RedstoneWireless extends Redstone[RedstoneAware] /* with WirelessReceivingDevice with WirelessTransmittingDevice TODO WRCBE */ {
var wirelessFrequency = 0
var wirelessInput = false
@@ -69,7 +71,7 @@ trait RedstoneWireless extends Redstone[RedstoneAware] with WirelessReceivingDev
}
// ----------------------------------------------------------------------- //
-
+/* TODO WRCBE
@Optional.Method(modid = Mods.IDs.WirelessRedstoneCBE)
override def updateDevice(frequency: Int, on: Boolean) {
if (frequency == wirelessFrequency && on != wirelessInput) {
@@ -82,14 +84,14 @@ trait RedstoneWireless extends Redstone[RedstoneAware] with WirelessReceivingDev
override def getPosition = Vector3.fromTileEntityCenter(owner)
@Optional.Method(modid = Mods.IDs.WirelessRedstoneCBE)
- override def getDimension = owner.world.provider.dimensionId
+ override def getDimension = owner.world.provider.getDimensionId
@Optional.Method(modid = Mods.IDs.WirelessRedstoneCBE)
override def getFreq = wirelessFrequency
@Optional.Method(modid = Mods.IDs.WirelessRedstoneCBE)
override def getAttachedEntity = null
-
+*/
// ----------------------------------------------------------------------- //
override def onConnect(node: Node) {
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeCrafting.scala b/src/main/scala/li/cil/oc/server/component/UpgradeCrafting.scala
index e9ff56b30..cae9e3f8f 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeCrafting.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeCrafting.scala
@@ -1,6 +1,6 @@
package li.cil.oc.server.component
-import cpw.mods.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.FMLCommonHandler
import li.cil.oc.api.Network
import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.internal.Robot
@@ -62,7 +62,7 @@ class UpgradeCrafting(val host: EnvironmentHost with Robot) extends prefab.Manag
if (container.isItemStackDamageable && container.getItemDamage > container.getMaxDamage) {
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(host.player, container))
}
- else if (container.getItem.doesContainerItemLeaveCraftingGrid(container) || getStackInSlot(slot) != null) {
+ else if (/* container.getItem.doesContainerItemLeaveCraftingGrid(container) || TODO */ getStackInSlot(slot) != null) {
surplus += container
}
else {
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeDatabase.scala b/src/main/scala/li/cil/oc/server/component/UpgradeDatabase.scala
index a19a61940..0ea7cc17c 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeDatabase.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeDatabase.scala
@@ -11,6 +11,7 @@ import li.cil.oc.api.prefab
import li.cil.oc.util.DatabaseAccess
import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.ExtendedNBT._
+import li.cil.oc.util.ItemUtils
import net.minecraft.inventory.IInventory
import net.minecraft.item.ItemStack
import net.minecraft.nbt.CompressedStreamTools
@@ -33,7 +34,7 @@ class UpgradeDatabase(val data: IInventory) extends prefab.ManagedEnvironment wi
def computeHash(context: Context, args: Arguments): Array[AnyRef] = {
data.getStackInSlot(args.checkSlot(data, 0)) match {
case stack: ItemStack =>
- val hash = Hashing.sha256().hashBytes(CompressedStreamTools.compress(stack))
+ val hash = Hashing.sha256().hashBytes(ItemUtils.saveStack(stack))
result(hash.toString)
case _ => null
}
@@ -79,7 +80,7 @@ class UpgradeDatabase(val data: IInventory) extends prefab.ManagedEnvironment wi
private def indexOf(needle: String, offset: Int = 0): Int = {
for (slot <- 0 until data.getSizeInventory) data.getStackInSlot(slot) match {
case stack: ItemStack =>
- val hash = Hashing.sha256().hashBytes(CompressedStreamTools.compress(stack))
+ val hash = Hashing.sha256().hashBytes(ItemUtils.saveStack(stack))
if (hash.toString == needle) return slot + offset
case _ =>
}
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeGenerator.scala b/src/main/scala/li/cil/oc/server/component/UpgradeGenerator.scala
index f0077c98f..3999c1e75 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeGenerator.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeGenerator.scala
@@ -135,7 +135,7 @@ class UpgradeGenerator(val host: EnvironmentHost with Robot) extends prefab.Mana
val world = host.world
val entity = new EntityItem(world, host.xPosition, host.yPosition, host.zPosition, stack.copy())
entity.motionY = 0.04
- entity.delayBeforeCanPickup = 5
+ entity.setPickupDelay(5)
world.spawnEntityInWorld(entity)
inventory = None
case _ =>
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeInventoryController.scala b/src/main/scala/li/cil/oc/server/component/UpgradeInventoryController.scala
index 52b15c3eb..07373fc63 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeInventoryController.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeInventoryController.scala
@@ -12,7 +12,7 @@ import li.cil.oc.common.tileentity
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedArguments._
import net.minecraft.entity.Entity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
object UpgradeInventoryController {
@@ -25,7 +25,7 @@ object UpgradeInventoryController {
override def position = BlockPosition(host)
- override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, ForgeDirection.VALID_DIRECTIONS: _*)
+ override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, EnumFacing.values: _*)
}
class Drone(val host: EnvironmentHost with entity.Drone) extends prefab.ManagedEnvironment with traits.InventoryAnalytics with traits.InventoryWorldControlMk2 with traits.WorldInventoryAnalytics {
@@ -43,7 +43,7 @@ object UpgradeInventoryController {
override def selectedSlot_=(value: Int) = host.selectedSlot = value
- override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, ForgeDirection.VALID_DIRECTIONS: _*)
+ override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, EnumFacing.values: _*)
}
class Robot(val host: EnvironmentHost with tileentity.Robot) extends prefab.ManagedEnvironment with traits.InventoryAnalytics with traits.InventoryWorldControlMk2 with traits.WorldInventoryAnalytics {
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeLeash.scala b/src/main/scala/li/cil/oc/server/component/UpgradeLeash.scala
index 50a0e6f13..9fe3e731d 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeLeash.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeLeash.scala
@@ -19,7 +19,7 @@ import net.minecraft.entity.EntityLiving
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagString
import net.minecraftforge.common.util.Constants.NBT
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.mutable
@@ -35,10 +35,10 @@ class UpgradeLeash(val host: Entity) extends prefab.ManagedEnvironment with trai
@Callback(doc = """function(side:number):boolean -- Tries to put an entity on the specified side of the device onto a leash.""")
def leash(context: Context, args: Arguments): Array[AnyRef] = {
if (leashedEntities.size >= 8) return result(Unit, "too many leashed entities")
- val side = args.checkSide(0, ForgeDirection.VALID_DIRECTIONS: _*)
+ val side = args.checkSide(0, EnumFacing.values: _*)
val nearBounds = position.bounds
- val farBounds = nearBounds.offset(side.offsetX * 2.0, side.offsetY * 2.0, side.offsetZ * 2.0)
- val bounds = nearBounds.func_111270_a(farBounds)
+ val farBounds = nearBounds.offset(side.getFrontOffsetX * 2.0, side.getFrontOffsetY * 2.0, side.getFrontOffsetZ * 2.0)
+ val bounds = nearBounds.union(farBounds)
entitiesInBounds[EntityLiving](bounds).find(_.allowLeashing()) match {
case Some(entity) =>
entity.setLeashedToEntity(host, true)
@@ -74,7 +74,7 @@ class UpgradeLeash(val host: Entity) extends prefab.ManagedEnvironment with trai
override def load(nbt: NBTTagCompound) {
super.load(nbt)
leashedEntities ++= nbt.getTagList("leashedEntities", NBT.TAG_STRING).
- map((s: NBTTagString) => UUID.fromString(s.func_150285_a_()))
+ map((s: NBTTagString) => UUID.fromString(s.getString))
// Re-acquire leashed entities. Need to do this manually because leashed
// entities only remember their leashee if it's an EntityLivingBase...
EventHandler.schedule(() => {
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradePiston.scala b/src/main/scala/li/cil/oc/server/component/UpgradePiston.scala
index e7152ef28..72e054dc3 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradePiston.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradePiston.scala
@@ -1,6 +1,6 @@
package li.cil.oc.server.component
-import cpw.mods.fml.relauncher.ReflectionHelper
+import net.minecraftforge.fml.relauncher.ReflectionHelper
import li.cil.oc.Settings
import li.cil.oc.api.Network
import li.cil.oc.api.driver.EnvironmentHost
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeSign.scala b/src/main/scala/li/cil/oc/server/component/UpgradeSign.scala
index 4a18cb76b..f52f062ed 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeSign.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeSign.scala
@@ -1,6 +1,7 @@
package li.cil.oc.server.component
-import cpw.mods.fml.common.eventhandler.Event
+import net.minecraft.util.ChatComponentText
+import net.minecraftforge.fml.common.eventhandler.Event
import li.cil.oc.Settings
import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.internal.Robot
@@ -12,7 +13,7 @@ import net.minecraft.tileentity.TileEntitySign
import net.minecraft.world.WorldServer
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.FakePlayerFactory
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.event.world.BlockEvent
abstract class UpgradeSign extends prefab.ManagedEnvironment {
@@ -36,14 +37,14 @@ abstract class UpgradeSign extends prefab.ManagedEnvironment {
return result(Unit, "not allowed")
}
- text.lines.padTo(4, "").map(line => if (line.length > 15) line.substring(0, 15) else line).copyToArray(sign.signText)
- host.world.markBlockForUpdate(sign.xCoord, sign.yCoord, sign.zCoord)
+ text.lines.padTo(4, "").map(line => if (line.length > 15) line.substring(0, 15) else line).map(new ChatComponentText(_)).copyToArray(sign.signText)
+ host.world.markBlockForUpdate(sign.getPos)
result(sign.signText.mkString("\n"))
case _ => result(Unit, "no sign")
}
}
- protected def findSign(side: ForgeDirection) = {
+ protected def findSign(side: EnumFacing) = {
val hostPos = BlockPosition(host)
host.world.getTileEntity(hostPos) match {
case sign: TileEntitySign => Option(sign)
@@ -55,10 +56,10 @@ abstract class UpgradeSign extends prefab.ManagedEnvironment {
}
private def canChangeSign(player: EntityPlayer, tileEntity: TileEntitySign): Boolean = {
- if (!host.world.canMineBlock(player, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)) {
+ if (!host.world.isBlockModifiable(player, tileEntity.getPos)) {
return false
}
- val event = new BlockEvent.BreakEvent(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, host.world, tileEntity.getBlockType, tileEntity.getBlockMetadata, player)
+ val event = new BlockEvent.BreakEvent(host.world, tileEntity.getPos, tileEntity.getWorld.getBlockState(tileEntity.getPos), player)
MinecraftForge.EVENT_BUS.post(event)
!(event.isCanceled || event.getResult == Event.Result.DENY)
}
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeSignInAdapter.scala b/src/main/scala/li/cil/oc/server/component/UpgradeSignInAdapter.scala
index e18ec5f85..f8b379a9b 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeSignInAdapter.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeSignInAdapter.scala
@@ -7,7 +7,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._
import li.cil.oc.util.ExtendedArguments._
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class UpgradeSignInAdapter(val host: EnvironmentHost) extends UpgradeSign {
override val node = Network.newNode(this, Visibility.Network).
@@ -18,8 +18,8 @@ class UpgradeSignInAdapter(val host: EnvironmentHost) extends UpgradeSign {
// ----------------------------------------------------------------------- //
@Callback(doc = """function(side:number):string -- Get the text on the sign on the specified side of the adapter.""")
- def getValue(context: Context, args: Arguments): Array[AnyRef] = super.getValue(findSign(args.checkSide(0, ForgeDirection.VALID_DIRECTIONS: _*)))
+ def getValue(context: Context, args: Arguments): Array[AnyRef] = super.getValue(findSign(args.checkSide(0, EnumFacing.values: _*)))
@Callback(doc = """function(side:number, value:string):string -- Set the text on the sign on the specified side of the adapter.""")
- def setValue(context: Context, args: Arguments): Array[AnyRef] = super.setValue(findSign(args.checkSide(0, ForgeDirection.VALID_DIRECTIONS: _*)), args.checkString(1))
+ def setValue(context: Context, args: Arguments): Array[AnyRef] = super.setValue(findSign(args.checkSide(0, EnumFacing.values: _*)), args.checkString(1))
}
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeSolarGenerator.scala b/src/main/scala/li/cil/oc/server/component/UpgradeSolarGenerator.scala
index dd4d1798b..8a516bb08 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeSolarGenerator.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeSolarGenerator.scala
@@ -7,7 +7,7 @@ import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab
import li.cil.oc.util.BlockPosition
import net.minecraft.world.biome.BiomeGenDesert
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
class UpgradeSolarGenerator(val host: EnvironmentHost) extends prefab.ManagedEnvironment {
override val node = Network.newNode(this, Visibility.Network).
@@ -36,10 +36,10 @@ class UpgradeSolarGenerator(val host: EnvironmentHost) extends prefab.ManagedEnv
}
private def isSunVisible = {
- val blockPos = BlockPosition(host).offset(ForgeDirection.UP)
+ val blockPos = BlockPosition(host).offset(EnumFacing.UP)
host.world.isDaytime &&
- (!host.world.provider.hasNoSky) &&
- host.world.canBlockSeeTheSky(blockPos.x, blockPos.y, blockPos.z) &&
- (host.world.getWorldChunkManager.getBiomeGenAt(blockPos.x, blockPos.z).isInstanceOf[BiomeGenDesert] || (!host.world.isRaining && !host.world.isThundering))
+ (!host.world.provider.getHasNoSky) &&
+ host.world.canBlockSeeSky(blockPos.toBlockPos) &&
+ (host.world.getWorldChunkManager.getBiomeGenerator(blockPos.toBlockPos).isInstanceOf[BiomeGenDesert] || (!host.world.isRaining && !host.world.isThundering))
}
}
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeTankController.scala b/src/main/scala/li/cil/oc/server/component/UpgradeTankController.scala
index e94669142..5ab981c79 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeTankController.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeTankController.scala
@@ -10,7 +10,7 @@ import li.cil.oc.common.tileentity
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedArguments._
import net.minecraft.entity.Entity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
object UpgradeTankController {
@@ -23,7 +23,7 @@ object UpgradeTankController {
override def position = BlockPosition(host)
- override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, ForgeDirection.VALID_DIRECTIONS: _*)
+ override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, EnumFacing.values: _*)
}
class Drone(val host: EnvironmentHost with entity.Drone) extends prefab.ManagedEnvironment with traits.TankInventoryControl with traits.WorldTankAnalytics {
@@ -45,7 +45,7 @@ object UpgradeTankController {
override def selectedTank_=(value: Int) = host.selectedTank = value
- override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, ForgeDirection.VALID_DIRECTIONS: _*)
+ override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSide(n, EnumFacing.values: _*)
}
class Robot(val host: EnvironmentHost with tileentity.Robot) extends prefab.ManagedEnvironment with traits.TankInventoryControl with traits.WorldTankAnalytics {
diff --git a/src/main/scala/li/cil/oc/server/component/UpgradeTractorBeam.scala b/src/main/scala/li/cil/oc/server/component/UpgradeTractorBeam.scala
index e9412e519..d6724a017 100644
--- a/src/main/scala/li/cil/oc/server/component/UpgradeTractorBeam.scala
+++ b/src/main/scala/li/cil/oc/server/component/UpgradeTractorBeam.scala
@@ -11,6 +11,7 @@ import li.cil.oc.api.prefab
import net.minecraft.entity.item.EntityItem
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.util.AxisAlignedBB
+import net.minecraft.util.BlockPos
import scala.collection.convert.WrapAsScala._
@@ -27,7 +28,7 @@ class UpgradeTractorBeam(owner: EnvironmentHost, player: () => EntityPlayer) ext
def suck(context: Context, args: Arguments): Array[AnyRef] = {
val items = world.getEntitiesWithinAABB(classOf[EntityItem], pickupBounds)
.map(_.asInstanceOf[EntityItem])
- .filter(item => item.isEntityAlive && item.delayBeforeCanPickup <= 0)
+ .filter(item => item.isEntityAlive && !item.cannotPickup)
if (items.nonEmpty) {
val item = items(world.rand.nextInt(items.size))
val stack = item.getEntityItem
@@ -35,7 +36,7 @@ class UpgradeTractorBeam(owner: EnvironmentHost, player: () => EntityPlayer) ext
item.onCollideWithPlayer(player())
if (stack.stackSize < size || item.isDead) {
context.pause(Settings.get.suckDelay)
- world.playAuxSFX(2003, math.floor(item.posX).toInt, math.floor(item.posY).toInt, math.floor(item.posZ).toInt, 0)
+ world.playAuxSFX(2003, new BlockPos(math.floor(item.posX).toInt, math.floor(item.posY).toInt, math.floor(item.posZ).toInt), 0)
return result(true)
}
}
@@ -47,7 +48,7 @@ class UpgradeTractorBeam(owner: EnvironmentHost, player: () => EntityPlayer) ext
val x = player.posX
val y = player.posY
val z = player.posZ
- AxisAlignedBB.getBoundingBox(
+ AxisAlignedBB.fromBounds(
x - pickupRadius, y - pickupRadius, z - pickupRadius,
x + pickupRadius, y + pickupRadius, z + pickupRadius)
}
diff --git a/src/main/scala/li/cil/oc/server/component/robot/FakeNetworkManager.scala b/src/main/scala/li/cil/oc/server/component/robot/FakeNetworkManager.scala
index 28ebfb07b..801df5cf6 100644
--- a/src/main/scala/li/cil/oc/server/component/robot/FakeNetworkManager.scala
+++ b/src/main/scala/li/cil/oc/server/component/robot/FakeNetworkManager.scala
@@ -2,9 +2,12 @@ package li.cil.oc.server.component.robot
import io.netty.util.concurrent.Future
import io.netty.util.concurrent.GenericFutureListener
+import net.minecraft.network.EnumPacketDirection
import net.minecraft.network.NetworkManager
import net.minecraft.network.Packet
-object FakeNetworkManager extends NetworkManager(false) {
- override def scheduleOutboundPacket(packet: Packet, listener: GenericFutureListener[_ <: Future[_]]*) {}
+object FakeNetworkManager extends NetworkManager(EnumPacketDirection.CLIENTBOUND) {
+ override def sendPacket(packetIn: Packet) {}
+
+ override def sendPacket(packetIn: Packet, listener: GenericFutureListener[_ <: Future[_]], listeners: GenericFutureListener[_ <: Future[_]]*) {}
}
diff --git a/src/main/scala/li/cil/oc/server/component/robot/Inventory.scala b/src/main/scala/li/cil/oc/server/component/robot/Inventory.scala
index b69ecf8ca..50b707f8e 100644
--- a/src/main/scala/li/cil/oc/server/component/robot/Inventory.scala
+++ b/src/main/scala/li/cil/oc/server/component/robot/Inventory.scala
@@ -5,6 +5,7 @@ import net.minecraft.block.Block
import net.minecraft.entity.player.InventoryPlayer
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
+import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagList
import scala.util.control.Breaks._
@@ -30,15 +31,11 @@ class Inventory(val robot: tileentity.Robot) extends InventoryPlayer(null) {
else inventorySlots.find(slot => getStackInSlot(slot) == null && isItemValidForSlot(slot, stack)).getOrElse(-1)
}
- override def func_146030_a(p_146030_1_ : Item, p_146030_2_ : Int, p_146030_3_ : Boolean, p_146030_4_ : Boolean) = setCurrentItem(p_146030_1_, p_146030_2_, p_146030_3_, p_146030_4_)
-
- def setCurrentItem(item: Item, itemDamage: Int, checkDamage: Boolean, create: Boolean) {}
+ override def setCurrentItem(item: Item, itemDamage: Int, checkDamage: Boolean, create: Boolean) {}
override def changeCurrentItem(direction: Int) {}
- override def clearInventory(item: Item, itemDamage: Int) = 0
-
- override def func_70439_a(item: Item, itemDamage: Int) {}
+ override def func_174925_a(item: Item, damage: Int, count: Int, tag: NBTTagCompound) = 0
override def decrementAnimations() {
for (slot <- 0 until getSizeInventory) {
@@ -121,9 +118,7 @@ class Inventory(val robot: tileentity.Robot) extends InventoryPlayer(null) {
override def setInventorySlotContents(slot: Int, stack: ItemStack) = robot.setInventorySlotContents(slot, stack)
- override def func_146023_a(p_146023_1_ : Block) = getStrVsBlock(p_146023_1_)
-
- def getStrVsBlock(block: Block) = Option(getCurrentItem).fold(1f)(_.func_150997_a(block))
+ override def getStrVsBlock(block: Block) = Option(getCurrentItem).fold(1f)(_.getStrVsBlock(block))
override def writeToNBT(nbt: NBTTagList) = nbt
@@ -133,7 +128,7 @@ class Inventory(val robot: tileentity.Robot) extends InventoryPlayer(null) {
override def getStackInSlot(slot: Int) = robot.getStackInSlot(slot)
- override def getInventoryName = robot.getInventoryName
+ override def getName = robot.getName
override def getInventoryStackLimit = robot.getInventoryStackLimit
diff --git a/src/main/scala/li/cil/oc/server/component/robot/Player.scala b/src/main/scala/li/cil/oc/server/component/robot/Player.scala
index 01846be27..c0e882d83 100644
--- a/src/main/scala/li/cil/oc/server/component/robot/Player.scala
+++ b/src/main/scala/li/cil/oc/server/component/robot/Player.scala
@@ -1,8 +1,9 @@
package li.cil.oc.server.component.robot
import com.mojang.authlib.GameProfile
-import cpw.mods.fml.common.ObfuscationReflectionHelper
-import cpw.mods.fml.common.eventhandler.Event
+import net.minecraft.world.IInteractionObject
+import net.minecraftforge.fml.common.ObfuscationReflectionHelper
+import net.minecraftforge.fml.common.eventhandler.Event
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api.event._
@@ -34,7 +35,7 @@ import net.minecraft.world.WorldServer
import net.minecraftforge.common.ForgeHooks
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.FakePlayer
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.event.ForgeEventFactory
import net.minecraftforge.event.entity.player.EntityInteractEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent
@@ -63,8 +64,8 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
capabilities.disableDamage = true
capabilities.isFlying = true
onGround = true
- yOffset = 0.5f
- eyeHeight = 0f
+ override def getYOffset = 0.5f
+ override def getEyeHeight = 0f
setSize(1, 1)
if (Mods.BattleGear2.isAvailable) {
@@ -72,30 +73,30 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
}
else inventory = robot.inventory
- var facing, side = ForgeDirection.SOUTH
+ var facing, side = EnumFacing.SOUTH
var customItemInUseBecauseMinecraftIsBloodyStupidAndMakesRandomMethodsClientSided: ItemStack = _
def world = robot.world
- override def getPlayerCoordinates = new ChunkCoordinates(robot.x, robot.y, robot.z)
+ override def getPosition = new BlockPos(posX, posY, posZ)
override def getDefaultEyeHeight = 0f
- override def getDisplayName = robot.name
+ override def getDisplayName = new ChatComponentText(robot.name)
theItemInWorldManager.setBlockReachDistance(1)
// ----------------------------------------------------------------------- //
- def updatePositionAndRotation(facing: ForgeDirection, side: ForgeDirection) {
+ def updatePositionAndRotation(facing: EnumFacing, side: EnumFacing) {
this.facing = facing
this.side = side
// Slightly offset in robot's facing to avoid glitches (e.g. Portal Gun).
- val direction = Vec3.createVectorHelper(
- facing.offsetX + side.offsetX + robot.facing.offsetX * 0.01,
- facing.offsetY + side.offsetY + robot.facing.offsetY * 0.01,
- facing.offsetZ + side.offsetZ + robot.facing.offsetZ * 0.01).normalize()
+ val direction = new Vec3(
+ facing.getFrontOffsetX + side.getFrontOffsetX + robot.facing.getFrontOffsetX * 0.01,
+ facing.getFrontOffsetY + side.getFrontOffsetY + robot.facing.getFrontOffsetY * 0.01,
+ facing.getFrontOffsetZ + side.getFrontOffsetZ + robot.facing.getFrontOffsetZ * 0.01).normalize()
val yaw = Math.toDegrees(-Math.atan2(direction.xCoord, direction.zCoord)).toFloat
val pitch = Math.toDegrees(-Math.atan2(direction.yCoord, Math.sqrt((direction.xCoord * direction.xCoord) + (direction.zCoord * direction.zCoord)))).toFloat * 0.99f
setLocationAndAngles(robot.x + 0.5, robot.y, robot.z + 0.5, yaw, pitch)
@@ -103,24 +104,24 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
prevRotationYaw = rotationYaw
}
- def closestEntity[Type <: Entity : ClassTag](side: ForgeDirection = facing) = {
- val (x, y, z) = (robot.x + side.offsetX, robot.y + side.offsetY, robot.z + side.offsetZ)
- val bounds = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)
+ def closestEntity[Type <: Entity : ClassTag](side: EnumFacing = facing) = {
+ val (x, y, z) = (robot.x + side.getFrontOffsetX, robot.y + side.getFrontOffsetY, robot.z + side.getFrontOffsetZ)
+ val bounds = AxisAlignedBB.fromBounds(x, y, z, x + 1, y + 1, z + 1)
Option(world.findNearestEntityWithinAABB(classTag[Type].runtimeClass, bounds, this)).map(_.asInstanceOf[Type])
}
- def entitiesOnSide[Type <: Entity : ClassTag](side: ForgeDirection) = {
- val (x, y, z) = (robot.x + side.offsetX, robot.y + side.offsetY, robot.z + side.offsetZ)
+ def entitiesOnSide[Type <: Entity : ClassTag](side: EnumFacing) = {
+ val (x, y, z) = (robot.x + side.getFrontOffsetX, robot.y + side.getFrontOffsetY, robot.z + side.getFrontOffsetZ)
entitiesInBlock[Type](x, y, z)
}
def entitiesInBlock[Type <: Entity : ClassTag](x: Int, y: Int, z: Int) = {
- val bounds = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)
+ val bounds = AxisAlignedBB.fromBounds(x, y, z, x + 1, y + 1, z + 1)
world.getEntitiesWithinAABB(classTag[Type].runtimeClass, bounds).map(_.asInstanceOf[Type])
}
private def adjacentItems = {
- val bounds = AxisAlignedBB.getBoundingBox(robot.x - 2, robot.y - 2, robot.z - 2, robot.x + 3, robot.y + 3, robot.z + 3)
+ val bounds = AxisAlignedBB.fromBounds(robot.x - 2, robot.y - 2, robot.z - 2, robot.x + 3, robot.y + 3, robot.z + 3)
world.getEntitiesWithinAABB(classOf[EntityItem], bounds).map(_.asInstanceOf[EntityItem])
}
@@ -128,7 +129,7 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
val itemsAfter = adjacentItems
val itemsDropped = itemsAfter -- itemsBefore
for (drop <- itemsDropped) {
- drop.delayBeforeCanPickup = 0
+ drop.setNoPickupDelay()
drop.onCollideWithPlayer(this)
}
}
@@ -168,26 +169,27 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
})
}
- def activateBlockOrUseItem(x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float, duration: Double): ActivationType.Value = {
+ def activateBlockOrUseItem(pos: BlockPos, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float, duration: Double): ActivationType.Value = {
callUsingItemInSlot(0, stack => {
- if (shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.RIGHT_CLICK_BLOCK, x, y, z, side, world))) {
+ if (shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.RIGHT_CLICK_BLOCK, world, pos, side))) {
return ActivationType.None
}
val item = if (stack != null) stack.getItem else null
if (!PortalGun.isPortalGun(stack)) {
- if (item != null && item.onItemUseFirst(stack, this, world, x, y, z, side, hitX, hitY, hitZ)) {
+ if (item != null && item.onItemUseFirst(stack, this, world, pos, side, hitX, hitY, hitZ)) {
return ActivationType.ItemUsed
}
}
- val block = world.getBlock(x, y, z)
- val canActivate = block != null && Settings.get.allowActivateBlocks
- val shouldActivate = canActivate && (!isSneaking || (item == null || item.doesSneakBypassUse(world, x, y, z, this)))
+ val state = world.getBlockState(pos)
+ val block = state.getBlock
+ val canActivate = block != Blocks.air && Settings.get.allowActivateBlocks
+ val shouldActivate = canActivate && (!isSneaking || (item == null || item.doesSneakBypassUse(world, pos, this)))
val result =
- if (shouldActivate && block.onBlockActivated(world, x, y, z, this, side, hitX, hitY, hitZ))
+ if (shouldActivate && block.onBlockActivated(world, pos, state, this, side, hitX, hitY, hitZ))
ActivationType.BlockActivated
- else if (isItemUseAllowed(stack) && tryPlaceBlockWhileHandlingFunnySpecialCases(stack, x, y, z, side, hitX, hitY, hitZ))
+ else if (isItemUseAllowed(stack) && tryPlaceBlockWhileHandlingFunnySpecialCases(stack, pos, side, hitX, hitY, hitZ))
ActivationType.ItemPlaced
else if (tryUseItem(stack, duration))
ActivationType.ItemUsed
@@ -200,7 +202,7 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
def useEquippedItem(duration: Double) = {
callUsingItemInSlot(0, stack => {
- if (!shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.RIGHT_CLICK_AIR, 0, 0, 0, 0, world))) {
+ if (!shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.RIGHT_CLICK_AIR, world, getPosition, facing))) {
tryUseItem(stack, duration)
}
else false
@@ -217,18 +219,18 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
// Change the offset at which items are used, to avoid hitting
// the robot itself (e.g. with bows, potions, mining laser, ...).
val offset = facing
- posX += offset.offsetX * 0.6
- posY += offset.offsetY * 0.6
- posZ += offset.offsetZ * 0.6
+ posX += offset.getFrontOffsetX * 0.6
+ posY += offset.getFrontOffsetY * 0.6
+ posZ += offset.getFrontOffsetZ * 0.6
val newStack = stack.useItemRightClick(world, this)
if (isUsingItem) {
val remaining = customItemInUseBecauseMinecraftIsBloodyStupidAndMakesRandomMethodsClientSided.getMaxItemUseDuration - heldTicks
customItemInUseBecauseMinecraftIsBloodyStupidAndMakesRandomMethodsClientSided.onPlayerStoppedUsing(world, this, remaining)
clearItemInUse()
}
- posX -= offset.offsetX * 0.6
- posY -= offset.offsetY * 0.6
- posZ -= offset.offsetZ * 0.6
+ posX -= offset.getFrontOffsetX * 0.6
+ posY -= offset.getFrontOffsetY * 0.6
+ posZ -= offset.getFrontOffsetZ * 0.6
robot.machine.pause(heldTicks / 20.0)
// These are functions to avoid null pointers if newStack is null.
def sizeOrDamageChanged = newStack.stackSize != oldSize || newStack.getItemDamage != oldDamage
@@ -242,69 +244,70 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
}
}
- def placeBlock(slot: Int, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
+ def placeBlock(slot: Int, pos: BlockPos, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
callUsingItemInSlot(slot, stack => {
- if (shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.RIGHT_CLICK_BLOCK, x, y, z, side, world))) {
+ if (shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.RIGHT_CLICK_BLOCK, world, pos, side))) {
return false
}
- tryPlaceBlockWhileHandlingFunnySpecialCases(stack, x, y, z, side, hitX, hitY, hitZ)
+ tryPlaceBlockWhileHandlingFunnySpecialCases(stack, pos, side, hitX, hitY, hitZ)
}, repair = false)
}
- def clickBlock(x: Int, y: Int, z: Int, side: Int): Double = {
+ def clickBlock(pos: BlockPos, side: EnumFacing): Double = {
callUsingItemInSlot(0, stack => {
- if (shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.LEFT_CLICK_BLOCK, x, y, z, side, world))) {
+ if (shouldCancel(() => ForgeEventFactory.onPlayerInteract(this, Action.LEFT_CLICK_BLOCK, world, pos, side))) {
return 0
}
// TODO Is this already handled via the event?
- if (MinecraftServer.getServer.isBlockProtected(world, x, y, z, this)) {
+ if (MinecraftServer.getServer.isBlockProtected(world, pos, this)) {
return 0
}
- val block = world.getBlock(x, y, z)
- val metadata = world.getBlockMetadata(x, y, z)
+ val state = world.getBlockState(pos)
+ val block = state.getBlock
+ val metadata = block.getMetaFromState(state)
val mayClickBlock = block != null
val canClickBlock = mayClickBlock &&
- !block.isAir(world, x, y, z) &&
+ !block.isAir(world, pos) &&
FluidRegistry.lookupFluidForBlock(block) == null
if (!canClickBlock) {
return 0
}
- val breakEvent = new BlockEvent.BreakEvent(x, y, z, world, block, metadata, this)
+ val breakEvent = new BlockEvent.BreakEvent(world, pos, state, this)
MinecraftForge.EVENT_BUS.post(breakEvent)
if (breakEvent.isCanceled) {
return 0
}
- block.onBlockClicked(world, x, y, z, this)
- world.extinguishFire(this, x, y, z, side)
+ block.onBlockClicked(world, pos, this)
+ world.extinguishFire(this, pos, side)
- val isBlockUnbreakable = block.getBlockHardness(world, x, y, z) < 0
- val canDestroyBlock = !isBlockUnbreakable && block.canEntityDestroy(world, x, y, z, this)
+ val isBlockUnbreakable = block.getBlockHardness(world, pos) < 0
+ val canDestroyBlock = !isBlockUnbreakable && block.canEntityDestroy(world, pos, this)
if (!canDestroyBlock) {
return 0
}
- if (world.getWorldInfo.getGameType.isAdventure && !isCurrentToolAdventureModeExempt(x, y, z)) {
+ if (world.getWorldInfo.getGameType.isAdventure && !canPlayerEdit(pos, side, stack)) {
return 0
}
val cobwebOverride = block == Blocks.web && Settings.get.screwCobwebs
- if (!ForgeHooks.canHarvestBlock(block, this, metadata) && !cobwebOverride) {
+ if (!ForgeHooks.canHarvestBlock(block, this, world, pos) && !cobwebOverride) {
return 0
}
- val hardness = block.getBlockHardness(world, x, y, z)
- val strength = getBreakSpeed(block, false, metadata, x, y, z)
+ val hardness = block.getBlockHardness(world, pos)
+ val strength = getBreakSpeed(state, pos)
val breakTime =
if (cobwebOverride) Settings.get.swingDelay
else hardness * 1.5 / strength
- val preEvent = new RobotBreakBlockEvent.Pre(robot, world, x, y, z, breakTime * Settings.get.harvestRatio)
+ val preEvent = new RobotBreakBlockEvent.Pre(robot, world, pos, breakTime * Settings.get.harvestRatio)
MinecraftForge.EVENT_BUS.post(preEvent)
if (preEvent.isCanceled) return 0
val adjustedBreakTime = math.max(0.05, preEvent.getBreakTime)
@@ -317,7 +320,7 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
posY -= 1.62
prevPosY = posY
}
- val cancel = stack != null && stack.getItem.onBlockStartBreak(stack, x, y, z, this)
+ val cancel = stack != null && stack.getItem.onBlockStartBreak(stack, pos, this)
if (cancel && TinkersConstruct.isInfiTool(stack)) {
posY += 1.62
prevPosY = posY
@@ -327,19 +330,20 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
return 0
}
- world.playAuxSFXAtEntity(this, 2001, x, y, z, Block.getIdFromBlock(block) + (metadata << 12))
+ world.playAuxSFXAtEntity(this, 2001, pos, Block.getIdFromBlock(block) + (metadata << 12))
if (stack != null) {
- stack.func_150999_a(world, block, x, y, z, this)
+ stack.onBlockDestroyed(world, block, pos, this)
}
- block.onBlockHarvested(world, x, y, z, metadata, this)
- if (block.removedByPlayer(world, this, x, y, z, block.canHarvestBlock(this, metadata))) {
- block.onBlockDestroyedByPlayer(world, x, y, z, metadata)
+ val te = world.getTileEntity(pos)
+ block.onBlockHarvested(world, pos, state, this)
+ if (block.removedByPlayer(world, pos, this, block.canHarvestBlock(world, pos, this))) {
+ block.onBlockDestroyedByPlayer(world, pos, state)
// Note: the block has been destroyed by `removeBlockByPlayer`. This
// check only serves to test whether the block can drop anything at all.
- if (block.canHarvestBlock(this, metadata)) {
- block.harvestBlock(world, this, x, y, z, metadata)
+ if (block.canHarvestBlock(world, pos, this)) {
+ block.harvestBlock(world, this, pos, state, te)
MinecraftForge.EVENT_BUS.post(new RobotBreakBlockEvent.Post(robot, breakEvent.getExpToDrop))
}
else if (stack != null) {
@@ -407,18 +411,18 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
}
}
- private def tryPlaceBlockWhileHandlingFunnySpecialCases(stack: ItemStack, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
+ private def tryPlaceBlockWhileHandlingFunnySpecialCases(stack: ItemStack, pos: BlockPos, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
stack != null && stack.stackSize > 0 && {
- val event = new RobotPlaceBlockEvent.Pre(robot, stack, world, x, y, z)
+ val event = new RobotPlaceBlockEvent.Pre(robot, stack, world, pos)
MinecraftForge.EVENT_BUS.post(event)
if (event.isCanceled) false
else {
val fakeEyeHeight = if (rotationPitch < 0 && isSomeKindOfPiston(stack)) 1.82 else 0
setPosition(posX, posY - fakeEyeHeight, posZ)
- val didPlace = stack.tryPlaceItemIntoWorld(this, world, x, y, z, side, hitX, hitY, hitZ)
+ val didPlace = stack.onItemUse(this, world, pos, side, hitX, hitY, hitZ)
setPosition(posX, posY + fakeEyeHeight, posZ)
if (didPlace) {
- MinecraftForge.EVENT_BUS.post(new RobotPlaceBlockEvent.Post(robot, stack, world, x, y, z))
+ MinecraftForge.EVENT_BUS.post(new RobotPlaceBlockEvent.Post(robot, stack, world, pos))
}
didPlace
}
@@ -428,7 +432,7 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
private def isSomeKindOfPiston(stack: ItemStack) =
stack.getItem match {
case itemBlock: ItemBlock =>
- val block = itemBlock.field_150939_a
+ val block = itemBlock.getBlock
block != null && block.isInstanceOf[BlockPistonBase]
case _ => false
}
@@ -452,10 +456,6 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
MinecraftForge.EVENT_BUS.post(new RobotExhaustionEvent(robot, amount))
}
- override def displayGUIMerchant(merchant: IMerchant, name: String) {
- merchant.setCustomer(null)
- }
-
override def closeScreen() {}
override def swingItem() {}
@@ -488,29 +488,21 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta
override def mountEntity(entity: Entity) {}
- override def sleepInBedAt(x: Int, y: Int, z: Int) = EnumStatus.OTHER_PROBLEM
+ override def trySleep(bedLocation: BlockPos) = EnumStatus.OTHER_PROBLEM
override def addChatMessage(message: IChatComponent) {}
- override def displayGUIWorkbench(x: Int, y: Int, z: Int) {}
-
- override def displayGUIEnchantment(x: Int, y: Int, z: Int, idk: String) {}
-
- override def displayGUIAnvil(x: Int, y: Int, z: Int) {}
-
override def displayGUIChest(inventory: IInventory) {}
- override def displayGUIHopperMinecart(cart: EntityMinecartHopper) {}
+ override def displayGUIBook(bookStack: ItemStack) {}
+
+ override def displayVillagerTradeGui(villager: IMerchant): Unit = {
+ villager.setCustomer(null)
+ }
+
+ override def displayGui(guiOwner: IInteractionObject) {}
override def displayGUIHorse(horse: EntityHorse, inventory: IInventory) {}
- override def func_146104_a(tileEntity: TileEntityBeacon) {}
-
- override def func_146098_a(tileEntity: TileEntityBrewingStand) {}
-
- override def func_146102_a(tileEntity: TileEntityDispenser) {}
-
- override def func_146101_a(tileEntity: TileEntityFurnace) {}
-
- override def func_146093_a(tileEntity: TileEntityHopper) {}
+ override def openEditSign(signTile: TileEntitySign) {}
}
diff --git a/src/main/scala/li/cil/oc/server/component/robot/Robot.scala b/src/main/scala/li/cil/oc/server/component/robot/Robot.scala
index 742024cb2..d444d97fe 100644
--- a/src/main/scala/li/cil/oc/server/component/robot/Robot.scala
+++ b/src/main/scala/li/cil/oc/server/component/robot/Robot.scala
@@ -22,11 +22,12 @@ import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityMinecart
import net.minecraft.nbt.NBTTagCompound
+import net.minecraft.util.BlockPos
import net.minecraft.util.MovingObjectPosition
import net.minecraft.util.MovingObjectPosition.MovingObjectType
import net.minecraft.util.Vec3
import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.convert.WrapAsScala._
@@ -68,7 +69,7 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
override protected def checkSideForAction(args: Arguments, n: Int) = robot.toGlobal(args.checkSideForAction(n))
- private def checkSideForFace(args: Arguments, n: Int, facing: ForgeDirection) = robot.toGlobal(args.checkSideForFace(n, robot.toLocal(facing)))
+ private def checkSideForFace(args: Arguments, n: Int, facing: EnumFacing) = robot.toGlobal(args.checkSideForFace(n, robot.toLocal(facing)))
// ----------------------------------------------------------------------- //
@@ -94,7 +95,7 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
}
else {
// Always try the direction we're looking first.
- Iterable(facing) ++ ForgeDirection.VALID_DIRECTIONS.filter(side => side != facing && side != facing.getOpposite).toIterable
+ Iterable(facing) ++ EnumFacing.values.filter(side => side != facing && side != facing.getOpposite).toIterable
}
val sneaky = args.isBoolean(2) && args.checkBoolean(2)
val stack = robot.inventory.selectedItemStack
@@ -107,11 +108,11 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
player.setSneaking(sneaky)
val success = Option(pick(player, Settings.get.useAndPlaceRange)) match {
case Some(hit) if hit.typeOfHit == MovingObjectType.BLOCK =>
- val (bx, by, bz, hx, hy, hz) = clickParamsFromHit(hit)
- player.placeBlock(robot.selectedSlot, bx, by, bz, hit.sideHit, hx, hy, hz)
+ val (blockPos, hx, hy, hz) = clickParamsFromHit(hit)
+ player.placeBlock(robot.selectedSlot, blockPos, hit.sideHit, hx, hy, hz)
case None if canPlaceInAir && player.closestEntity[Entity]().isEmpty =>
- val (bx, by, bz, hx, hy, hz) = clickParamsForPlace(facing)
- player.placeBlock(robot.selectedSlot, bx, by, bz, facing.ordinal, hx, hy, hz)
+ val (blockPos, hx, hy, hz) = clickParamsForPlace(facing)
+ player.placeBlock(robot.selectedSlot, blockPos, facing, hx, hy, hz)
case _ => false
}
player.setSneaking(false)
@@ -137,7 +138,7 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
}
else {
// Always try the direction we're looking first.
- Iterable(facing) ++ ForgeDirection.VALID_DIRECTIONS.filter(side => side != facing && side != facing.getOpposite).toIterable
+ Iterable(facing) ++ EnumFacing.values.filter(side => side != facing && side != facing.getOpposite).toIterable
}
val sneaky = args.isBoolean(2) && args.checkBoolean(2)
@@ -160,8 +161,8 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
triggerDelay()
(true, "entity")
}
- def click(player: Player, x: Int, y: Int, z: Int, side: Int) = {
- val breakTime = player.clickBlock(x, y, z, side)
+ def click(player: Player, pos: BlockPos, side: EnumFacing) = {
+ val breakTime = player.clickBlock(pos, side)
val broke = breakTime > 0
if (broke) {
// Subtract one tick because we take one to trigger the action - a bit
@@ -186,7 +187,7 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
case MovingObjectType.ENTITY =>
attack(player, hit.entityHit)
case MovingObjectType.BLOCK =>
- click(player, hit.blockX, hit.blockY, hit.blockZ, hit.sideHit)
+ click(player, hit.getBlockPos, hit.sideHit)
case _ =>
// Retry with full block bounds, disregarding swing range.
player.closestEntity[EntityLivingBase]() match {
@@ -221,7 +222,7 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
}
else {
// Always try the direction we're looking first.
- Iterable(facing) ++ ForgeDirection.VALID_DIRECTIONS.filter(side => side != facing && side != facing.getOpposite).toIterable
+ Iterable(facing) ++ EnumFacing.values.filter(side => side != facing && side != facing.getOpposite).toIterable
}
val sneaky = args.isBoolean(2) && args.checkBoolean(2)
val duration =
@@ -261,16 +262,16 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
triggerDelay()
(true, "item_interacted")
case Some(hit) if hit.typeOfHit == MovingObjectType.BLOCK =>
- val (bx, by, bz, hx, hy, hz) = clickParamsFromHit(hit)
- activationResult(player.activateBlockOrUseItem(bx, by, bz, hit.sideHit, hx, hy, hz, duration))
+ val (blockPos, hx, hy, hz) = clickParamsFromHit(hit)
+ activationResult(player.activateBlockOrUseItem(blockPos, hit.sideHit, hx, hy, hz, duration))
case _ =>
(if (canPlaceInAir) {
- val (bx, by, bz, hx, hy, hz) = clickParamsForPlace(facing)
- if (player.placeBlock(0, bx, by, bz, facing.ordinal, hx, hy, hz))
+ val (blockPos, hx, hy, hz) = clickParamsForPlace(facing)
+ if (player.placeBlock(0, blockPos, facing, hx, hy, hz))
ActivationType.ItemPlaced
else {
- val (bx, by, bz, hx, hy, hz) = clickParamsForItemUse(facing, side)
- player.activateBlockOrUseItem(bx, by, bz, side.getOpposite.ordinal, hx, hy, hz, duration)
+ val (blockPos, hx, hy, hz) = clickParamsForItemUse(facing, side)
+ player.activateBlockOrUseItem(blockPos, side.getOpposite, hx, hy, hz, duration)
}
} else ActivationType.None) match {
case ActivationType.None =>
@@ -339,8 +340,8 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
def turn(context: Context, args: Arguments): Array[AnyRef] = {
val clockwise = args.checkBoolean(0)
if (node.tryChangeBuffer(-Settings.get.robotTurnCost)) {
- if (clockwise) robot.rotate(ForgeDirection.UP)
- else robot.rotate(ForgeDirection.DOWN)
+ if (clockwise) robot.rotate(EnumFacing.UP)
+ else robot.rotate(EnumFacing.DOWN)
robot.animateTurn(clockwise, Settings.get.turnDelay)
context.pause(Settings.get.turnDelay)
result(true)
@@ -403,44 +404,44 @@ class Robot(val robot: tileentity.Robot) extends prefab.ManagedEnvironment with
// ----------------------------------------------------------------------- //
private def pick(player: Player, range: Double) = {
- val origin = Vec3.createVectorHelper(
- player.posX + player.facing.offsetX * 0.5,
- player.posY + player.facing.offsetY * 0.5,
- player.posZ + player.facing.offsetZ * 0.5)
+ val origin = new Vec3(
+ player.posX + player.facing.getFrontOffsetX * 0.5,
+ player.posY + player.facing.getFrontOffsetY * 0.5,
+ player.posZ + player.facing.getFrontOffsetZ * 0.5)
val blockCenter = origin.addVector(
- player.facing.offsetX * 0.5,
- player.facing.offsetY * 0.5,
- player.facing.offsetZ * 0.5)
+ player.facing.getFrontOffsetX * 0.5,
+ player.facing.getFrontOffsetY * 0.5,
+ player.facing.getFrontOffsetZ * 0.5)
val target = blockCenter.addVector(
- player.side.offsetX * range,
- player.side.offsetY * range,
- player.side.offsetZ * range)
+ player.side.getFrontOffsetX * range,
+ player.side.getFrontOffsetY * range,
+ player.side.getFrontOffsetZ * range)
val hit = world.rayTraceBlocks(origin, target)
player.closestEntity[Entity]() match {
- case Some(entity@(_: EntityLivingBase | _: EntityMinecart)) if hit == null || Vec3.createVectorHelper(player.posX, player.posY, player.posZ).distanceTo(hit.hitVec) > player.getDistanceToEntity(entity) => new MovingObjectPosition(entity)
+ case Some(entity@(_: EntityLivingBase | _: EntityMinecart)) if hit == null || new Vec3(player.posX, player.posY, player.posZ).distanceTo(hit.hitVec) > player.getDistanceToEntity(entity) => new MovingObjectPosition(entity)
case _ => hit
}
}
- private def clickParamsForPlace(facing: ForgeDirection) = {
- (position.x, position.y, position.z,
- 0.5f + facing.offsetX * 0.5f,
- 0.5f + facing.offsetY * 0.5f,
- 0.5f + facing.offsetZ * 0.5f)
+ private def clickParamsForPlace(facing: EnumFacing) = {
+ (position.toBlockPos,
+ 0.5f + facing.getFrontOffsetX * 0.5f,
+ 0.5f + facing.getFrontOffsetY * 0.5f,
+ 0.5f + facing.getFrontOffsetZ * 0.5f)
}
- private def clickParamsForItemUse(facing: ForgeDirection, side: ForgeDirection) = {
+ private def clickParamsForItemUse(facing: EnumFacing, side: EnumFacing) = {
val blockPos = position.offset(facing).offset(side)
- (blockPos.x, blockPos.y, blockPos.z,
- 0.5f - side.offsetX * 0.5f,
- 0.5f - side.offsetY * 0.5f,
- 0.5f - side.offsetZ * 0.5f)
+ (blockPos.toBlockPos,
+ 0.5f - side.getFrontOffsetX * 0.5f,
+ 0.5f - side.getFrontOffsetY * 0.5f,
+ 0.5f - side.getFrontOffsetZ * 0.5f)
}
private def clickParamsFromHit(hit: MovingObjectPosition) = {
- (hit.blockX, hit.blockY, hit.blockZ,
- (hit.hitVec.xCoord - hit.blockX).toFloat,
- (hit.hitVec.yCoord - hit.blockY).toFloat,
- (hit.hitVec.zCoord - hit.blockZ).toFloat)
+ (hit.getBlockPos,
+ (hit.hitVec.xCoord - hit.getBlockPos.getX).toFloat,
+ (hit.hitVec.yCoord - hit.getBlockPos.getY).toFloat,
+ (hit.hitVec.zCoord - hit.getBlockPos.getZ).toFloat)
}
}
diff --git a/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControl.scala b/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControl.scala
index e263249b5..54ca1a883 100644
--- a/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControl.scala
+++ b/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControl.scala
@@ -5,12 +5,11 @@ import li.cil.oc.api.machine.Arguments
import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
import li.cil.oc.util.ExtendedArguments._
-import li.cil.oc.util.ExtendedWorld._
import li.cil.oc.util.InventoryUtils
import li.cil.oc.util.ResultWrapper.result
import net.minecraft.entity.item.EntityItem
import net.minecraft.item.ItemBlock
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait InventoryWorldControl extends InventoryAware with WorldAware with SideRestricted {
@Callback
@@ -19,9 +18,10 @@ trait InventoryWorldControl extends InventoryAware with WorldAware with SideRest
stackInSlot(selectedSlot) match {
case Some(stack) => Option(stack.getItem) match {
case Some(item: ItemBlock) =>
- val blockPos = position.offset(side)
- val idMatches = item.field_150939_a == world.getBlock(blockPos)
- val subTypeMatches = !item.getHasSubtypes || item.getMetadata(stack.getItemDamage) == world.getBlockMetadata(blockPos)
+ val blockPos = position.offset(side).toBlockPos
+ val state = world.getBlockState(blockPos)
+ val idMatches = item.getBlock == state.getBlock
+ val subTypeMatches = !item.getHasSubtypes || item.getMetadata(stack.getItemDamage) == state.getBlock.getMetaFromState(state)
return result(idMatches && subTypeMatches)
case _ =>
}
@@ -74,7 +74,7 @@ trait InventoryWorldControl extends InventoryAware with WorldAware with SideRest
result(true)
}
else {
- for (entity <- suckableItems(facing) if !entity.isDead && entity.delayBeforeCanPickup <= 0) {
+ for (entity <- suckableItems(facing) if !entity.isDead && !entity.cannotPickup) {
val stack = entity.getEntityItem
val size = stack.stackSize
onSuckCollect(entity)
@@ -87,7 +87,7 @@ trait InventoryWorldControl extends InventoryAware with WorldAware with SideRest
}
}
- protected def suckableItems(side: ForgeDirection) = entitiesOnSide[EntityItem](side)
+ protected def suckableItems(side: EnumFacing) = entitiesOnSide[EntityItem](side)
protected def onSuckCollect(entity: EntityItem): Unit = entity.onCollideWithPlayer(fakePlayer)
}
diff --git a/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControlMk2.scala b/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControlMk2.scala
index 417765b95..1aee2f33e 100644
--- a/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControlMk2.scala
+++ b/src/main/scala/li/cil/oc/server/component/traits/InventoryWorldControlMk2.scala
@@ -8,7 +8,7 @@ import li.cil.oc.server.component.result
import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.InventoryUtils
import net.minecraft.inventory.IInventory
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait InventoryWorldControlMk2 extends InventoryAware with WorldAware with SideRestricted {
@Callback(doc = """function(facing:number, slot:number[, count:number]):boolean -- Drops the selected item stack into the specified slot of an inventory.""")
@@ -54,7 +54,7 @@ trait InventoryWorldControlMk2 extends InventoryAware with WorldAware with SideR
})
}
- private def withInventory(side: ForgeDirection, f: IInventory => Array[AnyRef]) =
+ private def withInventory(side: EnumFacing, f: IInventory => Array[AnyRef]) =
InventoryUtils.inventoryAt(position.offset(side)) match {
case Some(inventory) if inventory.isUseableByPlayer(fakePlayer) => f(inventory)
case _ => result(Unit, "no inventory")
diff --git a/src/main/scala/li/cil/oc/server/component/traits/SideRestricted.scala b/src/main/scala/li/cil/oc/server/component/traits/SideRestricted.scala
index c65f2df9e..1201e3522 100644
--- a/src/main/scala/li/cil/oc/server/component/traits/SideRestricted.scala
+++ b/src/main/scala/li/cil/oc/server/component/traits/SideRestricted.scala
@@ -1,8 +1,8 @@
package li.cil.oc.server.component.traits
import li.cil.oc.api.machine.Arguments
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait SideRestricted {
- protected def checkSideForAction(args: Arguments, n: Int): ForgeDirection
+ protected def checkSideForAction(args: Arguments, n: Int): EnumFacing
}
diff --git a/src/main/scala/li/cil/oc/server/component/traits/WorldAware.scala b/src/main/scala/li/cil/oc/server/component/traits/WorldAware.scala
index a99c9b316..071633938 100644
--- a/src/main/scala/li/cil/oc/server/component/traits/WorldAware.scala
+++ b/src/main/scala/li/cil/oc/server/component/traits/WorldAware.scala
@@ -12,7 +12,7 @@ import net.minecraft.world.WorldServer
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.FakePlayer
import net.minecraftforge.common.util.FakePlayerFactory
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import net.minecraftforge.event.world.BlockEvent
import net.minecraftforge.fluids.FluidRegistry
@@ -41,16 +41,16 @@ trait WorldAware {
entitiesInBounds[Type](blockPos.bounds)
}
- def entitiesOnSide[Type <: Entity : ClassTag](side: ForgeDirection) = {
+ def entitiesOnSide[Type <: Entity : ClassTag](side: EnumFacing) = {
entitiesInBlock[Type](position.offset(side))
}
- def closestEntity[Type <: Entity : ClassTag](side: ForgeDirection) = {
+ def closestEntity[Type <: Entity : ClassTag](side: EnumFacing) = {
val blockPos = position.offset(side)
Option(world.findNearestEntityWithinAABB(classTag[Type].runtimeClass, blockPos.bounds, fakePlayer)).map(_.asInstanceOf[Type])
}
- def blockContent(side: ForgeDirection) = {
+ def blockContent(side: EnumFacing) = {
closestEntity[Entity](side) match {
case Some(_@(_: EntityLivingBase | _: EntityMinecart)) =>
(true, "entity")
@@ -62,12 +62,12 @@ trait WorldAware {
(false, "air")
}
else if (FluidRegistry.lookupFluidForBlock(block) != null) {
- val event = new BlockEvent.BreakEvent(blockPos.x, blockPos.y, blockPos.z, world, block, metadata, fakePlayer)
+ val event = new BlockEvent.BreakEvent(world, blockPos.toBlockPos, metadata, fakePlayer)
MinecraftForge.EVENT_BUS.post(event)
(event.isCanceled, "liquid")
}
else if (block.isReplaceable(blockPos)) {
- val event = new BlockEvent.BreakEvent(blockPos.x, blockPos.y, blockPos.z, world, block, metadata, fakePlayer)
+ val event = new BlockEvent.BreakEvent(world, blockPos.toBlockPos, metadata, fakePlayer)
MinecraftForge.EVENT_BUS.post(event)
(event.isCanceled, "replaceable")
}
diff --git a/src/main/scala/li/cil/oc/server/component/traits/WorldInventoryAnalytics.scala b/src/main/scala/li/cil/oc/server/component/traits/WorldInventoryAnalytics.scala
index 936b64830..e5eaff024 100644
--- a/src/main/scala/li/cil/oc/server/component/traits/WorldInventoryAnalytics.scala
+++ b/src/main/scala/li/cil/oc/server/component/traits/WorldInventoryAnalytics.scala
@@ -10,7 +10,7 @@ import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.InventoryUtils
import net.minecraft.inventory.IInventory
import net.minecraft.item.ItemStack
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
trait WorldInventoryAnalytics extends WorldAware with SideRestricted with NetworkAware {
@Callback(doc = """function(side:number):number -- Get the number of slots in the inventory on the specified side of the robot.""")
@@ -64,7 +64,7 @@ trait WorldInventoryAnalytics extends WorldAware with SideRestricted with Networ
withInventory(facing, inventory => store(inventory.getStackInSlot(args.checkSlot(inventory, 1))))
}
- private def withInventory(side: ForgeDirection, f: IInventory => Array[AnyRef]) =
+ private def withInventory(side: EnumFacing, f: IInventory => Array[AnyRef]) =
InventoryUtils.inventoryAt(position.offset(side)) match {
case Some(inventory) if inventory.isUseableByPlayer(fakePlayer) => f(inventory)
case _ => result(Unit, "no inventory")
diff --git a/src/main/scala/li/cil/oc/server/driver/CompoundBlockDriver.scala b/src/main/scala/li/cil/oc/server/driver/CompoundBlockDriver.scala
index f7a4fbbb4..8c88f8ec0 100644
--- a/src/main/scala/li/cil/oc/server/driver/CompoundBlockDriver.scala
+++ b/src/main/scala/li/cil/oc/server/driver/CompoundBlockDriver.scala
@@ -1,7 +1,8 @@
package li.cil.oc.server.driver
import com.google.common.base.Strings
-import cpw.mods.fml.relauncher.ReflectionHelper
+import net.minecraft.util.BlockPos
+import net.minecraftforge.fml.relauncher.ReflectionHelper
import li.cil.oc.api.driver
import li.cil.oc.api.driver.NamedBlock
import li.cil.oc.api.network.ManagedEnvironment
@@ -12,52 +13,50 @@ import net.minecraft.tileentity.TileEntity
import net.minecraft.world.World
class CompoundBlockDriver(val blocks: driver.Block*) extends driver.Block {
- override def createEnvironment(world: World, x: Int, y: Int, z: Int) = {
+ override def createEnvironment(world: World, pos: BlockPos) = {
val list = blocks.map {
- driver => Option(driver.createEnvironment(world, x, y, z)) match {
+ driver => Option(driver.createEnvironment(world, pos)) match {
case Some(environment) => (driver, environment)
case _ => null
}
} filter (_ != null)
if (list.isEmpty) null
- else new CompoundBlockEnvironment(cleanName(tryGetName(world, x, y, z, list.map(_._2))), list: _*)
+ else new CompoundBlockEnvironment(cleanName(tryGetName(world, pos, list.map(_._2))), list: _*)
}
- override def worksWith(world: World, x: Int, y: Int, z: Int) = blocks.forall(_.worksWith(world, x, y, z))
+ override def worksWith(world: World, pos: BlockPos) = blocks.forall(_.worksWith(world, pos))
override def equals(obj: Any) = obj match {
case multi: CompoundBlockDriver if multi.blocks.length == blocks.length => blocks.intersect(multi.blocks).length == blocks.length
case _ => false
}
- private def tryGetName(world: World, x: Int, y: Int, z: Int, environments: Seq[ManagedEnvironment]): String = {
+ // TODO rework this method
+ private def tryGetName(world: World, pos: BlockPos, environments: Seq[ManagedEnvironment]): String = {
environments.collect {
case named: NamedBlock => named
}.sortBy(_.priority).lastOption match {
case Some(named) => return named.preferredName
case _ => // No preferred name.
}
- try world.getTileEntity(x, y, z) match {
- case inventory: IInventory if !Strings.isNullOrEmpty(inventory.getInventoryName) => return inventory.getInventoryName.stripPrefix("container.")
+ try world.getTileEntity(pos) match {
+ case inventory: IInventory if !Strings.isNullOrEmpty(inventory.getName) => return inventory.getName.stripPrefix("container.")
} catch {
case _: Throwable =>
}
try {
- val block = world.getBlock(x, y, z)
- val stack = try Option(block.getPickBlock(null, world, x, y, z)) catch {
- case _: Throwable =>
- if (Item.getItemFromBlock(block) != null) {
- Some(new ItemStack(block, 1, block.getDamageValue(world, x, y, z)))
+ val block = world.getBlockState(pos).getBlock
+ val stack = if (Item.getItemFromBlock(block) != null) {
+ Some(new ItemStack(block, 1, block.getDamageValue(world, pos)))
}
else None
- }
if (stack.isDefined) {
return stack.get.getUnlocalizedName.stripPrefix("tile.")
}
} catch {
case _: Throwable =>
}
- try world.getTileEntity(x, y, z) match {
+ try world.getTileEntity(pos) match {
case tileEntity: TileEntity =>
val map = ReflectionHelper.getPrivateValue[java.util.Map[Class[_], String], TileEntity](classOf[TileEntity], tileEntity, "classToNameMap", "field_145853_j")
return map.get(tileEntity.getClass)
diff --git a/src/main/scala/li/cil/oc/server/driver/Registry.scala b/src/main/scala/li/cil/oc/server/driver/Registry.scala
index 0533efca1..d3d32ad11 100644
--- a/src/main/scala/li/cil/oc/server/driver/Registry.scala
+++ b/src/main/scala/li/cil/oc/server/driver/Registry.scala
@@ -9,6 +9,7 @@ import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.driver.item.HostAware
import li.cil.oc.api.machine.Value
import net.minecraft.item.ItemStack
+import net.minecraft.util.BlockPos
import net.minecraft.world.World
import scala.collection.convert.WrapAsJava._
@@ -57,8 +58,8 @@ private[oc] object Registry extends api.detail.DriverAPI {
if (!converters.contains(converter)) converters += converter
}
- override def driverFor(world: World, x: Int, y: Int, z: Int) =
- blocks.filter(_.worksWith(world, x, y, z)) match {
+ override def driverFor(world: World, pos: BlockPos) =
+ blocks.filter(_.worksWith(world, pos)) match {
case drivers if drivers.nonEmpty => new CompoundBlockDriver(drivers: _*)
case _ => null
}
diff --git a/src/main/scala/li/cil/oc/server/fs/ComputerCraftFileSystem.scala b/src/main/scala/li/cil/oc/server/fs/ComputerCraftFileSystem.scala
deleted file mode 100644
index a478acdf9..000000000
--- a/src/main/scala/li/cil/oc/server/fs/ComputerCraftFileSystem.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-package li.cil.oc.server.fs
-
-import dan200.computercraft.api.filesystem.IMount
-
-class ComputerCraftFileSystem(val mount: IMount) extends InputStreamFileSystem {
- override def spaceTotal = 0
-
- override def spaceUsed = 0
-
- // ----------------------------------------------------------------------- //
-
- override def exists(path: String) = mount.exists(path)
-
- override def isDirectory(path: String) = mount.isDirectory(path)
-
- override def lastModified(path: String) = 0L
-
- override def list(path: String) = {
- val result = new java.util.ArrayList[String]
- mount.list(path, result)
- result.toArray.map(_.asInstanceOf[String])
- }
-
- override def size(path: String) = mount.getSize(path)
-
- // ----------------------------------------------------------------------- //
-
- protected def openInputChannel(path: String) = try {
- Some(new InputStreamChannel(mount.openForRead(path)))
- } catch {
- case _: Throwable => None
- }
-}
diff --git a/src/main/scala/li/cil/oc/server/fs/ComputerCraftWritableFileSystem.scala b/src/main/scala/li/cil/oc/server/fs/ComputerCraftWritableFileSystem.scala
deleted file mode 100644
index 4cbde8c0a..000000000
--- a/src/main/scala/li/cil/oc/server/fs/ComputerCraftWritableFileSystem.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-package li.cil.oc.server.fs
-
-import java.io.IOException
-import java.io.OutputStream
-
-import dan200.computercraft.api.filesystem.IWritableMount
-import li.cil.oc.api.fs.Mode
-
-class ComputerCraftWritableFileSystem(override val mount: IWritableMount)
- extends ComputerCraftFileSystem(mount)
- with OutputStreamFileSystem {
-
- override def delete(path: String) = try {
- mount.delete(path)
- true
- } catch {
- case _: Throwable => false
- }
-
- override def makeDirectory(path: String) = try {
- mount.makeDirectory(path)
- true
- } catch {
- case _: Throwable => false
- }
-
- override protected def openOutputHandle(id: Int, path: String, mode: Mode): Option[OutputHandle] = try {
- Some(new ComputerCraftOutputHandle(mount, mode match {
- case Mode.Append => mount.openForAppend(path)
- case Mode.Write => mount.openForWrite(path)
- case _ => throw new IllegalArgumentException()
- }, this, id, path))
- } catch {
- case _: Throwable => None
- }
-
- protected class ComputerCraftOutputHandle(val mount: IWritableMount, val stream: OutputStream, owner: OutputStreamFileSystem, handle: Int, path: String) extends OutputHandle(owner, handle, path) {
- override def length() = mount.getSize(path)
-
- override def position() = throw new IOException("bad file descriptor")
-
- override def write(value: Array[Byte]) = stream.write(value)
- }
-
-}
diff --git a/src/main/scala/li/cil/oc/server/fs/FileSystem.scala b/src/main/scala/li/cil/oc/server/fs/FileSystem.scala
index 2c48b6bb2..aa6c630e3 100644
--- a/src/main/scala/li/cil/oc/server/fs/FileSystem.scala
+++ b/src/main/scala/li/cil/oc/server/fs/FileSystem.scala
@@ -11,7 +11,6 @@ import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.fs.Label
import li.cil.oc.api.fs.Mode
import li.cil.oc.integration.Mods
-import li.cil.oc.integration.computercraft.DriverComputerCraftMedia
import li.cil.oc.server.component
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
@@ -98,12 +97,6 @@ object FileSystem extends api.detail.FileSystemAPI {
def fromMemory(capacity: Long): api.fs.FileSystem = new RamFileSystem(capacity)
- def fromComputerCraft(mount: AnyRef): api.fs.FileSystem =
- if (Mods.ComputerCraft.isAvailable) {
- DriverComputerCraftMedia.createFileSystem(mount).orNull
- }
- else null
-
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, host: EnvironmentHost, sound: String) =
Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label, Option(host), Option(sound)))).orNull
diff --git a/src/main/scala/li/cil/oc/server/machine/ArgumentsImpl.scala b/src/main/scala/li/cil/oc/server/machine/ArgumentsImpl.scala
index 190dbddb0..5c912d9a9 100644
--- a/src/main/scala/li/cil/oc/server/machine/ArgumentsImpl.scala
+++ b/src/main/scala/li/cil/oc/server/machine/ArgumentsImpl.scala
@@ -4,10 +4,9 @@ import java.util
import com.google.common.base.Charsets
import li.cil.oc.api.machine.Arguments
+import li.cil.oc.util.ItemUtils
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
-import net.minecraft.nbt.CompressedStreamTools
-import net.minecraft.nbt.NBTSizeTracker
import net.minecraft.nbt.NBTTagCompound
import scala.collection.convert.WrapAsJava._
@@ -225,5 +224,5 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends Arguments {
}
}
- private def toNbtTagCompound(data: Array[Byte]) = Option(CompressedStreamTools.func_152457_a(data, NBTSizeTracker.field_152451_a))
+ private def toNbtTagCompound(data: Array[Byte]) = Option(ItemUtils.loadTag(data))
}
diff --git a/src/main/scala/li/cil/oc/server/machine/Machine.scala b/src/main/scala/li/cil/oc/server/machine/Machine.scala
index 565afbd5d..5861bfc59 100644
--- a/src/main/scala/li/cil/oc/server/machine/Machine.scala
+++ b/src/main/scala/li/cil/oc/server/machine/Machine.scala
@@ -124,8 +124,8 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
_users.synchronized(_users.isEmpty || _users.contains(player)) ||
MinecraftServer.getServer.isSinglePlayer || {
val config = MinecraftServer.getServer.getConfigurationManager
- val entity = config.func_152612_a(player)
- entity != null && config.func_152596_g(entity.getGameProfile)
+ val entity = config.getPlayerByUsername(player)
+ entity != null && config.canSendCommands(entity.getGameProfile)
}
override def isRunning = state.synchronized(state.top != Machine.State.Stopped && state.top != Machine.State.Stopping)
@@ -487,7 +487,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
case Array(name: String, args@_*) if message.name == "computer.signal" =>
signal(name, Seq(message.source.address) ++ args: _*)
case Array(player: EntityPlayer, name: String, args@_*) if message.name == "computer.checked_signal" =>
- if (canInteract(player.getCommandSenderName))
+ if (canInteract(player.getName))
signal(name, Seq(message.source.address) ++ args: _*)
case _ =>
}
@@ -589,7 +589,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
bootAddress = nbt.getString("bootAddress")
state.pushAll(nbt.getIntArray("state").reverse.map(Machine.State(_)))
- nbt.getTagList("users", NBT.TAG_STRING).foreach((tag: NBTTagString) => _users += tag.func_150285_a_())
+ nbt.getTagList("users", NBT.TAG_STRING).foreach((tag: NBTTagString) => _users += tag.getString)
if (nbt.hasKey("message")) {
message = Some(nbt.getString("message"))
}
@@ -610,11 +610,11 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
val argsLength = argsNbt.getInteger("length")
new Machine.Signal(signalNbt.getString("name"),
(0 until argsLength).map("arg" + _).map(argsNbt.getTag).map {
- case tag: NBTTagByte if tag.func_150290_f == -1 => null
- case tag: NBTTagByte => Boolean.box(tag.func_150290_f == 1)
- case tag: NBTTagDouble => Double.box(tag.func_150286_g)
- case tag: NBTTagString => tag.func_150285_a_
- case tag: NBTTagByteArray => tag.func_150292_c
+ case tag: NBTTagByte if tag.getByte == -1 => null
+ case tag: NBTTagByte => Boolean.box(tag.getByte == 1)
+ case tag: NBTTagDouble => Double.box(tag.getDouble)
+ case tag: NBTTagString => tag.getString
+ case tag: NBTTagByteArray => tag.getByteArray
case tag: NBTTagList =>
val data = mutable.Map.empty[String, String]
for (i <- 0 until tag.tagCount by 2) {
diff --git a/src/main/scala/li/cil/oc/server/network/Network.scala b/src/main/scala/li/cil/oc/server/network/Network.scala
index deb0043fb..e461b2c6b 100644
--- a/src/main/scala/li/cil/oc/server/network/Network.scala
+++ b/src/main/scala/li/cil/oc/server/network/Network.scala
@@ -1,10 +1,14 @@
package li.cil.oc.server.network
+/* FMP
import codechicken.lib.vec.Cuboid6
import codechicken.multipart.JNormalOcclusion
import codechicken.multipart.NormalOcclusionTest
import codechicken.multipart.TFacePart
import codechicken.multipart.TileMultipart
+import li.cil.oc.common.block.Cable
+import li.cil.oc.integration.fmp.CablePart
+*/
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import li.cil.oc.api
@@ -14,16 +18,14 @@ import li.cil.oc.api.network.SidedEnvironment
import li.cil.oc.api.network.Visibility
import li.cil.oc.api.network.WirelessEndpoint
import li.cil.oc.api.network.{Node => ImmutableNode}
-import li.cil.oc.common.block.Cable
import li.cil.oc.common.tileentity
import li.cil.oc.integration.Mods
-import li.cil.oc.integration.fmp.CablePart
import li.cil.oc.server.network.{Node => MutableNode}
-import li.cil.oc.util.Color
import li.cil.oc.util.SideTracker
+import net.minecraft.item.EnumDyeColor
import net.minecraft.nbt._
import net.minecraft.tileentity.TileEntity
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.JavaConverters._
import scala.collection.mutable
@@ -382,15 +384,12 @@ private class Network private(private val data: mutable.Map[String, Network.Vert
object Network extends api.detail.NetworkAPI {
override def joinOrCreateNetwork(tileEntity: TileEntity): Unit =
- if (!tileEntity.isInvalid && !tileEntity.getWorldObj.isRemote) {
- for (side <- ForgeDirection.VALID_DIRECTIONS) {
- val (nx, ny, nz) = (
- tileEntity.xCoord + side.offsetX,
- tileEntity.yCoord + side.offsetY,
- tileEntity.zCoord + side.offsetZ)
- if (tileEntity.getWorldObj.blockExists(nx, ny, nz)) {
+ if (!tileEntity.isInvalid && !tileEntity.getWorld.isRemote) {
+ for (side <- EnumFacing.values) {
+ val npos = tileEntity.getPos.offset(side)
+ if (tileEntity.getWorld.isBlockLoaded(npos)) {
val localNode = getNetworkNode(tileEntity, side)
- val neighborTileEntity = tileEntity.getWorldObj.getTileEntity(nx, ny, nz)
+ val neighborTileEntity = tileEntity.getWorld.getTileEntity(npos)
val neighborNode = getNetworkNode(neighborTileEntity, side.getOpposite)
localNode match {
case Some(node: MutableNode) =>
@@ -419,7 +418,7 @@ object Network extends api.detail.NetworkAPI {
case _ =>
}
- private def getNetworkNode(tileEntity: TileEntity, side: ForgeDirection) =
+ private def getNetworkNode(tileEntity: TileEntity, side: EnumFacing) =
tileEntity match {
case host: SidedEnvironment => Option(host.sidedNode(side))
case host: Environment => Some(host.node)
@@ -427,7 +426,8 @@ object Network extends api.detail.NetworkAPI {
case _ => None
}
- private def getMultiPartNode(tileEntity: TileEntity) =
+ private def getMultiPartNode(tileEntity: TileEntity) = None
+ /* TODO FMP
tileEntity match {
case host: TileMultipart => host.partList.find(_.isInstanceOf[CablePart]) match {
case Some(part: CablePart) => Some(part.node)
@@ -435,29 +435,33 @@ object Network extends api.detail.NetworkAPI {
}
case _ => None
}
+ */
private def cableColor(tileEntity: TileEntity) =
tileEntity match {
case cable: tileentity.Cable => cable.color
case _ =>
if (Mods.ForgeMultipart.isAvailable) cableColorFMP(tileEntity)
- else Color.LightGray
+ else EnumDyeColor.SILVER
}
- private def cableColorFMP(tileEntity: TileEntity) =
+ private def cableColorFMP(tileEntity: TileEntity) = EnumDyeColor.SILVER
+ /* TODO FMP
tileEntity match {
case host: TileMultipart => (host.partList collect {
case cable: CablePart => cable.color
}).headOption.getOrElse(Color.LightGray)
case _ => Color.LightGray
}
+ */
private def canConnectBasedOnColor(te1: TileEntity, te2: TileEntity) = {
val (c1, c2) = (cableColor(te1), cableColor(te2))
- c1 == c2 || c1 == Color.LightGray || c2 == Color.LightGray
+ c1 == c2 || c1 == EnumDyeColor.SILVER || c2 == EnumDyeColor.SILVER
}
- private def canConnectFromSideFMP(tileEntity: TileEntity, side: ForgeDirection) =
+ private def canConnectFromSideFMP(tileEntity: TileEntity, side: EnumFacing) = true
+ /* TODO FMP
tileEntity match {
case host: TileMultipart =>
host.partList.forall {
@@ -471,8 +475,9 @@ object Network extends api.detail.NetworkAPI {
}
case _ => true
}
+ */
- private def canConnectFromSideIM(tileEntity: TileEntity, side: ForgeDirection) =
+ private def canConnectFromSideIM(tileEntity: TileEntity, side: EnumFacing) =
tileEntity match {
case im: tileentity.traits.ImmibisMicroblock => im.ImmibisMicroblocks_isSideOpen(side.ordinal)
case _ => true
@@ -524,11 +529,11 @@ object Network extends api.detail.NetworkAPI {
val data = (for (i <- 0 until nbt.getInteger("dataLength")) yield {
if (nbt.hasKey("data" + i)) {
nbt.getTag("data" + i) match {
- case boolean: NBTTagByte => Boolean.box(boolean.func_150290_f == 1)
- case integer: NBTTagInt => Int.box(integer.func_150287_d)
- case double: NBTTagDouble => Double.box(double.func_150286_g)
- case string: NBTTagString => string.func_150285_a_(): AnyRef
- case array: NBTTagByteArray => array.func_150292_c
+ case tag: NBTTagByte => Boolean.box(tag.getByte == 1)
+ case tag: NBTTagInt => Int.box(tag.getInt)
+ case tag: NBTTagDouble => Double.box(tag.getDouble)
+ case tag: NBTTagString => tag.getString: AnyRef
+ case tag: NBTTagByteArray => tag.getByteArray
}
}
else null
diff --git a/src/main/scala/li/cil/oc/server/network/WirelessNetwork.scala b/src/main/scala/li/cil/oc/server/network/WirelessNetwork.scala
index 4f340594e..a4430aeea 100644
--- a/src/main/scala/li/cil/oc/server/network/WirelessNetwork.scala
+++ b/src/main/scala/li/cil/oc/server/network/WirelessNetwork.scala
@@ -1,9 +1,12 @@
package li.cil.oc.server.network
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
+import li.cil.oc.util.BlockPosition
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.Settings
import li.cil.oc.api.network.WirelessEndpoint
import li.cil.oc.util.RTree
+import li.cil.oc.util.ExtendedBlock._
+import li.cil.oc.util.ExtendedWorld._
import net.minecraft.util.Vec3
import net.minecraftforge.event.world.ChunkEvent
import net.minecraftforge.event.world.WorldEvent
@@ -17,21 +20,21 @@ object WirelessNetwork {
@SubscribeEvent
def onWorldUnload(e: WorldEvent.Unload) {
if (!e.world.isRemote) {
- dimensions.remove(e.world.provider.dimensionId)
+ dimensions.remove(e.world.provider.getDimensionId)
}
}
@SubscribeEvent
def onWorldLoad(e: WorldEvent.Load) {
if (!e.world.isRemote) {
- dimensions.remove(e.world.provider.dimensionId)
+ dimensions.remove(e.world.provider.getDimensionId)
}
}
// Safety clean up, in case some tile entities didn't properly leave the net.
@SubscribeEvent
def onChunkUnload(e: ChunkEvent.Unload) {
- e.getChunk.chunkTileEntityMap.values.foreach {
+ e.getChunk.getTileEntityMap.values.foreach {
case endpoint: WirelessEndpoint => remove(endpoint)
case _ =>
}
@@ -81,7 +84,7 @@ object WirelessNetwork {
}
}
- private def dimension(endpoint: WirelessEndpoint) = endpoint.world.provider.dimensionId
+ private def dimension(endpoint: WirelessEndpoint) = endpoint.world.provider.getDimensionId
private def offset(endpoint: WirelessEndpoint, value: Double) =
(endpoint.x + 0.5 + value, endpoint.y + 0.5 + value, endpoint.z + 0.5 + value)
@@ -107,8 +110,8 @@ object WirelessNetwork {
// the message.
val world = endpoint.world
- val origin = Vec3.createVectorHelper(reference.x, reference.y, reference.z)
- val target = Vec3.createVectorHelper(endpoint.x, endpoint.y, endpoint.z)
+ val origin = new Vec3(reference.x, reference.y, reference.z)
+ val target = new Vec3(endpoint.x, endpoint.y, endpoint.z)
// Vector from reference endpoint (sender) to this one (receiver).
val delta = subtract(target, origin)
@@ -117,10 +120,10 @@ object WirelessNetwork {
// Get the vectors that are orthogonal to the direction vector.
val up = if (v.xCoord == 0 && v.zCoord == 0) {
assert(v.yCoord != 0)
- Vec3.createVectorHelper(1, 0, 0)
+ new Vec3(1, 0, 0)
}
else {
- Vec3.createVectorHelper(0, 1, 0)
+ new Vec3(0, 1, 0)
}
val side = crossProduct(v, up)
val top = crossProduct(v, side)
@@ -138,8 +141,9 @@ object WirelessNetwork {
val x = (origin.xCoord + v.xCoord * rGap + side.xCoord * rSide + top.xCoord * rTop).toInt
val y = (origin.yCoord + v.yCoord * rGap + side.yCoord * rSide + top.yCoord * rTop).toInt
val z = (origin.zCoord + v.zCoord * rGap + side.zCoord * rSide + top.zCoord * rTop).toInt
- Option(world.getBlock(x, y, z)) match {
- case Some(block) => hardness += block.getBlockHardness(world, x, y, z)
+ val blockPos = BlockPosition(x, y, z, world)
+ Option(world.getBlock(blockPos)) match {
+ case Some(block) => hardness += block.getBlockHardness(blockPos)
case _ =>
}
}
@@ -153,7 +157,7 @@ object WirelessNetwork {
else true
}
- private def subtract(v1: Vec3, v2: Vec3) = Vec3.createVectorHelper(v1.xCoord - v2.xCoord, v1.yCoord - v2.yCoord, v1.zCoord - v2.zCoord)
+ private def subtract(v1: Vec3, v2: Vec3) = new Vec3(v1.xCoord - v2.xCoord, v1.yCoord - v2.yCoord, v1.zCoord - v2.zCoord)
- private def crossProduct(v1: Vec3, v2: Vec3) = Vec3.createVectorHelper(v1.yCoord * v2.zCoord - v1.zCoord * v2.yCoord, v1.zCoord * v2.xCoord - v1.xCoord * v2.zCoord, v1.xCoord * v2.yCoord - v1.yCoord * v2.xCoord)
+ private def crossProduct(v1: Vec3, v2: Vec3) = new Vec3(v1.yCoord * v2.zCoord - v1.zCoord * v2.yCoord, v1.zCoord * v2.xCoord - v1.xCoord * v2.zCoord, v1.xCoord * v2.yCoord - v1.yCoord * v2.xCoord)
}
diff --git a/src/main/scala/li/cil/oc/util/Audio.scala b/src/main/scala/li/cil/oc/util/Audio.scala
index 468dee7ec..0754f35c2 100644
--- a/src/main/scala/li/cil/oc/util/Audio.scala
+++ b/src/main/scala/li/cil/oc/util/Audio.scala
@@ -2,9 +2,9 @@ package li.cil.oc.util
import java.nio.ByteBuffer
-import cpw.mods.fml.common.FMLCommonHandler
-import cpw.mods.fml.common.eventhandler.SubscribeEvent
-import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent
+import net.minecraftforge.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import li.cil.oc.OpenComputers
import net.minecraft.client.Minecraft
import net.minecraft.client.audio.SoundCategory
diff --git a/src/main/scala/li/cil/oc/util/BlockPosition.scala b/src/main/scala/li/cil/oc/util/BlockPosition.scala
index 212264096..5dadfa828 100644
--- a/src/main/scala/li/cil/oc/util/BlockPosition.scala
+++ b/src/main/scala/li/cil/oc/util/BlockPosition.scala
@@ -1,15 +1,9 @@
package li.cil.oc.util
-import appeng.api.util.DimensionalCoord
-import cpw.mods.fml.common.Optional
import li.cil.oc.api.driver.EnvironmentHost
-import li.cil.oc.integration.Mods
import net.minecraft.entity.Entity
-import net.minecraft.util.AxisAlignedBB
-import net.minecraft.util.ChunkCoordinates
-import net.minecraft.util.Vec3
+import net.minecraft.util._
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
class BlockPosition(val x: Int, val y: Int, val z: Int, val world: Option[World]) {
def this(x: Double, y: Double, z: Double, world: Option[World] = None) = this(
@@ -19,20 +13,20 @@ class BlockPosition(val x: Int, val y: Int, val z: Int, val world: Option[World]
world
)
- def offset(direction: ForgeDirection) = new BlockPosition(
- x + direction.offsetX,
- y + direction.offsetY,
- z + direction.offsetZ,
+ def offset(direction: EnumFacing) = new BlockPosition(
+ x + direction.getFrontOffsetX,
+ y + direction.getFrontOffsetY,
+ z + direction.getFrontOffsetZ,
world
)
- def offset(x: Double, y: Double, z: Double) = Vec3.createVectorHelper(this.x + x, this.y + y, this.z + z)
+ def offset(x: Double, y: Double, z: Double) = new Vec3(this.x + x, this.y + y, this.z + z)
- def bounds = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)
+ def bounds = AxisAlignedBB.fromBounds(x, y, z, x + 1, y + 1, z + 1)
- def toChunkCoordinates = new ChunkCoordinates(x, y, z)
+ def toBlockPos = new BlockPos(x, y, z)
- def toVec3 = Vec3.createVectorHelper(x + 0.5, y + 0.5, z + 0.5)
+ def toVec3 = new Vec3(x + 0.5, y + 0.5, z + 0.5)
override def equals(obj: scala.Any) = obj match {
case position: BlockPosition => position.x == x && position.y == y && position.z == z && position.world == world
@@ -53,6 +47,7 @@ object BlockPosition {
def apply(entity: Entity): BlockPosition = BlockPosition(entity.posX, entity.posY, entity.posZ, entity.worldObj)
- @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
- def apply(coord: DimensionalCoord): BlockPosition = BlockPosition(coord.x, coord.y, coord.z, coord.getWorld)
+ def apply(pos: BlockPos, world: World): BlockPosition = BlockPosition(pos.getX, pos.getY, pos.getZ, world)
+
+ def apply(pos: BlockPos): BlockPosition = BlockPosition(pos.getX, pos.getY, pos.getZ)
}
diff --git a/src/main/scala/li/cil/oc/util/Color.scala b/src/main/scala/li/cil/oc/util/Color.scala
index 6ae500f36..3d20a9b67 100644
--- a/src/main/scala/li/cil/oc/util/Color.scala
+++ b/src/main/scala/li/cil/oc/util/Color.scala
@@ -1,35 +1,30 @@
package li.cil.oc.util
+import net.minecraft.item.EnumDyeColor
import net.minecraft.item.ItemStack
import net.minecraftforge.oredict.OreDictionary
import scala.collection.convert.WrapAsScala._
object Color {
- val Black = 0x444444
- // 0x1E1B1B
- val Red = 0xB3312C
- val Green = 0x339911
- // 0x3B511A
- val Brown = 0x51301A
- val Blue = 0x6666FF
- // 0x253192
- val Purple = 0x7B2FBE
- val Cyan = 0x66FFFF
- // 0x287697
- val LightGray = 0xABABAB
- val Gray = 0x666666
- // 0x434343
- val Pink = 0xD88198
- val Lime = 0x66FF66
- // 0x41CD34
- val Yellow = 0xFFFF66
- // 0xDECF2A
- val LightBlue = 0xAAAAFF
- // 0x6689D3
- val Magenta = 0xC354CD
- val Orange = 0xEB8844
- val White = 0xF0F0F0
+ val rgbValues = Map(
+ EnumDyeColor.BLACK -> 0x444444, // 0x1E1B1B
+ EnumDyeColor.RED -> 0xB3312C,
+ EnumDyeColor.GREEN -> 0x339911, // 0x3B511A
+ EnumDyeColor.BROWN -> 0x51301A,
+ EnumDyeColor.BLUE -> 0x6666FF, // 0x253192
+ EnumDyeColor.PURPLE -> 0x7B2FBE,
+ EnumDyeColor.CYAN -> 0x66FFFF, // 0x287697
+ EnumDyeColor.SILVER -> 0xABABAB,
+ EnumDyeColor.GRAY -> 0x666666, // 0x434343
+ EnumDyeColor.PINK -> 0xD88198,
+ EnumDyeColor.LIME -> 0x66FF66, // 0x41CD34
+ EnumDyeColor.YELLOW -> 0xFFFF66, // 0xDECF2A
+ EnumDyeColor.LIGHT_BLUE -> 0xAAAAFF, // 0x6689D3
+ EnumDyeColor.MAGENTA -> 0xC354CD,
+ EnumDyeColor.ORANGE -> 0xEB8844,
+ EnumDyeColor.WHITE -> 0xF0F0F0
+ )
val dyes = Array(
"dyeBlack",
@@ -50,28 +45,28 @@ object Color {
"dyeWhite")
val byOreName = Map(
- "dyeBlack" -> Black,
- "dyeRed" -> Red,
- "dyeGreen" -> Green,
- "dyeBrown" -> Brown,
- "dyeBlue" -> Blue,
- "dyePurple" -> Purple,
- "dyeCyan" -> Cyan,
- "dyeLightGray" -> LightGray,
- "dyeGray" -> Gray,
- "dyePink" -> Pink,
- "dyeLime" -> Lime,
- "dyeYellow" -> Yellow,
- "dyeLightBlue" -> LightBlue,
- "dyeMagenta" -> Magenta,
- "dyeOrange" -> Orange,
- "dyeWhite" -> White)
+ "dyeBlack" -> EnumDyeColor.BLACK,
+ "dyeRed" -> EnumDyeColor.RED,
+ "dyeGreen" -> EnumDyeColor.GREEN,
+ "dyeBrown" -> EnumDyeColor.BROWN,
+ "dyeBlue" -> EnumDyeColor.BLUE,
+ "dyePurple" -> EnumDyeColor.PURPLE,
+ "dyeCyan" -> EnumDyeColor.CYAN,
+ "dyeLightGray" -> EnumDyeColor.SILVER,
+ "dyeGray" -> EnumDyeColor.GRAY,
+ "dyePink" -> EnumDyeColor.PINK,
+ "dyeLime" -> EnumDyeColor.LIME,
+ "dyeYellow" -> EnumDyeColor.YELLOW,
+ "dyeLightBlue" -> EnumDyeColor.LIGHT_BLUE,
+ "dyeMagenta" -> EnumDyeColor.MAGENTA,
+ "dyeOrange" -> EnumDyeColor.ORANGE,
+ "dyeWhite" -> EnumDyeColor.WHITE)
- val byTier = Array(LightGray, Yellow, Cyan, Magenta)
+ val byTier = Array(EnumDyeColor.SILVER, EnumDyeColor.YELLOW, EnumDyeColor.CYAN, EnumDyeColor.MAGENTA)
def findDye(stack: ItemStack) = byOreName.keys.find(OreDictionary.getOres(_).exists(oreStack => OreDictionary.itemMatches(stack, oreStack, false)))
def isDye(stack: ItemStack) = findDye(stack).isDefined
- def dyeColor(stack: ItemStack) = findDye(stack).fold(0xFF00FF)(byOreName(_))
+ def dyeColor(stack: ItemStack) = findDye(stack).fold(EnumDyeColor.MAGENTA)(byOreName(_))
}
diff --git a/src/main/scala/li/cil/oc/util/ExtendedArguments.scala b/src/main/scala/li/cil/oc/util/ExtendedArguments.scala
index c7f318d4d..8deb86afc 100644
--- a/src/main/scala/li/cil/oc/util/ExtendedArguments.scala
+++ b/src/main/scala/li/cil/oc/util/ExtendedArguments.scala
@@ -4,7 +4,7 @@ import li.cil.oc.api.internal.Robot
import li.cil.oc.api.machine.Arguments
import li.cil.oc.common.inventory.MultiTank
import net.minecraft.inventory.IInventory
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.language.implicitConversions
@@ -54,18 +54,18 @@ object ExtendedArguments {
tank
}
- def checkSideForAction(n: Int) = checkSide(n, ForgeDirection.SOUTH, ForgeDirection.UP, ForgeDirection.DOWN)
+ def checkSideForAction(n: Int) = checkSide(n, EnumFacing.SOUTH, EnumFacing.UP, EnumFacing.DOWN)
- def checkSideForMovement(n: Int) = checkSide(n, ForgeDirection.SOUTH, ForgeDirection.NORTH, ForgeDirection.UP, ForgeDirection.DOWN)
+ def checkSideForMovement(n: Int) = checkSide(n, EnumFacing.SOUTH, EnumFacing.NORTH, EnumFacing.UP, EnumFacing.DOWN)
- def checkSideForFace(n: Int, facing: ForgeDirection) = checkSide(n, ForgeDirection.VALID_DIRECTIONS.filter(_ != facing.getOpposite): _*)
+ def checkSideForFace(n: Int, facing: EnumFacing) = checkSide(n, EnumFacing.values.filter(_ != facing.getOpposite): _*)
- def checkSide(n: Int, allowed: ForgeDirection*) = {
+ def checkSide(n: Int, allowed: EnumFacing*) = {
val side = args.checkInteger(n)
if (side < 0 || side > 5) {
throw new IllegalArgumentException("invalid side")
}
- val direction = ForgeDirection.getOrientation(side)
+ val direction = EnumFacing.getFront(side)
if (allowed.isEmpty || (allowed contains direction)) direction
else throw new IllegalArgumentException("unsupported side")
}
diff --git a/src/main/scala/li/cil/oc/util/ExtendedBlock.scala b/src/main/scala/li/cil/oc/util/ExtendedBlock.scala
index 5d515748b..ff3cb42f8 100644
--- a/src/main/scala/li/cil/oc/util/ExtendedBlock.scala
+++ b/src/main/scala/li/cil/oc/util/ExtendedBlock.scala
@@ -1,6 +1,7 @@
package li.cil.oc.util
import net.minecraft.block.Block
+import net.minecraft.world.World
import scala.language.implicitConversions
@@ -9,9 +10,11 @@ object ExtendedBlock {
implicit def extendedBlock(block: Block): ExtendedBlock = new ExtendedBlock(block)
class ExtendedBlock(val block: Block) {
- def isAir(position: BlockPosition) = block.isAir(position.world.get, position.x, position.y, position.z)
+ def isAir(position: BlockPosition) = block.isAir(position.world.get, position.toBlockPos)
- def isReplaceable(position: BlockPosition) = block.isReplaceable(position.world.get, position.x, position.y, position.z)
+ def isReplaceable(position: BlockPosition) = block.isReplaceable(position.world.get, position.toBlockPos)
+
+ def getBlockHardness(position: BlockPosition) = block.getBlockHardness(position.world.get, position.toBlockPos)
}
}
diff --git a/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala b/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala
index 9e99f1849..a7fa03ee9 100644
--- a/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala
+++ b/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala
@@ -91,7 +91,7 @@ object ExtendedLuaState {
val tableIndex = lua.getTop
memo += obj -> tableIndex
for ((key: AnyRef, value: AnyRef) <- map) {
- if (key != null && key != Unit && !key.isInstanceOf[BoxedUnit]) {
+ if (key != null && !key.isInstanceOf[BoxedUnit]) {
pushValue(key, memo)
val keyIndex = lua.getTop
pushValue(value, memo)
diff --git a/src/main/scala/li/cil/oc/util/ExtendedNBT.scala b/src/main/scala/li/cil/oc/util/ExtendedNBT.scala
index 0ba1524c4..0db2912f2 100644
--- a/src/main/scala/li/cil/oc/util/ExtendedNBT.scala
+++ b/src/main/scala/li/cil/oc/util/ExtendedNBT.scala
@@ -2,7 +2,7 @@ package li.cil.oc.util
import net.minecraft.item.ItemStack
import net.minecraft.nbt._
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.mutable.ArrayBuffer
import scala.language.implicitConversions
@@ -113,16 +113,12 @@ object ExtendedNBT {
def getDirection(name: String) = {
nbt.getByte(name) match {
- case id if id < 0 => None
- case id =>
- val side = ForgeDirection.getOrientation(id)
- // Backwards compatibility.
- if (side == ForgeDirection.UNKNOWN) None
- else Option(side)
+ case id if id < 0 || id > EnumFacing.values.length => None
+ case id => Option(EnumFacing.getFront(id))
}
}
- def setDirection(name: String, d: Option[ForgeDirection]): Unit = {
+ def setDirection(name: String, d: Option[EnumFacing]): Unit = {
d match {
case Some(side) => nbt.setByte(name, side.ordinal.toByte)
case _ => nbt.setByte(name, -1: Byte)
diff --git a/src/main/scala/li/cil/oc/util/ExtendedWorld.scala b/src/main/scala/li/cil/oc/util/ExtendedWorld.scala
index a3934f2c4..97efbaf5b 100644
--- a/src/main/scala/li/cil/oc/util/ExtendedWorld.scala
+++ b/src/main/scala/li/cil/oc/util/ExtendedWorld.scala
@@ -6,7 +6,7 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.language.implicitConversions
@@ -17,49 +17,49 @@ object ExtendedWorld {
implicit def extendedWorld(world: World): ExtendedWorld = new ExtendedWorld(world)
class ExtendedBlockAccess(val world: IBlockAccess) {
- def getBlock(position: BlockPosition) = world.getBlock(position.x, position.y, position.z)
+ def getBlock(position: BlockPosition) = world.getBlockState(position.toBlockPos).getBlock
def getBlockMapColor(position: BlockPosition) = getBlock(position).getMapColor(getBlockMetadata(position))
- def getBlockMetadata(position: BlockPosition) = world.getBlockMetadata(position.x, position.y, position.z)
+ def getBlockMetadata(position: BlockPosition) = world.getBlockState(position.toBlockPos)
- def getTileEntity(position: BlockPosition): TileEntity = world.getTileEntity(position.x, position.y, position.z)
+ def getTileEntity(position: BlockPosition): TileEntity = world.getTileEntity(position.toBlockPos)
def getTileEntity(host: EnvironmentHost): TileEntity = getTileEntity(BlockPosition(host))
- def isAirBlock(position: BlockPosition) = world.isAirBlock(position.x, position.y, position.z)
+ def isAirBlock(position: BlockPosition) = world.isAirBlock(position.toBlockPos)
}
class ExtendedWorld(override val world: World) extends ExtendedBlockAccess(world) {
- def blockExists(position: BlockPosition) = world.blockExists(position.x, position.y, position.z)
+ def blockExists(position: BlockPosition) = world.isBlockLoaded(position.toBlockPos)
- def breakBlock(position: BlockPosition, drops: Boolean = true) = world.func_147480_a(position.x, position.y, position.z, drops)
+ def breakBlock(position: BlockPosition, drops: Boolean = true) = world.destroyBlock(position.toBlockPos, drops)
- def extinguishFire(player: EntityPlayer, position: BlockPosition, side: ForgeDirection) = world.extinguishFire(player, position.x, position.y, position.z, side.ordinal)
+ def extinguishFire(player: EntityPlayer, position: BlockPosition, side: EnumFacing) = world.extinguishFire(player, position.toBlockPos, side)
- def getBlockHardness(position: BlockPosition) = getBlock(position).getBlockHardness(world, position.x, position.y, position.z)
+ def getBlockHardness(position: BlockPosition) = getBlock(position).getBlockHardness(world, position.toBlockPos)
def getBlockHarvestLevel(position: BlockPosition) = getBlock(position).getHarvestLevel(getBlockMetadata(position))
def getBlockHarvestTool(position: BlockPosition) = getBlock(position).getHarvestTool(getBlockMetadata(position))
- def getIndirectPowerLevelTo(position: BlockPosition, side: ForgeDirection) = world.getIndirectPowerLevelTo(position.x, position.y, position.z, side.ordinal)
+ def getIndirectPowerLevelTo(position: BlockPosition, side: EnumFacing) = world.getRedstonePower(position.toBlockPos, side)
- def markBlockForUpdate(position: BlockPosition) = world.markBlockForUpdate(position.x, position.y, position.z)
+ def markBlockForUpdate(position: BlockPosition) = world.markBlockForUpdate(position.toBlockPos)
- def notifyBlockOfNeighborChange(position: BlockPosition, block: Block) = world.notifyBlockOfNeighborChange(position.x, position.y, position.z, block)
+ def notifyBlockOfNeighborChange(position: BlockPosition, block: Block) = world.notifyBlockOfStateChange(position.toBlockPos, block)
- def notifyBlocksOfNeighborChange(position: BlockPosition, block: Block) = world.notifyBlocksOfNeighborChange(position.x, position.y, position.z, block)
+ def notifyBlocksOfNeighborChange(position: BlockPosition, block: Block) = world.notifyNeighborsOfStateChange(position.toBlockPos, block)
- def notifyBlocksOfNeighborChange(position: BlockPosition, block: Block, side: ForgeDirection) = world.notifyBlocksOfNeighborChange(position.x, position.y, position.z, block, side.ordinal)
+ def notifyBlocksOfNeighborChange(position: BlockPosition, block: Block, side: EnumFacing) = world.notifyNeighborsOfStateExcept(position.toBlockPos, block, side)
- def playAuxSFX(id: Int, position: BlockPosition, data: Int) = world.playAuxSFX(id, position.x, position.y, position.z, data)
+ def playAuxSFX(id: Int, position: BlockPosition, data: Int) = world.playAuxSFX(id, position.toBlockPos, data)
- def setBlock(position: BlockPosition, block: Block) = world.setBlock(position.x, position.y, position.z, block)
+ def setBlock(position: BlockPosition, block: Block) = world.setBlockState(position.toBlockPos, block.getDefaultState)
- def setBlock(position: BlockPosition, block: Block, metadata: Int, flag: Int) = world.setBlock(position.x, position.y, position.z, block, metadata, flag)
+ def setBlock(position: BlockPosition, block: Block, metadata: Int, flag: Int) = world.setBlockState(position.toBlockPos, block.getStateFromMeta(metadata), flag)
- def setBlockToAir(position: BlockPosition) = world.setBlockToAir(position.x, position.y, position.z)
+ def setBlockToAir(position: BlockPosition) = world.setBlockToAir(position.toBlockPos)
}
}
diff --git a/src/main/scala/li/cil/oc/util/InventoryUtils.scala b/src/main/scala/li/cil/oc/util/InventoryUtils.scala
index fcf6557b9..0e00f6db6 100644
--- a/src/main/scala/li/cil/oc/util/InventoryUtils.scala
+++ b/src/main/scala/li/cil/oc/util/InventoryUtils.scala
@@ -7,7 +7,7 @@ import net.minecraft.inventory.IInventory
import net.minecraft.inventory.ISidedInventory
import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntityChest
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
import scala.collection.convert.WrapAsScala._
@@ -20,7 +20,7 @@ object InventoryUtils {
*/
def inventoryAt(position: BlockPosition): Option[IInventory] = position.world match {
case Some(world) if world.blockExists(position) => world.getTileEntity(position) match {
- case chest: TileEntityChest => Option(net.minecraft.init.Blocks.chest.func_149951_m(world, chest.xCoord, chest.yCoord, chest.zCoord))
+ case chest: TileEntityChest => Option(net.minecraft.init.Blocks.chest.getLockableContainer(world, chest.getPos))
case inventory: IInventory => Some(inventory)
case _ => world.getEntitiesWithinAABB(classOf[EntityMinecartContainer], position.bounds).
map(_.asInstanceOf[EntityMinecartContainer]).
@@ -50,10 +50,10 @@ object InventoryUtils {
* The number of items inserted can be limited, to avoid unnecessary
* changes to the inventory the stack may come from, for example.
*/
- def insertIntoInventorySlot(stack: ItemStack, inventory: IInventory, side: Option[ForgeDirection], slot: Int, limit: Int = 64, simulate: Boolean = false) =
+ def insertIntoInventorySlot(stack: ItemStack, inventory: IInventory, side: Option[EnumFacing], slot: Int, limit: Int = 64, simulate: Boolean = false) =
(stack != null && limit > 0) && {
val isSideValidForSlot = (inventory, side) match {
- case (inventory: ISidedInventory, Some(s)) => inventory.canInsertItem(slot, stack, s.ordinal)
+ case (inventory: ISidedInventory, Some(s)) => inventory.canInsertItem(slot, stack, s)
case _ => true
}
(stack.stackSize > 0 && inventory.isItemValidForSlot(slot, stack) && isSideValidForSlot) && {
@@ -109,11 +109,11 @@ object InventoryUtils {
* also be achieved by a check in the consumer, but it saves some unnecessary
* code repetition this way.
*/
- def extractFromInventorySlot(consumer: (ItemStack) => Unit, inventory: IInventory, side: ForgeDirection, slot: Int, limit: Int = 64) = {
+ def extractFromInventorySlot(consumer: (ItemStack) => Unit, inventory: IInventory, side: EnumFacing, slot: Int, limit: Int = 64) = {
val stack = inventory.getStackInSlot(slot)
(stack != null && limit > 0) && {
val isSideValidForSlot = inventory match {
- case inventory: ISidedInventory => inventory.canExtractItem(slot, stack, side.ordinal)
+ case inventory: ISidedInventory => inventory.canExtractItem(slot, stack, side)
case _ => true
}
(stack.stackSize > 0 && isSideValidForSlot) && {
@@ -149,7 +149,7 @@ object InventoryUtils {
* item stack will be adjusted to reflect the number items inserted, by
* having its size decremented accordingly.
*/
- def insertIntoInventory(stack: ItemStack, inventory: IInventory, side: Option[ForgeDirection] = None, limit: Int = 64, simulate: Boolean = false, slots: Option[Iterable[Int]] = None) =
+ def insertIntoInventory(stack: ItemStack, inventory: IInventory, side: Option[EnumFacing] = None, limit: Int = 64, simulate: Boolean = false, slots: Option[Iterable[Int]] = None) =
(stack != null && limit > 0) && {
var success = false
var remaining = limit
@@ -188,28 +188,28 @@ object InventoryUtils {
*
* This returns true if at least one item was extracted.
*/
- def extractFromInventory(consumer: (ItemStack) => Unit, inventory: IInventory, side: ForgeDirection, limit: Int = 64) =
+ def extractFromInventory(consumer: (ItemStack) => Unit, inventory: IInventory, side: EnumFacing, limit: Int = 64) =
(0 until inventory.getSizeInventory).exists(slot => extractFromInventorySlot(consumer, inventory, side, slot, limit))
/**
* Utility method for calling insertIntoInventory on an inventory
* in the world.
*/
- def insertIntoInventoryAt(stack: ItemStack, position: BlockPosition, side: ForgeDirection, limit: Int = 64, simulate: Boolean = false): Boolean =
+ def insertIntoInventoryAt(stack: ItemStack, position: BlockPosition, side: EnumFacing, limit: Int = 64, simulate: Boolean = false): Boolean =
inventoryAt(position).exists(insertIntoInventory(stack, _, Option(side), limit, simulate))
/**
* Utility method for calling extractFromInventory on an inventory
* in the world.
*/
- def extractFromInventoryAt(consumer: (ItemStack) => Unit, position: BlockPosition, side: ForgeDirection, limit: Int = 64) =
+ def extractFromInventoryAt(consumer: (ItemStack) => Unit, position: BlockPosition, side: EnumFacing, limit: Int = 64) =
inventoryAt(position).exists(extractFromInventory(consumer, _, side, limit))
/**
* Utility method for dropping contents from a single inventory slot into
* the world.
*/
- def dropSlot(position: BlockPosition, inventory: IInventory, slot: Int, count: Int, direction: Option[ForgeDirection] = None) = {
+ def dropSlot(position: BlockPosition, inventory: IInventory, slot: Int, count: Int, direction: Option[EnumFacing] = None) = {
Option(inventory.decrStackSize(slot, count)) match {
case Some(stack) if stack.stackSize > 0 => spawnStackInWorld(position, stack, direction); true
case _ => false
@@ -233,10 +233,10 @@ object InventoryUtils {
/**
* Utility method for spawning an item stack in the world.
*/
- def spawnStackInWorld(position: BlockPosition, stack: ItemStack, direction: Option[ForgeDirection] = None): EntityItem = position.world match {
+ def spawnStackInWorld(position: BlockPosition, stack: ItemStack, direction: Option[EnumFacing] = None): EntityItem = position.world match {
case Some(world) =>
val rng = world.rand
- val (ox, oy, oz) = direction.fold((0, 0, 0))(d => (d.offsetX, d.offsetY, d.offsetZ))
+ val (ox, oy, oz) = direction.fold((0, 0, 0))(d => (d.getFrontOffsetX, d.getFrontOffsetY, d.getFrontOffsetZ))
val (tx, ty, tz) = (
0.1 * (rng.nextDouble - 0.5) + ox * 0.65,
0.1 * (rng.nextDouble - 0.5) + oy * 0.75 + (ox + oz) * 0.25,
@@ -246,7 +246,7 @@ object InventoryUtils {
entity.motionX = 0.0125 * (rng.nextDouble - 0.5) + ox * 0.03
entity.motionY = 0.0125 * (rng.nextDouble - 0.5) + oy * 0.08 + (ox + oz) * 0.03
entity.motionZ = 0.0125 * (rng.nextDouble - 0.5) + oz * 0.03
- entity.delayBeforeCanPickup = 15
+ entity.setPickupDelay(15)
world.spawnEntityInWorld(entity)
entity
case _ => null
diff --git a/src/main/scala/li/cil/oc/util/ItemCosts.scala b/src/main/scala/li/cil/oc/util/ItemCosts.scala
index 121f0ef80..8bd09f7b4 100644
--- a/src/main/scala/li/cil/oc/util/ItemCosts.scala
+++ b/src/main/scala/li/cil/oc/util/ItemCosts.scala
@@ -98,7 +98,7 @@ object ItemCosts {
case Some(recipe: ShapelessRecipes) => (recipe.recipeItems.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
case Some(recipe: ShapedOreRecipe) => (recipe.getInput.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
case Some(recipe: ShapelessOreRecipe) => (recipe.getInput.flatMap(accumulate(_, path :+ stack)).toIterable, recipe.getRecipeOutput.stackSize)
- case _ => FurnaceRecipes.smelting.getSmeltingList.asInstanceOf[util.Map[ItemStack, ItemStack]].find {
+ case _ => FurnaceRecipes.instance.getSmeltingList.asInstanceOf[util.Map[ItemStack, ItemStack]].find {
case (_, value) => fuzzyEquals(stack, value)
} match {
case Some((rein, raus)) => (accumulate(rein, path :+ stack), raus.stackSize)
diff --git a/src/main/scala/li/cil/oc/util/ItemUtils.scala b/src/main/scala/li/cil/oc/util/ItemUtils.scala
index 29fcb435d..0813a86c7 100644
--- a/src/main/scala/li/cil/oc/util/ItemUtils.scala
+++ b/src/main/scala/li/cil/oc/util/ItemUtils.scala
@@ -1,5 +1,7 @@
package li.cil.oc.util
+import java.io.ByteArrayInputStream
+import java.io.ByteArrayOutputStream
import java.util.Random
import com.google.common.base.Charsets
@@ -9,8 +11,6 @@ import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.Persistable
import li.cil.oc.common.Tier
-import li.cil.oc.common.block.DelegatorConverter
-import li.cil.oc.common.init.Items
import li.cil.oc.integration.opencomputers.DriverScreen
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.item.ItemBucket
@@ -20,6 +20,7 @@ import net.minecraft.item.crafting.CraftingManager
import net.minecraft.item.crafting.IRecipe
import net.minecraft.item.crafting.ShapedRecipes
import net.minecraft.item.crafting.ShapelessRecipes
+import net.minecraft.nbt.CompressedStreamTools
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.world.World
import net.minecraftforge.common.util.Constants.NBT
@@ -47,7 +48,28 @@ object ItemUtils {
else Tier.None
}
- def loadStack(nbt: NBTTagCompound) = DelegatorConverter.convert(ItemStack.loadItemStackFromNBT(nbt))
+ def loadStack(nbt: NBTTagCompound) = ItemStack.loadItemStackFromNBT(nbt)
+
+ def loadStack(data: Array[Byte]) = {
+ ItemStack.loadItemStackFromNBT(loadTag(data))
+ }
+
+ def loadTag(data: Array[Byte]) = {
+ val bais = new ByteArrayInputStream(data)
+ CompressedStreamTools.readCompressed(bais)
+ }
+
+ def saveStack(stack: ItemStack) = {
+ val tag = new NBTTagCompound()
+ stack.writeToNBT(tag)
+ saveTag(tag)
+ }
+
+ def saveTag(tag: NBTTagCompound) = {
+ val baos = new ByteArrayOutputStream()
+ CompressedStreamTools.writeCompressed(tag, baos)
+ baos.toByteArray
+ }
def getIngredients(stack: ItemStack): Array[ItemStack] = try {
val recipes = CraftingManager.getInstance.getRecipeList.map(_.asInstanceOf[IRecipe])
@@ -157,7 +179,7 @@ object ItemUtils {
newInfo.components.foreach(cs => Option(api.Driver.driverFor(cs)) match {
case Some(driver) if driver == DriverScreen =>
val nbt = driver.dataTag(cs)
- for (tagName <- nbt.func_150296_c().toArray) {
+ for (tagName <- nbt.getKeySet.toArray) {
nbt.removeTag(tagName.asInstanceOf[String])
}
case _ =>
@@ -239,12 +261,6 @@ object ItemUtils {
toArray[NBTTagCompound].map(loadStack)
containers = nbt.getTagList(Settings.namespace + "containers", NBT.TAG_COMPOUND).
toArray[NBTTagCompound].map(loadStack)
-
- // Code for migrating from 1.4.1 -> 1.4.2, add EEPROM.
- // TODO Remove in 1.5
- if (!nbt.hasKey(Settings.namespace + "biosFlag")) {
- components :+= Items.createLuaBios()
- }
}
override def save(nbt: NBTTagCompound) {
@@ -259,9 +275,6 @@ object ItemUtils {
nbt.setInteger(Settings.namespace + "tier", tier)
nbt.setNewTagList(Settings.namespace + "components", components.toIterable)
nbt.setNewTagList(Settings.namespace + "containers", containers.toIterable)
-
- // TODO Remove in 1.5
- nbt.setBoolean(Settings.namespace + "biosFlag", true)
}
def createItemStack() = {
@@ -278,7 +291,7 @@ object ItemUtils {
newInfo.components.foreach(cs => Option(api.Driver.driverFor(cs)) match {
case Some(driver) if driver == DriverScreen =>
val nbt = driver.dataTag(cs)
- for (tagName <- nbt.func_150296_c().toArray) {
+ for (tagName <- nbt.getKeySet.toArray) {
nbt.removeTag(tagName.asInstanceOf[String])
}
case _ =>
@@ -328,13 +341,6 @@ object ItemUtils {
isRunning = nbt.getBoolean(Settings.namespace + "isRunning")
energy = nbt.getDouble(Settings.namespace + "energy")
maxEnergy = nbt.getDouble(Settings.namespace + "maxEnergy")
-
- // Code for migrating from 1.4.1 -> 1.4.2, add EEPROM.
- // TODO Remove in 1.5
- if (!nbt.hasKey(Settings.namespace + "biosFlag")) {
- val firstEmpty = items.indexWhere(_.isEmpty)
- items(firstEmpty) = Option(Items.createLuaBios())
- }
}
override def save(nbt: NBTTagCompound) {
@@ -350,9 +356,6 @@ object ItemUtils {
nbt.setBoolean(Settings.namespace + "isRunning", isRunning)
nbt.setDouble(Settings.namespace + "energy", energy)
nbt.setDouble(Settings.namespace + "maxEnergy", maxEnergy)
-
- // TODO Remove in 1.5
- nbt.setBoolean(Settings.namespace + "biosFlag", true)
}
}
diff --git a/src/main/scala/li/cil/oc/util/Rarity.scala b/src/main/scala/li/cil/oc/util/Rarity.scala
index 2c7b8ddf8..428461ea6 100644
--- a/src/main/scala/li/cil/oc/util/Rarity.scala
+++ b/src/main/scala/li/cil/oc/util/Rarity.scala
@@ -3,7 +3,7 @@ package li.cil.oc.util
import net.minecraft.item.EnumRarity
object Rarity {
- private val lookup = Array(EnumRarity.common, EnumRarity.uncommon, EnumRarity.rare, EnumRarity.epic)
+ private val lookup = Array(EnumRarity.COMMON, EnumRarity.UNCOMMON, EnumRarity.RARE, EnumRarity.EPIC)
def byTier(tier: Int) = lookup(tier max 0 min (lookup.length - 1))
}
diff --git a/src/main/scala/li/cil/oc/util/RotationHelper.scala b/src/main/scala/li/cil/oc/util/RotationHelper.scala
index ec7821671..b90710e1e 100644
--- a/src/main/scala/li/cil/oc/util/RotationHelper.scala
+++ b/src/main/scala/li/cil/oc/util/RotationHelper.scala
@@ -1,14 +1,14 @@
package li.cil.oc.util
-import net.minecraftforge.common.util.ForgeDirection
+import net.minecraft.util.EnumFacing
object RotationHelper {
def fromYaw(yaw: Float) = {
(yaw / 360 * 4).round & 3 match {
- case 0 => ForgeDirection.SOUTH
- case 1 => ForgeDirection.WEST
- case 2 => ForgeDirection.NORTH
- case 3 => ForgeDirection.EAST
+ case 0 => EnumFacing.SOUTH
+ case 1 => EnumFacing.WEST
+ case 2 => EnumFacing.NORTH
+ case 3 => EnumFacing.EAST
}
}
}
diff --git a/src/main/scala/li/cil/oc/util/Tooltip.scala b/src/main/scala/li/cil/oc/util/Tooltip.scala
index 89dca660e..75195910a 100644
--- a/src/main/scala/li/cil/oc/util/Tooltip.scala
+++ b/src/main/scala/li/cil/oc/util/Tooltip.scala
@@ -12,7 +12,7 @@ import scala.collection.convert.WrapAsScala._
object Tooltip {
private val maxWidth = 220
- private def font = Minecraft.getMinecraft.fontRenderer
+ private def font = Minecraft.getMinecraft.fontRendererObj
def get(name: String, args: Any*): java.util.List[String] = {
if (!Localization.canLocalize(Settings.namespace + "tooltip." + name)) return Seq.empty[String]
diff --git a/src/main/scala/li/cil/oc/util/UpdateCheck.scala b/src/main/scala/li/cil/oc/util/UpdateCheck.scala
index f485f1450..ff270efd6 100644
--- a/src/main/scala/li/cil/oc/util/UpdateCheck.scala
+++ b/src/main/scala/li/cil/oc/util/UpdateCheck.scala
@@ -5,8 +5,8 @@ import java.net.URL
import com.google.gson.Gson
import com.google.gson.stream.JsonReader
-import cpw.mods.fml.common.Loader
-import cpw.mods.fml.common.versioning.ComparableVersion
+import net.minecraftforge.fml.common.Loader
+import net.minecraftforge.fml.common.versioning.ComparableVersion
import li.cil.oc.OpenComputers
import li.cil.oc.Settings