|
@@ -81,6 +81,7 @@ import me.km.networking.ModPacketHandler;
|
|
import me.km.pathfinder.PathfinderUtils;
|
|
import me.km.pathfinder.PathfinderUtils;
|
|
import me.km.skills.LeveledSkill;
|
|
import me.km.skills.LeveledSkill;
|
|
import me.km.skills.Skill;
|
|
import me.km.skills.Skill;
|
|
|
|
+import net.minecraft.block.BlockCrops;
|
|
import net.minecraft.entity.item.EntityItem;
|
|
import net.minecraft.entity.item.EntityItem;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraft.util.math.MathHelper;
|
|
@@ -194,10 +195,36 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
setTag(args));
|
|
setTag(args));
|
|
parser.registerFunction("player.gettag", (args, qd) ->
|
|
parser.registerFunction("player.gettag", (args, qd) ->
|
|
getTag(args));
|
|
getTag(args));
|
|
|
|
+ parser.registerConsumer("player.setguild", (args, qd) ->
|
|
|
|
+ {
|
|
|
|
+ if(args[0] instanceof EntityPlayer)
|
|
|
|
+ {
|
|
|
|
+ KajetansMod.playerbank.setGuildId((EntityPlayer) args[0], ScriptUtils.getInt(args[1]));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ KajetansMod.playerbank.setGuildId(args[0].toString(), ScriptUtils.getInt(args[1]));
|
|
|
|
+ });
|
|
|
|
+ parser.registerFunction("player.getguild", (args, qd) ->
|
|
|
|
+ {
|
|
|
|
+ if(args[0] instanceof EntityPlayer)
|
|
|
|
+ {
|
|
|
|
+ return new Fraction(KajetansMod.playerbank.getGuildId((EntityPlayer) args[0]));
|
|
|
|
+ }
|
|
|
|
+ return new Fraction(KajetansMod.playerbank.getGuildId(args[0].toString()));
|
|
|
|
+ });
|
|
|
|
+
|
|
parser.registerConsumer("player.dropinventory", (args, qd) ->
|
|
parser.registerConsumer("player.dropinventory", (args, qd) ->
|
|
dropInventory(args));
|
|
dropInventory(args));
|
|
parser.registerFunction("player.gettarget", (args, qd) ->
|
|
parser.registerFunction("player.gettarget", (args, qd) ->
|
|
- new Location(((EntityPlayer) args[0]).world, Utils.getPlayerTarget((EntityPlayer) args[0], ScriptUtils.getInt(args[1]))));
|
|
|
|
|
|
+ {
|
|
|
|
+ if(args.length > 2)
|
|
|
|
+ {
|
|
|
|
+ return new Location(((EntityPlayer) args[0]).world,
|
|
|
|
+ Utils.getPlayerTarget((EntityPlayer) args[0], ScriptUtils.getInt(args[1]), (boolean) args[2]));
|
|
|
|
+ }
|
|
|
|
+ return new Location(((EntityPlayer) args[0]).world, Utils.getPlayerTarget((EntityPlayer) args[0], ScriptUtils.getInt(args[1])));
|
|
|
|
+ });
|
|
|
|
+
|
|
parser.registerFunction("player.gettargetentity", (args, qd) ->
|
|
parser.registerFunction("player.gettargetentity", (args, qd) ->
|
|
Utils.getTargetedEntity((EntityPlayer) args[0], ScriptUtils.getDouble(args[1]), getClass(args[2].toString())));
|
|
Utils.getTargetedEntity((EntityPlayer) args[0], ScriptUtils.getDouble(args[1]), getClass(args[2].toString())));
|
|
parser.registerFunction("player.hasquest", (args, qd) ->
|
|
parser.registerFunction("player.hasquest", (args, qd) ->
|
|
@@ -322,11 +349,11 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
});
|
|
});
|
|
|
|
|
|
parser.registerFunction("loc.getx", (args, qd) ->
|
|
parser.registerFunction("loc.getx", (args, qd) ->
|
|
- ((Location) args[0]).getX());
|
|
|
|
|
|
+ Fraction.fromDouble(((Location) args[0]).getX()));
|
|
parser.registerFunction("loc.gety", (args, qd) ->
|
|
parser.registerFunction("loc.gety", (args, qd) ->
|
|
- ((Location) args[0]).getY());
|
|
|
|
|
|
+ Fraction.fromDouble(((Location) args[0]).getY()));
|
|
parser.registerFunction("loc.getz", (args, qd) ->
|
|
parser.registerFunction("loc.getz", (args, qd) ->
|
|
- ((Location) args[0]).getZ());
|
|
|
|
|
|
+ Fraction.fromDouble(((Location) args[0]).getZ()));
|
|
|
|
|
|
parser.registerConsumer("loc.setx", (args, qd) ->
|
|
parser.registerConsumer("loc.setx", (args, qd) ->
|
|
((Location) args[0]).setX(ScriptUtils.getDouble(args[1])));
|
|
((Location) args[0]).setX(ScriptUtils.getDouble(args[1])));
|
|
@@ -393,6 +420,44 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
addItemAmountChest(args));
|
|
addItemAmountChest(args));
|
|
parser.registerFunction("block.subitem", (args, qd) ->
|
|
parser.registerFunction("block.subitem", (args, qd) ->
|
|
removeItemAmountChest(args));
|
|
removeItemAmountChest(args));
|
|
|
|
+ parser.registerConsumer("block.grow", (args, qd) ->
|
|
|
|
+ {
|
|
|
|
+ World w = ((Location) args[0]).getWorld();
|
|
|
|
+ BlockPos pos1 = ((Location) args[0]).getBlockPos();
|
|
|
|
+ BlockPos pos2 = ((Location) args[1]).getBlockPos();
|
|
|
|
+
|
|
|
|
+ int x = Math.min(pos1.getX(), pos2.getX());
|
|
|
|
+ int endX = Math.max(pos1.getX(), pos2.getX());
|
|
|
|
+
|
|
|
|
+ int y = Math.min(pos1.getY(), pos2.getY());
|
|
|
|
+ int endY = Math.max(pos1.getY(), pos2.getY());
|
|
|
|
+
|
|
|
|
+ int z = Math.min(pos1.getZ(), pos2.getZ());
|
|
|
|
+ int endZ = Math.max(pos1.getZ(), pos2.getZ());
|
|
|
|
+
|
|
|
|
+ if(endX - x > 50 || endY - y > 50 || endZ - z > 50)
|
|
|
|
+ {
|
|
|
|
+ throw new IllegalArgumentException("uhh, that area seems way to big for growing plants");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BlockPos relative;
|
|
|
|
+ IBlockState state;
|
|
|
|
+ for(; x <= endX; x++)
|
|
|
|
+ {
|
|
|
|
+ for(; y <= endY; y++)
|
|
|
|
+ {
|
|
|
|
+ for(; z <= endZ; z++)
|
|
|
|
+ {
|
|
|
|
+ relative = new BlockPos(x, y, z);
|
|
|
|
+ state = w.getBlockState(relative);
|
|
|
|
+ if(state.getBlock() instanceof BlockCrops)
|
|
|
|
+ {
|
|
|
|
+ w.setBlockState(relative, state.withProperty(BlockCrops.AGE, 7));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
// -------------------------------------------------------------
|
|
// -------------------------------------------------------------
|
|
// Event-Bibliothek
|
|
// Event-Bibliothek
|
|
@@ -1488,7 +1553,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
KajetansMod.playerbank.getDataBank().setTag((EntityPlayer) args[0], args[1].toString(), ScriptUtils.getInt(args[2]));
|
|
KajetansMod.playerbank.getDataBank().setTag((EntityPlayer) args[0], args[1].toString(), ScriptUtils.getInt(args[2]));
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- KajetansMod.playerbank.getDataBank().setTag(KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()), args[1].toString(), ScriptUtils.getInt(args[2]));
|
|
|
|
|
|
+ KajetansMod.playerbank.getDataBank().setTag(args[0].toString(), args[1].toString(), ScriptUtils.getInt(args[2]));
|
|
}
|
|
}
|
|
|
|
|
|
private static Fraction getTag(Object[] args)
|
|
private static Fraction getTag(Object[] args)
|
|
@@ -1497,7 +1562,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
{
|
|
{
|
|
return new Fraction(KajetansMod.playerbank.getDataBank().getTag((EntityPlayer) args[0], args[1].toString()));
|
|
return new Fraction(KajetansMod.playerbank.getDataBank().getTag((EntityPlayer) args[0], args[1].toString()));
|
|
}
|
|
}
|
|
- return new Fraction(KajetansMod.playerbank.getDataBank().getTag(KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()), args[1].toString()));
|
|
|
|
|
|
+ return new Fraction(KajetansMod.playerbank.getDataBank().getTag(args[0].toString(), args[1].toString()));
|
|
}
|
|
}
|
|
|
|
|
|
private static void setGlobalVar(Object[] args)
|
|
private static void setGlobalVar(Object[] args)
|
|
@@ -1505,9 +1570,15 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
if(args[0] instanceof EntityPlayer)
|
|
if(args[0] instanceof EntityPlayer)
|
|
{
|
|
{
|
|
KajetansMod.scripts.getDataBank(ScriptBank.class).setVar(args[2].toString(), args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().toString());
|
|
KajetansMod.scripts.getDataBank(ScriptBank.class).setVar(args[2].toString(), args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().toString());
|
|
- return;
|
|
|
|
}
|
|
}
|
|
- KajetansMod.scripts.getDataBank(ScriptBank.class).setVar(args[2].toString(), args[1].toString(), KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()));
|
|
|
|
|
|
+ else if(args[0].equals("SERVER"))
|
|
|
|
+ {
|
|
|
|
+ KajetansMod.scripts.getDataBank(ScriptBank.class).setVar(args[2].toString(), args[1].toString(), "-1");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ KajetansMod.scripts.getDataBank(ScriptBank.class).setVar(args[2].toString(), args[1].toString(), args[0].toString());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private static Object getGlobalVar(Object[] args)
|
|
private static Object getGlobalVar(Object[] args)
|
|
@@ -1516,7 +1587,11 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
{
|
|
{
|
|
return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().toString());
|
|
return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().toString());
|
|
}
|
|
}
|
|
- return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()));
|
|
|
|
|
|
+ else if(args[0].equals("SERVER"))
|
|
|
|
+ {
|
|
|
|
+ return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), "-1");
|
|
|
|
+ }
|
|
|
|
+ return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), args[0].toString());
|
|
}
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
// -------------------------------------------------------------------------
|