Search in sources :

Example 1 with Target

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);
                    }
                }
            }
        }
    });
}
Also used : Target(com.lowdragmc.lowdraglib.gui.ingredient.Target) Nonnull(javax.annotation.Nonnull) Rectangle2d(net.minecraft.client.renderer.Rectangle2d)

Example 2 with Target

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);
                }
            }
        }
    });
}
Also used : Target(com.lowdragmc.lowdraglib.gui.ingredient.Target) Nonnull(javax.annotation.Nonnull) FluidStack(net.minecraftforge.fluids.FluidStack) Rectangle2d(net.minecraft.client.renderer.Rectangle2d)

Aggregations

Target (com.lowdragmc.lowdraglib.gui.ingredient.Target)2 Nonnull (javax.annotation.Nonnull)2 Rectangle2d (net.minecraft.client.renderer.Rectangle2d)2 FluidStack (net.minecraftforge.fluids.FluidStack)1