• 0

    posted a message on [FORGE] 1.6.2 Crafting Table with custom grid sizes [updating to 1.6.4] adding videos
    Don't know why I didn't put the code in the first post... Well here it is now:

    MachForge (Base Class)

    package lynexer.Mach;

    import net.minecraft.block.Block;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraftforge.common.Configuration;
    import net.minecraftforge.common.MinecraftForge;
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.EventHandler;
    import cpw.mods.fml.common.Mod.Init;
    import cpw.mods.fml.common.Mod.Instance;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import cpw.mods.fml.common.network.NetworkMod;
    import cpw.mods.fml.common.network.NetworkRegistry;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.common.registry.LanguageRegistry;
    import cpw.mods.fml.common.registry.VillagerRegistry;

    @Mod(modid = "Mach Forge", name = "Mach Forge", version = "1.0")
    @NetworkMod(clientSideRequired = true, serverSideRequired = false)

    public class MachForge
    {
    @Instance("Mach Forge")
    public static MachForge instance;

    private GuiHandlerForge guiHandlerForge = new GuiHandlerForge();

    public static Block forge;
    public static int forgeID;

    @SidedProxy(clientSide = "lynexer.Mach.ClientProxy", serverSide = "lynexer.Mach.ServerProxy")
    public static ServerProxy proxy;

    @EventHandler
    public void PreInit(FMLPreInitializationEvent event)
    {
    Configuration config = new Configuration(event.getSuggestedConfigurationFile());
    config.load();

    forgeID = config.getBlock("builder ID", 3001, (String)null).getInt();

    config.save();

    }

    @EventHandler
    public void load(FMLInitializationEvent event)
    {
    forge = new BlockForge(forgeID).setHardness(2.5F).setResistance(2000.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("forge");

    GameRegistry.registerBlock(forge, "forge");
    LanguageRegistry.addName(forge, "Forge");

    NetworkRegistry.instance().registerGuiHandler(this, guiHandlerForge);

    proxy.registerRenderThings();

    }

    @EventHandler
    public void PostInit(FMLPostInitializationEvent event)
    {

    }

    }

    Block

    package lynexer.Mach;

    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IconRegister;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.util.Icon;
    import net.minecraft.world.World;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;

    public class BlockForge extends Block
    {
    @SideOnly(Side.CLIENT)
    private Icon workbenchIconTop;
    @SideOnly(Side.CLIENT)
    private Icon workbenchIconFront;

    public BlockForge(int i)
    {
    super(i, Material.ground);
    this.setCreativeTab(CreativeTabs.tabBlock);
    }

    @SideOnly(Side.CLIENT)
    public Icon getIcon(int par1, int par2)
    {
    return par1 == 1 ? this.workbenchIconTop : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.workbenchIconFront));
    }

    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister par1IconRegister)
    {
    this.blockIcon = par1IconRegister.registerIcon("BetterTable:better_side");
    this.workbenchIconTop = par1IconRegister.registerIcon("BetterTable:better_top");
    this.workbenchIconFront = par1IconRegister.registerIcon("BetterTable:better_front");
    }

    public boolean onBlockActivated(World var1, int var2, int var3, int var4, EntityPlayer player, int var6, float var7, float var8, float var9)
    {
    if (!player.isSneaking())
    {
    player.openGui(MachForge.instance, 0, var1, var2, var3, var4);
    return true;
    }
    else
    {
    return false;
    }
    }
    }

    GuiHandler


    package lynexer.Mach;

    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.network.IGuiHandler;

    public class GuiHandlerForge implements IGuiHandler
    {
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
    {
    TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
    switch(id)
    {
    case 0: return id == 0 && world.getBlockId(x, y, z) == MachForge.forge.blockID ? new ContainerForge(player.inventory, world, x, y, z) : null;
    }
    return null;
    }
    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
    {
    TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
    switch(id)
    {
    case 0: return id == 0 && world.getBlockId(x, y, z) == MachForge.forge.blockID ? new GuiForge(player.inventory, world, x, y, z) : null;
    }
    return null;
    }
    }

    Container


    package lynexer.Mach;

    import lynexer.Mach.MachForge;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.inventory.InventoryCraftResult;
    import net.minecraft.inventory.InventoryCrafting;
    import net.minecraft.inventory.Slot;
    import net.minecraft.inventory.SlotCrafting;
    import net.minecraft.item.ItemStack;
    import net.minecraft.world.World;

    public class ContainerForge extends Container
    {

    public InventoryCrafting craftMatrix;
    public IInventory craftResult;
    private World worldObj;
    private int posX;
    private int posY;
    private int posZ;

    public ContainerForge(InventoryPlayer inventoryplayer, World world, int i, int j, int k)
    {
    craftMatrix = new InventoryCrafting(this, 5, 5);
    craftResult = new InventoryCraftResult();
    worldObj = world;
    posX = i;
    posY = j;
    posZ = k;
    this.addSlotToContainer(new SlotCrafting(inventoryplayer.player, craftMatrix, craftResult, 0, 131, 36));
    for(int l = 0; l < 5; l++)
    {
    for(int k1 = 0; k1 < 5; k1++)
    {
    this.addSlotToContainer(new Slot(craftMatrix, k1 + l * 5, 4 + k1 * 18, 3 + l * 18));
    }

    }

    for(int i1 = 0; i1 < 3; i1++)
    {
    for(int l1 = 0; l1 < 9; l1++)
    {
    this.addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 94 + i1 * 18));
    }

    }

    for(int j1 = 0; j1 < 9; j1++)
    {
    this.addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 148));
    }

    onCraftMatrixChanged(craftMatrix);
    }

    public void onCraftMatrixChanged(IInventory iinventory)
    {
    craftResult.setInventorySlotContents(0, ForgeCraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
    }

    public void onContainerClosed(EntityPlayer entityplayer)
    {
    super.onContainerClosed(entityplayer);
    if(worldObj.isRemote)
    {
    return;
    }
    for(int i = 0; i < 25; i++)
    {
    ItemStack itemstack = craftMatrix.getStackInSlot(i);
    if(itemstack != null)
    {
    entityplayer.dropPlayerItem(itemstack);
    }
    }

    }

    public boolean canInteractWith(EntityPlayer entityplayer)
    {
    if(worldObj.getBlockId(posX, posY, posZ) != MachForge.forge.blockID)
    {
    return false;
    } else
    {
    return entityplayer.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64D;
    }
    }

    public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
    {
    ItemStack itemstack = null;
    Slot slot = (Slot)inventorySlots.get(par2);
    if(slot != null && slot.getHasStack())
    {
    ItemStack itemstack1 = slot.getStack();
    itemstack = itemstack1.copy();
    if(par2 == 0)
    {
    if(!mergeItemStack(itemstack1, 10, 46, true))
    {
    return null;
    }
    } else
    if(par2 >= 10 && par2 < 37)
    {
    if(!mergeItemStack(itemstack1, 37, 46, false))
    {
    return null;
    }
    } else
    if(par2 >= 37 && par2 < 46)
    {
    if(!mergeItemStack(itemstack1, 10, 37, false))
    {
    return null;
    }
    } else
    if(!mergeItemStack(itemstack1, 10, 46, false))
    {
    return null;
    }
    if(itemstack1.stackSize == 0)
    {
    slot.putStack(null);
    } else
    {
    slot.onSlotChanged();
    }
    if(itemstack1.stackSize != itemstack.stackSize)
    {
    slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
    } else
    {
    return null;
    }
    }
    return itemstack;
    }
    }

    Crafting Manager

    package lynexer.Mach;

    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.HashMap;
    import java.util.List;

    import lynexer.Mach.MachForge;
    import lynexer.Mach.ForgeRecipeSorter;
    import lynexer.Mach.ForgeShapedRecipes;
    import lynexer.Mach.ForgeShapelessRecipes;
    import cpw.mods.fml.common.registry.GameRegistry;
    import net.minecraft.block.Block;
    import net.minecraft.inventory.InventoryCrafting;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.item.crafting.IRecipe;
    import net.minecraft.world.World;

    public class ForgeCraftingManager
    {
    public static final int WILDCARD_VALUE = Short.MAX_VALUE;
    private static final ForgeCraftingManager instance = new ForgeCraftingManager();
    private List recipes = new ArrayList();

    public static final ForgeCraftingManager getInstance()
    {
    return instance;
    }

    private ForgeCraftingManager()
    {
    recipes = new ArrayList();

    //This is where your recipes will go

    Collections.sort(this.recipes, new ForgeRecipeSorter(this));
    System.out.println(this.recipes.size() + " recipes");
    }

    public ForgeShapedRecipes func_92051_a(ItemStack par1ItemStack, Object ... par2ArrayOfObj)
    {
    String var3 = "";
    int var4 = 0;
    int var5 = 0;
    int var6 = 0;

    if (par2ArrayOfObj[var4] instanceof String[])
    {
    String[] var7 = (String[])((String[])par2ArrayOfObj[var4++]);

    for (int var8 = 0; var8 < var7.length; ++var8)
    {
    String var9 = var7[var8];
    ++var6;
    var5 = var9.length();
    var3 = var3 + var9;
    }
    }
    else
    {
    while (par2ArrayOfObj[var4] instanceof String)
    {
    String var11 = (String)par2ArrayOfObj[var4++];
    ++var6;
    var5 = var11.length();
    var3 = var3 + var11;
    }
    }

    HashMap var12;

    for (var12 = new HashMap(); var4 < par2ArrayOfObj.length; var4 += 2)
    {
    Character var13 = (Character)par2ArrayOfObj[var4];
    ItemStack var14 = null;

    if (par2ArrayOfObj[var4 + 1] instanceof Item)
    {
    var14 = new ItemStack((Item)par2ArrayOfObj[var4 + 1]);
    }
    else if (par2ArrayOfObj[var4 + 1] instanceof Block)
    {
    var14 = new ItemStack((Block)par2ArrayOfObj[var4 + 1], 1, -1);
    }
    else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack)
    {
    var14 = (ItemStack)par2ArrayOfObj[var4 + 1];
    }

    var12.put(var13, var14);
    }

    ItemStack[] var15 = new ItemStack[var5 * var6];

    for (int var16 = 0; var16 < var5 * var6; ++var16)
    {
    char var10 = var3.charAt(var16);

    if (var12.containsKey(Character.valueOf(var10)))
    {
    var15[var16] = ((ItemStack)var12.get(Character.valueOf(var10))).copy();
    }
    else
    {
    var15[var16] = null;
    }
    }

    ForgeShapedRecipes var17 = new ForgeShapedRecipes(var5, var6, var15, par1ItemStack);
    this.recipes.add(var17);
    return var17;
    }

    public void addBuilderShapelessRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj)
    {
    ArrayList var3 = new ArrayList();
    Object[] var4 = par2ArrayOfObj;
    int var5 = par2ArrayOfObj.length;

    for (int var6 = 0; var6 < var5; ++var6)
    {
    Object var7 = var4[var6];

    if (var7 instanceof ItemStack)
    {
    var3.add(((ItemStack)var7).copy());
    }
    else if (var7 instanceof Item)
    {
    var3.add(new ItemStack((Item)var7));
    }
    else
    {
    if (!(var7 instanceof Block))
    {
    throw new RuntimeException("Invalid shapeless recipe!");
    }

    var3.add(new ItemStack((Block)var7));
    }
    }

    this.recipes.add(new ForgeShapelessRecipes(par1ItemStack, var3));
    }

    public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
    {
    int var3 = 0;
    ItemStack var4 = null;
    ItemStack var5 = null;
    int var6;

    for (var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6)
    {
    ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6);

    if (var7 != null)
    {
    if (var3 == 0)
    {
    var4 = var7;
    }

    if (var3 == 1)
    {
    var5 = var7;
    }

    ++var3;
    }
    }

    if (var3 == 2 && var4.itemID == var5.itemID && var4.stackSize == 1 && var5.stackSize == 1 && Item.itemsList[var4.itemID].isRepairable())
    {
    Item var11 = Item.itemsList[var4.itemID];
    int var13 = var11.getMaxDamage() - var4.getItemDamageForDisplay();
    int var8 = var11.getMaxDamage() - var5.getItemDamageForDisplay();
    int var9 = var13 + var8 + var11.getMaxDamage() * 5 / 100;
    int var10 = var11.getMaxDamage() - var9;

    if (var10 < 0)
    {
    var10 = 0;
    }

    return new ItemStack(var4.itemID, 1, var10);
    }
    else
    {
    for (var6 = 0; var6 < this.recipes.size(); ++var6)
    {
    IRecipe var12 = (IRecipe)this.recipes.get(var6);

    if (var12.matches(par1InventoryCrafting, par2World))
    {
    return var12.getCraftingResult(par1InventoryCrafting);
    }
    }

    return null;
    }
    }

    /**
    * returns the List<> of all recipes
    */
    public List getRecipeList()
    {
    return this.recipes;
    }
    }

    Gui


    package lynexer.Mach;

    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.StatCollector;
    import net.minecraft.world.World;
    import org.lwjgl.opengl.GL11;

    public class GuiForge extends GuiContainer
    {
    private ResourceLocation better = new ResourceLocation("textures/gui/container/5x5_Gui(1).png");
    public GuiForge(InventoryPlayer inventoryplayer, World world, int i, int j, int k)
    {
    super(new ContainerForge(inventoryplayer, world, i, j, k));
    }

    public void onGuiClosed()
    {
    super.onGuiClosed();
    }

    protected void drawGuiContainerForegroundLayer(int par1, int par2)
    {
    this.fontRenderer.drawString(StatCollector.translateToLocal("Forge"), 8, this.ySize - 150 - 14, 0x404040);
    this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 - 14, 0x404040);
    //Fix positioning after gui is fixed
    }

    protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
    {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.func_110577_a(better);
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    drawTexturedModalRect(l, i1, 0, 0, xSize, ySize);
    }
    }

    Thanks in advance. :)
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [FORGE] 1.6.2 Crafting Table with custom grid sizes [updating to 1.6.4] adding videos
    Awesome tutorial, it helped a lot. I'm only having one problem. Every time I click on my block the GUI gets cut off.



    I've tried sizing it down in photoshop, but the only thing it does it make it a blurrier cut off GUI.
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on Mrgreen33gamer's [1.6.1\1.6.2\1.6.4\]Forge/ModLoader Modding Tutorials
    Hia,

    Love the grenades creator, the only thing is where do I put the image that you see when you throw the grenade? For example when you throw an egg you see an egg flying through the air. Where does the image go that does that. (Using ModLoader)

    Thanks in advance.
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on Looking for builders for a series
    No I am sorry Artistunknown we do not need writers. Thanks for the offer though.

    ~lyn
    Posted in: Other Help
  • 0

    posted a message on Looking for builders for a series
    Looking for steampunk builders (people that can build steampunk buildings, airships, etc.) for a new series being created. Please post a comment in the form below if you would like to apply.

    Name:
    IGN:
    Age:
    Skype name:
    References and where to find them (if any):
    Time you will be available:
    Previous builds (link some pics or a video):
    Favorite band (optional, its just to get to know you a little more):
    Anything else you would like to include:

    I will contact you with more info if you are accepted.

    Thank you
    ~lyn
    Posted in: Other Help
  • 0

    posted a message on Recruiting for Series: "Pirates of the Skylands."
    IGN: lynexer
    Skype: lyn.exer
    Time Zone: WST
    Do you have previous experience? If so list and link: No, but heres some pictures of other peoples stuff http://unitedblocks.tumblr.com/
    Machentertainment.com Forum account: lynexer
    Posted in: Video/Series Help
  • 0

    posted a message on MachEntertainment Server
    A server dedicated to all players with multiple maps and worlds. Curently two maps/worlds: Creative, and Paradoxia. In Paradoxia factions are enabled and pvp and griefing is allowed. There are very helpful and friendly staff. Also very friendly memebers.

    24/7 server
    Come join the server at this IP: machentertainment.com
    Posted in: Minecraft Survival Servers (archive)
  • To post a comment, please or register a new account.