Skip to content
Open
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: 2 additions & 0 deletions src/client/java/aztech/modern_industrialization/MIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import aztech.modern_industrialization.misc.version.VersionEvents;
import aztech.modern_industrialization.pipes.MIPipes;
import aztech.modern_industrialization.pipes.MIPipesClient;
import aztech.modern_industrialization.pipes.fe.FEWireScreen;
import aztech.modern_industrialization.pipes.fluid.FluidPipeScreen;
import aztech.modern_industrialization.pipes.impl.DelegatingUnbakedModel;
import aztech.modern_industrialization.pipes.impl.PipeUnbakedModel;
Expand Down Expand Up @@ -197,6 +198,7 @@ private static void registerMenuScreens(RegisterMenuScreensEvent event) {

event.register(MIPipes.SCREEN_HANDLER_TYPE_ITEM_PIPE.get(), ItemPipeScreen::new);
event.register(MIPipes.SCREEN_HANDLER_TYPE_FLUID_PIPE.get(), FluidPipeScreen::new);
event.register(MIPipes.SCREEN_HANDLER_TYPE_FE_WIRE.get(), FEWireScreen::new);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,35 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi
helper.text(Component.literal("" + items).withStyle(MITooltips.NUMBER_TEXT))
.align(IElement.Align.CENTER)));
}

if (tag.contains("energy")) {
long energy = tag.getLong("energy");
long maxEnergy = tag.getLong("maxEnergy");
long transfer = tag.getLong("transfer");
long maxTransfer = tag.getLong("maxTransfer");

tooltip.add(helper.progress(
MIJadeClientPlugin.ratio(energy, maxEnergy),
Component.literal("")
.append(Component.literal(IDisplayHelper.get().humanReadableNumber(energy, " EU", false))
.withStyle(ChatFormatting.WHITE))
.append(" / ")
.append(Component.literal(IDisplayHelper.get().humanReadableNumber(maxEnergy, " EU", false)))
.withStyle(ChatFormatting.GRAY),
helper.progressStyle().color(-5636096, -10092544).textColor(-1),
BoxStyle.getNestedBox(),
true));

tooltip.add(helper.progress(
MIJadeClientPlugin.ratio(transfer, maxTransfer),
MIJadeClientPlugin.textAndRatio(
MIText.NetworkTransfer.text(),
String.valueOf(IDisplayHelper.get().humanReadableNumber(transfer, "", false)),
String.valueOf(IDisplayHelper.get().humanReadableNumber(maxTransfer, " FE/t", false))),
helper.progressStyle().color(-5636096, -10092544).textColor(-1),
BoxStyle.getNestedBox(),
true));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public PipeRenderer create(Function<Material, TextureAtlasSprite> textureGetter)
private static final PipeRenderer.Factory FLUID_RENDERER = makeRenderer(
Arrays.asList("fluid", "fluid_item", "fluid_in", "fluid_in_out", "fluid_out"), true);
private static final PipeRenderer.Factory ELECTRICITY_RENDERER = makeRenderer(Arrays.asList("electricity", "electricity_blocks"), false);
private static final PipeRenderer.Factory FE_RENDERER = makeRenderer(Arrays.asList("fe", "fe_item", "fe_in", "fe_in_out", "fe_out"), false);

// Use a set to avoid loading the same renderer multiple times
public static final Collection<PipeRenderer.Factory> RENDERERS = new LinkedHashSet<>();
Expand All @@ -131,6 +132,8 @@ private static void registerRenderers() {
PipeRenderer.register(type, FLUID_RENDERER);
} else if (type.getIdentifier().getPath().endsWith("cable")) {
PipeRenderer.register(type, ELECTRICITY_RENDERER);
} else if (type.getIdentifier().getPath().endsWith("fe_wire")) {
PipeRenderer.register(type, FE_RENDERER);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* MIT License
*
* Copyright (c) 2020 Azercoco & Technici4n
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package aztech.modern_industrialization.pipes.fe;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.MITooltips;
import aztech.modern_industrialization.pipes.gui.PipeScreen;
import aztech.modern_industrialization.util.RenderHelper;
import aztech.modern_industrialization.util.TextHelper;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;

public class FEWireScreen extends PipeScreen<FEWireScreenHandler> {
private static final ResourceLocation TEXTURE = MI.id("textures/gui/pipe/fe.png");

public FEWireScreen(FEWireScreenHandler handler, Inventory inventory, Component title) {
super(handler, inventory, title, FEWireScreenHandler.HEIGHT);
}

@Override
protected void init() {
super.init();

addConnectionTypeButton(148, 22, menu.iface);

addPriorityWidgets(33, 42, menu.iface, 0, () -> {
List<Component> lines = new ArrayList<>();

MIText priorityText = MIText.PriorityTransfer;
lines.add(priorityText.text(menu.iface.getPriority(0)));

MIText priorityTextHelp = MIText.PriorityTransferWireHelp;
lines.add(priorityTextHelp.text().setStyle(TextHelper.GRAY_TEXT));

return lines;
}, () -> true);
}

@Override
protected void renderTooltip(GuiGraphics guiGraphics, int x, int y) {
super.renderTooltip(guiGraphics, x, y);

if (hoveredSlot != null && hoveredSlot instanceof FEWireScreenHandler.UpgradeSlot && !hoveredSlot.hasItem()) {
List<Component> lines = new ArrayList<>();
lines.add(MIText.PutBatteryToUpgrade.text());
if (menu.iface.getConnectionType() == 0) {
lines.add(MIText.PriorityNotApplicable.text(
MIText.PipeConnectionTooltipInsertOnly.text().setStyle(MITooltips.HIGHLIGHT_STYLE),
MIText.PipeConnectionIn.text().setStyle(MITooltips.HIGHLIGHT_STYLE))
.setStyle(TextHelper.GRAY_TEXT));
}
guiGraphics.renderTooltip(font, RenderHelper.splitTooltip(lines), x, y);
}
}

@Override
protected ResourceLocation getBackgroundTexture() {
return TEXTURE;
}
}
Loading