// Path: src/main/java/net/mechanicalcat/pycode/PythonEngine.java
// public class PythonEngine {
//     private static PythonEngine instance = null;
//     private PyScriptEngine engine;
// 
//     private PythonEngine() {
//         ScriptEngineManager manager = new ScriptEngineManager();
//         engine = (PyScriptEngine) manager.getEngineByName("python");
//         if (engine == null) {
//             FMLLog.severe("FAILED to getBlock Python");
//         } else {
//             FMLLog.fine("Got Python");
//         }
//         try {
//             engine.eval("print 'Python Ready'");
//         } catch (ScriptException e) {
//             FMLLog.severe("Python failed: %s", e);
//         }
//     }
// 
//     public static PythonEngine getEngine() {
//         if (instance == null) {
//             instance = new PythonEngine();
//         }
//         return instance;
//     }
// 
//     public static CompiledScript compile(String code) throws ScriptException {
//         return getEngine().engine.compile(code);
//     }
// 
//     public static Object eval(String code, ScriptContext context) throws ScriptException {
//         return getEngine().engine.eval(code, context);
//     }
// }


import net.mechanicalcat.pycode.PythonEngine;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.FMLLog;
import org.python.core.Py;
import org.python.core.PyFunction;
import org.python.core.PyObject;
import javax.annotation.Nullable;
import javax.script.*;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
/*
 * Copyright (c) 2017 Richard Jones <richard@mechanicalcat.net>
 * All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

package net.mechanicalcat.pycode.script;



public class PythonCode {
    private String code = "";
    private boolean codeChanged = false;
    private SimpleScriptContext context;
    private Bindings bindings;
    private World world = null;
    private BlockPos pos;
    private ICommandSender runner;
    public static String CODE_NBT_TAG = "code";
    public MyEntityPlayers players;

    public PythonCode() {
        this.context = new SimpleScriptContext();
        this.bindings = new SimpleBindings();
        this.context.setBindings(this.bindings, ScriptContext.ENGINE_SCOPE);
    }

    public String getCode() {return code;}

    public boolean hasCode() {return !code.isEmpty();}

    public void check(String code) throws ScriptException {
// Path: src/main/java/net/mechanicalcat/pycode/PythonEngine.java
// public class PythonEngine {
//     private static PythonEngine instance = null;
//     private PyScriptEngine engine;
// 
//     private PythonEngine() {
//         ScriptEngineManager manager = new ScriptEngineManager();
//         engine = (PyScriptEngine) manager.getEngineByName("python");
//         if (engine == null) {
//             FMLLog.severe("FAILED to getBlock Python");
//         } else {
//             FMLLog.fine("Got Python");
//         }
//         try {
//             engine.eval("print 'Python Ready'");
//         } catch (ScriptException e) {
//             FMLLog.severe("Python failed: %s", e);
//         }
//     }
// 
//     public static PythonEngine getEngine() {
//         if (instance == null) {
//             instance = new PythonEngine();
//         }
//         return instance;
//     }
// 
//     public static CompiledScript compile(String code) throws ScriptException {
//         return getEngine().engine.compile(code);
//     }
// 
//     public static Object eval(String code, ScriptContext context) throws ScriptException {
//         return getEngine().engine.eval(code, context);
//     }
// }


// Path: src/main/java/net/mechanicalcat/pycode/script/PythonCode.java
import net.mechanicalcat.pycode.PythonEngine;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.FMLLog;
import org.python.core.Py;
import org.python.core.PyFunction;
import org.python.core.PyObject;
import javax.annotation.Nullable;
import javax.script.*;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

/*
 * Copyright (c) 2017 Richard Jones <richard@mechanicalcat.net>
 * All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

package net.mechanicalcat.pycode.script;



public class PythonCode {
    private String code = "";
    private boolean codeChanged = false;
    private SimpleScriptContext context;
    private Bindings bindings;
    private World world = null;
    private BlockPos pos;
    private ICommandSender runner;
    public static String CODE_NBT_TAG = "code";
    public MyEntityPlayers players;

    public PythonCode() {
        this.context = new SimpleScriptContext();
        this.bindings = new SimpleBindings();
        this.context.setBindings(this.bindings, ScriptContext.ENGINE_SCOPE);
    }

    public String getCode() {return code;}

    public boolean hasCode() {return !code.isEmpty();}

    public void check(String code) throws ScriptException {
        PythonEngine.compile(code);