Jump to content

Forge and Minecraft 1.3.1


ThunderSmotch

Recommended Posts

package techCraft.common;

import java.util.Random;

import net.minecraft.client.Minecraft;
import net.minecraft.src.*;
import net.minecraftforge.client.MinecraftForgeClient;
import techCraft.client.*;

public class mod_BlockDualWorkbench extends Block {
        
        public mod_BlockDualWorkbench(int id) {
                super(id, Material.iron);
                this.setCreativeTab(CreativeTabs.tabBlock);
                setHardness(2.5F);
                setBlockName("dualworkbench");
        }
        
        
        int Top = ModLoader.addOverride("/terrain.png", "/techCraft/workbenchTop.png");
        int Side1 =	ModLoader.addOverride("/terrain.png", "/techCraft/workbenchSide1.png");		
        int Side2 =	ModLoader.addOverride("/terrain.png", "/techCraft/workbenchSide2.png");
        

                public int idDropped(int metadata, Random random) {
                                return blockID;
                }

                protected int damageDropped(int metadata) {
                                return metadata;
                }

                // If you use metadata to change the texture of the block.
                public int getBlockTextureFromSideAndMetadata(int side, int metadata) {
                                switch (metadata){
                                case 0: {
                                	if(side == 1)
                                	return Top;
                                	if(side == 0)
                                    	return Block.blockSteel.getBlockTextureFromSide(0);
                                	if(side == 2)
                                    	return Side1;
                                	if(side == 3)
                                    	return Side1;
                                	if(side == 4)
                                    	return Side2;
                                	if(side == 5)
                                    	return Side2;
                                	
                                	break;
                                }
                                
                                }
							return Top;

                	

                }
                
                public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
                {
                	 if(par1World.isRemote)
                     {
                         return true;
                     } else
                     {
                    	 Minecraft.getMinecraft().displayGuiScreen(new mod_GuiCrafting(par5EntityPlayer.inventory, par1World, par2, par3, par4));
                         //par5EntityPlayer.openGui(mod_TechCraft.instance, 1, par1World, par2, par3, par4 );
                         
                         return true;
                     }
                		
                }

                

                
                                
}

 

package techCraft.client;

import net.minecraft.src.*;

import org.lwjgl.opengl.GL11;

import techCraft.common.mod_ContainerWorkbench;

public class mod_GuiCrafting extends GuiContainer
{
    public mod_GuiCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
    {
        super(new mod_ContainerWorkbench(par1InventoryPlayer, par2World, par3, par4, par5));
        this.ySize = 219;
    }

    /**
     * Called when the screen is unloaded. Used to disable keyboard repeat events
     */
    public void onGuiClosed()
    {
        super.onGuiClosed();
    }

    /**
     * Draw the foreground layer for the GuiContainer (everythin in front of the items)
     */
    protected void drawGuiContainerForegroundLayer()
    {
        this.fontRenderer.drawString(StatCollector.translateToLocal("container.crafting"), 28, 6, 4210752);
        this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
    }

    /**
     * Draw the background layer for the GuiContainer (everything behind the items)
     */
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
        int var4 = this.mc.renderEngine.getTexture("/gui/dual.png");
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture(var4);
        int var5 = (this.width - this.xSize) / 2;
        int var6 = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
    }

public static Object buildGUI(InventoryPlayer inventory, World world, int x, int y, int z) {

	return new mod_GuiCrafting(inventory, world, x, y, z);
}


}

 

These are the codes ;s

Link to comment
Share on other sites

Oh you use your own workbench gui, I thought you 'barrowed' the vanilla one...

(I want to make a mod that adds a workbench item instead of a block to the game, but I have no clue on how to trick mc into opening a crafting window without workbench...)

Thanks a lot though, I might end up making an own GUI too.

Please send me all the typo's you found, I'm from Belgium and I'm a little dyslectic and suck @ typing.

width=700 height=100http://dries007.net/banner.png[/img]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Your drivers are in a broken state, follow the guide in the FAQ: https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/#:~:text=How do I update my drivers%3F
    • A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffc3fe22b60, pid=15228, tid=5140 # # JRE version: OpenJDK Runtime Environment Microsoft-8035246 (17.0.8+7) (build 17.0.8+7-LTS) # Java VM: OpenJDK 64-Bit Server VM Microsoft-8035246 (17.0.8+7-LTS, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) # Problematic frame: # C [atio6axx.dll+0x192b60] # # No core dump will be written. Minidumps are not enabled by default on client versions of Windows # # If you would like to submit a bug report, please visit: # https://aka.ms/minecraftjavacrashes # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug i have no idea why please help
    • Quick-Books is great with regards to coordinating your monetary data. You can decide to live talk with a specialist at Quick-Books to get the answer for your questions. You will actually want to get to the talk going to the landing page and call us +1855-210-1428.
    • Update: I managed to make the item not disappear after crafting, but it doesn't remove any durability. import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.enchantment.UnbreakingEnchantment; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class NuggetHammer extends Item { private boolean damage; public NuggetHammer(Properties p_i48487_1_) { super(p_i48487_1_); } @Override public int getMaxDamage(ItemStack stack) { return 54 - 1; } public boolean isBarVisible(ItemStack stack) { return false; } @Override public ItemStack getContainerItem(ItemStack stack) { ItemStack copy = stack.copy(); copy.setCount(1); if (!this.damage) return copy; int unbreaking = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, stack); for (int i = 0; i < unbreaking; i++) { if (UnbreakingEnchantment.shouldIgnoreDurabilityDrop(stack, unbreaking, random)) return copy; } copy.setDamageValue(stack.getDamageValue() + 1); if (copy.getDamageValue() > stack.getMaxDamage()) return ItemStack.EMPTY; return copy; } }  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.