Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ neo_version=26.1.2.44-beta
mod_id=cakesticklib
mod_name=CakeStickLib
mod_license=Custom License
mod_version=1.10
mod_version=1.10.1
mod_group_id=com.devdyna.cakestick
mod_authors=DevDyna
mod_description=A standalone port of Synergy API to unify most of the code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.devdyna.cakesticklib.api;
package com.devdyna.cakesticklib.api.animations;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -83,7 +83,7 @@ private MutableComponent tick() {
}

private void pickNext() {
if (bag.isEmpty())
if (bag.isEmpty())
refillBag();

currentRaw = entries.get(bag.remove(0));
Expand All @@ -92,7 +92,7 @@ private void pickNext() {
private void refillBag() {
bag.clear();

for (int i = 0; i < entries.size(); i++)
for (int i = 0; i < entries.size(); i++)
bag.add(i);

Collections.shuffle(bag);
Expand All @@ -103,5 +103,4 @@ private void randomizeDelay() {
+ RANDOM.nextInt((int) (3.5 * TimeUtil.ONE_SECOND)));
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.devdyna.cakesticklib.api.animations;

import java.util.List;

import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.resources.Identifier;
import net.minecraft.util.ARGB;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.Slot;

/**
* Utility render class based on
* {@code net.minecraft.client.gui.screens.inventory.CyclingSlotBackground}
*/
public class CyclicImageGui {

private final int slotIndex;
private List<Identifier> icons = List.of();
private int tick;
private int iconIndex;
private int tickDelay = 30;

public CyclicImageGui(int slotIndex, int delay) {
this(slotIndex);
this.tickDelay = delay;
}

public CyclicImageGui(int slotIndex) {
this.slotIndex = slotIndex;
}

public void tick(List<Identifier> newIcons) {
if (!this.icons.equals(newIcons)) {
this.icons = newIcons;
this.iconIndex = 0;
}

if (!this.icons.isEmpty() && ++this.tick % tickDelay == 0)
this.iconIndex = (this.iconIndex + 1) % this.icons.size();

}

public void render(AbstractContainerMenu menu, GuiGraphicsExtractor graphics, float partialTicks,
int top, int left, int width, int height, int u, int v, int textureX, int textureY) {
Slot slot = menu.getSlot(this.slotIndex);
if (!this.icons.isEmpty() && !slot.hasItem()) {
float alphaProgress = (this.icons.size() > 1 && this.tick >= tickDelay)
? (Math.min((this.tick % tickDelay) + partialTicks, 4.0F) / 4.0F)
: 1.0F;
if (alphaProgress < 1.0F)
sprite(slot,
this.icons.get(Math.floorMod(this.iconIndex - 1, this.icons.size())),
1.0F - alphaProgress, graphics, top, left, width, height, u, v, textureX, textureY);

sprite(slot, this.icons.get(this.iconIndex), alphaProgress, graphics, top, left, width, height, u, v,
textureX, textureY);
}

}

private void sprite(Slot slot, Identifier image, float alphaProgress,
GuiGraphicsExtractor graphics, int top, int left, int width, int height, int u, int v, int textureX,
int textureY) {
graphics.blit(RenderPipelines.GUI_TEXTURED, image,
left + slot.x - 1, top + slot.y - 1,
u, v,
width, height,
textureX, textureY,
ARGB.white(alphaProgress));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public Size tickPos() {
}

/**
* Default : 0xA0A0A0
* Default : 0xFFA0A0A0
*/
public int tickColor() {
return 0xA0A0A0;
return 0xFFA0A0A0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static JEIFluidTankHelper of() {

public void build(BiFunction<Integer, Integer, IRecipeSlotBuilder> builder) {
var height = (int) (Math.min(16, Math.max((int) ((fluids.getFirst().getAmount() + 256) * 0.016), 1)) * h);
builder.apply((int) (x0 * w), y0 - height)
builder.apply((int) (x0 * w), y0 - height)//TODO +16
.addIngredients(NeoForgeTypes.FLUID_STACK, fluids)
.setFluidRenderer(fluids.getFirst().getAmount(), false, (int) (w * 16), height);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public interface ClientUtils {

final Color defaultToolTipColor = ColorUtils.color(64, 64, 64);
final Color defaultToolTipColor = ColorUtils.color(64, 64, 64,255);

default boolean hasShiftDown() {
return Minecraft.getInstance().hasShiftDown();
Expand Down
102 changes: 96 additions & 6 deletions src/main/java/com/devdyna/cakesticklib/api/gui/ImageGui.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.devdyna.cakesticklib.api.gui;

import com.devdyna.cakesticklib.CakeStickLib;
import com.devdyna.cakesticklib.api.primitive.Pos;
import com.devdyna.cakesticklib.api.primitive.Size;
import com.devdyna.cakesticklib.api.utils.ColorUtils;
import java.awt.Color;

import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.resources.Identifier;

public class ImageGui {

private int x;
private int y;
private String rl;
private int x = 0;
private int y = 0;
private String rl = "";
private String modid = CakeStickLib.MODULE_ID;
private int xo = 0;
private int yo = 0;
Expand All @@ -19,6 +23,9 @@ public class ImageGui {

private int u = 0;
private int v = 0;
private int color = -1;// default

private boolean flag_first_offset = true;

public ImageGui() {

Expand Down Expand Up @@ -47,8 +54,30 @@ public ImageGui uv(int u, int v) {
}

public ImageGui offset(int xo, int yo) {
this.xo = xo;
this.yo = yo;
if (flag_first_offset) {
this.xo = xo;
this.yo = yo;
flag_first_offset = false;
} else {
this.xo = this.xo + xo;
this.yo = this.yo + yo;
}

return this;
}

public ImageGui color(int c) {
this.color = c;
return this;
}

public ImageGui color(int a, int r, int g, int b) {
this.color = ColorUtils.argb(a, r, g, b);
return this;
}

public ImageGui color(Color c) {
this.color = ColorUtils.argb(c);
return this;
}

Expand All @@ -69,6 +98,66 @@ public ImageGui rl(Identifier rl) {
return this;
}

public Identifier getLocation() {
return com.devdyna.cakesticklib.api.utils.x.rl(modid, rl);
}

public Size getSpriteSize() {
return Size.of(x, y);
}

public Pos getOffsetPos() {
return Pos.of(xo, yo);
}

public Size getTextureSize() {
return Size.of(tx, ty);
}

public int getPosX() {
return x;
}

public int getPosY() {
return y;
}

public int getOffsetX() {
return xo;
}

public int getOffsetY() {
return yo;
}

public int getTextureX() {
return tx;
}

public int getTextureY() {
return ty;
}

public int getU() {
return u;
}

public int getV() {
return v;
}

public int getColor() {
return color;
}

public String getModid() {
return modid;
}

public String getPath() {
return rl;
}

public void render(GuiGraphicsExtractor g) {

g.blit(
Expand All @@ -78,7 +167,8 @@ public void render(GuiGraphicsExtractor g) {
yo - 1,
u, v,
x, y,
tx, ty);
tx, ty,
color);

}

Expand Down
Loading