Fix being unable to start autocrafting
This commit is contained in:
@@ -3,7 +3,7 @@ package com.refinedmods.refinedstorage.api.network.grid;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.refinedmods.refinedstorage.api.render.IElementDrawer;
|
||||
import com.refinedmods.refinedstorage.api.util.IFilter;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -24,14 +24,12 @@ public interface IGridTab {
|
||||
/**
|
||||
* Draws the tooltip of this tab at the given position.
|
||||
*
|
||||
* @param matrixStack the matrix stack
|
||||
* @param x the x position
|
||||
* @param y the y position
|
||||
* @param screenWidth the screen width
|
||||
* @param screenHeight the screen height
|
||||
* @param fontRenderer the font renderer
|
||||
* @param matrixStack the matrix stack
|
||||
* @param x the x position
|
||||
* @param y the y position
|
||||
* @param screen the screen
|
||||
*/
|
||||
void drawTooltip(PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, Font fontRenderer);
|
||||
void drawTooltip(PoseStack matrixStack, int x, int y, Screen screen);
|
||||
|
||||
/**
|
||||
* Draws the icon.
|
||||
|
@@ -1,13 +1,10 @@
|
||||
package com.refinedmods.refinedstorage.apiimpl.network.grid;
|
||||
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGridTab;
|
||||
import com.refinedmods.refinedstorage.api.render.IElementDrawer;
|
||||
import com.refinedmods.refinedstorage.api.util.IFilter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -39,12 +36,9 @@ public class GridTab implements IGridTab {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, Font fontRenderer) {
|
||||
public void drawTooltip(PoseStack matrixStack, int x, int y, Screen screen) {
|
||||
if (name != null) {
|
||||
Screen screen = Minecraft.getInstance().screen;
|
||||
if (screen != null) {
|
||||
screen.renderTooltip(matrixStack, name, x, y);
|
||||
}
|
||||
screen.renderTooltip(matrixStack, name, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,19 +15,20 @@ public class ClientProxy {
|
||||
}
|
||||
|
||||
public static void onReceivedCraftingPreviewResponseMessage(GridCraftingPreviewResponseMessage message) {
|
||||
Screen screen = Minecraft.getInstance().screen;
|
||||
Screen parent = Minecraft.getInstance().screen;
|
||||
|
||||
if (screen instanceof CraftingSettingsScreen) {
|
||||
screen = ((CraftingSettingsScreen) screen).getParent();
|
||||
if (parent instanceof CraftingSettingsScreen) {
|
||||
parent = ((CraftingSettingsScreen) parent).getParent();
|
||||
}
|
||||
|
||||
Minecraft.getInstance().setScreen(new CraftingPreviewScreen(
|
||||
screen,
|
||||
parent,
|
||||
message.getElements(),
|
||||
message.getId(),
|
||||
message.getQuantity(),
|
||||
message.isFluids(),
|
||||
new TranslatableComponent("gui.refinedstorage.crafting_preview")
|
||||
new TranslatableComponent("gui.refinedstorage.crafting_preview"),
|
||||
Minecraft.getInstance().player.getInventory()
|
||||
));
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,6 @@ package com.refinedmods.refinedstorage.screen;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.refinedmods.refinedstorage.RS;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
@@ -21,10 +20,11 @@ import com.refinedmods.refinedstorage.screen.widget.TabListWidget;
|
||||
import com.refinedmods.refinedstorage.screen.widget.sidebutton.RedstoneModeSideButton;
|
||||
import com.refinedmods.refinedstorage.tile.craftingmonitor.ICraftingMonitor;
|
||||
import com.refinedmods.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -281,26 +281,28 @@ public class CraftingMonitorScreen extends BaseScreen<CraftingMonitorContainer>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, Font fontRenderer) {
|
||||
List<Component> textLines = Lists.newArrayList(requested.getItem() != null ? requested.getItem().getHoverName() : requested.getFluid().getDisplayName());
|
||||
List<String> smallTextLines = Lists.newArrayList();
|
||||
public void drawTooltip(PoseStack matrixStack, int x, int y, Screen screen) {
|
||||
List<Component> lines = Lists.newArrayList(requested.getItem() != null ? requested.getItem().getHoverName() : requested.getFluid().getDisplayName());
|
||||
|
||||
int totalSecs = (int) (System.currentTimeMillis() - executionStarted) / 1000;
|
||||
int hours = totalSecs / 3600;
|
||||
int minutes = (totalSecs % 3600) / 60;
|
||||
int seconds = totalSecs % 60;
|
||||
|
||||
smallTextLines.add(I18n.get("gui.refinedstorage.crafting_monitor.tooltip.requested", requested.getFluid() != null ? API.instance().getQuantityFormatter().formatInBucketForm(qty) : API.instance().getQuantityFormatter().format(qty)));
|
||||
lines.add(new TranslatableComponent(
|
||||
"gui.refinedstorage.crafting_monitor.tooltip.requested",
|
||||
requested.getFluid() != null ? API.instance().getQuantityFormatter().formatInBucketForm(qty) : API.instance().getQuantityFormatter().format(qty)
|
||||
).withStyle(ChatFormatting.GRAY));
|
||||
|
||||
if (hours > 0) {
|
||||
smallTextLines.add(String.format("%02d:%02d:%02d", hours, minutes, seconds));
|
||||
lines.add(new TextComponent(String.format("%02d:%02d:%02d", hours, minutes, seconds)).withStyle(ChatFormatting.GRAY));
|
||||
} else {
|
||||
smallTextLines.add(String.format("%02d:%02d", minutes, seconds));
|
||||
lines.add(new TextComponent(String.format("%02d:%02d", minutes, seconds)).withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
smallTextLines.add(String.format("%d%%", completionPercentage));
|
||||
lines.add(new TextComponent(String.format("%d%%", completionPercentage)).withStyle(ChatFormatting.GRAY));
|
||||
|
||||
RenderUtils.drawTooltipWithSmallText(matrixStack, textLines, smallTextLines, true, ItemStack.EMPTY, x, y, screenWidth, screenHeight, fontRenderer);
|
||||
screen.renderComponentTooltip(matrixStack, lines, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -22,6 +22,7 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -50,13 +51,13 @@ public class CraftingPreviewScreen extends BaseScreen<AbstractContainerMenu> {
|
||||
private ItemStack hoveringStack;
|
||||
private FluidStack hoveringFluid;
|
||||
|
||||
public CraftingPreviewScreen(Screen parent, List<ICraftingPreviewElement> elements, UUID id, int quantity, boolean fluids, Component title) {
|
||||
public CraftingPreviewScreen(Screen parent, List<ICraftingPreviewElement> elements, UUID id, int quantity, boolean fluids, Component title, Inventory inventory) {
|
||||
super(new AbstractContainerMenu(null, 0) {
|
||||
@Override
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return false;
|
||||
}
|
||||
}, 254, 201, null, title);
|
||||
}, 254, 201, inventory, title);
|
||||
|
||||
this.elements = new ArrayList<>(elements);
|
||||
this.parent = parent;
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.refinedmods.refinedstorage.screen.grid;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -33,9 +32,11 @@ import com.refinedmods.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import com.refinedmods.refinedstorage.tile.grid.portable.PortableGridTile;
|
||||
import com.refinedmods.refinedstorage.util.RenderUtils;
|
||||
import com.refinedmods.refinedstorage.util.TimeUtils;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@@ -467,19 +468,24 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
|
||||
private void drawGridTooltip(PoseStack matrixStack, IGridStack gridStack, int mouseX, int mouseY) {
|
||||
List<Component> textLines = gridStack.getTooltip(true);
|
||||
List<String> smallTextLines = Lists.newArrayList();
|
||||
|
||||
if (!gridStack.isCraftable()) {
|
||||
smallTextLines.add(I18n.get("misc.refinedstorage.total", gridStack.getFormattedFullQuantity()));
|
||||
ItemStack stackContext = gridStack instanceof ItemGridStack ? ((ItemGridStack) gridStack).getStack() : ItemStack.EMPTY;
|
||||
|
||||
if (RS.CLIENT_CONFIG.getGrid().getDetailedTooltip()) {
|
||||
Style detailedTextStyle = Style.EMPTY.applyFormat(ChatFormatting.GRAY).withItalic(true);
|
||||
|
||||
if (!gridStack.isCraftable()) {
|
||||
textLines.add(new TranslatableComponent("misc.refinedstorage.total", gridStack.getFormattedFullQuantity())
|
||||
.withStyle(detailedTextStyle));
|
||||
}
|
||||
|
||||
if (gridStack.getTrackerEntry() != null) {
|
||||
textLines.add(new TranslatableComponent(TimeUtils.getAgo(gridStack.getTrackerEntry().getTime(), gridStack.getTrackerEntry().getName()))
|
||||
.withStyle(detailedTextStyle));
|
||||
}
|
||||
}
|
||||
|
||||
if (gridStack.getTrackerEntry() != null) {
|
||||
smallTextLines.add(TimeUtils.getAgo(gridStack.getTrackerEntry().getTime(), gridStack.getTrackerEntry().getName()));
|
||||
}
|
||||
|
||||
ItemStack stack = gridStack instanceof ItemGridStack ? ((ItemGridStack) gridStack).getStack() : ItemStack.EMPTY;
|
||||
|
||||
RenderUtils.drawTooltipWithSmallText(matrixStack, textLines, smallTextLines, RS.CLIENT_CONFIG.getGrid().getDetailedTooltip(), stack, mouseX, mouseY, width, height, font);
|
||||
renderTooltip(matrixStack, stackContext, mouseX, mouseY, textLines);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.refinedmods.refinedstorage.screen.widget;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.refinedmods.refinedstorage.RS;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGridTab;
|
||||
@@ -29,6 +28,7 @@ public class TabListWidget<T extends AbstractContainerMenu> {
|
||||
private boolean hadTabs;
|
||||
private Button left;
|
||||
private Button right;
|
||||
|
||||
public TabListWidget(BaseScreen<T> screen, ElementDrawers<T> drawers, Supplier<List<IGridTab>> tabs, Supplier<Integer> pages, Supplier<Integer> page, Supplier<Integer> selected, int tabsPerPage) {
|
||||
this.screen = screen;
|
||||
this.drawers = drawers;
|
||||
@@ -149,7 +149,7 @@ public class TabListWidget<T extends AbstractContainerMenu> {
|
||||
|
||||
public void drawTooltip(PoseStack matrixStack, Font fontRenderer, int mouseX, int mouseY) {
|
||||
if (tabHovering >= 0 && tabHovering < tabs.get().size()) {
|
||||
tabs.get().get(tabHovering).drawTooltip(matrixStack, mouseX, mouseY, screen.width, screen.height, fontRenderer);
|
||||
tabs.get().get(tabHovering).drawTooltip(matrixStack, mouseX, mouseY, screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.util;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
@@ -9,7 +8,6 @@ import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.render.Styles;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
@@ -17,7 +15,6 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -27,7 +24,6 @@ import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -108,11 +104,6 @@ public final class RenderUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// @Volatile: Copied with some tweaks from GuiUtils#drawHoveringText(@Nonnull final ItemStack stack, List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
|
||||
public static void drawTooltipWithSmallText(PoseStack matrixStack, List<? extends FormattedText> textLines, List<String> smallTextLines, boolean showSmallText, @Nonnull ItemStack stack, int mouseX, int mouseY, int screenWidth, int screenHeight, Font fontRenderer) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// @Volatile: From Screen#getTooltipFromItem
|
||||
public static List<Component> getTooltipFromItem(ItemStack stack) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
|
Reference in New Issue
Block a user