GUI update for assembly machine. Some work for #1512
This commit is contained in:
parent
7bc792fd69
commit
ed9cdc7353
7 changed files with 40 additions and 157 deletions
|
@ -39,7 +39,7 @@ public class BlockAssemblingMachine extends BlockMachineBase {
|
||||||
|
|
||||||
public BlockAssemblingMachine() {
|
public BlockAssemblingMachine() {
|
||||||
super();
|
super();
|
||||||
this.setCreativeTab(TechRebornCreativeTab.instance);
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier1_machines"));
|
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier1_machines"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,66 +24,41 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import techreborn.tiles.tier1.TileAssemblingMachine;
|
import techreborn.tiles.tier1.TileAssemblingMachine;
|
||||||
|
|
||||||
public class GuiAssemblingMachine extends GuiContainer {
|
public class GuiAssemblingMachine extends GuiBase {
|
||||||
|
|
||||||
public static final ResourceLocation texture = new ResourceLocation("techreborn",
|
TileAssemblingMachine tile;
|
||||||
"textures/gui/assembling_machine.png");
|
|
||||||
|
|
||||||
TileAssemblingMachine assemblingmachine;
|
public GuiAssemblingMachine(final EntityPlayer player, final TileAssemblingMachine tile) {
|
||||||
|
super(player, tile, tile.createContainer(player));
|
||||||
public GuiAssemblingMachine(final EntityPlayer player, final TileAssemblingMachine assemblingMachine) {
|
this.tile = tile;
|
||||||
super(assemblingMachine.createContainer(player));
|
|
||||||
this.xSize = 176;
|
|
||||||
this.ySize = 167;
|
|
||||||
this.assemblingmachine = assemblingMachine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) {
|
||||||
super.initGui();
|
super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
|
||||||
|
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||||
|
|
||||||
|
// Battery slot
|
||||||
|
this.drawSlot(8, 72, layer);
|
||||||
|
|
||||||
|
// Input slots
|
||||||
|
this.drawSlot(55, 35, layer);
|
||||||
|
this.drawSlot(55, 55, layer);
|
||||||
|
|
||||||
|
this.drawOutputSlot(101, 45, layer);
|
||||||
|
|
||||||
|
this.builder.drawJEIButton(this, 150, 4, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||||
this.drawDefaultBackground();
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||||
this.mc.getTextureManager().bindTexture(GuiAssemblingMachine.texture);
|
|
||||||
final int k = (this.width - this.xSize) / 2;
|
|
||||||
final int l = (this.height - this.ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
|
||||||
|
|
||||||
int j = 0;
|
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
|
||||||
|
this.builder.drawMultiEnergyBar(this, 9, 19, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||||
j = this.assemblingmachine.getProgressScaled(20);
|
|
||||||
if (j > 0) {
|
|
||||||
this.drawTexturedModalRect(k + 86, l + 34, 176, 14, j + 1, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
j = this.assemblingmachine.getEnergyScaled(12);
|
|
||||||
if (j > 0) {
|
|
||||||
this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
|
||||||
final String name = I18n.format("tile.techreborn:assembly_machine.name");
|
|
||||||
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6,
|
|
||||||
4210752);
|
|
||||||
this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8,
|
|
||||||
this.ySize - 96 + 2, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
this.renderHoveredToolTip(mouseX, mouseY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,11 +332,11 @@ public class TechRebornJeiPlugin implements IModPlugin {
|
||||||
addRecipeClickArea(GuiFusionReactor.class, 150, 4, 18, 18, RecipeCategoryUids.FUSION_REACTOR);
|
addRecipeClickArea(GuiFusionReactor.class, 150, 4, 18, 18, RecipeCategoryUids.FUSION_REACTOR);
|
||||||
addRecipeClickArea(GuiRollingMachine.class, 150, 4, 20, 12, RecipeCategoryUids.ROLLING_MACHINE);
|
addRecipeClickArea(GuiRollingMachine.class, 150, 4, 20, 12, RecipeCategoryUids.ROLLING_MACHINE);
|
||||||
addRecipeClickArea(GuiFluidReplicator.class, 150, 4, 20, 12, RecipeCategoryUids.FLUID_REPLICATOR);
|
addRecipeClickArea(GuiFluidReplicator.class, 150, 4, 20, 12, RecipeCategoryUids.FLUID_REPLICATOR);
|
||||||
|
addRecipeClickArea(GuiAssemblingMachine.class, 150, 4, 20, 12, RecipeCategoryUids.ASSEMBLING_MACHINE);
|
||||||
|
|
||||||
//OLD ONES
|
//OLD ONES
|
||||||
addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
|
addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
|
||||||
VanillaRecipeCategoryUid.FUEL);
|
VanillaRecipeCategoryUid.FUEL);
|
||||||
addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
|
|
||||||
addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
|
addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
|
||||||
VanillaRecipeCategoryUid.FUEL);
|
VanillaRecipeCategoryUid.FUEL);
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,8 @@ import mezz.jei.api.IGuiHelper;
|
||||||
import mezz.jei.api.gui.*;
|
import mezz.jei.api.gui.*;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.IRecipeCategory;
|
import mezz.jei.api.recipe.IRecipeCategory;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
import techreborn.client.gui.GuiAssemblingMachine;
|
|
||||||
import techreborn.compat.jei.RecipeCategoryUids;
|
import techreborn.compat.jei.RecipeCategoryUids;
|
||||||
import techreborn.compat.jei.RecipeUtil;
|
import techreborn.compat.jei.RecipeUtil;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
|
@ -39,18 +38,16 @@ import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class AssemblingMachineRecipeCategory implements IRecipeCategory<AssemblingMachineRecipeWrapper> {
|
public class AssemblingMachineRecipeCategory implements IRecipeCategory<AssemblingMachineRecipeWrapper> {
|
||||||
|
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png");
|
||||||
private static final int[] INPUT_SLOTS = { 0, 1 };
|
private static final int[] INPUT_SLOTS = { 0, 1 };
|
||||||
private static final int[] OUTPUT_SLOTS = { 2 };
|
private static final int[] OUTPUT_SLOTS = { 2 };
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
private final IDrawableAnimated electricity;
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
public AssemblingMachineRecipeCategory(IGuiHelper guiHelper) {
|
public AssemblingMachineRecipeCategory(IGuiHelper guiHelper) {
|
||||||
background = guiHelper.createDrawable(GuiAssemblingMachine.texture, 46, 16, 91, 54);
|
// TO-DO add texture to JEI
|
||||||
IDrawableStatic electricityDrawable = guiHelper.createDrawable(GuiAssemblingMachine.texture, 176, 0, 14, 14);
|
background = guiHelper.createDrawable(texture, 0, 94, 120, 78);
|
||||||
electricity = guiHelper.createAnimatedDrawable(electricityDrawable, 300, IDrawableAnimated.StartDirection.TOP,
|
|
||||||
true);
|
|
||||||
title = I18n.translateToLocal("tile.techreborn.assemblingmachine.name");
|
title = I18n.translateToLocal("tile.techreborn.assemblingmachine.name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,21 +75,10 @@ public class AssemblingMachineRecipeCategory implements IRecipeCategory<Assembli
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawExtras(
|
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull AssemblingMachineRecipeWrapper recipeWrapper,
|
||||||
@Nonnull
|
@Nonnull IIngredients ingredients) {
|
||||||
Minecraft minecraft) {
|
|
||||||
electricity.draw(minecraft, 10, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRecipe(
|
|
||||||
@Nonnull
|
|
||||||
IRecipeLayout recipeLayout,
|
|
||||||
@Nonnull
|
|
||||||
AssemblingMachineRecipeWrapper recipeWrapper,
|
|
||||||
@Nonnull
|
|
||||||
IIngredients ingredients) {
|
|
||||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||||
|
// TODO: fix slots
|
||||||
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 0);
|
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 0);
|
||||||
guiItemStacks.init(INPUT_SLOTS[1], true, 18, 0);
|
guiItemStacks.init(INPUT_SLOTS[1], true, 18, 0);
|
||||||
guiItemStacks.init(OUTPUT_SLOTS[0], false, 69, 18);
|
guiItemStacks.init(OUTPUT_SLOTS[0], false, 69, 18);
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 TechReborn
|
|
||||||
*
|
|
||||||
* 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 techreborn.compat.jei.assemblingMachine;
|
|
||||||
|
|
||||||
import mezz.jei.api.IJeiHelpers;
|
|
||||||
import mezz.jei.api.recipe.IRecipeHandler;
|
|
||||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
|
||||||
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
|
||||||
import techreborn.compat.jei.RecipeCategoryUids;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class AssemblingMachineRecipeHandler implements IRecipeHandler<AssemblingMachineRecipe> {
|
|
||||||
@Nonnull
|
|
||||||
private final IJeiHelpers jeiHelpers;
|
|
||||||
|
|
||||||
public AssemblingMachineRecipeHandler(
|
|
||||||
@Nonnull
|
|
||||||
IJeiHelpers jeiHelpers) {
|
|
||||||
this.jeiHelpers = jeiHelpers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Class<AssemblingMachineRecipe> getRecipeClass() {
|
|
||||||
return AssemblingMachineRecipe.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public String getRecipeCategoryUid(
|
|
||||||
@Nonnull
|
|
||||||
AssemblingMachineRecipe recipe) {
|
|
||||||
return RecipeCategoryUids.ASSEMBLING_MACHINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public IRecipeWrapper getRecipeWrapper(
|
|
||||||
@Nonnull
|
|
||||||
AssemblingMachineRecipe recipe) {
|
|
||||||
return new AssemblingMachineRecipeWrapper(jeiHelpers, recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRecipeValid(
|
|
||||||
@Nonnull
|
|
||||||
AssemblingMachineRecipe recipe) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,7 +30,7 @@ import mezz.jei.api.gui.IDrawableAnimated;
|
||||||
import mezz.jei.api.gui.IDrawableStatic;
|
import mezz.jei.api.gui.IDrawableStatic;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
||||||
import techreborn.client.gui.GuiAssemblingMachine;
|
import techreborn.client.gui.TRBuilder;
|
||||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -38,21 +38,17 @@ import javax.annotation.Nonnull;
|
||||||
public class AssemblingMachineRecipeWrapper extends BaseRecipeWrapper<AssemblingMachineRecipe> {
|
public class AssemblingMachineRecipeWrapper extends BaseRecipeWrapper<AssemblingMachineRecipe> {
|
||||||
private final IDrawableAnimated progress;
|
private final IDrawableAnimated progress;
|
||||||
|
|
||||||
public AssemblingMachineRecipeWrapper(
|
public AssemblingMachineRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull AssemblingMachineRecipe baseRecipe) {
|
||||||
@Nonnull
|
|
||||||
IJeiHelpers jeiHelpers,
|
|
||||||
@Nonnull
|
|
||||||
AssemblingMachineRecipe baseRecipe) {
|
|
||||||
super(baseRecipe);
|
super(baseRecipe);
|
||||||
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||||
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiAssemblingMachine.texture, 176, 14, 20, 18);
|
IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10);
|
||||||
this.progress = guiHelper.createAnimatedDrawable(progressStatic, baseRecipe.tickTime(),
|
this.progress = guiHelper.createAnimatedDrawable(progressStatic, baseRecipe.tickTime(),
|
||||||
IDrawableAnimated.StartDirection.LEFT, false);
|
IDrawableAnimated.StartDirection.LEFT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||||
progress.draw(minecraft, 40, 18);
|
progress.draw(minecraft, 25, 11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ public class TileAssemblingMachine extends TileGenericMachine implements IContai
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
@Override
|
@Override
|
||||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||||
return new ContainerBuilder("assemblingmachine").player(player.inventory).inventory(8, 84).hotbar(8, 142)
|
return new ContainerBuilder("assemblingmachine").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().tile(this).slot(0, 47, 17).slot(1, 65, 17).outputSlot(2, 116, 35).energySlot(3, 56, 53)
|
.addInventory().tile(this).slot(0, 55, 35).slot(1, 55, 55).outputSlot(2, 101, 45).energySlot(3, 8, 72)
|
||||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this);
|
.syncEnergyValue().syncCrafterValue().addInventory().create(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue