Skip to content

Commit

Permalink
Fixed Block:GetMeta() and Block:SetMeta() being the same as Block:Set…
Browse files Browse the repository at this point in the history
…ID() and Block:GetID()
  • Loading branch information
bkacjios committed Feb 2, 2016
1 parent 2b78f1a commit 188b937
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
17 changes: 17 additions & 0 deletions main/java/com/luacraft/library/LuaGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,23 @@ public static void Init(final LuaState l) {
l.pushJavaFunction(loadfile);
l.setGlobal("loadfile");

/**
* @enum WORLD_NETHER
* @enum WORLD_OVERWORLD
* @enum WORLD_END
* @enum RESULT_ALLOW
* @enum RESULT_DENY
* @enum RESULT_DEFAULT
* @enum MODE_NONE
* @enum MODE_SURVIVAL
* @enum MODE_CREATIVE
* @enum MODE_ADVENTURE
* @enum DIFFICULTY_PEACEFUL
* @enum DIFFICULTY_EASY
* @enum DIFFICULTY_NORMAL
* @enum DIFFICULTY_HARD
*/

l.pushNumber(-1);
l.setGlobal("WORLD_NETHER");
l.pushNumber(0);
Expand Down
12 changes: 5 additions & 7 deletions main/java/com/luacraft/meta/LuaBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ public int invoke(LuaState l) {
public static JavaFunction SetID = new JavaFunction() {
public int invoke(LuaState l) {
LuaJavaBlock self = (LuaJavaBlock) l.checkUserdata(1, LuaJavaBlock.class, "Block");

int id = l.checkInteger(2, 0);
IBlockState meta = Block.getStateById(id);
self.blockWorld.setBlockState(self.getPos(), meta, 3);
IBlockState state = Block.getStateById(id);
self.blockWorld.setBlockState(self.getPos(), state);
return 0;
}
};
Expand All @@ -144,7 +143,7 @@ public int invoke(LuaState l) {
public static JavaFunction GetMeta = new JavaFunction() {
public int invoke(LuaState l) {
LuaJavaBlock self = (LuaJavaBlock) l.checkUserdata(1, LuaJavaBlock.class, "Block");
l.pushInteger(Block.getStateId(self.blockWorld.getBlockState(self.getPos())));
l.pushInteger(self.block.getMetaFromState((IBlockState) self.getState()));
return 1;
}
};
Expand All @@ -160,10 +159,9 @@ public int invoke(LuaState l) {
public static JavaFunction SetMeta = new JavaFunction() {
public int invoke(LuaState l) {
LuaJavaBlock self = (LuaJavaBlock) l.checkUserdata(1, LuaJavaBlock.class, "Block");

int metaID = l.checkInteger(2, 0);
IBlockState meta = Block.getStateById(metaID);
self.blockWorld.setBlockState(self.getPos(), meta, 3);
IBlockState meta = self.block.getStateFromMeta(metaID);
self.blockWorld.setBlockState(self.getPos(), meta);
return 0;
}
};
Expand Down
13 changes: 13 additions & 0 deletions main/java/com/luacraft/meta/LuaThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ public static void Init(LuaState l) {
}
l.pop(1);

/**
* @author Jake
* @enum THREAD_PRIORITY_MAX
* @enum THREAD_PRIORITY_MIN
* @enum THREAD_PRIORITY_NORM
* @enum THREAD_STATE_BLOCKED
* @enum THREAD_STATE_NEW
* @enum THREAD_STATE_RUNNABLE
* @enum THREAD_STATE_TERMINATED
* @enum THREAD_STATE_TIMED_WAITING
* @enum THREAD_STATE_WAITING
*/

l.pushNumber(Thread.MAX_PRIORITY);
l.setGlobal("THREAD_PRIORITY_MAX");
l.pushNumber(Thread.MIN_PRIORITY);
Expand Down

0 comments on commit 188b937

Please sign in to comment.