More auto crafting table stuff
This commit is contained in:
parent
3071d19db0
commit
a7316bc6c0
6 changed files with 148 additions and 2 deletions
|
@ -1,17 +1,26 @@
|
|||
package techreborn.client.gui.autocrafting;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButtonImage;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.packets.PacketSetRecipe;
|
||||
import techreborn.tiles.TileAutoCraftingTable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static net.minecraft.item.ItemStack.EMPTY;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 20/06/2017.
|
||||
*/
|
||||
|
@ -21,9 +30,11 @@ public class GuiAutoCrafting extends GuiBase {
|
|||
private GuiButtonImage recipeButton;
|
||||
boolean showGui = true;
|
||||
InventoryCrafting dummyInv;
|
||||
TileAutoCraftingTable tileAutoCraftingTable;
|
||||
|
||||
public GuiAutoCrafting(EntityPlayer player, TileAutoCraftingTable tile) {
|
||||
super(player, tile, tile.createContainer(player));
|
||||
this.tileAutoCraftingTable = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,9 +43,32 @@ public class GuiAutoCrafting extends GuiBase {
|
|||
recipeSlector.func_193957_d();
|
||||
}
|
||||
|
||||
public void renderItemStack(ItemStack stack, int x, int y) {
|
||||
if (stack != EMPTY) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
IRecipe recipe = tileAutoCraftingTable.getIRecipe();
|
||||
if(recipe != null){
|
||||
renderItemStack(recipe.getRecipeOutput(), 10, 25);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
recipeSlector.setGuiAutoCrafting(this);
|
||||
dummyInv = new InventoryCrafting(new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn) {
|
||||
|
@ -51,7 +85,7 @@ public class GuiAutoCrafting extends GuiBase {
|
|||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
if (showGui) {
|
||||
this.recipeSlector.func_191861_a(mouseX, mouseY, partialTicks);
|
||||
this.recipeSlector.func_191861_a(mouseX, mouseY, 0.1F);
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.recipeSlector.func_191864_a(this.guiLeft, this.guiTop, false, partialTicks);
|
||||
} else {
|
||||
|
@ -87,4 +121,10 @@ public class GuiAutoCrafting extends GuiBase {
|
|||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
public void setRecipe(IRecipe recipe){
|
||||
tileAutoCraftingTable.setCurrentRecipe(recipe.getRegistryName());
|
||||
NetworkManager.sendToServer(new PacketSetRecipe(tileAutoCraftingTable, recipe.getRegistryName()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package techreborn.client.gui.autocrafting;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButtonToggle;
|
||||
import net.minecraft.client.gui.recipebook.GuiRecipeBook;
|
||||
import net.minecraft.client.gui.recipebook.RecipeList;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
/**
|
||||
|
@ -9,8 +13,29 @@ import net.minecraft.item.crafting.IRecipe;
|
|||
*/
|
||||
public class GuiAutoCraftingRecipeSlector extends GuiRecipeBook {
|
||||
|
||||
GuiAutoCrafting guiAutoCrafting;
|
||||
|
||||
|
||||
@Override
|
||||
public void func_193014_a(boolean p_193014_1_, InventoryCrafting p_193014_2_) {
|
||||
super.func_193014_a(p_193014_1_, p_193014_2_);
|
||||
//Pulls the button off the screen as we dont need it
|
||||
field_193960_m = new GuiButtonToggle(0, -1000, -1000, 26, 16, false);
|
||||
field_193960_m.func_191751_a(152, 41, 28, 18, RECIPE_BOOK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_191856_a(int p_191856_1_, int p_191856_2_, Minecraft mc, boolean p_191856_4_, Container p_191856_5_, InventoryCrafting p_191856_6_) {
|
||||
super.func_191856_a(p_191856_1_, p_191856_2_, mc, p_191856_4_, p_191856_5_, p_191856_6_);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_193945_a(IRecipe recipe, RecipeList recipes) {
|
||||
System.out.println(recipe.getRecipeOutput().getDisplayName());
|
||||
guiAutoCrafting.setRecipe(recipe);
|
||||
}
|
||||
|
||||
public void setGuiAutoCrafting(GuiAutoCrafting guiAutoCrafting) {
|
||||
this.guiAutoCrafting = guiAutoCrafting;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue