Răsfoiți Sursa

bugfixes, recipes fixes, snuvi script fixes, normal behaviour of villagers in normal world

Kajetan Johannes Hammerle 7 ani în urmă
părinte
comite
b8597cc7cf

+ 1 - 2
src/main/java/me/km/ClientProxy.java

@@ -11,7 +11,6 @@ import me.km.items.ModelCylinder;
 import me.km.items.ModelHat;
 import me.km.networking.KeyManager;
 import me.km.utils.ReflectionUtils;
-import static me.km.utils.ReflectionUtils.getFinalStaticField;
 import net.minecraft.block.Block;
 import net.minecraft.block.state.IBlockState;
 import net.minecraft.client.Minecraft;
@@ -151,7 +150,7 @@ public class ClientProxy extends CommonProxy
     }
     
     @SideOnly(Side.CLIENT)
-    private final static Field LOC_GRASS_PNG = getFinalStaticField(GrassColorReloadListener.class, "field_130078_a", "LOC_GRASS_PNG");   
+    private final static Field LOC_GRASS_PNG = ReflectionUtils.getFinalStaticField(GrassColorReloadListener.class, "field_130078_a", "LOC_GRASS_PNG");   
     
     @Override
     public void setGrass(ResourceLocation loc)

+ 1 - 1
src/main/java/me/km/KajetansMod.java

@@ -68,7 +68,7 @@ public class KajetansMod
 
     public static final String MODID = "km";
     public static final String NAME = "Kajetans Mod";
-    public static final String VERSION = "0.0.19";
+    public static final String VERSION = "0.0.21";
 
     @Mod.Instance(MODID)
     public static KajetansMod instance;

+ 6 - 13
src/main/java/me/km/ObjectRegistry.java

@@ -1,7 +1,5 @@
 package me.km;
 
-import java.util.List;
-import java.util.stream.Collectors;
 import me.km.blocks.ModBlocks;
 import me.km.fluids.ModFluids;
 import me.km.items.ModItems;
@@ -11,15 +9,10 @@ import net.minecraft.block.Block;
 import net.minecraft.init.Blocks;
 import net.minecraft.item.Item;
 import net.minecraft.item.crafting.IRecipe;
-import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.SoundEvent;
 import net.minecraftforge.event.RegistryEvent;
-import net.minecraftforge.fml.common.FMLCommonHandler;
 import net.minecraftforge.fml.common.Mod;
 import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.registry.ForgeRegistries;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.registries.ForgeRegistry;
 
 @Mod.EventBusSubscriber
 public class ObjectRegistry 
@@ -49,10 +42,10 @@ public class ObjectRegistry
         ModBlocks.initItemBlocks(e.getRegistry());
     }
     
-    /*@SubscribeEvent
+    @SubscribeEvent
     public static void onRecipeRegistry(RegistryEvent.Register<IRecipe> e) 
     {
-        if(FMLCommonHandler.instance().getSide() == Side.SERVER)
+        /*if(FMLCommonHandler.instance().getSide() == Side.SERVER)
         {
             System.out.println("_______________________________________");
             System.out.println("_______________________________________");
@@ -61,9 +54,9 @@ public class ObjectRegistry
             System.out.println("_______________________________________");
             System.out.println("_______________________________________");
             System.out.println("_______________________________________");
-            System.out.println("Registering recipes");
+            System.out.println("Registering recipes");*/
             ModRecipes.init(e.getRegistry());
-        }
+        /*}
         else
         {
             System.out.println("_______________________________________");
@@ -78,8 +71,8 @@ public class ObjectRegistry
             ForgeRegistry<IRecipe> recipeRegistry = (ForgeRegistry<IRecipe>) ForgeRegistries.RECIPES;
             List<ResourceLocation> recipes = recipeRegistry.getKeys().stream().collect(Collectors.toList());
             recipes.forEach(key -> recipeRegistry.remove(key));
-        }
-    }*/
+        }*/
+    }
     
     @SubscribeEvent
     public static void onSoundRegistry(RegistryEvent.Register<SoundEvent> e) 

+ 31 - 1
src/main/java/me/km/blocks/BlockHayBed.java

@@ -1,11 +1,19 @@
 package me.km.blocks;
 
+import java.util.Random;
+import static me.km.blocks.BlockModBed.PART;
 import me.km.items.ModItems;
+import static net.minecraft.block.Block.spawnAsEntity;
+import net.minecraft.block.BlockBed;
 import net.minecraft.block.SoundType;
 import net.minecraft.block.state.IBlockState;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
 import net.minecraft.util.math.AxisAlignedBB;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
 
 public class BlockHayBed extends BlockModBed
 { 
@@ -13,7 +21,7 @@ public class BlockHayBed extends BlockModBed
     
     public BlockHayBed(String name, String local) 
     {
-        super(name, local, ModItems.realHayBed);
+        super(name, local);
         super.setSoundType(SoundType.PLANT);
     }
     
@@ -28,4 +36,26 @@ public class BlockHayBed extends BlockModBed
     {
         return 0;
     }
+    
+    @Override
+    public Item getItemDropped(IBlockState state, Random rand, int fortune)
+    {
+        return state.getValue(PART) == BlockBed.EnumPartType.FOOT ? Items.AIR : ModItems.realHayBed;
+    }
+    
+    @Override
+    public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
+    {
+        if(state.getValue(PART) == BlockBed.EnumPartType.HEAD)
+        {
+            spawnAsEntity(worldIn, pos, new ItemStack(ModItems.realHayBed));
+        }
+    }
+    
+    @Override
+    public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
+    {
+        return new ItemStack(ModItems.realHayBed);
+    }
+
 }

+ 1 - 26
src/main/java/me/km/blocks/BlockModBed.java

@@ -20,8 +20,6 @@ import net.minecraft.entity.EntityLivingBase;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.entity.player.EntityPlayerMP;
 import net.minecraft.init.Biomes;
-import net.minecraft.init.Items;
-import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.tileentity.TileEntity;
 import net.minecraft.util.BlockRenderLayer;
@@ -45,9 +43,8 @@ public abstract class BlockModBed extends BlockHorizontal
     
     protected String name;
     private SoundType type;
-    private final Item drop;
     
-    public BlockModBed(String name, String local, Item drop)
+    public BlockModBed(String name, String local)
     {
         super(Material.CLOTH);
         this.setDefaultState(this.blockState.getBaseState().withProperty(PART, BlockBed.EnumPartType.FOOT)
@@ -58,7 +55,6 @@ public abstract class BlockModBed extends BlockHorizontal
         this.setRegistryName(name);
         super.setUnlocalizedName(local);
         this.type = SoundType.CLOTH;
-        this.drop = drop;
         super.setHardness(0.2F);
         super.disableStats();
     }
@@ -244,12 +240,6 @@ public abstract class BlockModBed extends BlockHorizontal
         }
     }
 
-    @Override
-    public Item getItemDropped(IBlockState state, Random rand, int fortune)
-    {
-        return state.getValue(PART) == BlockBed.EnumPartType.FOOT ? Items.AIR : drop;
-    }
-
     @Override
     public abstract AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos);
 
@@ -266,15 +256,6 @@ public abstract class BlockModBed extends BlockHorizontal
         return net.minecraft.block.BlockBed.getSafeExitLocation(w, pos, tries);
     }
 
-    @Override
-    public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
-    {
-        if(state.getValue(PART) == BlockBed.EnumPartType.HEAD)
-        {
-            spawnAsEntity(worldIn, pos, new ItemStack(drop));
-        }
-    }
-
     @Override
     public EnumPushReaction getMobilityFlag(IBlockState state)
     {
@@ -294,12 +275,6 @@ public abstract class BlockModBed extends BlockHorizontal
         return EnumBlockRenderType.MODEL;
     }
 
-    @Override
-    public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
-    {
-        return new ItemStack(drop);
-    }
-
     @Override
     public void onBlockHarvested(World w, BlockPos pos, IBlockState state, EntityPlayer player)
     {

+ 14 - 5
src/main/java/me/km/datatools/DataToolsEvents.java

@@ -2,6 +2,7 @@ package me.km.datatools;
 
 import me.km.api.Module;
 import me.km.api.ModuleListener;
+import me.km.dimensions.ModDimensions;
 import me.km.inventory.CustomContainer;
 import me.km.inventory.InventoryBase;
 import me.km.inventory.InventoryUtils;
@@ -75,11 +76,15 @@ public class DataToolsEvents extends ModuleListener
         if (e.getEntity() instanceof EntityVillager)
         {
             EntityVillager v = (EntityVillager) e.getEntity();
-            ReflectionUtils.setCareerLevel(v, 10);
-            MerchantRecipeList list = v.getRecipes(null);
-            if(list != null)
+            int dim = v.getWorld().provider.getDimension();
+            if(dim >= 2)
             {
-                list.clear();
+                ReflectionUtils.setCareerLevel(v, 10);
+                MerchantRecipeList list = v.getRecipes(null);
+                if(list != null)
+                {
+                    list.clear();
+                }
             }
         }
     }
@@ -90,7 +95,11 @@ public class DataToolsEvents extends ModuleListener
     { 
         if(e.getEntityLiving() instanceof EntityVillager && !e.getSource().isCreativePlayer())
         {
-            e.setCanceled(true);
+            int dim = e.getEntity().getEntityWorld().provider.getDimension();
+            if(dim >= 2)
+            {
+                e.setCanceled(true);
+            }
         }
     }
 }

+ 20 - 5
src/main/java/me/km/events/CustomEventCaller.java

@@ -12,21 +12,36 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
 import net.minecraftforge.event.entity.living.LivingHurtEvent;
 import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
 import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.relauncher.Side;
 
 public class CustomEventCaller 
 {
     private static final ArrayList<EntityArrow> ARROWS = new ArrayList<>();
     
+    private static double x;
+    private static double y;
+    private static double z;
+    
     @SubscribeEvent
     public void onPlayerMove(TickEvent.PlayerTickEvent e)
     {      
-        if(e.phase == TickEvent.Phase.END)
+        if(e.side == Side.SERVER)
         {
-            EntityPlayer p = e.player;
-            if(p.prevPosX != p.posX || p.prevPosY != p.posY || p.prevPosZ != p.posZ)
+            if(e.phase == TickEvent.Phase.END)
+            {
+                EntityPlayer p = e.player;
+                x = p.prevPosX;
+                y = p.prevPosY;
+                z = p.prevPosZ;
+            }
+            else
             {
-                MinecraftForge.EVENT_BUS.post(new PlayerMoveEvent(p));
-            }  
+                EntityPlayer p = e.player;
+                if(p.posX != x || p.posY != y || p.posZ != z)
+                {
+                    MinecraftForge.EVENT_BUS.post(new PlayerMoveEvent(p));
+                }  
+            }
         }
     } 
     

+ 76 - 14
src/main/java/me/km/recipes/ModRecipes.java

@@ -1,9 +1,6 @@
 package me.km.recipes;
 
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Collectors;
 import me.km.blocks.EnumMetals;
 import me.km.blocks.ModBlocks;
 import me.km.items.ModItems;
@@ -14,16 +11,12 @@ import net.minecraft.init.Items;
 import net.minecraft.item.EnumDyeColor;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
-import net.minecraft.item.crafting.CraftingManager;
 import net.minecraft.item.crafting.FurnaceRecipes;
 import net.minecraft.item.crafting.IRecipe;
 import net.minecraft.item.crafting.Ingredient;
 import net.minecraft.item.crafting.ShapedRecipes;
 import net.minecraft.item.crafting.ShapelessRecipes;
 import net.minecraft.util.NonNullList;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.common.registry.ForgeRegistries;
-import net.minecraftforge.registries.ForgeRegistry;
 import net.minecraftforge.registries.IForgeRegistry;
 
 public class ModRecipes 
@@ -68,6 +61,9 @@ public class ModRecipes
     {
         ShapedRecipes recipe = newShapedRecipe(group, pattern, result, chars, stacks);
         recipe.setRegistryName(buildRegistryName(result));
+        System.out.println("Registering " + recipe.getRegistryName());
+        System.out.println(recipe.getIngredients());
+        System.out.println(recipe.getRecipeOutput());
         r.register(recipe);
     }
     
@@ -153,6 +149,8 @@ public class ModRecipes
                 new char[] {'X'}, new ItemStack[][] {{new ItemStack(ModBlocks.realHayBlock)}});
         registerShaped(r, "", new String[] {" X ", "XXX"}, new ItemStack(ModItems.strawHat), 
                 new char[] {'X'}, new ItemStack[][] {{new ItemStack(Items.WHEAT)}});
+        registerShaped(r, "", new String[] {"XXX", "XXX"}, new ItemStack(ModItems.campFire), 
+                new char[] {'X'}, new ItemStack[][] {{new ItemStack(Items.STICK)}});
         registerShaped(r, "", new String[] {"XXX", "GCG", "XXX"}, new ItemStack(ModBlocks.lantern), 
                 new char[] {'X', 'G', 'C'}, new ItemStack[][] 
                 {
@@ -193,6 +191,7 @@ public class ModRecipes
             {ModItems.copperBoots, ModItems.bronzeBoots}
         };
         addArmorRecipes(r, armorItems);
+        addArmorNuggetRecipes(fr, armorItems, ModItems.copperNugget, ModItems.bronzeNugget);
         
         // additionel old tool recipes
         String[][] toolPatterns = new String[][] 
@@ -256,8 +255,18 @@ public class ModRecipes
             {ModBlocks.realHayBlock, new ItemStack(ModItems.hayBundle, 9)}, 
         };
         addIngotRecipes(r, ingotItems);
-
-        addNuggetRecipes(fr, toolItems, armorItems, ModItems.copperNugget, ModItems.bronzeNugget);
+        
+        // tool nuggets
+        toolItems = new Object[][] 
+        {
+            {ModItems.copperPickaxe, ModItems.copperShovel, ModItems.copperAxe, ModItems.copperHoe, ModItems.copperSword, ModItems.copperStick, ModItems.copperDagger, ModItems.copperHammer},
+            {ModItems.bronzePickaxe, ModItems.bronzeShovel, ModItems.bronzeAxe, ModItems.bronzeHoe, ModItems.bronzeSword, ModItems.bronzeStick, ModItems.bronzeDagger, ModItems.bronzeHammer}, 
+            {ModItems.ironStick, ModItems.ironDagger, ModItems.ironHammer},
+            {ModItems.goldStick, ModItems.goldDagger, ModItems.goldHammer}
+        };
+        addToolNuggetRecipes(fr, toolItems, ModItems.copperNugget, ModItems.bronzeNugget, Items.IRON_NUGGET, Items.GOLD_NUGGET);
+        
+        addWoodRecipes(r);
     }
 
     // -----------------------------------------------------------------------------------
@@ -358,14 +367,10 @@ public class ModRecipes
         }
     }
     
-    private static void addNuggetRecipes(FurnaceRecipes fr, Object[][] toolItems, Item[][] armorItems, Item... nuggets)
+    private static void addArmorNuggetRecipes(FurnaceRecipes fr, Item[][] armorItems, Item... nuggets)
     {
         for(int i = 0; i < nuggets.length; i++)
         {
-            for(int j = 1; j < toolItems.length; j++)
-            {
-                fr.addSmelting((Item) toolItems[j][i], new ItemStack(nuggets[i]), 0.1f);
-            }
             for(int j = 1; j < armorItems.length; j++)
             {
                 fr.addSmelting((Item) armorItems[j][i], new ItemStack(nuggets[i]), 0.1f);
@@ -373,6 +378,17 @@ public class ModRecipes
         }
     }
     
+    private static void addToolNuggetRecipes(FurnaceRecipes fr, Object[][] toolItems, Item... nuggets)
+    {
+        for(int i = 0; i < nuggets.length; i++)
+        {
+            for(Object toolItem : toolItems[i]) 
+            {
+                fr.addSmelting((Item) toolItem, new ItemStack(nuggets[i]), 0.1f);
+            }
+        }
+    }
+    
     private static void addMetalRecipes(IForgeRegistry<IRecipe> r, String group, String[] pattern, Item output, int amount)
     {
         char[] chars = new char[] {'X'};
@@ -403,4 +419,50 @@ public class ModRecipes
         }
         registerShaped(r, "", pattern, result, chars, stacks);
     }
+    
+    private static void addWoodRecipes(IForgeRegistry<IRecipe> r)
+    {
+        ItemStack[] planks = new ItemStack[] 
+        {
+            new ItemStack(Blocks.PLANKS, 1, 0), new ItemStack(Blocks.PLANKS, 1, 1), 
+            new ItemStack(Blocks.PLANKS, 1, 2), new ItemStack(Blocks.PLANKS, 1, 3), 
+            new ItemStack(Blocks.PLANKS, 1, 4), new ItemStack(Blocks.PLANKS, 1, 5) 
+        };
+        String[] pattern = new String[] {"X X", "X X", "XXX"};
+        ItemStack[] result = new ItemStack[] 
+        {
+            new ItemStack(ModBlocks.cauldronOak), new ItemStack(ModBlocks.cauldronSpruce), 
+            new ItemStack(ModBlocks.cauldronBirch), new ItemStack(ModBlocks.cauldronJungle), 
+            new ItemStack(ModBlocks.cauldronAcacia), new ItemStack(ModBlocks.cauldronBigOak) 
+        };
+        
+        for(int i = 0; i < planks.length; i++)
+        {
+            registerShaped(r, "", pattern, result[i], new char[] {'X'}, new ItemStack[][] {{planks[i]}});
+        }
+        
+        result = new ItemStack[] 
+        {
+            new ItemStack(ModBlocks.crateOak), new ItemStack(ModBlocks.crateSpruce), 
+            new ItemStack(ModBlocks.crateBirch), new ItemStack(ModBlocks.crateJungle), 
+            new ItemStack(ModBlocks.crateAcacia), new ItemStack(ModBlocks.crateBigOak) 
+        };
+        pattern = new String[] {"XXX", "XXX", "XXX"};
+        for(int i = 0; i < planks.length; i++)
+        {
+            registerShaped(r, "", pattern, result[i], new char[] {'X'}, new ItemStack[][] {{planks[i]}});
+        }
+        
+        result = new ItemStack[] 
+        {
+            new ItemStack(ModBlocks.barrelOak), new ItemStack(ModBlocks.barrelSpruce), 
+            new ItemStack(ModBlocks.barrelBirch), new ItemStack(ModBlocks.barrelJungle), 
+            new ItemStack(ModBlocks.barrelAcacia), new ItemStack(ModBlocks.barrelBigOak) 
+        };
+        pattern = new String[] {"X X", "XXX", "X X"};
+        for(int i = 0; i < planks.length; i++)
+        {
+            registerShaped(r, "", pattern, result[i], new char[] {'X'}, new ItemStack[][] {{planks[i]}});
+        }
+    }
 }

+ 37 - 6
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -341,11 +341,11 @@ public class MinecraftFunctions implements ISnuviLogger
                     if(args.length >= 6)
                     {
                         return new Location(ModDimensions.getWorldFromName(args[0].toString()), 
-                                ScriptUtils.getDouble(args[0]), ScriptUtils.getDouble(args[1]), ScriptUtils.getDouble(args[2]), 
-                                ScriptUtils.getFloat(args[3]), ScriptUtils.getFloat(args[4]));
+                                ScriptUtils.getDouble(args[1]), ScriptUtils.getDouble(args[2]), ScriptUtils.getDouble(args[3]), 
+                                ScriptUtils.getFloat(args[4]), ScriptUtils.getFloat(args[5]));
                     }
                     return new Location(ModDimensions.getWorldFromName(args[0].toString()), 
-                            ScriptUtils.getDouble(args[0]), ScriptUtils.getDouble(args[1]), ScriptUtils.getDouble(args[2]), 0, 0);
+                            ScriptUtils.getDouble(args[1]), ScriptUtils.getDouble(args[2]), ScriptUtils.getDouble(args[3]), 0, 0);
                 });  
         
         parser.registerFunction("loc.getx", (args, qd) -> 
@@ -678,6 +678,7 @@ public class MinecraftFunctions implements ISnuviLogger
                 qd.setVar(args[0].toString(), new Table(ScriptUtils.getInt(args[1]))));
         parser.registerConsumer("table.frommap", (args, qd) -> 
                 qd.setVar(args[0].toString(), new Table((Map<Object, Object>) args[1])));
+        parser.registerAlias("map.totable", "table.frommap");
         parser.registerConsumer("table.sort", (args, qd) -> 
                 ((Table) args[0]).sort());
         parser.registerConsumer("table.reverse", (args, qd) -> 
@@ -828,6 +829,8 @@ public class MinecraftFunctions implements ISnuviLogger
         parser.registerConsumer("setglobalvar", (args, qd) -> 
                 setGlobalVar(args));                          
         parser.registerAlias("sgv", "setglobalvar");
+        parser.registerConsumer("delglobalvar", (args, qd) -> 
+                delGlobalVar(args)); 
         parser.registerConsumer("msg", (args, qd) -> 
                 sendMessageToGroup(args[0], qd, NBTUtils.concat(1, args)));       
         parser.registerFunction("removeformat", (args, qd) -> 
@@ -1581,17 +1584,45 @@ public class MinecraftFunctions implements ISnuviLogger
         }
     }
     
+    private static void delGlobalVar(Object[] args)
+    {
+        if(args[0] instanceof EntityPlayer)
+        {
+            KajetansMod.scripts.getDataBank(ScriptBank.class).deleteVar(args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().toString());
+        }
+        else if(args[0].equals("SERVER"))
+        {
+            KajetansMod.scripts.getDataBank(ScriptBank.class).deleteVar(args[1].toString(), "-1");
+        }
+        else
+        {
+            KajetansMod.scripts.getDataBank(ScriptBank.class).deleteVar(args[1].toString(), args[0].toString());
+        }
+    }
+    
     private static Object getGlobalVar(Object[] args)
     {
+        if(args.length == 2)
+        {
+            if(args[0] instanceof EntityPlayer)
+            {
+                return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().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());
+        }
         if(args[0] instanceof EntityPlayer)
         {
-            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(), args[2]);
         }
         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(), "-1", args[2]);
         }
-        return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), args[0].toString());
+        return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), args[0].toString(), args[2]);
     }
     
     // -------------------------------------------------------------------------    

+ 19 - 2
src/main/java/me/km/snuviscript/ScriptBank.java

@@ -86,12 +86,29 @@ public class ScriptBank extends SimpleDataBank
                 + "ON DUPLICATE KEY UPDATE questdata.value='" + value + "';", false);
     }
 
-    public Object getVar(String var, String uuid)
+    public void deleteVar(String var, String uuid)
     {
-        return Code.convertInput(null, this.getFirst("SELECT value from questdata "
+        this.update("DELETE FROM questdata LEFT JOIN players ON players.id = questdata.player_id " +
+            "WHERE players.uuid = '" + uuid + "' AND " +
+            "questdata.var='" + var + "';", false);
+    }
+    
+    public Object getVar(String var, String uuid, Object error)
+    {
+        Object o = Code.convertInput(null, this.getFirst("SELECT value from questdata "
                 + "LEFT JOIN players ON players.id = questdata.player_id "
                 + "WHERE players.uuid = '" + uuid + "' AND "
                 + "questdata.var='" + var + "';", String.class), false);
+        if(o == null)
+        {
+            return error;
+        }
+        return o;
+    } 
+    
+    public Object getVar(String var, String uuid)
+    {
+        return getVar(var, uuid, null);
     }    
     
     public void addMapElement(String map, String key, String value)