I'm trying to make an eyedropper tool (one where it picks up the color the tool is being pointed at) for a Minecraft mod that uses Forge on IntelliJ IDEA. I already have the item/tool ready and able to be crafted, but I'm not sure how to build it so it can pick up pixel color, whether it's possible without Javascript, or if it would be possible to build it as of now considering it's in a game software rather than within a browser.
This is the closest I've come to with research on how I can build it with Java, but import net.java.swing.application.*
was an issue for which I'm not sure the reason.
import java.text.*;
import java.util.List;
import java.awt.*;
import javax.swing.*;
public class PickupColor extends SingleFrameApplication { // "Cannot resolve symbol 'SingleFrameApplication'"
public JButton eyedropper, quit;
public JComponent colormap;
public JFrame rootFrame;
public Image background_image;
public Robot robot;
public Dimension screen_size;
public Container contentPane;
public JComponent button_panel;
public JPanel image_panel;
public JPanel control_panel;
public JPanel color_panel;
public ColorLabel selected_color; // "Cannot resolve symbol 'ColorLabel'"
public ColorLabel color_rich, color_pale,
color_bright, color_dark; // // "Cannot resolve symbol 'ColorLabel'"
public Font color_font;
/* init code */
public void init(JFrame rootFrame,
Container contentPane, List args) {
try {
this.rootFrame = rootFrame;
this.contentPane = contentPane;
this.color_font = new Font("Monospaced",Font.PLAIN,14);
// take a screenshot
screen_size = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle rect = new Rectangle(0,0,
(int)screen_size.getWidth(),
(int)screen_size.getHeight());
this.robot = new Robot();
background_image = robot.createScreenCapture(rect);
super.init(rootFrame,contentPane,args); // "Cannot resolve method 'init(JFrame, Container, List)'"
} catch (Exception ex) {
p(ex.toString()); // "Cannot resolve method 'p' in 'PickupColor'"
}
}
The errors listed above are most likely because of that one import I am unable to include.
The plan for the tool is as follows:
- The eyedropper tool is in the right hand of the player, and similar to mods like Chisels and Bits (here is the GitHub too), it would pick up the pixels of the block that's being pointed at with the tool
- The one specific pixel being pointed at is zoomed in on and displays the hex value of that pixel above
- The player can right-click it to save that color temporarily for other functions