|
@@ -21,8 +21,8 @@ import me.km.databank.DataBank;
|
|
import me.km.utils.Location;
|
|
import me.km.utils.Location;
|
|
import me.km.utils.Utils;
|
|
import me.km.utils.Utils;
|
|
import me.km.world.WorldManager;
|
|
import me.km.world.WorldManager;
|
|
-import me.km.effects.EffectUtils;
|
|
|
|
import me.km.entities.EntityHuman;
|
|
import me.km.entities.EntityHuman;
|
|
|
|
+import me.km.entities.EntityItemProjectile;
|
|
import me.km.entities.ModEntities;
|
|
import me.km.entities.ModEntities;
|
|
import me.km.inventory.InventoryUtils;
|
|
import me.km.inventory.InventoryUtils;
|
|
import me.km.utils.ItemStackUtils;
|
|
import me.km.utils.ItemStackUtils;
|
|
@@ -61,19 +61,35 @@ import net.minecraft.command.arguments.BlockStateParser;
|
|
import net.minecraft.entity.AgeableEntity;
|
|
import net.minecraft.entity.AgeableEntity;
|
|
import net.minecraft.entity.EntityType;
|
|
import net.minecraft.entity.EntityType;
|
|
import net.minecraft.entity.LivingEntity;
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
+import net.minecraft.entity.MobEntity;
|
|
import net.minecraft.entity.SharedMonsterAttributes;
|
|
import net.minecraft.entity.SharedMonsterAttributes;
|
|
|
|
+import net.minecraft.entity.SpawnReason;
|
|
import net.minecraft.entity.ai.attributes.AttributeModifier.Operation;
|
|
import net.minecraft.entity.ai.attributes.AttributeModifier.Operation;
|
|
|
|
+import net.minecraft.entity.effect.LightningBoltEntity;
|
|
|
|
+import net.minecraft.entity.item.EnderPearlEntity;
|
|
|
|
+import net.minecraft.entity.item.ExperienceBottleEntity;
|
|
import net.minecraft.entity.item.ItemEntity;
|
|
import net.minecraft.entity.item.ItemEntity;
|
|
import net.minecraft.entity.item.ItemFrameEntity;
|
|
import net.minecraft.entity.item.ItemFrameEntity;
|
|
import net.minecraft.entity.monster.CreeperEntity;
|
|
import net.minecraft.entity.monster.CreeperEntity;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
|
|
+import net.minecraft.entity.projectile.AbstractArrowEntity;
|
|
|
|
+import net.minecraft.entity.projectile.ArrowEntity;
|
|
|
|
+import net.minecraft.entity.projectile.DamagingProjectileEntity;
|
|
|
|
+import net.minecraft.entity.projectile.DragonFireballEntity;
|
|
|
|
+import net.minecraft.entity.projectile.EggEntity;
|
|
|
|
+import net.minecraft.entity.projectile.FireballEntity;
|
|
import net.minecraft.entity.projectile.PotionEntity;
|
|
import net.minecraft.entity.projectile.PotionEntity;
|
|
|
|
+import net.minecraft.entity.projectile.SmallFireballEntity;
|
|
|
|
+import net.minecraft.entity.projectile.SnowballEntity;
|
|
|
|
+import net.minecraft.entity.projectile.SpectralArrowEntity;
|
|
|
|
+import net.minecraft.entity.projectile.WitherSkullEntity;
|
|
import net.minecraft.inventory.EquipmentSlotType;
|
|
import net.minecraft.inventory.EquipmentSlotType;
|
|
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;
|
|
import net.minecraft.nbt.CompoundNBT;
|
|
import net.minecraft.nbt.CompoundNBT;
|
|
|
|
+import net.minecraft.nbt.JsonToNBT;
|
|
import net.minecraft.nbt.NBTUtil;
|
|
import net.minecraft.nbt.NBTUtil;
|
|
import net.minecraft.network.play.client.CChatMessagePacket;
|
|
import net.minecraft.network.play.client.CChatMessagePacket;
|
|
import net.minecraft.network.play.client.CClientStatusPacket;
|
|
import net.minecraft.network.play.client.CClientStatusPacket;
|
|
@@ -81,6 +97,12 @@ import net.minecraft.network.play.server.SEntityVelocityPacket;
|
|
import net.minecraft.network.play.server.SSpawnPositionPacket;
|
|
import net.minecraft.network.play.server.SSpawnPositionPacket;
|
|
import net.minecraft.network.play.server.STitlePacket;
|
|
import net.minecraft.network.play.server.STitlePacket;
|
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
|
|
|
+import net.minecraft.particles.BlockParticleData;
|
|
|
|
+import net.minecraft.particles.IParticleData;
|
|
|
|
+import net.minecraft.particles.ItemParticleData;
|
|
|
|
+import net.minecraft.particles.ParticleType;
|
|
|
|
+import net.minecraft.particles.ParticleTypes;
|
|
|
|
+import net.minecraft.particles.RedstoneParticleData;
|
|
import net.minecraft.potion.Effect;
|
|
import net.minecraft.potion.Effect;
|
|
import net.minecraft.potion.EffectInstance;
|
|
import net.minecraft.potion.EffectInstance;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.MinecraftServer;
|
|
@@ -97,6 +119,7 @@ import net.minecraft.tileentity.SkullTileEntity;
|
|
import net.minecraft.util.Direction;
|
|
import net.minecraft.util.Direction;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
+import net.minecraft.util.SoundEvent;
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraft.util.text.ITextComponent;
|
|
import net.minecraft.util.text.ITextComponent;
|
|
import net.minecraft.util.text.StringTextComponent;
|
|
import net.minecraft.util.text.StringTextComponent;
|
|
@@ -227,7 +250,8 @@ public class MinecraftFunctions
|
|
stack.setCount(InventoryUtils.addToInventory(((PlayerEntity) in[0].get(sc)).inventory, stack));
|
|
stack.setCount(InventoryUtils.addToInventory(((PlayerEntity) in[0].get(sc)).inventory, stack));
|
|
return stack;
|
|
return stack;
|
|
});
|
|
});
|
|
- sm.registerFunction("player.shootprojectile", (sc, in) -> EffectUtils.launchProjectile((PlayerEntity) in[0].get(sc), getClass(in[1].getString(sc)), in[2].getDouble(sc), in[3].get(sc)));
|
|
|
|
|
|
+ sm.registerFunction("player.shootprojectile", (sc, in) -> launchProjectile((PlayerEntity) in[0].get(sc),
|
|
|
|
+ getClass(in[1].getString(sc)), in[2].getDouble(sc), in.length >= 4 ? in[3].get(sc) : null));
|
|
sm.registerFunction("player.respawn", (sc, in) ->
|
|
sm.registerFunction("player.respawn", (sc, in) ->
|
|
{
|
|
{
|
|
final ServerPlayerEntity p = ((ServerPlayerEntity) in[0].get(sc));
|
|
final ServerPlayerEntity p = ((ServerPlayerEntity) in[0].get(sc));
|
|
@@ -402,11 +426,6 @@ public class MinecraftFunctions
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("player.kick", (sc, in) -> scripts.unregisterPlayer(sc, (PlayerEntity) in[0].get(sc)));
|
|
sm.registerFunction("player.kick", (sc, in) -> scripts.unregisterPlayer(sc, (PlayerEntity) in[0].get(sc)));
|
|
- sm.registerFunction("player.playsound", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- EffectUtils.playSound((ServerPlayerEntity) in[0].get(sc), Mapper.getSound(in[1].getString(sc)), SoundCategory.MASTER);
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
sm.registerFunction("player.getspawn", (sc, in) ->
|
|
sm.registerFunction("player.getspawn", (sc, in) ->
|
|
{
|
|
{
|
|
ServerWorld ws = (ServerWorld) in[1].get(sc);
|
|
ServerWorld ws = (ServerWorld) in[1].get(sc);
|
|
@@ -501,52 +520,6 @@ public class MinecraftFunctions
|
|
return Utils.getPlayers(l.getWorld(), l.getX(), l.getY(), l.getZ(), in[1].getDouble(sc));
|
|
return Utils.getPlayers(l.getWorld(), l.getX(), l.getY(), l.getZ(), in[1].getDouble(sc));
|
|
});
|
|
});
|
|
|
|
|
|
- // ---------------------------------------------------------------------
|
|
|
|
- // Custom-library
|
|
|
|
- // ---------------------------------------------------------------------
|
|
|
|
- /*parser.registerFunction("custom.registershapelessrecipe", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- ItemStack[] stacks = new ItemStack[in.length - 1];
|
|
|
|
- for(int i = 0; i < stacks.length; i++)
|
|
|
|
- {
|
|
|
|
- stacks[i] = (ItemStack) in[i + 1].get(sc);
|
|
|
|
- }
|
|
|
|
- RecipeUtils.registerShapelessRecipe((ItemStack) in[0].get(sc), stacks);
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("custom.registershapedrecipe", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- int counter = 0;
|
|
|
|
- while(in[counter + 1].get(sc).getClass() == String.class)
|
|
|
|
- {
|
|
|
|
- counter++;
|
|
|
|
- }
|
|
|
|
- String[] s = new String[counter];
|
|
|
|
- for(int i = 0; i < s.length; i++)
|
|
|
|
- {
|
|
|
|
- s[i] = in[i + 1].toString();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ItemStack[] stacks = new ItemStack[in.length - 1 - s.length];
|
|
|
|
- for(int i = 0; i < stacks.length; i++)
|
|
|
|
- {
|
|
|
|
- stacks[i] = (ItemStack) in[i + 1 + counter].get(sc);
|
|
|
|
- }
|
|
|
|
- RecipeUtils.registerShapedRecipe((ItemStack) in[0].get(sc), s, stacks);
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("custom.registerfurnacerecipe", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- RecipeUtils.registerFurnaceRecipe((ItemStack) in[0].get(sc), (ItemStack) in[1].get(sc));
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("custom.clearrecipes", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- RecipeUtils.clearRecipes();
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });*/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
// World-library
|
|
// World-library
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
@@ -746,7 +719,6 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
ItemStack stack = (ItemStack) in[0].get(sc);
|
|
ItemStack stack = (ItemStack) in[0].get(sc);
|
|
int value = in[1].getInt(sc);
|
|
int value = in[1].getInt(sc);
|
|
- System.out.println(stack.getItem());
|
|
|
|
if(stack.getItem() instanceof ArmorItem)
|
|
if(stack.getItem() instanceof ArmorItem)
|
|
{
|
|
{
|
|
CompoundNBT com = stack.getTag();
|
|
CompoundNBT com = stack.getTag();
|
|
@@ -1358,15 +1330,15 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
LivingEntity base = (LivingEntity) in[0].get(sc);
|
|
LivingEntity base = (LivingEntity) in[0].get(sc);
|
|
Effect potion = Mapper.getPotion(in[1].getString(sc));
|
|
Effect potion = Mapper.getPotion(in[1].getString(sc));
|
|
- if(base == null) // doing this only to prevent EffectUtils.addPotionTo doing shit
|
|
|
|
|
|
+ if(potion == null) // doing this only to prevent EffectInstance doing shit
|
|
{
|
|
{
|
|
- throw new NullPointerException("null not allowed for entity");
|
|
|
|
|
|
+ throw new IllegalArgumentException("potion does not exist");
|
|
}
|
|
}
|
|
- else if(potion == null)
|
|
|
|
|
|
+ if(base.isPotionActive(potion))
|
|
{
|
|
{
|
|
- throw new NullPointerException("potion does not exist");
|
|
|
|
|
|
+ base.removePotionEffect(potion);
|
|
}
|
|
}
|
|
- EffectUtils.addPotionTo(base, potion, in[2].getInt(sc), in[3].getInt(sc));
|
|
|
|
|
|
+ base.addPotionEffect(new EffectInstance(potion, in[2].getInt(sc), in[3].getInt(sc)));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("entity.cleareffects", (sc, in) ->
|
|
sm.registerFunction("entity.cleareffects", (sc, in) ->
|
|
@@ -1385,6 +1357,7 @@ public class MinecraftFunctions
|
|
Location l = ((Location) in[0].get(sc));
|
|
Location l = ((Location) in[0].get(sc));
|
|
ItemFrameEntity frame = new ItemFrameEntity(l.getWorld().getWorld(), l.getBlockPos(), Direction.byName(in[1].getString(sc)));
|
|
ItemFrameEntity frame = new ItemFrameEntity(l.getWorld().getWorld(), l.getBlockPos(), Direction.byName(in[1].getString(sc)));
|
|
frame.setDisplayedItem(((ItemStack) in[2].get(sc))); // copy happens in internals
|
|
frame.setDisplayedItem(((ItemStack) in[2].get(sc))); // copy happens in internals
|
|
|
|
+ l.getWorld().addEntity(frame);
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("entity.getitemframe", (sc, in) -> ((ItemFrameEntity) in[0].get(sc)).getDisplayedItem());
|
|
sm.registerFunction("entity.getitemframe", (sc, in) -> ((ItemFrameEntity) in[0].get(sc)).getDisplayedItem());
|
|
@@ -1412,8 +1385,29 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
sm.registerFunction("entity.spawn", (sc, in) ->
|
|
sm.registerFunction("entity.spawn", (sc, in) ->
|
|
{
|
|
{
|
|
- // Todo
|
|
|
|
- return null;
|
|
|
|
|
|
+ ResourceLocation rl = new ResourceLocation(in[0].getString(sc));
|
|
|
|
+ Location l = (Location) in[1].get(sc);
|
|
|
|
+ ServerWorld sw = (ServerWorld) l.getWorld();
|
|
|
|
+
|
|
|
|
+ CompoundNBT compoundnbt = in.length >= 3 ? JsonToNBT.getTagFromJson(in[2].getString(sc)) : new CompoundNBT();
|
|
|
|
+ compoundnbt.putString("id", rl.toString());
|
|
|
|
+ if(EntityType.getKey(EntityType.LIGHTNING_BOLT).equals(rl))
|
|
|
|
+ {
|
|
|
|
+ LightningBoltEntity ent = new LightningBoltEntity(sw, l.getX(), l.getY(), l.getZ(), false);
|
|
|
|
+ sw.addLightningBolt(ent);
|
|
|
|
+ return ent;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Entity entity = EntityType.func_220335_a(compoundnbt, sw, (ent) ->
|
|
|
|
+ {
|
|
|
|
+ ent.setLocationAndAngles(l.getX(), l.getY(), l.getZ(), ent.rotationYaw, ent.rotationPitch);
|
|
|
|
+ return sw.summonEntity(ent) ? ent : null;
|
|
|
|
+ });
|
|
|
|
+ if(entity != null && entity instanceof MobEntity)
|
|
|
|
+ {
|
|
|
|
+ ((MobEntity) entity).onInitialSpawn(sw, sw.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.COMMAND, null, null);
|
|
|
|
+ }
|
|
|
|
+ return entity;
|
|
});
|
|
});
|
|
sm.registerFunction("entity.near", (sc, in) -> Utils.getLiving((Entity) in[0].get(sc), in[1].getDouble(sc)));
|
|
sm.registerFunction("entity.near", (sc, in) -> Utils.getLiving((Entity) in[0].get(sc), in[1].getDouble(sc)));
|
|
sm.registerFunction("entity.setspeed", (sc, in) ->
|
|
sm.registerFunction("entity.setspeed", (sc, in) ->
|
|
@@ -1454,73 +1448,7 @@ public class MinecraftFunctions
|
|
((EntityHuman) in[0].get(sc)).setSlim(in[1].getBoolean(sc));
|
|
((EntityHuman) in[0].get(sc)).setSlim(in[1].getBoolean(sc));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
-
|
|
|
|
- // ---------------------------------------------------------------------
|
|
|
|
- // villager commands
|
|
|
|
- // ---------------------------------------------------------------------
|
|
|
|
- //sm.registerFunction("villager.showtrades", (sc, in) ->
|
|
|
|
- //{
|
|
|
|
- // ((ServerPlayerEntity) in[0].get(sc)).displayVillagerTradeGui(((EntityVillager) in[1].get(sc)));
|
|
|
|
- // return Void.TYPE;
|
|
|
|
- //});
|
|
|
|
- //sm.registerFunction("villager.cleartrades", (sc, in) ->
|
|
|
|
- //{
|
|
|
|
- // ((VillagerEntity) in[0].get(sc)).getRecipes(null).clear();
|
|
|
|
- // return Void.TYPE;
|
|
|
|
- //});
|
|
|
|
- //sm.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;
|
|
|
|
- //});
|
|
|
|
- //sm.registerFunction("villager.removetrade", (sc, in) ->
|
|
|
|
- //{
|
|
|
|
- // EntityVillager v = (EntityVillager) in[0].get(sc);
|
|
|
|
- // v.getRecipes(null).remove(in[1].get(sc));
|
|
|
|
- // return Void.TYPE;
|
|
|
|
- //});
|
|
|
|
- //sm.registerFunction("villager.tradeamount", (sc, in) -> ((EntityVillager) in[0].get(sc)).getRecipes(null).size());
|
|
|
|
- //sm.registerFunction("villager.getslot", (sc, in) -> ((EntityVillager) in[0].get(sc)).getVillagerInventory().getStackInSlot(in[1].getInt(sc)));
|
|
|
|
- //sm.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;
|
|
|
|
- //});
|
|
|
|
- //sm.registerFunction("villager.spawn", (sc, in) ->
|
|
|
|
- //{
|
|
|
|
- // Location l = (Location) in[0].get(sc);
|
|
|
|
- // World w = l.getWorld().getWorld();
|
|
|
|
- // EntityVillager v = new EntityVillager(w, in[1].getInt(sc));
|
|
|
|
- // v.setPosition(l.getX(), l.getY(), l.getZ());
|
|
|
|
- // w.spawnEntity(v);
|
|
|
|
- // return v;
|
|
|
|
- //});
|
|
|
|
-
|
|
|
|
|
|
+
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
// GMap-library
|
|
// GMap-library
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
@@ -1907,19 +1835,103 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
- // Effect-library
|
|
|
|
|
|
+ // particle library
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
- sm.registerFunction("effect.playsound", (sc, in) ->
|
|
|
|
|
|
+ sm.registerFunction("particle.get", (sc, in) ->
|
|
{
|
|
{
|
|
- Location l = (Location) in[0].get(sc);
|
|
|
|
- Vec3d v = l.getPos();
|
|
|
|
- EffectUtils.playSound((ServerWorld) l.getWorld(), Mapper.getSound(in[1].getString(sc)), SoundCategory.MASTER, v.x, v.y, v.z);
|
|
|
|
|
|
+ IParticleData data = Mapper.getParticle(in[0].getString(sc));
|
|
|
|
+ if(data == ParticleTypes.BLOCK || data == ParticleTypes.FALLING_DUST)
|
|
|
|
+ {
|
|
|
|
+ data = new BlockParticleData((ParticleType<BlockParticleData>) data, Mapper.getBlock(in[1].getString(sc)).getDefaultState());
|
|
|
|
+ }
|
|
|
|
+ else if(data == ParticleTypes.DUST)
|
|
|
|
+ {
|
|
|
|
+ data = new RedstoneParticleData(in[1].getFloat(sc), in[2].getFloat(sc), in[3].getFloat(sc), in[4].getFloat(sc));
|
|
|
|
+ }
|
|
|
|
+ else if(data == ParticleTypes.ITEM)
|
|
|
|
+ {
|
|
|
|
+ data = new ItemParticleData((ParticleType<ItemParticleData>) data, new ItemStack(Mapper.getItem(in[1].getString(sc))));
|
|
|
|
+ }
|
|
|
|
+ return data;
|
|
|
|
+ });
|
|
|
|
+ sm.registerFunction("particle.spawn", (sc, in) ->
|
|
|
|
+ {
|
|
|
|
+ Location l = ((Location) in[0].get(sc));
|
|
|
|
+ IParticleData data = ((IParticleData) in[1].get(sc));
|
|
|
|
+ int count = in.length >= 3 ? in[2].getInt(sc) : 1;
|
|
|
|
+ double speed = in.length >= 4 ? in[3].getDouble(sc) : 0.0;
|
|
|
|
+ double offX = in.length >= 5 ? in[4].getDouble(sc) : 0.0;
|
|
|
|
+ double offY = in.length >= 6 ? in[5].getDouble(sc) : 0.0;
|
|
|
|
+ double offZ = in.length >= 7 ? in[6].getDouble(sc) : 0.0;
|
|
|
|
+ ((ServerWorld) l.getWorld()).spawnParticle(data, l.getX(), l.getY(), l.getZ(), count, offX, offY, offZ, speed);
|
|
|
|
+ return Void.TYPE;
|
|
|
|
+ });
|
|
|
|
+ sm.registerFunction("particle.spawncircle", (sc, in) ->
|
|
|
|
+ {
|
|
|
|
+ Location l = ((Location) in[0].get(sc));
|
|
|
|
+ IParticleData data = ((IParticleData) in[1].get(sc));
|
|
|
|
+ int instances = in[2].getInt(sc);
|
|
|
|
+ double radius = in[3].getDouble(sc);
|
|
|
|
+ int count = in.length >= 5 ? in[4].getInt(sc) : 1;
|
|
|
|
+ double speed = in.length >= 6 ? in[5].getDouble(sc) : 0.0;
|
|
|
|
+ double offX = in.length >= 7 ? in[6].getDouble(sc) : 0.0;
|
|
|
|
+ double offY = in.length >= 8 ? in[7].getDouble(sc) : 0.0;
|
|
|
|
+ double offZ = in.length >= 9 ? in[8].getDouble(sc) : 0.0;
|
|
|
|
+ double x = l.getX();
|
|
|
|
+ double y = l.getY();
|
|
|
|
+ double z = l.getZ();
|
|
|
|
+ ServerWorld sw = (ServerWorld) l.getWorld();
|
|
|
|
+ double angle = 2 * Math.PI / instances;
|
|
|
|
+ for(int i = 0; i < instances; i++)
|
|
|
|
+ {
|
|
|
|
+ sw.spawnParticle(data, x + Math.cos(i * angle) * radius, y, z + Math.sin(i * angle) * radius, count, offX, offY, offZ, speed);
|
|
|
|
+ }
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
- sm.registerFunction("effect.play", (sc, in) ->
|
|
|
|
|
|
+ sm.registerFunction("particle.spawnline", (sc, in) ->
|
|
{
|
|
{
|
|
Location l = ((Location) in[0].get(sc));
|
|
Location l = ((Location) in[0].get(sc));
|
|
- EffectUtils.spawnParticle((ServerWorld) l.getWorld(), Mapper.getParticle(in[1].getString(sc)), l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, in[2].getInt(sc));
|
|
|
|
|
|
+ IParticleData data = ((IParticleData) in[1].get(sc));
|
|
|
|
+ int instances = in[2].getInt(sc);
|
|
|
|
+ double stepX = in[3].getDouble(sc);
|
|
|
|
+ double stepY = in[4].getDouble(sc);
|
|
|
|
+ double stepZ = in[5].getDouble(sc);
|
|
|
|
+
|
|
|
|
+ int count = in.length >= 7 ? in[6].getInt(sc) : 1;
|
|
|
|
+ double speed = in.length >= 8 ? in[7].getDouble(sc) : 0.0;
|
|
|
|
+ double offX = in.length >= 9 ? in[8].getDouble(sc) : 0.0;
|
|
|
|
+ double offY = in.length >= 10 ? in[9].getDouble(sc) : 0.0;
|
|
|
|
+ double offZ = in.length >= 11 ? in[10].getDouble(sc) : 0.0;
|
|
|
|
+ double x = l.getX();
|
|
|
|
+ double y = l.getY();
|
|
|
|
+ double z = l.getZ();
|
|
|
|
+ ServerWorld sw = (ServerWorld) l.getWorld();
|
|
|
|
+ for(int i = 0; i < instances; i++)
|
|
|
|
+ {
|
|
|
|
+ sw.spawnParticle(data, x + i * stepX, y + i * stepY, z + i * stepZ, count, offX, offY, offZ, speed);
|
|
|
|
+ }
|
|
|
|
+ return Void.TYPE;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // ---------------------------------------------------------------------
|
|
|
|
+ // particle library
|
|
|
|
+ // ---------------------------------------------------------------------
|
|
|
|
+ sm.registerFunction("sound.get", (sc, in) -> Mapper.getSound(in[0].getString(sc)));
|
|
|
|
+ sm.registerFunction("sound.spawn", (sc, in) ->
|
|
|
|
+ {
|
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
|
+ ServerWorld sw = (ServerWorld) l.getWorld();
|
|
|
|
+ float volume = in.length >= 3 ? in[2].getFloat(sc) : 1.0f;
|
|
|
|
+ float pitch = in.length >= 4 ? in[3].getFloat(sc) : (sw.rand.nextFloat() * 0.1f + 0.9f);
|
|
|
|
+ sw.playSound(null, l.getX(), l.getY(), l.getZ(), (SoundEvent) in[1].get(sc), SoundCategory.MASTER, volume, pitch);
|
|
|
|
+ return Void.TYPE;
|
|
|
|
+ });
|
|
|
|
+ sm.registerFunction("sound.spawnforplayer", (sc, in) ->
|
|
|
|
+ {
|
|
|
|
+ ServerPlayerEntity p = (ServerPlayerEntity) in[0].get(sc);
|
|
|
|
+ float volume = in.length >= 3 ? in[2].getFloat(sc) : 1.0f;
|
|
|
|
+ float pitch = in.length >= 4 ? in[3].getFloat(sc) : (p.world.rand.nextFloat() * 0.1f + 0.9f);
|
|
|
|
+ p.playSound((SoundEvent) in[1].get(sc), volume, pitch);
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -2019,32 +2031,15 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
sm.registerFunction("read.spawnmob", (sc, in) ->
|
|
sm.registerFunction("read.spawnmob", (sc, in) ->
|
|
{
|
|
{
|
|
- /*Location l = (Location) in[0].get(sc);
|
|
|
|
- String data = SnuviUtils.connect(sc, in, 1).replace('\'', '"');
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- CompoundNBT 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)
|
|
|
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
|
+ ServerWorld sw = (ServerWorld) l.getWorld();
|
|
|
|
+ CompoundNBT compoundnbt = JsonToNBT.getTagFromJson(SnuviUtils.connect(sc, in, 1));
|
|
|
|
+ Entity entity = EntityType.func_220335_a(compoundnbt, sw, (ent) ->
|
|
{
|
|
{
|
|
- throw new IllegalArgumentException("illegal entity string '" + data + "'");
|
|
|
|
- }*/
|
|
|
|
- return null;
|
|
|
|
|
|
+ ent.setLocationAndAngles(l.getX(), l.getY(), l.getZ(), ent.rotationYaw, ent.rotationPitch);
|
|
|
|
+ return sw.summonEntity(ent) ? ent : null;
|
|
|
|
+ });
|
|
|
|
+ return entity;
|
|
});
|
|
});
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
@@ -2345,4 +2340,95 @@ public class MinecraftFunctions
|
|
}
|
|
}
|
|
return text;
|
|
return text;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private static <T> T launchProjectile(PlayerEntity p, Class<? extends T> projectile, double scale, Object data)
|
|
|
|
+ {
|
|
|
|
+ World w = p.world;
|
|
|
|
+ Entity launch = null;
|
|
|
|
+
|
|
|
|
+ if(EntityItemProjectile.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ if(data == null)
|
|
|
|
+ {
|
|
|
|
+ throw new NullPointerException("Data musn't be null for EntityItemProjectile");
|
|
|
|
+ }
|
|
|
|
+ ItemStack stack = (ItemStack) data;
|
|
|
|
+ if(stack.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ throw new IllegalArgumentException("Empty ItemStack not allowed here");
|
|
|
|
+ }
|
|
|
|
+ launch = new EntityItemProjectile(p, stack.copy());
|
|
|
|
+ ((EntityItemProjectile) launch).setHeadingFromThrower(p, p.rotationPitch, p.rotationYaw, 0.0f, 1.5f, 1.0f);
|
|
|
|
+ }
|
|
|
|
+ else if(SnowballEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new SnowballEntity(w, p);
|
|
|
|
+ ((SnowballEntity) launch).shoot(p, p.rotationPitch, p.rotationYaw, 0.0f, 1.5f, 1.0f);
|
|
|
|
+ }
|
|
|
|
+ else if(EggEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new EggEntity(w, p);
|
|
|
|
+ ((EggEntity) launch).shoot(p, p.rotationPitch, p.rotationYaw, 0.0f, 1.5f, 1.0f);
|
|
|
|
+ }
|
|
|
|
+ else if(EnderPearlEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new EnderPearlEntity(w, p);
|
|
|
|
+ ((EnderPearlEntity) launch).shoot(p, p.rotationPitch, p.rotationYaw, 0.0f, 1.5f, 1.0f);
|
|
|
|
+ }
|
|
|
|
+ else if(PotionEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new PotionEntity(w, p);
|
|
|
|
+ ((PotionEntity) launch).setItem((ItemStack) data);
|
|
|
|
+ ((PotionEntity) launch).shoot(p, p.rotationPitch, p.rotationYaw, -20.0f, 0.5f, 1.0f);
|
|
|
|
+ }
|
|
|
|
+ else if(ExperienceBottleEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new ExperienceBottleEntity(w, p);
|
|
|
|
+ ((ExperienceBottleEntity) launch).shoot(p, p.rotationPitch, p.rotationYaw, -20.0f, 0.7f, 1.0f);
|
|
|
|
+ }
|
|
|
|
+ else if(AbstractArrowEntity.class.isAssignableFrom(projectile))
|
|
|
|
+ {
|
|
|
|
+ if(SpectralArrowEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new SpectralArrowEntity(w, p);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ launch = new ArrowEntity(w, p);
|
|
|
|
+ if(data != null)
|
|
|
|
+ {
|
|
|
|
+ ((ArrowEntity) launch).setPotionEffect((ItemStack) data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ((AbstractArrowEntity) launch).shoot(p, p.rotationPitch, p.rotationYaw, 0.0F, 3.0F, 1.0F);
|
|
|
|
+ }
|
|
|
|
+ else if(DamagingProjectileEntity.class.isAssignableFrom(projectile))
|
|
|
|
+ {
|
|
|
|
+ Vec3d v = p.getLookVec().scale(10);
|
|
|
|
+ if(SmallFireballEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new SmallFireballEntity(w, p, v.x, v.y, v.z);
|
|
|
|
+ }
|
|
|
|
+ else if(WitherSkullEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new WitherSkullEntity(w, p, v.x, v.y, v.z);
|
|
|
|
+ }
|
|
|
|
+ else if(DragonFireballEntity.class == projectile)
|
|
|
|
+ {
|
|
|
|
+ launch = new DragonFireballEntity(w, p, v.x, v.y, v.z);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ launch = new FireballEntity(w, p, v.x, v.y, v.z);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ launch.setMotion(launch.getMotion().scale(scale));
|
|
|
|
+ w.addEntity(launch);
|
|
|
|
+ return (T) launch;
|
|
|
|
+ }
|
|
}
|
|
}
|