|
@@ -84,7 +84,10 @@ import net.minecraft.entity.projectile.SmallFireballEntity;
|
|
import net.minecraft.entity.projectile.SnowballEntity;
|
|
import net.minecraft.entity.projectile.SnowballEntity;
|
|
import net.minecraft.entity.projectile.SpectralArrowEntity;
|
|
import net.minecraft.entity.projectile.SpectralArrowEntity;
|
|
import net.minecraft.entity.projectile.WitherSkullEntity;
|
|
import net.minecraft.entity.projectile.WitherSkullEntity;
|
|
|
|
+import net.minecraft.inventory.EnderChestInventory;
|
|
import net.minecraft.inventory.EquipmentSlotType;
|
|
import net.minecraft.inventory.EquipmentSlotType;
|
|
|
|
+import net.minecraft.inventory.container.ChestContainer;
|
|
|
|
+import net.minecraft.inventory.container.SimpleNamedContainerProvider;
|
|
import net.minecraft.item.ArmorItem;
|
|
import net.minecraft.item.ArmorItem;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.Items;
|
|
import net.minecraft.item.Items;
|
|
@@ -194,9 +197,9 @@ public class MinecraftFunctions
|
|
|
|
|
|
|
|
|
|
sm.registerFunction("table.getstart", (sc, in) -> TableUtils.getTableStart(in[0].getInt(sc), in[1].getInt(sc), in[2].getString(sc)));
|
|
sm.registerFunction("table.getstart", (sc, in) -> TableUtils.getTableStart(in[0].getInt(sc), in[1].getInt(sc), in[2].getString(sc)));
|
|
- sm.registerFunction("title.getmiddle", (sc, in) -> TableUtils.getTableMiddle(in[0].getInt(sc), in[1].getInt(sc), in[2].getString(sc)));
|
|
+ sm.registerFunction("table.getmiddle", (sc, in) -> TableUtils.getTableMiddle(in[0].getInt(sc), in[1].getInt(sc), in[2].getString(sc)));
|
|
- sm.registerFunction("title.getend", (sc, in) -> TableUtils.getTableEnd(in[0].getInt(sc), in[1].getInt(sc), in[2].getString(sc)));
|
|
+ sm.registerFunction("table.getend", (sc, in) -> TableUtils.getTableEnd(in[0].getInt(sc), in[1].getInt(sc), in[2].getString(sc)));
|
|
- sm.registerFunction("title.get", (sc, in) ->
|
|
+ sm.registerFunction("table.get", (sc, in) ->
|
|
{
|
|
{
|
|
String[] columns = new String[in.length - 2];
|
|
String[] columns = new String[in.length - 2];
|
|
for(int i = 0; i < columns.length; i++)
|
|
for(int i = 0; i < columns.length; i++)
|
|
@@ -209,7 +212,7 @@ public class MinecraftFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- sm.registerFunction("table.settime", (sc, in) ->
|
|
+ sm.registerFunction("title.settime", (sc, in) ->
|
|
{
|
|
{
|
|
((ServerPlayerEntity) in[0].get(sc)).connection.sendPacket(new STitlePacket(in[1].getInt(sc), in[2].getInt(sc), in[3].getInt(sc)));
|
|
((ServerPlayerEntity) in[0].get(sc)).connection.sendPacket(new STitlePacket(in[1].getInt(sc), in[2].getInt(sc), in[3].getInt(sc)));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
@@ -470,12 +473,21 @@ public class MinecraftFunctions
|
|
sm.registerAlias("player.setspawn", "player.setbedspawn");
|
|
sm.registerAlias("player.setspawn", "player.setbedspawn");
|
|
sm.registerFunction("player.damageitem", (sc, in) ->
|
|
sm.registerFunction("player.damageitem", (sc, in) ->
|
|
{
|
|
{
|
|
- ((PlayerEntity) in[0].get(sc)).getHeldItemMainhand().damageItem(in[1].getInt(sc), (PlayerEntity) in[0].get(sc), (c) -> {});
|
|
+ PlayerEntity p =(PlayerEntity) in[0].get(sc);
|
|
|
|
+ p.getHeldItemMainhand().damageItem(in[1].getInt(sc), p, (c) -> {});
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("player.openenderchest", (sc, in) ->
|
|
sm.registerFunction("player.openenderchest", (sc, in) ->
|
|
{
|
|
{
|
|
- ((PlayerEntity) in[1].get(sc)).getInventoryEnderChest().openInventory((PlayerEntity) in[0].get(sc));
|
|
+ PlayerEntity p1 = (PlayerEntity) in[0].get(sc);
|
|
|
|
+ PlayerEntity p2 = (PlayerEntity) in[1].get(sc);
|
|
|
|
+
|
|
|
|
+ EnderChestInventory inv = p2.getInventoryEnderChest();
|
|
|
|
+ p1.openContainer(new SimpleNamedContainerProvider((id, pInv, p) ->
|
|
|
|
+ {
|
|
|
|
+ return ChestContainer.createGeneric9X3(id, pInv, inv);
|
|
|
|
+ }, new StringTextComponent(in[2].getString(sc))));
|
|
|
|
+
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("player.getlevel", (sc, in) -> (double) ((PlayerEntity) in[0].get(sc)).experienceLevel);
|
|
sm.registerFunction("player.getlevel", (sc, in) -> (double) ((PlayerEntity) in[0].get(sc)).experienceLevel);
|
|
@@ -504,11 +516,7 @@ public class MinecraftFunctions
|
|
sm.registerFunction("player.gethead", (sc, in) ->
|
|
sm.registerFunction("player.gethead", (sc, in) ->
|
|
{
|
|
{
|
|
ItemStack stack = new ItemStack(Items.PLAYER_HEAD);
|
|
ItemStack stack = new ItemStack(Items.PLAYER_HEAD);
|
|
- CompoundNBT com = stack.getTag();
|
|
+ CompoundNBT com = stack.getOrCreateTag();
|
|
- if(com == null)
|
|
|
|
- {
|
|
|
|
- return stack;
|
|
|
|
- }
|
|
|
|
GameProfile gp = new GameProfile(getUUID(in[0].get(sc)), in[1].getString(sc));
|
|
GameProfile gp = new GameProfile(getUUID(in[0].get(sc)), in[1].getString(sc));
|
|
gp = SkullTileEntity.updateGameProfile(gp);
|
|
gp = SkullTileEntity.updateGameProfile(gp);
|
|
com.put("SkullOwner", NBTUtil.writeGameProfile(new CompoundNBT(), gp));
|
|
com.put("SkullOwner", NBTUtil.writeGameProfile(new CompoundNBT(), gp));
|
|
@@ -696,7 +704,7 @@ public class MinecraftFunctions
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("item.gettag", (sc, in) -> ItemTags.getCollection().get(new ResourceLocation(in[0].getString(sc))));
|
|
sm.registerFunction("item.gettag", (sc, in) -> ItemTags.getCollection().get(new ResourceLocation(in[0].getString(sc))));
|
|
- sm.registerFunction("item.hastag", (sc, in) -> ((Tag<Item>) in[0].get(sc)).contains(((ItemStack) in[0].get(sc)).getItem()));
|
|
+ sm.registerFunction("item.hastag", (sc, in) -> ((Tag<Item>) in[0].get(sc)).contains(((ItemStack) in[1].get(sc)).getItem()));
|
|
sm.registerFunction("item.get", (sc, in) -> ((ItemStack) in[0].get(sc)).getItem());
|
|
sm.registerFunction("item.get", (sc, in) -> ((ItemStack) in[0].get(sc)).getItem());
|
|
sm.registerFunction("item.gettype", (sc, in) -> ((ItemStack) in[0].get(sc)).getItem().getRegistryName().toString());
|
|
sm.registerFunction("item.gettype", (sc, in) -> ((ItemStack) in[0].get(sc)).getItem().getRegistryName().toString());
|
|
sm.registerFunction("item.getamount", (sc, in) -> (double) ((ItemStack) in[0].get(sc)).getCount());
|
|
sm.registerFunction("item.getamount", (sc, in) -> (double) ((ItemStack) in[0].get(sc)).getCount());
|
|
@@ -909,7 +917,7 @@ public class MinecraftFunctions
|
|
|
|
|
|
|
|
|
|
sm.registerFunction("block.gettag", (sc, in) -> BlockTags.getCollection().get(new ResourceLocation(in[0].getString(sc))));
|
|
sm.registerFunction("block.gettag", (sc, in) -> BlockTags.getCollection().get(new ResourceLocation(in[0].getString(sc))));
|
|
- sm.registerFunction("block.hastag", (sc, in) -> ((Tag<Block>) in[0].get(sc)).contains((Block) in[0].get(sc)));
|
|
+ sm.registerFunction("block.hastag", (sc, in) -> ((Tag<Block>) in[0].get(sc)).contains((Block) in[1].get(sc)));
|
|
sm.registerFunction("block.gettype", (sc, in) ->
|
|
sm.registerFunction("block.gettype", (sc, in) ->
|
|
{
|
|
{
|
|
Location l = (Location) in[0].get(sc);
|
|
Location l = (Location) in[0].get(sc);
|
|
@@ -1167,6 +1175,16 @@ public class MinecraftFunctions
|
|
((LivingEntity) in[0].get(sc)).attackEntityFrom(DamageSource.GENERIC, in[1].getFloat(sc));
|
|
((LivingEntity) in[0].get(sc)).attackEntityFrom(DamageSource.GENERIC, in[1].getFloat(sc));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
|
|
+ sm.registerFunction("entity.fromsource", (sc, in) ->
|
|
|
|
+ {
|
|
|
|
+ DamageSource ds = (DamageSource) in[0].get(sc);
|
|
|
|
+ Entity ent = ds.getTrueSource();
|
|
|
|
+ if(ent == null)
|
|
|
|
+ {
|
|
|
|
+ return ds.getImmediateSource();
|
|
|
|
+ }
|
|
|
|
+ return ent;
|
|
|
|
+ });
|
|
sm.registerFunction("entity.getdamagesource", (sc, in) ->
|
|
sm.registerFunction("entity.getdamagesource", (sc, in) ->
|
|
{
|
|
{
|
|
Object o = in[0].get(sc);
|
|
Object o = in[0].get(sc);
|
|
@@ -1491,6 +1509,7 @@ public class MinecraftFunctions
|
|
((AgeableEntity) in[0].get(sc)).setGrowingAge(in[1].getInt(sc));
|
|
((AgeableEntity) in[0].get(sc)).setGrowingAge(in[1].getInt(sc));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
|
|
+ sm.registerFunction("entity.gettype", (sc, in) -> ((Entity) in[0].get(sc)).getType().getRegistryName().getPath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1702,7 +1721,10 @@ public class MinecraftFunctions
|
|
sm.registerFunction("databank.prepare", (sc, in) ->
|
|
sm.registerFunction("databank.prepare", (sc, in) ->
|
|
{
|
|
{
|
|
PreparedStatement p = dataBank.prepareUnsafeStatement(in[0].getString(sc));
|
|
PreparedStatement p = dataBank.prepareUnsafeStatement(in[0].getString(sc));
|
|
- sc.addCloseable(p);
|
|
+ if(in.length <= 1 || in[1].getBoolean(sc))
|
|
|
|
+ {
|
|
|
|
+ sc.addCloseable(p);
|
|
|
|
+ }
|
|
return p;
|
|
return p;
|
|
});
|
|
});
|
|
sm.registerFunction("databank.setint", (sc, in) ->
|
|
sm.registerFunction("databank.setint", (sc, in) ->
|
|
@@ -2233,16 +2255,16 @@ public class MinecraftFunctions
|
|
sm.registerFunction("text.copytext", (sc, in) ->
|
|
sm.registerFunction("text.copytext", (sc, in) ->
|
|
{
|
|
{
|
|
String s = in[1].getString(sc);
|
|
String s = in[1].getString(sc);
|
|
- s = s.replace('{', 'Ɛ');
|
|
+
|
|
- s = s.replace('}', 'Ƒ');
|
|
+
|
|
- s = s.replace('[', 'ƒ');
|
|
+
|
|
- s = s.replace(']', 'Ɠ');
|
|
+
|
|
- s = s.replace('(', 'ƕ');
|
|
+
|
|
- s = s.replace(')', 'Ɩ');
|
|
+
|
|
s = s.replace(" ", "%20");
|
|
s = s.replace(" ", "%20");
|
|
- s = s.replace('\'', 'Ɩ');
|
|
+
|
|
- s = s.replace('"', 'Ɩ');
|
|
+
|
|
- s = s.replace("\\", "");
|
|
+
|
|
|
|
|
|
StringTextComponent text = new StringTextComponent(in[0].getString(sc));
|
|
StringTextComponent text = new StringTextComponent(in[0].getString(sc));
|
|
Style style = text.getStyle();
|
|
Style style = text.getStyle();
|