Skip to content

Commit

Permalink
feat: ✨ Added new Decoration Table block
Browse files Browse the repository at this point in the history
- 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
P3pp3rF1y committed Dec 3, 2024
1 parent f56e623 commit c04e957
Show file tree
Hide file tree
Showing 18 changed files with 453 additions and 21 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ org.gradle.daemon=false
org.gradle.debug=false

parchment_minecraft_version=1.21
parchment_mappings_version=2024.07.07
minecraft_version=1.21
minecraft_version_range=[1.21,1.21.1)
neo_version=21.0.143
neo_version_range=[21.0.0-beta,)
parchment_mappings_version=2024.11.10
minecraft_version=1.21.1
minecraft_version_range=[1.21.1,1.21.2)
neo_version=21.1.80
neo_version_range=[21.1.0,)
loader_version_range=[4,)

mod_id=sophisticatedcore
mod_name=Sophisticated Core
mod_license=GNU General Public License v3.0
mod_version=0.7.13
mod_version=0.7.14
mod_group_id=sophisticatedcore
mod_authors=P3pp3rF1y
mod_description=A library / shared functionality mod for Sophisticated Storage and Backpacks
Expand All @@ -40,5 +40,5 @@ athena_cf_file_id=5431579
#publish
curseforge_id=618298
release_type=release
release_versions=1.21,1.21.1
release_versions=1.21.1
modrinth_project_id=nmoqTijg
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import net.p3pp3rf1y.sophisticatedcore.client.gui.utils.Dimension;
import net.p3pp3rf1y.sophisticatedcore.client.gui.utils.GuiHelper;
import net.p3pp3rf1y.sophisticatedcore.client.gui.utils.Position;
import net.p3pp3rf1y.sophisticatedcore.client.gui.utils.TranslationHelper;
import net.p3pp3rf1y.sophisticatedcore.common.gui.*;
import net.p3pp3rf1y.sophisticatedcore.network.TransferFullSlotPayload;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
Expand Down Expand Up @@ -740,7 +741,7 @@ protected void renderTooltip(GuiGraphics guiGraphics, int x, int y) {
protected List<Component> getTooltipFromContainerItem(ItemStack itemStack) {
List<Component> ret = getTooltipFromItem(minecraft, itemStack);
if (hoveredSlot != null && hoveredSlot.getMaxStackSize() > 99) {
ret.add(Component.translatable("gui.sophisticatedcore.tooltip.stack_count",
ret.add(Component.translatable(TranslationHelper.INSTANCE.translGuiTooltip("stack_count"),
Component.literal(NumberFormat.getNumberInstance().format(itemStack.getCount())).withStyle(ChatFormatting.DARK_AQUA)
.append(Component.literal(" / ").withStyle(ChatFormatting.GRAY))
.append(Component.literal(NumberFormat.getNumberInstance().format(hoveredSlot.getMaxStackSize(itemStack))).withStyle(ChatFormatting.DARK_AQUA)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,14 @@ false, getButtonStateData(new UV(16, 80), Dimension.SQUARE_16, new Position(1, 1

private static final TextureBlitData REMOVE_TAG_FOREGROUND = new TextureBlitData(ICONS, new Position(1, 1), Dimension.SQUARE_256, new UV(112, 32), Dimension.SQUARE_16);
public static final ButtonDefinition REMOVE_TAG = new ButtonDefinition(Dimension.SQUARE_18, DEFAULT_BUTTON_BACKGROUND, DEFAULT_BUTTON_HOVERED_BACKGROUND, REMOVE_TAG_FOREGROUND, Component.literal(""));

private static final TextureBlitData CONFIRM_BUTTON_FOREGROUND = new TextureBlitData(ICONS, new Position(1, 1), Dimension.SQUARE_256, new UV(192, 64), Dimension.SQUARE_16);
public static final ButtonDefinition CONFIRM = new ButtonDefinition(Dimension.SQUARE_16, DEFAULT_BUTTON_BACKGROUND, DEFAULT_BUTTON_HOVERED_BACKGROUND, CONFIRM_BUTTON_FOREGROUND,
Component.translatable(TranslationHelper.INSTANCE.translButton("confirm")));
private static final TextureBlitData CANCEL_BUTTON_FOREGROUND = new TextureBlitData(ICONS, new Position(1, 1), Dimension.SQUARE_256, new UV(208, 64), Dimension.SQUARE_16);
public static final ButtonDefinition CANCEL = new ButtonDefinition(Dimension.SQUARE_16, DEFAULT_BUTTON_BACKGROUND, DEFAULT_BUTTON_HOVERED_BACKGROUND, CANCEL_BUTTON_FOREGROUND,
Component.translatable(TranslationHelper.INSTANCE.translButton("cancel")));
private static final TextureBlitData TRANSPARENT_BUTTON_FOREGROUND = new TextureBlitData(ICONS, new Position(1, 1), Dimension.SQUARE_256, new UV(224, 64), Dimension.SQUARE_16);
public static final ButtonDefinition TRANSPARENT = new ButtonDefinition(Dimension.SQUARE_16, DEFAULT_BUTTON_BACKGROUND, DEFAULT_BUTTON_HOVERED_BACKGROUND, TRANSPARENT_BUTTON_FOREGROUND,
Component.translatable(TranslationHelper.INSTANCE.translButton("transparent")));
}
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);
}
}
}
Loading

0 comments on commit c04e957

Please sign in to comment.