-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ Added new Decoration Table block
- allows applying block "materials to barrels" in much easier and more customizable way than the material recipe - also allows applying color tints to any storage block in much straight forward way (just a single color pick instead of multiple dyes applied to get the color wanted) - uses much less blocks / dyes when making these cosmetic changes to storages than the recipes do
- Loading branch information
Showing
18 changed files
with
453 additions
and
21 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
53 changes: 53 additions & 0 deletions
53
src/main/java/net/p3pp3rf1y/sophisticatedcore/client/gui/controls/ColorButton.java
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,53 @@ | ||
package net.p3pp3rf1y.sophisticatedcore.client.gui.controls; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import net.p3pp3rf1y.sophisticatedcore.client.gui.utils.Dimension; | ||
import net.p3pp3rf1y.sophisticatedcore.client.gui.utils.Position; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.function.IntConsumer; | ||
import java.util.function.Supplier; | ||
|
||
public class ColorButton extends ButtonBase { | ||
private final Supplier<Integer> colorGetter; | ||
private final List<Component> tooltip; | ||
|
||
public ColorButton(Position position, Dimension dimension, Supplier<Integer> colorGetter, IntConsumer onClick, @Nullable Component tooltip) { | ||
super(position, dimension, onClick); | ||
this.colorGetter = colorGetter; | ||
this.tooltip = tooltip == null ? List.of() : List.of(tooltip); | ||
} | ||
|
||
@Override | ||
protected void renderBg(GuiGraphics guiGraphics, Minecraft minecraft, int mouseX, int mouseY) { | ||
int color = isMouseOver(mouseX, mouseY) ? 0xFF_FFFFFF : 0xFF_CCCCCC; | ||
guiGraphics.fill(x, y, x + getWidth(), y + getHeight(), color); | ||
} | ||
|
||
@Override | ||
protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { | ||
int color = colorGetter.get(); | ||
if (color == -1) { | ||
for (int row = 0; row < getHeight() - 2; row++) { | ||
for (int column = 0; column < getWidth() - 2; column++) { | ||
guiGraphics.fill(x + column + 1, y + row + 1, x + column + 2, y + row + 2, ((row + column) % 2 == 0) ? 0xFF_CCCCC : 0xFF_888888); | ||
} | ||
} | ||
} else { | ||
guiGraphics.fill(x + 1, y + 1, x + getWidth() - 1, y + getHeight() - 1, colorGetter.get()); | ||
} | ||
} | ||
|
||
@Override | ||
public void renderTooltip(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY) { | ||
super.renderTooltip(screen, guiGraphics, mouseX, mouseY); | ||
if (visible && isMouseOver(mouseX, mouseY) && !tooltip.isEmpty()) { | ||
guiGraphics.renderTooltip(screen.getMinecraft().font, tooltip, Optional.empty(), mouseX, mouseY); | ||
} | ||
} | ||
} |
Oops, something went wrong.