private WrappedStack(Object object, int stackSize) { if (object instanceof Item) { object = new ItemStack((Item) object); } else if (object instanceof Block) { object = new ItemStack((Block) object); } else if (object instanceof Fluid) { object = new FluidStack((Fluid) object, 1000); } if (object instanceof ItemStack) { ItemStack itemStack = ((ItemStack) object).copy(); objectType = "itemstack"; this.stackSize = stackSize; itemStack.stackSize = 1; wrappedStack = itemStack; } else if (object instanceof OreStack) { OreStack oreStack = (OreStack) object; objectType = "orestack"; this.stackSize = stackSize; oreStack.stackSize = 1; wrappedStack = oreStack; } else if (object instanceof ArrayList) { ArrayList<?> objectList = (ArrayList<?>) object; OreStack possibleOreStack = OreStack.getOreStackFromList(objectList); if (possibleOreStack != null) { objectType = "orestack"; this.stackSize = stackSize; possibleOreStack.stackSize = 1; wrappedStack = possibleOreStack; } else { objectType = null; this.stackSize = -1; wrappedStack = null; } } else if (object instanceof FluidStack) { FluidStack fluidStack = (FluidStack) object; objectType = "fluidstack"; this.stackSize = stackSize; fluidStack.amount = 1; wrappedStack = fluidStack; } else if (object instanceof WrappedStack) { WrappedStack wrappedStackObject = (WrappedStack) object; if (wrappedStackObject.getWrappedObject() != null) { this.objectType = wrappedStackObject.objectType; this.stackSize = stackSize; this.wrappedStack = wrappedStackObject.wrappedStack; } else { objectType = null; this.stackSize = -1; wrappedStack = null; } } else { objectType = null; this.stackSize = -1; wrappedStack = null; } }
public static boolean canBeWrapped(Object object) { if (object instanceof WrappedStack) { return true; } else if (object instanceof Item || object instanceof Block || object instanceof ItemStack) { return true; } else if (object instanceof OreStack) { return true; } else if (object instanceof List) { if (OreStack.getOreStackFromList((List<?>) object) != null) { return true; } } else if (object instanceof EnergyStack) { return true; } else if (object instanceof Fluid || object instanceof FluidStack) { return true; } return false; }
public WrappedStack(Object object) { if (object instanceof Item) { object = new ItemStack((Item) object); } else if (object instanceof Block) { object = new ItemStack((Block) object); } else if (object instanceof Fluid) { object = new FluidStack((Fluid) object, 1000); } if (object instanceof ItemStack) { ItemStack itemStack = ((ItemStack) object).copy(); className = ItemStack.class.getSimpleName(); stackSize = itemStack.stackSize; itemStack.stackSize = 1; wrappedStack = itemStack; } else if (object instanceof OreStack) { OreStack oreStack = (OreStack) object; className = OreStack.class.getSimpleName(); stackSize = oreStack.stackSize; oreStack.stackSize = 1; wrappedStack = oreStack; } else if (object instanceof ArrayList) { ArrayList<?> objectList = (ArrayList<?>) object; OreStack possibleOreStack = OreStack.getOreStackFromList(objectList); if (possibleOreStack != null) { className = OreStack.class.getSimpleName(); stackSize = possibleOreStack.stackSize; possibleOreStack.stackSize = 1; wrappedStack = possibleOreStack; } else { stackSize = -1; className = null; wrappedStack = null; } } else if (object instanceof EnergyStack) { EnergyStack energyStack = (EnergyStack) object; className = EnergyStack.class.getSimpleName(); stackSize = energyStack.stackSize; energyStack.stackSize = 1; wrappedStack = energyStack; } else if (object instanceof FluidStack) { FluidStack fluidStack = ((FluidStack) object).copy(); className = FluidStack.class.getSimpleName(); stackSize = fluidStack.amount; fluidStack.amount = 1; wrappedStack = fluidStack; } else if (object instanceof WrappedStack) { WrappedStack wrappedStackObject = (WrappedStack) object; if (wrappedStackObject.getWrappedStack() != null) { className = wrappedStackObject.wrappedStack.getClass().getSimpleName(); this.stackSize = wrappedStackObject.stackSize; this.wrappedStack = wrappedStackObject.wrappedStack; } else { className = null; stackSize = -1; wrappedStack = null; } } else if (object instanceof String) { WrappedStack wrappedStack = createFromJson((String) object); if (wrappedStack != null && wrappedStack.getWrappedStack() != null) { className = wrappedStack.getWrappedStack().getClass().getSimpleName(); stackSize = wrappedStack.stackSize; this.wrappedStack = wrappedStack.wrappedStack; } else { className = null; stackSize = -1; this.wrappedStack = null; } } else { className = null; stackSize = -1; wrappedStack = null; } }