Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
206 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package mezz.jei.api.gui; | ||
|
||
import mezz.jei.api.IGuiHelper; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
/** | ||
* Builder for creating drawables from a resource location. | ||
* Create an instance with {@link IGuiHelper#drawableBuilder(ResourceLocation, int, int, int, int)} | ||
* @since JEI 4.11.0 | ||
*/ | ||
public interface IDrawableBuilder { | ||
/** | ||
* For textures that are not 256x256, specify the size. | ||
*/ | ||
IDrawableBuilder setTextureSize(int width, int height); | ||
|
||
/** | ||
* Add extra blank space around the texture by adjusting the padding. | ||
*/ | ||
IDrawableBuilder addPadding(int paddingTop, int paddingBottom, int paddingLeft, int paddingRight); | ||
|
||
/** | ||
* Creates a normal, non-animated drawable. | ||
*/ | ||
IDrawableStatic build(); | ||
|
||
/** | ||
* Creates an animated texture for a gui, revealing the texture over time. | ||
* | ||
* @param ticksPerCycle the number of ticks for the animation to run before starting over | ||
* @param startDirection the direction that the animation starts drawing the texture | ||
* @param inverted when inverted is true, the texture will start fully drawn and be hidden over time | ||
*/ | ||
IDrawableAnimated buildAnimated(int ticksPerCycle, IDrawableAnimated.StartDirection startDirection, boolean inverted); | ||
|
||
/** | ||
* Creates an animated texture for a gui, revealing the texture over time. | ||
* | ||
* @param tickTimer a custom tick timer, used for advanced control over the animation | ||
* @param startDirection the direction that the animation starts drawing the texture | ||
*/ | ||
IDrawableAnimated buildAnimated(ITickTimer tickTimer, IDrawableAnimated.StartDirection startDirection); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package mezz.jei.gui.elements; | ||
|
||
import mezz.jei.api.gui.IDrawableAnimated; | ||
import mezz.jei.api.gui.IDrawableBuilder; | ||
import mezz.jei.api.gui.IDrawableStatic; | ||
import mezz.jei.api.gui.ITickTimer; | ||
import mezz.jei.util.ErrorUtil; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
public class DrawableBuilder implements IDrawableBuilder { | ||
private final ResourceLocation resourceLocation; | ||
private final int u; | ||
private final int v; | ||
private final int width; | ||
private final int height; | ||
private int textureWidth = 256; | ||
private int textureHeight = 256; | ||
private int paddingTop = 0; | ||
private int paddingBottom = 0; | ||
private int paddingLeft = 0; | ||
private int paddingRight = 0; | ||
|
||
public DrawableBuilder(ResourceLocation resourceLocation, int u, int v, int width, int height) { | ||
ErrorUtil.checkNotNull(resourceLocation, "resourceLocation"); | ||
this.u = u; | ||
this.v = v; | ||
this.width = width; | ||
this.height = height; | ||
this.resourceLocation = resourceLocation; | ||
} | ||
|
||
@Override | ||
public IDrawableBuilder setTextureSize(int width, int height) { | ||
this.textureWidth = width; | ||
this.textureHeight = height; | ||
return this; | ||
} | ||
|
||
@Override | ||
public IDrawableBuilder addPadding(int paddingTop, int paddingBottom, int paddingLeft, int paddingRight) { | ||
this.paddingTop = paddingTop; | ||
this.paddingBottom = paddingBottom; | ||
this.paddingLeft = paddingLeft; | ||
this.paddingRight = paddingRight; | ||
return this; | ||
} | ||
|
||
@Override | ||
public IDrawableStatic build() { | ||
return new DrawableResource(resourceLocation, u, v, width, height, paddingTop, paddingBottom, paddingLeft, paddingRight, textureWidth, textureHeight); | ||
} | ||
|
||
@Override | ||
public IDrawableAnimated buildAnimated(int ticksPerCycle, IDrawableAnimated.StartDirection startDirection, boolean inverted) { | ||
ErrorUtil.checkNotNull(startDirection, "startDirection"); | ||
IDrawableStatic drawable = build(); | ||
return new DrawableAnimated(drawable, ticksPerCycle, startDirection, inverted); | ||
} | ||
|
||
@Override | ||
public IDrawableAnimated buildAnimated(ITickTimer tickTimer, IDrawableAnimated.StartDirection startDirection) { | ||
IDrawableStatic drawable = build(); | ||
return new DrawableAnimated(drawable, tickTimer, startDirection); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.