Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
ShetiPhian

Adding an Upgrade

Question

I've added support for OpenComputers robots by creating an upgrade/driver for one of my mods tools.

 

While the upgrade works perfectly, there are a few quirks I couldn't seem to find the answer to.

 

1) How do I flag an upgrade for use in robots only?

-- Currently it can go into any upgrade slot but only works in the robots.

 

2) Is there a way to get a robots facing via the API?

-- Currently using ((Robot)host).facing()

 

Driver Registration is done in FMLInitializationEvent via:

Driver.add(new DriverColorizer());
DriverColorizer.class :

public class DriverColorizer extends DriverItem
{
    public DriverColorizer()
    {
        super (Values.stacks.get("robot_colorizer"));
    }

    @Override
    public ManagedEnvironment createEnvironment(ItemStack stack, EnvironmentHost host)
    {
        return (host instanceof Robot) ? new EnvironmentColorizer(host) : null;
    }

    @Override
    public String slot(ItemStack stack)
    {
        return Slot.Upgrade;
    }
}
EnvironmentColorizer.class (truncated)

public class EnvironmentColorizer extends ManagedEnvironment
{
    private final EnvironmentHost host;
    private final Robot robot;

    public EnvironmentColorizer(EnvironmentHost host)
    {
        this.host = host;
        setNode(Network.newNode(this, Visibility.Neighbors).withComponent("colorizer").create());
        robot = (Robot)host;
    }
    <SNIP>
}
Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.