use of mezz.jei.api.registration.IGuiHandlerRegistration in project SophisticatedBackpacks by P3pp3rF1y.
the class SBPPlugin method registerGuiHandlers.
@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
registration.addGuiContainerHandler(BackpackScreen.class, new IGuiContainerHandler<BackpackScreen>() {
@Override
public List<Rectangle2d> getGuiExtraAreas(BackpackScreen gui) {
List<Rectangle2d> ret = new ArrayList<>();
gui.getUpgradeSlotsRectangle().ifPresent(ret::add);
ret.addAll(gui.getUpgradeSettingsControl().getTabRectangles());
gui.getSortButtonsRectangle().ifPresent(ret::add);
return ret;
}
});
registration.addGuiContainerHandler(SettingsScreen.class, new IGuiContainerHandler<SettingsScreen>() {
@Override
public List<Rectangle2d> getGuiExtraAreas(SettingsScreen gui) {
return new ArrayList<>(gui.getSettingsTabControl().getTabRectangles());
}
});
registration.addGhostIngredientHandler(BackpackScreen.class, new IGhostIngredientHandler<BackpackScreen>() {
@Override
public <I> List<Target<I>> getTargets(BackpackScreen screen, I i, boolean b) {
List<Target<I>> targets = new ArrayList<>();
if (!(i instanceof ItemStack)) {
return targets;
}
ItemStack ghostStack = (ItemStack) i;
BackpackContainer container = screen.getMenu();
container.getOpenContainer().ifPresent(c -> c.getSlots().forEach(s -> {
if (s instanceof IFilterSlot && s.mayPlace(ghostStack)) {
targets.add(new Target<I>() {
@Override
public Rectangle2d getArea() {
return new Rectangle2d(screen.getGuiLeft() + s.x, screen.getGuiTop() + s.y, 17, 17);
}
@Override
public void accept(I i) {
PacketHandler.sendToServer(new SetGhostSlotMessage(ghostStack, s.index));
}
});
}
}));
return targets;
}
@Override
public void onComplete() {
// noop
}
});
}
Aggregations