use of com.lowdragmc.lowdraglib.gui.ingredient.Target in project Multiblocked by Low-Drag-MC.
the class ContentWidget method getPhantomTargets.
@Override
public List<Target> getPhantomTargets(Object ingredient) {
List<Target> pattern = super.getPhantomTargets(ingredient);
if (pattern != null && pattern.size() > 0)
return pattern;
Object ingredientContent = getJEIIngredient(getContent());
if (ingredientContent == null || !ingredient.getClass().equals(ingredientContent.getClass())) {
return Collections.emptyList();
}
Rectangle2d rectangle = toRectangleBox();
return Lists.newArrayList(new Target() {
@Nonnull
@Override
public Rectangle2d getArea() {
return rectangle;
}
@Override
public void accept(@Nonnull Object ingredient) {
Object ingredientContent = getJEIIngredient(getContent());
if (ingredientContent != null && ingredient.getClass().equals(ingredientContent.getClass())) {
T content = getJEIContent(ingredient);
if (content != null) {
setContent(io, content, chance, perTick);
if (onPhantomUpdate != null) {
onPhantomUpdate.accept(ContentWidget.this);
}
}
}
}
});
}
use of com.lowdragmc.lowdraglib.gui.ingredient.Target in project Multiblocked by Low-Drag-MC.
the class FluidContentWidget method getPhantomTargets.
@Override
public List<Target> getPhantomTargets(Object ingredient) {
List<Target> pattern = super.getPhantomTargets(ingredient);
if (pattern != null && pattern.size() > 0)
return pattern;
if (!(ingredient instanceof FluidStack) && PhantomFluidWidget.drainFrom(ingredient) == null) {
return Collections.emptyList();
}
Rectangle2d rectangle = toRectangleBox();
return Lists.newArrayList(new Target() {
@Nonnull
@Override
public Rectangle2d getArea() {
return rectangle;
}
@Override
public void accept(@Nonnull Object ingredient) {
FluidStack content;
if (ingredient instanceof FluidStack)
content = (FluidStack) ingredient;
else
content = PhantomFluidWidget.drainFrom(ingredient);
if (content != null) {
setContent(io, getJEIContent(content), chance, perTick);
if (onPhantomUpdate != null) {
onPhantomUpdate.accept(FluidContentWidget.this);
}
}
}
});
}
Aggregations