|
@@ -14,7 +14,6 @@ import java.util.stream.Collectors;
|
|
|
import me.hammerle.snuviscript.code.Script;
|
|
|
import me.hammerle.snuviscript.code.SnuviUtils;
|
|
|
import me.hammerle.snuviscript.code.SnuviParser;
|
|
|
-import me.hammerle.snuviscript.math.Fraction;
|
|
|
import me.km.api.Location;
|
|
|
import me.km.api.TitleAPI;
|
|
|
import me.km.api.Utils;
|
|
@@ -83,6 +82,7 @@ import net.minecraft.util.NonNullList;
|
|
|
import net.minecraft.util.math.MathHelper;
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
import net.minecraft.util.text.TextComponentString;
|
|
|
+import net.minecraft.world.GameType;
|
|
|
|
|
|
public class MinecraftFunctions
|
|
|
{
|
|
@@ -129,6 +129,7 @@ public class MinecraftFunctions
|
|
|
KajetansMod.perms.registerPlayerGroup(UUID.fromString(in[0].getString(sc)), in[1].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerFunction("perm.unregisterplayer", (sc, in) -> KajetansMod.perms.unregisterPlayer(UUID.fromString(in[0].getString(sc)), in[1].getInt(sc)));
|
|
|
parser.registerFunction("perm.has", (sc, in) -> KajetansMod.perms.hasPermission((ICommandSender) in[0].get(sc), in[1].getString(sc)));
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
@@ -172,7 +173,7 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Player-Bibliothek
|
|
|
// ---------------------------------------------------------------------
|
|
|
- parser.registerFunction("player.getitemamount", (sc, in) -> new Fraction(InventoryUtils.searchInventoryFor(((EntityPlayer) in[0].get(sc)).inventory, (ItemStack) in[2].get(sc), in[1].getBoolean(sc))));
|
|
|
+ parser.registerFunction("player.getitemamount", (sc, in) -> (double) InventoryUtils.searchInventoryFor(((EntityPlayer) in[0].get(sc)).inventory, (ItemStack) in[2].get(sc), in[1].getBoolean(sc)));
|
|
|
parser.registerFunction("player.removeitem", (sc, in) ->
|
|
|
{
|
|
|
ItemStack stack = ((ItemStack) in[1].get(sc)).copy();
|
|
@@ -201,6 +202,11 @@ public class MinecraftFunctions
|
|
|
});
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerFunction("player.clearinventory", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityPlayer) in[0].get(sc)).inventory.clear();
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
parser.registerFunction("player.inventorytolist", (sc, in) ->
|
|
|
{
|
|
|
in[0].set(sc, ((EntityPlayer) in[1].get(sc)).inventory.mainInventory);
|
|
@@ -230,16 +236,16 @@ public class MinecraftFunctions
|
|
|
((EntityPlayerMP) in[0].get(sc)).connection.sendPacket(new SPacketSpawnPosition(((Location) in[1].get(sc)).getBlockPos()));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("player.gethunger", (sc, in) -> new Fraction(((EntityPlayer) in[0].get(sc)).getFoodStats().getFoodLevel()));
|
|
|
+ parser.registerFunction("player.gethunger", (sc, in) -> (double) ((EntityPlayer) in[0].get(sc)).getFoodStats().getFoodLevel());
|
|
|
parser.registerFunction("player.sethunger", (sc, in) ->
|
|
|
{
|
|
|
((EntityPlayer) in[0].get(sc)).getFoodStats().setFoodLevel(in[1].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("player.getsaturation", (sc, in) -> Fraction.fromDouble(ReflectionUtils.getSaturation(((EntityPlayer) in[0].get(sc)).getFoodStats())));
|
|
|
+ parser.registerFunction("player.getsaturation", (sc, in) -> (double) ReflectionUtils.getSaturation(((EntityPlayer) in[0].get(sc)).getFoodStats()));
|
|
|
parser.registerFunction("player.setsaturation", (sc, in) ->
|
|
|
{
|
|
|
- ReflectionUtils.setSaturation(((EntityPlayer) in[0].get(sc)).getFoodStats(), in[1].getFraction(sc).floatValue());
|
|
|
+ ReflectionUtils.setSaturation(((EntityPlayer) in[0].get(sc)).getFoodStats(), in[1].getFloat(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("player.getname", (sc, in) ->
|
|
@@ -271,6 +277,37 @@ public class MinecraftFunctions
|
|
|
});
|
|
|
parser.registerFunction("player.isadventure", (sc, in) -> !((EntityPlayer) in[0].get(sc)).capabilities.allowEdit);
|
|
|
parser.registerFunction("player.hasfly", (sc, in) -> ((EntityPlayer) in[0].get(sc)).capabilities.allowFlying);
|
|
|
+ parser.registerFunction("player.setgamemode", (sc, in) ->
|
|
|
+ {
|
|
|
+ EntityPlayer p = (EntityPlayer) in[0].get(sc);
|
|
|
+ switch(in[1].get(sc).toString())
|
|
|
+ {
|
|
|
+ case "survival":
|
|
|
+ case "s":
|
|
|
+ case "0":
|
|
|
+ p.setGameType(GameType.SURVIVAL);
|
|
|
+ break;
|
|
|
+ case "creative":
|
|
|
+ case "c":
|
|
|
+ case "1":
|
|
|
+ p.setGameType(GameType.CREATIVE);
|
|
|
+ break;
|
|
|
+ case "adventure":
|
|
|
+ case "a":
|
|
|
+ case "2":
|
|
|
+ p.setGameType(GameType.ADVENTURE);
|
|
|
+ break;
|
|
|
+ case "specator":
|
|
|
+ case "w":
|
|
|
+ case "3":
|
|
|
+ p.setGameType(GameType.SPECTATOR);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ p.setGameType(GameType.CREATIVE);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
parser.registerFunction("player.getlastdamager", (sc, in) ->
|
|
|
{
|
|
|
DamageSource ds = ((EntityPlayer) in[0].get(sc)).getLastDamageSource();
|
|
@@ -296,9 +333,9 @@ public class MinecraftFunctions
|
|
|
Object o = in[0].get(sc);
|
|
|
if(o instanceof EntityPlayer)
|
|
|
{
|
|
|
- return new Fraction(KajetansMod.playerbank.getDataBank().getTag((EntityPlayer) o, in[1].getString(sc)));
|
|
|
+ return (double) KajetansMod.playerbank.getDataBank().getTag((EntityPlayer) o, in[1].getString(sc));
|
|
|
}
|
|
|
- return new Fraction(KajetansMod.playerbank.getDataBank().getTag(o.toString(), in[1].getString(sc)));
|
|
|
+ return (double) KajetansMod.playerbank.getDataBank().getTag(o.toString(), in[1].getString(sc));
|
|
|
});
|
|
|
parser.registerFunction("player.setguild", (sc, in) ->
|
|
|
{
|
|
@@ -316,9 +353,9 @@ public class MinecraftFunctions
|
|
|
Object o = in[0].get(sc);
|
|
|
if(o instanceof EntityPlayer)
|
|
|
{
|
|
|
- return new Fraction(KajetansMod.playerbank.getGuildId((EntityPlayer) o));
|
|
|
+ return (double) KajetansMod.playerbank.getGuildId((EntityPlayer) o);
|
|
|
}
|
|
|
- return new Fraction(KajetansMod.playerbank.getGuildId(o.toString()));
|
|
|
+ return (double) KajetansMod.playerbank.getGuildId(o.toString());
|
|
|
});
|
|
|
parser.registerFunction("player.dropinventory", (sc, in) ->
|
|
|
{
|
|
@@ -373,7 +410,7 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Players-Bibliothek
|
|
|
// ---------------------------------------------------------------------
|
|
|
- parser.registerFunction("players.getamount", (sc, in) -> new Fraction(KajetansMod.server.getCurrentPlayerCount()));
|
|
|
+ parser.registerFunction("players.getamount", (sc, in) -> (double) KajetansMod.server.getCurrentPlayerCount());
|
|
|
parser.registerFunction("players.tolist", (sc, in) ->
|
|
|
{
|
|
|
in[0].set(sc, new ArrayList(KajetansMod.server.getPlayerList().getPlayers()));
|
|
@@ -468,44 +505,43 @@ public class MinecraftFunctions
|
|
|
parser.registerAlias("players.toworldlist", "world.getplayers");
|
|
|
parser.registerFunction("world.setskills", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).skills = in[1].getBoolean(sc);
|
|
|
+ KajetansMod.worldManager.getWorldPreferences((World) in[0].get(sc)).skills = in[1].getBoolean(sc);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("world.setblockprotections", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).blockProtection = in[1].getBoolean(sc);
|
|
|
+ KajetansMod.worldManager.getWorldPreferences((World) in[0].get(sc)).blockProtection = in[1].getBoolean(sc);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("world.setdefaultenchanting", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).defaultEnchanting = in[1].getBoolean(sc);
|
|
|
+ KajetansMod.worldManager.getWorldPreferences((World) in[0].get(sc)).defaultEnchanting = in[1].getBoolean(sc);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("world.setpvpprotection", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).pvpProtection = in[1].getBoolean(sc);
|
|
|
+ KajetansMod.worldManager.getWorldPreferences((World) in[0].get(sc)).pvpProtection = in[1].getBoolean(sc);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("world.setstatuseffects", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).statusEffects = in[1].getBoolean(sc);
|
|
|
- return Void.TYPE;
|
|
|
- });
|
|
|
- parser.registerFunction("world.setmanabar", (sc, in) ->
|
|
|
- {
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).manabar = in[1].getBoolean(sc);
|
|
|
+ KajetansMod.worldManager.getWorldPreferences((World) in[0].get(sc)).statusEffects = in[1].getBoolean(sc);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("world.setscrolls", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).scrolls = in[1].getBoolean(sc);
|
|
|
+ KajetansMod.worldManager.getWorldPreferences((World) in[0].get(sc)).scrolls = in[1].getBoolean(sc);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("world.setdefaultproducing", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.worldManager.getWorldPreferences(ModDimensions.getWorldFromName(in[0].getString(sc))).defaultProducing = in[1].getBoolean(sc);
|
|
|
+ KajetansMod.worldManager.getWorldPreferences((World) in[0].get(sc)).defaultProducing = in[1].getBoolean(sc);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerFunction("world.get", (sc, in) ->
|
|
|
+ {
|
|
|
+ return ModDimensions.getWorldFromName(in[0].getString(sc));
|
|
|
+ });
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Item-Bibliothek
|
|
@@ -529,15 +565,17 @@ public class MinecraftFunctions
|
|
|
ItemStackUtils.drop(w, pos, stack);
|
|
|
}
|
|
|
return Void.TYPE;
|
|
|
- });
|
|
|
+ });
|
|
|
+ parser.registerFunction("item.gettooltype", (sc, in) -> Utils.getToolType((ItemStack) in[0].get(sc)).toString());
|
|
|
+ parser.registerFunction("item.get", (sc, in) -> ((ItemStack) in[0].get(sc)).getItem());
|
|
|
parser.registerFunction("item.gettype", (sc, in) -> ((ItemStack) in[0].get(sc)).getItem().getRegistryName().toString());
|
|
|
- parser.registerFunction("item.getdata", (sc, in) -> new Fraction(((ItemStack) in[0].get(sc)).getMetadata()));
|
|
|
+ parser.registerFunction("item.getdata", (sc, in) -> (double) ((ItemStack) in[0].get(sc)).getMetadata());
|
|
|
parser.registerFunction("item.setdata", (sc, in) ->
|
|
|
{
|
|
|
((ItemStack) in[0].get(sc)).setItemDamage(in[1].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("item.getamount", (sc, in) -> new Fraction(((ItemStack) in[0].get(sc)).getCount()));
|
|
|
+ parser.registerFunction("item.getamount", (sc, in) -> (double) ((ItemStack) in[0].get(sc)).getCount());
|
|
|
parser.registerFunction("item.setamount", (sc, in) ->
|
|
|
{
|
|
|
((ItemStack) in[0].get(sc)).setCount(in[1].getInt(sc));
|
|
@@ -564,7 +602,7 @@ public class MinecraftFunctions
|
|
|
ItemStackUtils.addLore((ItemStack) in[0].get(sc), SnuviUtils.connect(sc, in, 2), in[1].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("item.getenchantlevel", (sc, in) -> new Fraction(EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByLocation(in[1].getString(sc)), (ItemStack) in[0].get(sc))));
|
|
|
+ parser.registerFunction("item.getenchantlevel", (sc, in) -> (double) EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByLocation(in[1].getString(sc)), (ItemStack) in[0].get(sc)));
|
|
|
parser.registerFunction("item.setcooldown", (sc, in) ->
|
|
|
{
|
|
|
((EntityPlayer) in[0].get(sc)).getCooldownTracker().setCooldown(((ItemStack) in[1].get(sc)).getItem(), in[2].getInt(sc));
|
|
@@ -581,13 +619,13 @@ public class MinecraftFunctions
|
|
|
{
|
|
|
return new Location(ModDimensions.getWorldFromName(in[0].getString(sc)),
|
|
|
in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc),
|
|
|
- in[4].getFraction(sc).floatValue(), in[5].getFraction(sc).floatValue());
|
|
|
+ in[4].getFloat(sc), in[5].getFloat(sc));
|
|
|
}
|
|
|
return new Location(ModDimensions.getWorldFromName(in[0].getString(sc)), in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc), 0, 0);
|
|
|
});
|
|
|
- parser.registerFunction("loc.getx", (sc, in) -> Fraction.fromDouble(((Location) in[0].get(sc)).getX()));
|
|
|
- parser.registerFunction("loc.gety", (sc, in) -> Fraction.fromDouble(((Location) in[0].get(sc)).getY()));
|
|
|
- parser.registerFunction("loc.getz", (sc, in) -> Fraction.fromDouble(((Location) in[0].get(sc)).getZ()));
|
|
|
+ parser.registerFunction("loc.getx", (sc, in) -> ((Location) in[0].get(sc)).getX());
|
|
|
+ parser.registerFunction("loc.gety", (sc, in) -> ((Location) in[0].get(sc)).getY());
|
|
|
+ parser.registerFunction("loc.getz", (sc, in) -> ((Location) in[0].get(sc)).getZ());
|
|
|
parser.registerFunction("loc.setx", (sc, in) ->
|
|
|
{
|
|
|
((Location) in[0].get(sc)).setX(in[1].getDouble(sc));
|
|
@@ -620,15 +658,15 @@ public class MinecraftFunctions
|
|
|
});
|
|
|
parser.registerFunction("loc.setyaw", (sc, in) ->
|
|
|
{
|
|
|
- ((Location) in[0].get(sc)).setYaw(in[1].getFraction(sc).floatValue());
|
|
|
+ ((Location) in[0].get(sc)).setYaw(in[1].getFloat(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("loc.setpitch", (sc, in) ->
|
|
|
{
|
|
|
- ((Location) in[0].get(sc)).setPitch(in[1].getFraction(sc).floatValue());
|
|
|
+ ((Location) in[0].get(sc)).setPitch(in[1].getFloat(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("loc.distance", (sc, in) -> Fraction.fromDouble(((Location) in[0].get(sc)).getPos().distanceTo(((Location) in[1].get(sc)).getPos())));
|
|
|
+ parser.registerFunction("loc.distance", (sc, in) -> ((Location) in[0].get(sc)).getPos().distanceTo(((Location) in[1].get(sc)).getPos()));
|
|
|
parser.registerFunction("loc.mod", (sc, in) -> ((Location) in[0].get(sc)).copyAdd(in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc)));
|
|
|
parser.registerFunction("loc.getcoord", (sc, in) ->
|
|
|
{
|
|
@@ -636,24 +674,24 @@ public class MinecraftFunctions
|
|
|
switch(in[1].getString(sc))
|
|
|
{
|
|
|
case "x":
|
|
|
- return Fraction.fromDouble(l.getX());
|
|
|
+ return l.getX();
|
|
|
case "y":
|
|
|
- return Fraction.fromDouble(l.getY());
|
|
|
+ return l.getY();
|
|
|
case "z":
|
|
|
- return Fraction.fromDouble(l.getZ());
|
|
|
+ return l.getZ();
|
|
|
case "bx":
|
|
|
- return new Fraction(MathHelper.floor(l.getX()));
|
|
|
+ return (double) MathHelper.floor(l.getX());
|
|
|
case "by":
|
|
|
- return new Fraction(MathHelper.floor(l.getY()));
|
|
|
+ return (double) MathHelper.floor(l.getY());
|
|
|
case "bz":
|
|
|
- return new Fraction(MathHelper.floor(l.getZ()));
|
|
|
+ return (double) MathHelper.floor(l.getZ());
|
|
|
case "w":
|
|
|
return ModDimensions.getWorldName(l.getWorld());
|
|
|
default:
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
- parser.registerFunction("loc.gettime", (sc, in) -> new Fraction(((Location) in[0].get(sc)).getWorld().getWorldTime()));
|
|
|
+ parser.registerFunction("loc.gettime", (sc, in) -> (double) ((Location) in[0].get(sc)).getWorld().getWorldTime());
|
|
|
parser.registerFunction("loc.hasstorm", (sc, in) -> ((Location) in[0].get(sc)).getWorld().isRaining());
|
|
|
parser.registerFunction("loc.isbetween", (sc, in) ->
|
|
|
{
|
|
@@ -668,12 +706,21 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Block-Bibliothek
|
|
|
// ---------------------------------------------------------------------
|
|
|
- parser.registerFunction("block.gettype", (sc, in) -> ((Location) in[0].get(sc)).getWorld().getBlockState(((Location) in[0].get(sc)).getBlockPos()).getBlock().getRegistryName().toString());
|
|
|
+ parser.registerFunction("block.gettype", (sc, in) ->
|
|
|
+ {
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ return l.getWorld().getBlockState(l.getBlockPos()).getBlock().getRegistryName().toString();
|
|
|
+ });
|
|
|
+ parser.registerFunction("block.get", (sc, in) ->
|
|
|
+ {
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ return l.getWorld().getBlockState(l.getBlockPos()).getBlock();
|
|
|
+ });
|
|
|
parser.registerFunction("block.getdata", (sc, in) ->
|
|
|
{
|
|
|
Location l = (Location) in[0].get(sc);
|
|
|
IBlockState state = l.getWorld().getBlockState(l.getBlockPos());
|
|
|
- return new Fraction(state.getBlock().getMetaFromState(state));
|
|
|
+ return (double) state.getBlock().getMetaFromState(state);
|
|
|
});
|
|
|
parser.registerFunction("block.clone", (sc, in) ->
|
|
|
{
|
|
@@ -750,9 +797,9 @@ public class MinecraftFunctions
|
|
|
TileEntity te = l.getWorld().getTileEntity(l.getBlockPos());
|
|
|
if(te == null || !(te instanceof TileEntityChest))
|
|
|
{
|
|
|
- return new Fraction(0);
|
|
|
+ return 0.0d;
|
|
|
}
|
|
|
- return new Fraction(InventoryUtils.searchInventoryFor((TileEntityChest) te, (ItemStack) in[2].get(sc), in[1].getBoolean(sc)));
|
|
|
+ return (double) InventoryUtils.searchInventoryFor((TileEntityChest) te, (ItemStack) in[2].get(sc), in[1].getBoolean(sc));
|
|
|
});
|
|
|
parser.registerFunction("block.additem", (sc, in) ->
|
|
|
{
|
|
@@ -871,62 +918,62 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Job-Bibliothek
|
|
|
// ---------------------------------------------------------------------
|
|
|
- parser.registerFunction("job.getlevel", (sc, in) -> new Fraction(KajetansMod.jobs.getLevel((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue())));
|
|
|
+ parser.registerFunction("job.getlevel", (sc, in) -> (double) KajetansMod.jobs.getLevel((EntityPlayer) in[0].get(sc), in[1].getByte(sc)));
|
|
|
parser.registerFunction("job.addlevel", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.addLevel((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue(), in[2].getFraction(sc).byteValue());
|
|
|
+ KajetansMod.jobs.addLevel((EntityPlayer) in[0].get(sc), in[1].getByte(sc), in[2].getByte(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.setlevel", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.setLevel((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue(), in[2].getFraction(sc).byteValue());
|
|
|
+ KajetansMod.jobs.setLevel((EntityPlayer) in[0].get(sc), in[1].getByte(sc), in[2].getByte(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("job.getxp", (sc, in) -> new Fraction(KajetansMod.jobs.getXP((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue())));
|
|
|
+ parser.registerFunction("job.getxp", (sc, in) -> (double) KajetansMod.jobs.getXP((EntityPlayer) in[0].get(sc), in[1].getByte(sc)));
|
|
|
parser.registerFunction("job.addxp", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.addXP((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue(), in[2].getInt(sc));
|
|
|
+ KajetansMod.jobs.addXP((EntityPlayer) in[0].get(sc), in[1].getByte(sc), in[2].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.setxp", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.setXP((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue(), in[2].getInt(sc));
|
|
|
+ KajetansMod.jobs.setXP((EntityPlayer) in[0].get(sc), in[1].getByte(sc), in[2].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.registerjob", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.registerJob(in[0].getFraction(sc).byteValue(), SnuviUtils.connect(sc, in, 1));
|
|
|
+ KajetansMod.jobs.registerJob(in[0].getByte(sc), SnuviUtils.connect(sc, in, 1));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.registerrecipe", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.registerRecipe(in[0].getFraction(sc).byteValue(), ItemStackUtils.getItem(in[1].getString(sc)), in[2].getFraction(sc).byteValue());
|
|
|
+ KajetansMod.jobs.registerRecipe(in[0].getByte(sc), ItemStackUtils.getItem(in[1].getString(sc)), in[2].getByte(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.registermaterial", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.registerPreferedBlock(in[0].getFraction(sc).byteValue(), Block.getBlockFromName(in[1].getString(sc)));
|
|
|
+ KajetansMod.jobs.registerPreferedBlock(in[0].getByte(sc), Block.getBlockFromName(in[1].getString(sc)));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.registerskill", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.registerSkill(in[0].getFraction(sc).byteValue(), KajetansMod.skills.getSkill(in[1].getInt(sc)), in[2].getFraction(sc).byteValue(), in[3].getFraction(sc).byteValue());
|
|
|
+ KajetansMod.jobs.registerSkill(in[0].getByte(sc), KajetansMod.skills.getSkill(in[1].getInt(sc)), in[2].getByte(sc), in[3].getByte(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("job.getamount", (sc, in) -> new Fraction(KajetansMod.jobs.getNumberOfJobs()));
|
|
|
- parser.registerFunction("job.getname", (sc, in) -> KajetansMod.jobs.getJobName(in[0].getFraction(sc).byteValue()));
|
|
|
- parser.registerFunction("job.geteffectlevel", (sc, in) -> new Fraction(EffectUtils.getEffectLevel((EntityPlayer) in[0].get(sc), me.km.effects.Effect.valueOf(in[1].getString(sc)))));
|
|
|
- parser.registerFunction("job.hasjob", (sc, in) -> KajetansMod.jobs.hasJob((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue()));
|
|
|
+ parser.registerFunction("job.getamount", (sc, in) -> (double) KajetansMod.jobs.getNumberOfJobs());
|
|
|
+ parser.registerFunction("job.getname", (sc, in) -> KajetansMod.jobs.getJobName(in[0].getByte(sc)));
|
|
|
+ parser.registerFunction("job.geteffectlevel", (sc, in) -> (double) EffectUtils.getEffectLevel((EntityPlayer) in[0].get(sc), me.km.effects.Effect.valueOf(in[1].getString(sc))));
|
|
|
+ parser.registerFunction("job.hasjob", (sc, in) -> KajetansMod.jobs.hasJob((EntityPlayer) in[0].get(sc), in[1].getByte(sc)));
|
|
|
parser.registerFunction("job.hasrecipe", (sc, in) -> KajetansMod.jobs.hasRecipe((EntityPlayer) in[0].get(sc), ItemStackUtils.getItem(in[1].getString(sc))));
|
|
|
parser.registerFunction("job.getjobs", (sc, in) ->
|
|
|
{
|
|
|
- in[0].set(sc, KajetansMod.jobs.getJobs((EntityPlayer) in[1].get(sc)).stream().map(b -> new Fraction(b)).collect(Collectors.toList()));
|
|
|
+ in[0].set(sc, KajetansMod.jobs.getJobs((EntityPlayer) in[1].get(sc)).stream().map(b -> (double) b).collect(Collectors.toList()));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.isregmaterial", (sc, in) -> KajetansMod.jobs.isPreferedMaterial((EntityPlayer) in[0].get(sc),Block.getBlockFromName(in[1].getString(sc))));
|
|
|
parser.registerFunction("job.setjob", (sc, in) ->
|
|
|
{
|
|
|
- KajetansMod.jobs.setJob((EntityPlayer) in[0].get(sc), in[1].getFraction(sc).byteValue(), in[2].getBoolean(sc));
|
|
|
+ KajetansMod.jobs.setJob((EntityPlayer) in[0].get(sc), in[1].getByte(sc), in[2].getBoolean(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("job.reset", (sc, in) ->
|
|
@@ -944,10 +991,10 @@ public class MinecraftFunctions
|
|
|
// entity.damage(entity, damagefloat, DamageSource);
|
|
|
if(in.length >= 3)
|
|
|
{
|
|
|
- ((EntityLivingBase) in[0].get(sc)).attackEntityFrom((DamageSource) in[2].get(sc), in[1].getFraction(sc).floatValue());
|
|
|
+ ((EntityLivingBase) in[0].get(sc)).attackEntityFrom((DamageSource) in[2].get(sc), in[1].getFloat(sc));
|
|
|
return Void.TYPE;
|
|
|
}
|
|
|
- ((EntityLivingBase) in[0].get(sc)).attackEntityFrom(DamageSource.GENERIC, in[1].getFraction(sc).floatValue());
|
|
|
+ ((EntityLivingBase) in[0].get(sc)).attackEntityFrom(DamageSource.GENERIC, in[1].getFloat(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("entity.getdamagesource", (sc, in) ->
|
|
@@ -1023,10 +1070,10 @@ public class MinecraftFunctions
|
|
|
}
|
|
|
return DamageSource.GENERIC;
|
|
|
});
|
|
|
- parser.registerFunction("entity.gethealth", (sc, in) -> Fraction.fromDouble(((EntityLivingBase) in[0].get(sc)).getHealth()));
|
|
|
+ parser.registerFunction("entity.gethealth", (sc, in) -> (double) ((EntityLivingBase) in[0].get(sc)).getHealth());
|
|
|
parser.registerFunction("entity.sethealth", (sc, in) ->
|
|
|
{
|
|
|
- ((EntityLivingBase) in[0].get(sc)).setHealth(in[1].getFraction(sc).floatValue());
|
|
|
+ ((EntityLivingBase) in[0].get(sc)).setHealth(in[1].getFloat(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("entity.setname", (sc, in) ->
|
|
@@ -1203,10 +1250,10 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Status-Bibliothek
|
|
|
// ---------------------------------------------------------------------
|
|
|
- parser.registerFunction("status.getmana", (sc, in) -> new Fraction(EnvironmentAPI.getMana(((EntityPlayer) in[0].get(sc)))));
|
|
|
- parser.registerFunction("status.getcold", (sc, in) -> new Fraction(EnvironmentAPI.getCold(((EntityPlayer) in[0].get(sc)))));
|
|
|
- parser.registerFunction("status.getenergy", (sc, in) -> new Fraction(EnvironmentAPI.getEnergy(((EntityPlayer) in[0].get(sc)))));
|
|
|
- parser.registerFunction("status.getthirst", (sc, in) -> new Fraction(EnvironmentAPI.getThirst(((EntityPlayer) in[0].get(sc)))));
|
|
|
+ parser.registerFunction("status.getmana", (sc, in) -> (double) EnvironmentAPI.getMana(((EntityPlayer) in[0].get(sc))));
|
|
|
+ parser.registerFunction("status.getcold", (sc, in) -> (double) EnvironmentAPI.getCold(((EntityPlayer) in[0].get(sc))));
|
|
|
+ parser.registerFunction("status.getenergy", (sc, in) -> (double) EnvironmentAPI.getEnergy(((EntityPlayer) in[0].get(sc))));
|
|
|
+ parser.registerFunction("status.getthirst", (sc, in) -> (double) EnvironmentAPI.getThirst(((EntityPlayer) in[0].get(sc))));
|
|
|
parser.registerFunction("status.changemange", (sc, in) ->
|
|
|
{
|
|
|
EnvironmentAPI.changeMana(((EntityPlayer) in[0].get(sc)), in[1].getInt(sc));
|
|
@@ -1250,7 +1297,7 @@ public class MinecraftFunctions
|
|
|
parser.registerFunction("status.gettemperature", (sc, in) ->
|
|
|
{
|
|
|
Location l = (Location) in[0].get(sc);
|
|
|
- return new Fraction(EnvironmentAPI.getTemperature(l.getWorld(), l.getBlockPos()));
|
|
|
+ return (double) EnvironmentAPI.getTemperature(l.getWorld(), l.getBlockPos());
|
|
|
});
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
@@ -1391,13 +1438,13 @@ public class MinecraftFunctions
|
|
|
((Table) in[0].get(sc)).setElement(in[1].getInt(sc), in[2].getInt(sc), in[3].get(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("table.getindexof", (sc, in) -> new Fraction(((Table) in[0].get(sc)).getIndexOf(in[1].get(sc))));
|
|
|
+ parser.registerFunction("table.getindexof", (sc, in) -> (double) ((Table) in[0].get(sc)).getIndexOf(in[1].get(sc)));
|
|
|
parser.registerFunction("table.setsortcolumn", (sc, in) ->
|
|
|
{
|
|
|
((Table) in[0].get(sc)).setSortColumn(in[1].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("table.getsize", (sc, in) -> new Fraction(((Table) in[0].get(sc)).getSize()));
|
|
|
+ parser.registerFunction("table.getsize", (sc, in) -> (double) ((Table) in[0].get(sc)).getSize());
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Plot-Bibliothek
|
|
@@ -1422,7 +1469,7 @@ public class MinecraftFunctions
|
|
|
{
|
|
|
Location l = (Location) in[1].get(sc);
|
|
|
in[0].set(sc, KajetansMod.plots.getDataBank(ProtectionBank.class).getRegionIds(l.getWorld(),
|
|
|
- l.getBlockPos()).stream().map(o -> new Fraction(Integer.parseInt(o.toString()))).collect(Collectors.toSet()));
|
|
|
+ l.getBlockPos()).stream().map(o -> ((Number) o).doubleValue()).collect(Collectors.toSet()));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("plot.canbuild", (sc, in) ->
|
|
@@ -1457,7 +1504,7 @@ public class MinecraftFunctions
|
|
|
in[0].set(sc, new ArrayList<>(KajetansMod.scripts.getPlayerList(sc.getId())));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("script.getplayeramount", (sc, in) -> new Fraction(KajetansMod.scripts.getPlayerList(sc.getId()).size()));
|
|
|
+ parser.registerFunction("script.getplayeramount", (sc, in) -> (double) KajetansMod.scripts.getPlayerList(sc.getId()).size());
|
|
|
parser.registerFunction("script.start", (sc, in) ->
|
|
|
{
|
|
|
Object o = in[0].get(sc);
|
|
@@ -1519,14 +1566,14 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
parser.registerFunction("display.add", (sc, in) ->
|
|
|
{
|
|
|
- byte id = in[1].getFraction(sc).byteValue();
|
|
|
+ byte id = in[1].getByte(sc);
|
|
|
String message = SnuviUtils.connect(sc, in, 2);
|
|
|
doForGroup(in[0].get(sc), sc, p -> ModPacketHandler.sendToDisplay((EntityPlayerMP) p, (byte) 1, id, message));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("display.remove", (sc, in) ->
|
|
|
{
|
|
|
- byte id = in[1].getFraction(sc).byteValue();
|
|
|
+ byte id = in[1].getByte(sc);
|
|
|
doForGroup(in[0].get(sc), sc, p -> ModPacketHandler.sendToDisplay((EntityPlayerMP) p, (byte) 2, id, ""));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
@@ -1541,17 +1588,17 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
parser.registerFunction("head.add", (sc, in) ->
|
|
|
{
|
|
|
- byte id = in[1].getFraction(sc).byteValue();
|
|
|
+ byte id = in[1].getByte(sc);
|
|
|
String name = in[2].getString(sc);
|
|
|
int x = in[3].getInt(sc);
|
|
|
int y = in[4].getInt(sc);
|
|
|
- byte scale = in[5].getFraction(sc).byteValue();
|
|
|
+ byte scale = in[5].getByte(sc);
|
|
|
doForGroup(in[0].get(sc), sc, p -> ModPacketHandler.sendToHead((EntityPlayerMP) p, (byte) 1, id, name, x, y, scale));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("head.remove", (sc, in) ->
|
|
|
{
|
|
|
- byte id = in[1].getFraction(sc).byteValue();
|
|
|
+ byte id = in[1].getByte(sc);
|
|
|
doForGroup(in[0].get(sc), sc, p -> ModPacketHandler.sendToHead((EntityPlayerMP) p, (byte) 2, id, "", -1, -1, (byte) -1));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
@@ -1593,7 +1640,7 @@ public class MinecraftFunctions
|
|
|
});
|
|
|
parser.registerFunction("inv.getid", (sc, in) ->
|
|
|
{
|
|
|
- return new Fraction(((SnuviInventory) in[0].get(sc)).getId());
|
|
|
+ return (double) ((SnuviInventory) in[0].get(sc)).getId();
|
|
|
});
|
|
|
parser.registerFunction("inv.loadblock", (sc, in) ->
|
|
|
{
|
|
@@ -1771,6 +1818,7 @@ public class MinecraftFunctions
|
|
|
}
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerAlias("delglobalvar", "dgv");
|
|
|
parser.registerFunction("msg", (sc, in) ->
|
|
|
{
|
|
|
sendMessageToGroup(in[0].get(sc), sc, NBTUtils.concat(sc, 1, in));
|