Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DragonAPI/ModInteract/Lua/LuaPrintInv.java /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (42 sloc)
1.3 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /******************************************************************************* | |
| * @author Reika Kalseki | |
| * | |
| * Copyright 2017 | |
| * | |
| * All rights reserved. | |
| * Distribution of the software in any form is only allowed with | |
| * explicit, prior permission from the owner. | |
| ******************************************************************************/ | |
| package Reika.DragonAPI.ModInteract.Lua; | |
| import java.util.ArrayList; | |
| import net.minecraft.inventory.IInventory; | |
| import net.minecraft.item.ItemStack; | |
| import net.minecraft.tileentity.TileEntity; | |
| public class LuaPrintInv extends LuaMethod { | |
| public LuaPrintInv() { | |
| super("printInv", IInventory.class); | |
| } | |
| @Override | |
| protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException { | |
| ArrayList<String> li = new ArrayList(); | |
| IInventory ii = (IInventory) te; | |
| for (int i = 0; i < ii.getSizeInventory(); i++) { | |
| ItemStack is = ii.getStackInSlot(i); | |
| String name = is != null ? is.toString() : "Empty"; | |
| li.add(name); | |
| } | |
| return li.toArray(); | |
| } | |
| @Override | |
| public String getDocumentation() { | |
| return "Prints an entire inventory.\nArgs: None\nReturns: List of ItemStack.toString()"; | |
| } | |
| @Override | |
| public String getArgsAsString() { | |
| return ""; | |
| } | |
| @Override | |
| public ReturnType getReturnType() { | |
| return ReturnType.ARRAY; | |
| } | |
| } |