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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class InventoryTab extends BaseScreenTab<AndroidInventoryHandledScreen> {
private static final Identifier TEXTURE = Identifier.of("androids", "textures/gui/android_inventory.png");

// protected VerticalProgressBar progressBar;
protected VerticalProgressBar progressBar;
protected SwitchWidget switchWidget;

public InventoryTab(AndroidInventoryHandledScreen parent, Text title, @Nullable ItemStack iconStack, @Nullable Identifier texture) {
Expand All @@ -33,7 +33,7 @@ public void build(List<Drawable> elements) {
int i = (parent.width - parent.backgroundWidth) / 2;
int j = (parent.height - parent.backgroundHeight) / 2;

// elements.add((progressBar = new VerticalProgressBar(i + 141, j + 7, 8, 72, (int) parent.entity.getTotalPower(), (int) parent.entity.getTotalCapacity())));
elements.add((progressBar = new VerticalProgressBar(i + 141, j + 7, 8, 72, (int) parent.entity.getTotalPower(), (int) parent.entity.getTotalCapacity())));
if (parent.entity != null) {
var mc = MinecraftClient.getInstance();
elements.add((switchWidget = new SwitchWidget(i + 108, j + 18, 24, 24, parent.entity.isOn(), (widget, value) -> {
Expand Down Expand Up @@ -62,11 +62,11 @@ public void handledScreenTick() {
super.handledScreenTick();
parent.resyncEntity();
if (parent.entity.age % 4 == 0) {
// if (progressBar != null) {
// progressBar.value = (int) parent.entity.getTotalPower();
// progressBar.maxValue = (int) parent.entity.getTotalCapacity();
// progressBar.update();
// }
if (progressBar != null) {
progressBar.value = (int) parent.entity.getTotalPower();
progressBar.maxValue = (int) parent.entity.getTotalCapacity();
progressBar.update();
}
if (switchWidget != null)
switchWidget.isActive = parent.entity.isOn();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class BaseMachineScreen<T extends BaseMachineScreenHandler> extends Handl
private static final int TAB_FIRST_W = 25; // default base creative tab width
private static final int TAB_OTHER_W = 25; // scaled wider version
protected final PlayerInventory playerInventory;
protected Tab currentTab = Tab.FIRST;
protected Tab currentTab = Tab.THIRD;
private boolean productionTabTexturesAvailable = false; // tab_on/tab_off

public BaseMachineScreen(T handler, PlayerInventory inv, Text title) {
Expand Down Expand Up @@ -123,9 +123,9 @@ protected void drawBackground(DrawContext ctx, float delta, int mouseX, int mous
int secondY = firstY + TAB_BAR_HEIGHT + TAB_GAP;
int thirdY = secondY + TAB_BAR_HEIGHT + TAB_GAP;

drawTab(ctx, Tab.FIRST, tabX, firstY, TAB_FIRST_W, TAB_BAR_HEIGHT);
drawTab(ctx, Tab.SECOND, tabX, secondY, TAB_OTHER_W, TAB_BAR_HEIGHT);
drawTab(ctx, Tab.THIRD, tabX, thirdY, TAB_OTHER_W, TAB_BAR_HEIGHT);
// drawTab(ctx, Tab.FIRST, tabX, firstY, TAB_FIRST_W, TAB_BAR_HEIGHT);
// drawTab(ctx, Tab.SECOND, tabX, secondY, TAB_OTHER_W, TAB_BAR_HEIGHT);
// drawTab(ctx, Tab.THIRD, tabX, thirdY, TAB_OTHER_W, TAB_BAR_HEIGHT);

drawTabContent(ctx, currentTab, x, y);

Expand Down Expand Up @@ -377,34 +377,34 @@ protected void drawVerticalBar(DrawContext ctx, int x, int topY, int w, int h, d
}

// Interaction -----------------------------------------
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
int x = (this.width - this.backgroundWidth) / 2;
int y = (this.height - this.backgroundHeight) / 2;
// 与渲染逻辑保持一致:不再减去 TAB_OTHER_W
int tabX = x + this.backgroundWidth + getTabBaseOffsetX();
int firstY = y + 8;
int secondY = firstY + TAB_BAR_HEIGHT + TAB_GAP;
int thirdY = secondY + TAB_BAR_HEIGHT + TAB_GAP;
// 命中区域与绘制位置一致:激活标签有水平偏移
int firstX = tabX + ((currentTab == Tab.FIRST) ? getActiveTabShiftX() : 0);
int secondX = tabX + ((currentTab == Tab.SECOND) ? getActiveTabShiftX() : 0);
int thirdX = tabX + ((currentTab == Tab.THIRD) ? getActiveTabShiftX() : 0);

if (isInside(mouseX, mouseY, firstX, firstY, TAB_FIRST_W, TAB_BAR_HEIGHT)) {
currentTab = Tab.FIRST;
return true;
}
if (isInside(mouseX, mouseY, secondX, secondY, TAB_OTHER_W, TAB_BAR_HEIGHT)) {
currentTab = Tab.SECOND;
return true;
}
if (isInside(mouseX, mouseY, thirdX, thirdY, TAB_OTHER_W, TAB_BAR_HEIGHT)) {
currentTab = Tab.THIRD;
return true;
}
return super.mouseClicked(mouseX, mouseY, button);
}
// @Override
// public boolean mouseClicked(double mouseX, double mouseY, int button) {
// int x = (this.width - this.backgroundWidth) / 2;
// int y = (this.height - this.backgroundHeight) / 2;
// // 与渲染逻辑保持一致:不再减去 TAB_OTHER_W
// int tabX = x + this.backgroundWidth + getTabBaseOffsetX();
// int firstY = y + 8;
// int secondY = firstY + TAB_BAR_HEIGHT + TAB_GAP;
// int thirdY = secondY + TAB_BAR_HEIGHT + TAB_GAP;
// // 命中区域与绘制位置一致:激活标签有水平偏移
// int firstX = tabX + ((currentTab == Tab.FIRST) ? getActiveTabShiftX() : 0);
// int secondX = tabX + ((currentTab == Tab.SECOND) ? getActiveTabShiftX() : 0);
// int thirdX = tabX + ((currentTab == Tab.THIRD) ? getActiveTabShiftX() : 0);
//
// if (isInside(mouseX, mouseY, firstX, firstY, TAB_FIRST_W, TAB_BAR_HEIGHT)) {
// currentTab = Tab.FIRST;
// return true;
// }
// if (isInside(mouseX, mouseY, secondX, secondY, TAB_OTHER_W, TAB_BAR_HEIGHT)) {
// currentTab = Tab.SECOND;
// return true;
// }
// if (isInside(mouseX, mouseY, thirdX, thirdY, TAB_OTHER_W, TAB_BAR_HEIGHT)) {
// currentTab = Tab.THIRD;
// return true;
// }
// return super.mouseClicked(mouseX, mouseY, button);
// }

protected boolean isInside(double mx, double my, int x, int y, int w, int h) {
return mx >= x && mx < x + w && my >= y && my < y + h;
Expand All @@ -415,6 +415,7 @@ protected boolean isInside(double mx, double my, int x, int y, int w, int h) {
protected void drawForeground(DrawContext ctx, int mouseX, int mouseY) {
ctx.drawTextWithShadow(this.textRenderer, this.title, 8, 6, 0xFFFFFF);
ctx.drawTextWithShadow(this.textRenderer, this.playerInventory.getDisplayName(), 8, this.backgroundHeight - 96 + 2, 0xFFFFFF);
drawMouseoverTooltip(ctx, mouseX, mouseY);
}

// Hook: allow subclasses to request an overlay over the machine (top) portion before content is drawn.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.hanprogramer.androids.client.screen.solar;

import com.hanprogramer.androids.ModBlocks;
import com.hanprogramer.androids.ModItems;
import com.hanprogramer.androids.client.screen.base.BaseMachineScreen;
import com.hanprogramer.androids.screen.solar.SolarPanelScreenHandler;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;

/**
Expand All @@ -21,6 +24,8 @@ protected boolean shouldDrawMachineOverlay() {
}

@Override
protected void drawMachineOverlay(DrawContext ctx, int x, int y) {
protected void drawForeground(DrawContext ctx, int mouseX, int mouseY) {
ctx.drawItem(new ItemStack(ModBlocks.SOLAR_PANEL.getRight()), -22, 20);
super.drawForeground(ctx, mouseX, mouseY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ protected void renderWidget(DrawContext context, int mouseX, int mouseY, float d
if (maxValue > 0 && value > 0) {
var ph = (int) (this.height * percentage);
context.fill(RenderPipelines.GUI,
this.getX() + 1, this.getY() + ph - 1,
this.getX() + this.width - 1, this.getY() + this.height - ph + 1,
this.getX() + 1, this.getY() + this.height - ph + 1,
this.getX() + this.width - 1, this.getY() + this.height - 1,
0xAAAAFF00);
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/client/resources/assets/androids/blockstates/chargepad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"variants": {
"facing=north,half=lower": {
"model": "androids:block/chargepad",
"y": 90
},
"facing=east,half=lower": {
"model": "androids:block/chargepad",
"y": 180
},
"facing=south,half=lower": {
"model": "androids:block/chargepad",
"y": 270
},
"facing=west,half=lower": {
"model": "androids:block/chargepad",
"y": 0
},

"facing=north,half=upper": { "model": "androids:block/empty" },
"facing=south,half=upper": { "model": "androids:block/empty" },
"facing=west,half=upper": { "model": "androids:block/empty" },
"facing=east,half=upper": { "model": "androids:block/empty" }
}
}
6 changes: 6 additions & 0 deletions src/client/resources/assets/androids/items/chargepad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "androids:item/chargepad"
}
}
6 changes: 5 additions & 1 deletion src/client/resources/assets/androids/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"item.androids.battery_3": "Creative Battery",
"item.androids.remote": "Remote",
"item.androids.android_spawner": "Android",
"item.androids.block_name_tag": "Block Name Tag"
"item.androids.block_name_tag": "Block Name Tag",

"tooltip.androids.energy": "Energy: %s / %s (%s%%)",
"block.androids.chargepad": "Charging Pad",
"item.androids.chargepad": "Charging Pad"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"meta":{"format_version":"5.0","model_format":"java_block","box_uv":false},"name":"chargepad","parent":"chargepad","java_block_version":"1.21.6","ambientocclusion":true,"front_gui_light":false,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"unhandled_root_fields":{},"resolution":{"width":64,"height":64},"elements":[{"name":"cube","box_uv":false,"render_order":"default","rescale":false,"locked":false,"shade":true,"light_emission":0,"allow_mirror_modeling":true,"from":[0,0,0],"to":[16,2,16],"autouv":0,"color":6,"origin":[8,1,9],"faces":{"north":{"uv":[36,36,52,38],"texture":0},"east":{"uv":[36,28,54,30],"texture":0},"south":{"uv":[38,0,54,2],"texture":0},"west":{"uv":[36,30,54,32],"texture":0},"up":{"uv":[16,18,0,0],"texture":0},"down":{"uv":[32,0,16,18],"texture":0}},"type":"cube","uuid":"5c843a3a-75d6-0290-db05-72bd25fcd9ba"},{"name":"cube","box_uv":false,"render_order":"default","rescale":false,"locked":false,"shade":true,"light_emission":0,"allow_mirror_modeling":true,"from":[0,2,0],"to":[2,30,2],"autouv":0,"color":6,"origin":[0,0,0],"faces":{"north":{"uv":[32,0,34,28],"texture":0},"east":{"uv":[32,28,34,56],"texture":0},"south":{"uv":[34,0,36,28],"texture":0},"west":{"uv":[34,28,36,56],"texture":0},"up":{"uv":[24,38,22,36],"texture":0},"down":{"uv":[26,36,24,38],"texture":0}},"type":"cube","uuid":"46f4aee4-322d-7d11-d243-b6011f334412"},{"name":"cube","box_uv":false,"render_order":"default","rescale":false,"locked":false,"shade":true,"light_emission":0,"allow_mirror_modeling":true,"from":[14,2,0],"to":[16,30,2],"autouv":0,"color":6,"origin":[14,0,0],"faces":{"north":{"uv":[0,36,2,64],"texture":0},"east":{"uv":[36,0,38,28],"texture":0},"south":{"uv":[2,36,4,64],"texture":0},"west":{"uv":[4,36,6,64],"texture":0},"up":{"uv":[28,38,26,36],"texture":0},"down":{"uv":[30,36,28,38],"texture":0}},"type":"cube","uuid":"1e4ddad7-ef31-0857-a758-4971fc4f806d"},{"name":"cube","box_uv":false,"render_order":"default","rescale":false,"locked":false,"shade":true,"light_emission":0,"allow_mirror_modeling":true,"from":[0,2,14],"to":[2,30,16],"autouv":0,"color":6,"origin":[0,0,14],"faces":{"north":{"uv":[6,36,8,64],"texture":0},"east":{"uv":[8,36,10,64],"texture":0},"south":{"uv":[10,36,12,64],"texture":0},"west":{"uv":[12,36,14,64],"texture":0},"up":{"uv":[32,38,30,36],"texture":0},"down":{"uv":[40,6,38,8],"texture":0}},"type":"cube","uuid":"006c8bde-51f6-1619-b76c-820b954b3e7d"},{"name":"cube","box_uv":false,"render_order":"default","rescale":false,"locked":false,"shade":true,"light_emission":0,"allow_mirror_modeling":true,"from":[14,2,14],"to":[16,30,16],"autouv":0,"color":6,"origin":[14,0,14],"faces":{"north":{"uv":[14,36,16,64],"texture":0},"east":{"uv":[16,36,18,64],"texture":0},"south":{"uv":[18,36,20,64],"texture":0},"west":{"uv":[20,36,22,64],"texture":0},"up":{"uv":[40,10,38,8],"texture":0},"down":{"uv":[40,10,38,12],"texture":0}},"type":"cube","uuid":"220a651b-60f8-b807-a968-da138c7947e1"},{"name":"cube","box_uv":false,"render_order":"default","rescale":false,"locked":false,"shade":true,"light_emission":0,"allow_mirror_modeling":true,"from":[0,30,0],"to":[16,32,16],"autouv":0,"color":6,"origin":[8,31,9],"faces":{"north":{"uv":[38,2,54,4],"texture":0},"east":{"uv":[36,32,54,34],"texture":0},"south":{"uv":[38,4,54,6],"texture":0},"west":{"uv":[36,34,54,36],"texture":0},"up":{"uv":[16,36,0,18],"texture":0},"down":{"uv":[32,18,16,36],"texture":0}},"type":"cube","uuid":"1521bb86-dfb8-05cc-1a4b-cf631f62e77b"}],"groups":[],"outliner":["5c843a3a-75d6-0290-db05-72bd25fcd9ba","1521bb86-dfb8-05cc-1a4b-cf631f62e77b","46f4aee4-322d-7d11-d243-b6011f334412","1e4ddad7-ef31-0857-a758-4971fc4f806d","220a651b-60f8-b807-a968-da138c7947e1","006c8bde-51f6-1619-b76c-820b954b3e7d"],"textures":[{"name":"cragepad.png","relative_path":"../../textures/block/cragepad.png","folder":"block","namespace":"androids","id":"0","group":"","width":64,"height":64,"uv_width":64,"uv_height":64,"particle":true,"use_as_default":false,"layers_enabled":false,"sync_to_project":"","render_mode":"default","render_sides":"auto","pbr_channel":"color","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":true,"saved":true,"uuid":"ac201deb-9d22-cd27-2034-6bf0aaf41611","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAIN0lEQVR4AdTaz4sdWRUH8PuqO+l0J4F0d37IyIgLhwSiETfOdtBF1AFBEVfiTnDnH6Aggv4B7gR34kpEQRg1C2W240aMBhI6PySDg/nRnUCmp9NJd3rqU5nzuP263ntV/X6kO+TLOfec77k/zr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BD+acu245VzLqqFWQCUhqodHdUtps4W/MMmq7uABQXqFiAxYc/1sB1muecMiMVEQmLBTngnPT9b7tfmw6EDXhPoBx/oTWLGySl3/MtLIDqNe7EJAbuJlcTq0qCzBbQBF4cO4R8mYzy8XNeeBro7wKRz9A7uN3k+QToEj44T7cMiy6K93AEqCJGE3gX02oe1e+P7tY0ZvlwP26RlYdAcvQNaKFvcHulsAW3QxqEfJnQvgUGTlqDw53rYRpWSB6P2s5/4RgnQcXmtVIcgHSQC6EDHobeBt0bXrl3r3Lx5cyp/G9w7t0Lmc/QStPktEOhsdKADHeiHCd0HoX6TtigIPx2atoN3UGW5a3ffBdzOQKXbIBYYMdE+6LLvGaDKbRALjZhoH3S55xKoW4CqxkJynU0b6EAH+mFA3x0Qk/eMH3pIL01Cd+/PF0yH8B90Wf2tsGs+JmryEG0+uyLa9PyRl44TfjpEe9Jy1P4/BgAA//+Dyno5AAAABklEQVQDAA4FmiYJ1TnbAAAAAElFTkSuQmCC"}],"display":{"thirdperson_righthand":{"scale":[0.3,0.3,0.3]},"thirdperson_lefthand":{"scale":[0.3,0.3,0.3]},"firstperson_righthand":{"scale":[0.3,0.3,0.3]},"firstperson_lefthand":{"scale":[0.3,0.3,0.3]},"ground":{"scale":[0.3,0.3,0.3]},"gui":{"rotation":[33.25,-29,0],"translation":[0,-1.75,0],"scale":[0.3,0.3,0.3]},"fixed":{"translation":[0,-1.75,0],"scale":[0.3,0.3,0.3]},"on_shelf":{"translation":[0,-1.75,0],"scale":[0.3,0.3,0.3]}}}
Loading
Loading