|
@@ -6,13 +6,13 @@ import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import me.km.KajetansMod;
|
|
|
-import me.km.utils.NBTUtils;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.GregorianCalendar;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
import java.util.function.Consumer;
|
|
|
+import me.hammerle.snuviscript.code.InputProvider;
|
|
|
import me.hammerle.snuviscript.code.Script;
|
|
|
import me.hammerle.snuviscript.code.SnuviUtils;
|
|
|
import me.hammerle.snuviscript.code.SnuviParser;
|
|
@@ -22,6 +22,7 @@ import me.km.utils.Utils;
|
|
|
import me.km.chatchannel.ChatChannel;
|
|
|
import me.km.world.ModDimensions;
|
|
|
import me.km.effects.EffectUtils;
|
|
|
+import me.km.entities.EntityHuman;
|
|
|
import me.km.inventory.InventoryUtils;
|
|
|
import me.km.utils.ItemStackUtils;
|
|
|
import me.km.utils.ReflectionUtils;
|
|
@@ -73,11 +74,15 @@ import me.km.items.weapons.*;
|
|
|
import me.km.networking.ModPacketHandler;
|
|
|
import me.km.scoreboard.ScoreboardUtils;
|
|
|
import net.minecraft.block.BlockCrops;
|
|
|
+import net.minecraft.entity.EntityAgeable;
|
|
|
import net.minecraft.entity.EntityList;
|
|
|
+import net.minecraft.entity.SharedMonsterAttributes;
|
|
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
+import net.minecraft.init.Blocks;
|
|
|
import net.minecraft.init.Items;
|
|
|
import net.minecraft.item.Item;
|
|
|
+import net.minecraft.item.ItemArmor;
|
|
|
import net.minecraft.item.ItemAxe;
|
|
|
import net.minecraft.nbt.JsonToNBT;
|
|
|
import net.minecraft.nbt.NBTException;
|
|
@@ -91,7 +96,12 @@ import net.minecraft.tileentity.TileEntitySkull;
|
|
|
import net.minecraft.util.NonNullList;
|
|
|
import net.minecraft.util.math.MathHelper;
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
+import net.minecraft.util.text.Style;
|
|
|
import net.minecraft.util.text.TextComponentString;
|
|
|
+import net.minecraft.util.text.TextFormatting;
|
|
|
+import net.minecraft.util.text.event.ClickEvent;
|
|
|
+import net.minecraft.util.text.event.HoverEvent;
|
|
|
+import net.minecraft.village.MerchantRecipe;
|
|
|
import net.minecraft.world.EnumDifficulty;
|
|
|
import net.minecraft.world.GameType;
|
|
|
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
|
@@ -173,15 +183,6 @@ public class MinecraftFunctions
|
|
|
TitleUtils.setSubTitle((EntityPlayerMP) in[0].get(sc), SnuviUtils.connect(sc, in, 1));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- parser.registerFunction("villager.showtrades", (sc, in) ->
|
|
|
- {
|
|
|
- ((EntityPlayer) in[0].get(sc)).displayVillagerTradeGui(((EntityVillager) in[1].get(sc)));
|
|
|
- return Void.TYPE;
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
|
@@ -245,7 +246,7 @@ public class MinecraftFunctions
|
|
|
});
|
|
|
parser.registerFunction("player.speak", (sc, in) ->
|
|
|
{
|
|
|
- sendMessageToGroup(in[0].get(sc), sc, NBTUtils.concat(sc, 2, "§7[§r" + in[1].getString(sc) + "§7]§r ", in));
|
|
|
+ sendMessageToGroup(in[0].get(sc), sc, concat(sc, 2, "§7[§r" + in[1].getString(sc) + "§7]§r ", in));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("player.setcompass", (sc, in) ->
|
|
@@ -746,6 +747,40 @@ public class MinecraftFunctions
|
|
|
PotionUtils.appendEffects(stack, list);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerFunction("item.addflag", (sc, in) ->
|
|
|
+ {
|
|
|
+ ItemStackUtils.addItemFlag((ItemStack) in[0].get(sc), ItemStackUtils.ItemFlag.valueOf(in[0].getString(sc).toUpperCase()));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("item.addattribute", (sc, in) ->
|
|
|
+ {
|
|
|
+ ItemStackUtils.addAttribute((ItemStack) in[0].get(sc),
|
|
|
+ ItemStackUtils.Attribute.valueOf(in[1].getString(sc).toUpperCase()),
|
|
|
+ EntityEquipmentSlot.valueOf(in[2].getString(sc).toUpperCase()),
|
|
|
+ in[3].getDouble(sc),
|
|
|
+ ItemStackUtils.Operation.valueOf(in[4].getString(sc).toUpperCase()));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("item.setmagic", (sc, in) ->
|
|
|
+ {
|
|
|
+ ItemStack stack = (ItemStack) in[0].get(sc);
|
|
|
+ int value = in[1].getInt(sc);
|
|
|
+ if(stack.getItem() instanceof ItemArmor)
|
|
|
+ {
|
|
|
+ NBTTagCompound com = stack.getTagCompound();
|
|
|
+ if(com == null)
|
|
|
+ {
|
|
|
+ com = new NBTTagCompound();
|
|
|
+ stack.setTagCompound(com);
|
|
|
+ }
|
|
|
+ com.setInteger("magic", value);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new IllegalArgumentException("magic resistance is only for armor");
|
|
|
+ }
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
|
@@ -866,7 +901,42 @@ public class MinecraftFunctions
|
|
|
{
|
|
|
Location l0 = (Location) in[0].get(sc);
|
|
|
Location l1 = (Location) in[1].get(sc);
|
|
|
- NBTUtils.cloneBlock(l0.getWorld(), l0.getBlockPos(), l1.getWorld(), l1.getBlockPos());
|
|
|
+
|
|
|
+ World w = l0.getWorld();
|
|
|
+ BlockPos oldPos = l0.getBlockPos();
|
|
|
+ World newW = l1.getWorld();
|
|
|
+ BlockPos newPos = l1.getBlockPos();
|
|
|
+
|
|
|
+ if(oldPos.equals(newPos))
|
|
|
+ {
|
|
|
+ return Void.TYPE;
|
|
|
+ }
|
|
|
+
|
|
|
+ IBlockState state = w.getBlockState(oldPos);
|
|
|
+ NBTTagCompound nbt = null;
|
|
|
+
|
|
|
+ if(state.getBlock() != Blocks.AIR)
|
|
|
+ {
|
|
|
+ TileEntity te = w.getTileEntity(oldPos);
|
|
|
+ if (te != null)
|
|
|
+ {
|
|
|
+ nbt = te.writeToNBT(new NBTTagCompound());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ newW.setBlockState(newPos, state);
|
|
|
+ if(nbt != null)
|
|
|
+ {
|
|
|
+ TileEntity te = newW.getTileEntity(newPos);
|
|
|
+ if(te != null)
|
|
|
+ {
|
|
|
+ nbt.setInteger("x", newPos.getX());
|
|
|
+ nbt.setInteger("y", newPos.getY());
|
|
|
+ nbt.setInteger("z", newPos.getZ());
|
|
|
+ te.readFromNBT(nbt);
|
|
|
+ te.markDirty();
|
|
|
+ }
|
|
|
+ }
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("block.set", (sc, in) ->
|
|
@@ -879,13 +949,54 @@ public class MinecraftFunctions
|
|
|
parser.registerFunction("block.set2", (sc, in) ->
|
|
|
{
|
|
|
Location l = (Location) in[0].get(sc);
|
|
|
- if(in.length >= 4)
|
|
|
+
|
|
|
+ World w = l.getWorld();
|
|
|
+ BlockPos pos = l.getBlockPos();
|
|
|
+ int dv = in[2].getInt(sc);
|
|
|
+ Block block = Block.getBlockFromName(in[1].getString(sc));
|
|
|
+ String data = in.length >= 4 ? SnuviUtils.connect(sc, in, 3) : null;
|
|
|
+
|
|
|
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
|
|
|
+ boolean flag = false;
|
|
|
+
|
|
|
+ if(data != null && block.hasTileEntity())
|
|
|
{
|
|
|
- NBTUtils.setBlockWithData(l.getWorld(), l.getBlockPos(), in[2].getInt(sc), Block.getBlockFromName(in[1].getString(sc)), SnuviUtils.connect(sc, in, 3));
|
|
|
+ try
|
|
|
+ {
|
|
|
+ nbttagcompound = JsonToNBT.getTagFromJson(data);
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ catch(NBTException ex)
|
|
|
+ {
|
|
|
+ throw new IllegalStringException(data);
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ TileEntity tileentity = w.getTileEntity(pos);
|
|
|
+ if (tileentity != null)
|
|
|
+ {
|
|
|
+ if (tileentity instanceof IInventory)
|
|
|
+ {
|
|
|
+ ((IInventory) tileentity).clear();
|
|
|
+ }
|
|
|
+ w.setBlockState(pos, Blocks.AIR.getDefaultState(), block == Blocks.AIR ? 2 : 4);
|
|
|
+ }
|
|
|
+
|
|
|
+ IBlockState iblockdata = block.getStateFromMeta(dv);
|
|
|
+ if(w.setBlockState(pos, iblockdata, 2))
|
|
|
{
|
|
|
- NBTUtils.setBlockWithData(l.getWorld(), l.getBlockPos(), in[2].getInt(sc), Block.getBlockFromName(in[1].getString(sc)), null);
|
|
|
+ if(flag)
|
|
|
+ {
|
|
|
+ TileEntity tileentity1 = w.getTileEntity(pos);
|
|
|
+ if (tileentity1 != null)
|
|
|
+ {
|
|
|
+ nbttagcompound.setInteger("x", pos.getX());
|
|
|
+ nbttagcompound.setInteger("y", pos.getY());
|
|
|
+ nbttagcompound.setInteger("z", pos.getZ());
|
|
|
+ tileentity1.readFromNBT(nbttagcompound);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ w.notifyNeighborsRespectDebug(pos, iblockdata.getBlock(), false);
|
|
|
}
|
|
|
return Void.TYPE;
|
|
|
});
|
|
@@ -1054,7 +1165,7 @@ public class MinecraftFunctions
|
|
|
});
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
parser.registerFunction("entity.getlocation", (sc, in) -> new Location((Entity) in[0].get(sc)));
|
|
|
parser.registerFunction("entity.damage", (sc, in) ->
|
|
@@ -1156,7 +1267,7 @@ public class MinecraftFunctions
|
|
|
ent.setAlwaysRenderNameTag(in[2].getBoolean(sc));
|
|
|
return Void.TYPE;
|
|
|
}
|
|
|
- ent.setAlwaysRenderNameTag(true);
|
|
|
+ ent.setAlwaysRenderNameTag(false);
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("entity.getname", (sc, in) -> ((Entity) in[0].get(sc)).getDisplayName().getUnformattedText());
|
|
@@ -1245,14 +1356,9 @@ public class MinecraftFunctions
|
|
|
((Entity) in[0].get(sc)).setSilent(in[1].getBoolean(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
- parser.registerFunction("entity.hide", (sc, in) ->
|
|
|
- {
|
|
|
- ((Entity) in[0].get(sc)).setInvisible(true);
|
|
|
- return Void.TYPE;
|
|
|
- });
|
|
|
- parser.registerFunction("entity.show", (sc, in) ->
|
|
|
+ parser.registerFunction("entity.setinvisible", (sc, in) ->
|
|
|
{
|
|
|
- ((Entity) in[0].get(sc)).setInvisible(false);
|
|
|
+ ((Entity) in[0].get(sc)).setInvisible(in[1].getBoolean(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("entity.ride", (sc, in) ->
|
|
@@ -1376,6 +1482,110 @@ public class MinecraftFunctions
|
|
|
in[0].set(sc, Utils.getLiving(ent, in[2].getDouble(sc)));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerFunction("entity.setspeed", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityLivingBase) in[0].get(sc)).getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(in[1].getDouble(sc));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("entity.setgrowingage", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityAgeable) in[0].get(sc)).setGrowingAge(in[1].getInt(sc));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ parser.registerFunction("human.spawn", (sc, in) ->
|
|
|
+ {
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ World w = l.getWorld();
|
|
|
+ EntityHuman h = new EntityHuman(w);
|
|
|
+ h.setPosition(l.getX(), l.getY(), l.getZ());
|
|
|
+ w.spawnEntity(h);
|
|
|
+ return h;
|
|
|
+ });
|
|
|
+ parser.registerFunction("human.setskin", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityHuman) in[0].get(sc)).setSkinName(in[1].getString(sc));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("human.setscale", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityHuman) in[0].get(sc)).setScale(in[1].getFloat(sc));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("human.setslim", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityHuman) in[0].get(sc)).setSlim(in[1].getBoolean(sc));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ parser.registerFunction("villager.showtrades", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityPlayer) in[0].get(sc)).displayVillagerTradeGui(((EntityVillager) in[1].get(sc)));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("villager.cleartrades", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityVillager) in[0].get(sc)).getRecipes(null).clear();
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("villager.addtrade", (sc, in) ->
|
|
|
+ {
|
|
|
+ EntityVillager v = (EntityVillager) in[0].get(sc);
|
|
|
+ ReflectionUtils.setCareerLevel(v, 10);
|
|
|
+ ItemStack buy1 = (ItemStack) in[1].get(sc);
|
|
|
+ if(buy1 == null)
|
|
|
+ {
|
|
|
+ buy1 = ItemStack.EMPTY;
|
|
|
+ }
|
|
|
+ ItemStack buy2 = (ItemStack) in[2].get(sc);
|
|
|
+ if(buy2 == null)
|
|
|
+ {
|
|
|
+ buy2 = ItemStack.EMPTY;
|
|
|
+ }
|
|
|
+ ItemStack sell = (ItemStack) in[3].get(sc);
|
|
|
+ if(buy2 == null)
|
|
|
+ {
|
|
|
+ buy2 = ItemStack.EMPTY;
|
|
|
+ }
|
|
|
+ MerchantRecipe mr = new MerchantRecipe(buy1, buy2, sell, 0, Integer.MAX_VALUE);
|
|
|
+ if(in.length > 4)
|
|
|
+ {
|
|
|
+ v.getRecipes(null).set(in[4].getInt(sc), mr);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ v.getRecipes(null).add(mr);
|
|
|
+ }
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("villager.removetrade", (sc, in) ->
|
|
|
+ {
|
|
|
+ EntityVillager v = (EntityVillager) in[0].get(sc);
|
|
|
+ v.getRecipes(null).remove(in[1].get(sc));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("villager.tradeamount", (sc, in) -> ((EntityVillager) in[0].get(sc)).getRecipes(null).size());
|
|
|
+ parser.registerFunction("villager.getslot", (sc, in) -> ((EntityVillager) in[0].get(sc)).getVillagerInventory().getStackInSlot(in[1].getInt(sc)));
|
|
|
+ parser.registerFunction("villager.setslot", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityVillager) in[0].get(sc)).getVillagerInventory().setInventorySlotContents(in[1].getInt(sc), ((ItemStack) in[2].get(sc)).copy());
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("villager.spawn", (sc, in) ->
|
|
|
+ {
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ World w = l.getWorld();
|
|
|
+ EntityVillager v = new EntityVillager(w, in[1].getInt(sc));
|
|
|
+ v.setPosition(l.getX(), l.getY(), l.getZ());
|
|
|
+ w.spawnEntity(v);
|
|
|
+ return v;
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
|
@@ -2101,7 +2311,35 @@ public class MinecraftFunctions
|
|
|
}
|
|
|
return stack;
|
|
|
});
|
|
|
- parser.registerFunction("read.spawnmob", (sc, in) -> NBTUtils.fromString(SnuviUtils.connect(sc, in, 1).replace('\'', '"'), (Location) in[0].get(sc)));
|
|
|
+ parser.registerFunction("read.spawnmob", (sc, in) ->
|
|
|
+ {
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ String data = SnuviUtils.connect(sc, in, 1).replace('\'', '"');
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ NBTTagCompound nbt = JsonToNBT.getTagFromJson(data);
|
|
|
+ Vec3d v = l.getPos();
|
|
|
+ Entity ent = AnvilChunkLoader.readWorldEntityPos(nbt, l.getWorld(), v.x, v.y, v.z, true);
|
|
|
+ if(ent == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ent.setLocationAndAngles(v.x, v.y, v.z, ent.rotationYaw, ent.rotationPitch);
|
|
|
+ if(ent instanceof EntityLiving)
|
|
|
+ {
|
|
|
+ ((EntityLiving) ent).onInitialSpawn(ent.getEntityWorld().getDifficultyForLocation(new BlockPos(ent)), null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ent;
|
|
|
+ }
|
|
|
+ catch(NBTException ex)
|
|
|
+ {
|
|
|
+ throw new IllegalArgumentException("illegal entity string '" + data + "'");
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
|
@@ -2109,8 +2347,74 @@ public class MinecraftFunctions
|
|
|
parser.registerFunction("text.location", (sc, in) -> ((Location) in[0].get(sc)).toString());
|
|
|
parser.registerFunction("text.locationblock", (sc, in) -> ((Location) in[0].get(sc)).toBlockString());
|
|
|
parser.registerFunction("text.item", (sc, in) -> ItemStackUtils.getNbtString((ItemStack) in[0].get(sc)));
|
|
|
- parser.registerFunction("text.click", (sc, in) -> NBTUtils.getClickable(in[0].get(sc), in[1].getString(sc)));
|
|
|
- parser.registerFunction("text.hover", (sc, in) -> NBTUtils.getHoverable(in[0].get(sc), in[1].getString(sc)));
|
|
|
+ parser.registerFunction("text.click", (sc, in) ->
|
|
|
+ {
|
|
|
+ Object message = in[0].get(sc);
|
|
|
+ ITextComponent text;
|
|
|
+ if(message instanceof ITextComponent)
|
|
|
+ {
|
|
|
+ text = (ITextComponent) message;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ text = new TextComponentString(String.valueOf(message));
|
|
|
+ }
|
|
|
+ Style style = text.getStyle();
|
|
|
+ style.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, in[1].getString(sc)));
|
|
|
+ return text;
|
|
|
+ });
|
|
|
+ parser.registerFunction("text.hover", (sc, in) ->
|
|
|
+ {
|
|
|
+ Object message = in[0].get(sc);
|
|
|
+ ITextComponent text;
|
|
|
+ if(message instanceof ITextComponent)
|
|
|
+ {
|
|
|
+ text = (ITextComponent) message;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ text = new TextComponentString(String.valueOf(message));
|
|
|
+ }
|
|
|
+ Style style = text.getStyle();
|
|
|
+ style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(in[1].getString(sc))));
|
|
|
+ return text;
|
|
|
+ });
|
|
|
+ parser.registerFunction("text.link", (sc, in) ->
|
|
|
+ {
|
|
|
+ TextComponentString text = new TextComponentString(in[0].getString(sc));
|
|
|
+ Style style = text.getStyle();
|
|
|
+ style.setColor(TextFormatting.RED);
|
|
|
+ style.setBold(true);
|
|
|
+ style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, in[1].getString(sc)));
|
|
|
+ return text;
|
|
|
+ });
|
|
|
+ parser.registerFunction("text.copytext", (sc, in) ->
|
|
|
+ {
|
|
|
+ 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('\'', 'Ɩ');
|
|
|
+ s = s.replace('"', 'Ɩ');
|
|
|
+ s = s.replace("\\", "");
|
|
|
+
|
|
|
+ TextComponentString text = new TextComponentString(in[0].getString(sc));
|
|
|
+ Style style = text.getStyle();
|
|
|
+ style.setColor(TextFormatting.RED);
|
|
|
+ style.setBold(true);
|
|
|
+ style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://minecraft.hammerle.me/showtext.php/?text=" + s));
|
|
|
+ return text;
|
|
|
+ });
|
|
|
+ parser.registerFunction("text.entity", (sc, in) ->
|
|
|
+ {
|
|
|
+ NBTTagCompound tag = new NBTTagCompound();
|
|
|
+ ((Entity) in[0].get(sc)).writeToNBTAtomically(tag);
|
|
|
+ return tag.toString();
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
|
@@ -2184,7 +2488,7 @@ public class MinecraftFunctions
|
|
|
parser.registerAlias("delglobalvar", "dgv");
|
|
|
parser.registerFunction("msg", (sc, in) ->
|
|
|
{
|
|
|
- sendMessageToGroup(in[0].get(sc), sc, NBTUtils.concat(sc, 1, in));
|
|
|
+ sendMessageToGroup(in[0].get(sc), sc, concat(sc, 1, "", in));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("removeformat", (sc, in) -> SnuviUtils.connect(sc, in, 0).replaceAll("§.", ""));
|
|
@@ -2283,4 +2587,23 @@ public class MinecraftFunctions
|
|
|
{
|
|
|
doForGroup(group, sc, p -> p.sendMessage(text));
|
|
|
}
|
|
|
+
|
|
|
+ private static ITextComponent concat(Script sc, int start, String pre, InputProvider... ob)
|
|
|
+ {
|
|
|
+ TextComponentString text = new TextComponentString(pre);
|
|
|
+ Object o;
|
|
|
+ for(int i = start; i < ob.length; i++)
|
|
|
+ {
|
|
|
+ o = ob[i].get(sc);
|
|
|
+ if(o instanceof ITextComponent)
|
|
|
+ {
|
|
|
+ text.appendSibling((ITextComponent) o);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ text.appendText(String.valueOf(o));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return text;
|
|
|
+ }
|
|
|
}
|