Minecraft Level 1 - TechWise Academy
centertopMinecraft Level 1 – November 14, 2015 TOC \o "1-3" \h \z \u Environment Setup PAGEREF _Toc435128681 \h 2What is a “mod”? PAGEREF _Toc435128682 \h 2My Environment PAGEREF _Toc435128683 \h 2Install and set up Java PAGEREF _Toc435128684 \h 2Install Eclipse PAGEREF _Toc435128685 \h 5Install and configure Minecraft Forge PAGEREF _Toc435128686 \h 6Configure Eclipse Environment PAGEREF _Toc435128687 \h 7Setting up Eclipse Project PAGEREF _Toc435128688 \h 8Custom Item PAGEREF _Toc435128689 \h 10Custom Weapons/Tools – Sword ToolMaterial PAGEREF _Toc435128690 \h 13Sword PAGEREF _Toc435128691 \h 13Custom Armor PAGEREF _Toc435128692 \h 15Environment SetupWhat is a “mod”?Simply put, it’s a modification of the?underlying code that runs the Minecraft game on your PC. ?It allows developers to create new items, blocks, characters, etc. inside the Minecraft environment. ?It is also perfectly legal and encouraged by Mojang (the game developers) in their licensing agreement: ?“If you’ve bought the Game, you may play around with it and modify it.”My EnvironmentWindows 8.1 64 bit; Minecraft 1.8.8There are four?steps which I’ll describe in sections below:Install and set up?JavaInstall EclipseInstall and configure Minecraft ForgeConfigure Eclipse environmentInstall and set up JavaJava is the programming language that you’ll use to make modifications to Minecraft. ?This section is probably the trickiest if you’ve not used Java before.Download the?Java Development Kit (JDK). ?Note that you need the development kit and not the Runtime Environment (JRE). ?This will give you what you need to not only run Java programs but to also be able to compile Java code on your machine. ?You also need to make sure you select the correct version for your computer.Click on the downloaded .exe file and your new code should be installed somewhere similar to:?C:\Program Files\Java\jdk1.7.0_79You’ll now need to setup your system’s environment variables. ?On Windows (in your Metro interface, not desktop mode), click on the Search bar and type ‘Edit the System’ and the following will appear:Click on the ‘Edit the system environment variables’ link. ?This window will pop up and you should click the ‘Environment Variables…’ button at the bottom.There are two settings that you need to update/edit.First, JAVA_HOME. ?It’s Value should match the install folder that was created above when you clicked the java .exe.Second, Path. ?It’s Value should have a lot of values already setup. ?At the very end (after the semicolon) enter the above path followed by \bin;Now your machine is setup to compile Java code. ?(Fun, right?)Install EclipseEclipse serves as the Development Environment for your Java code. ?It provides built-in features that make programming much easier. ?Download Eclipse?(select your appropriate environment on the upper right-hand area of the screen).The downloaded file will be a .zip file. ?Once downloaded, you should right-click on that file and select ‘Extract All…’. ?This will open the .zip file and dump its contents into the folder that you choose. ?Mine looks like this:Eclipse is now installed?on your machine.Install and configure Minecraft Forge“Minecraft Forge is a modding API (Application Programming Interface), which makes it easier to create mods, and also make sure mods are compatible with each other.” ?It helps us create mods better and faster. ?I spent a lot of time finding the correct files to download so my time spent is time saved for you. ?There are two methods for setting up Forge: ?1) ?For running mods that other people have created; and 2) being able to create and compile your own mods. ?Find the ‘Download Recommended’ area on the right and click on the ‘Src’ button.Be careful, the next screen will display a “Download” button in the middle of the screen. ?It’s actually an ad and will download adware to your computer.??Wait 5 seconds and a ‘Skip’ button will be displayed at the top right. ?Again, this will be downloaded as a .zip file.Right-click on the .zip file and ‘Extract All…’ again. ?My folder is?C:\MinecraftModding\Forge. ?Once this is finished extracting, right-click in the MinecraftModding folder and click New->Folder and call it ‘workspace’ (this is for our Eclipse setup later).Click on the “Forge” folder and you should see the following:Hold down shift, and right click, then select “Open command window here”.Once the command window opens, type the following command exactly:gradlew setupDecompWorkspace --refresh-dependenciesThis will run through several commands and will take several minutes. ?I found that if I was on an unstable internet connection the process would fail (and the error wasn’t much help). ?Once I got to a stable connection it ran fine.Next, run the following command to associate Forge with Eclipse:gradlew eclipseConfigure Eclipse EnvironmentLast step and you should be ready to go. ?Click on the eclipse.exe file in the folder that you extracted to earlier (mine was?C:\eclipse-java-mars-R-win32-x86_64\eclipse).Eclipse will ask you to?select a workspace. ?I chose the folder that you created earlier in the MinecraftModding folder entitled ‘workspace’. ?You can select to make this Default so that you’re not asked again but I work on other Java projects so I didn’t want to always open to Minecraft mods?In Eclipse you first have to create your mod project. To do so, you click onFile > New > Project?and select “Java Project” in the pop-up window which will appear. Give your project a name and click Finish. Now you?have a blank Java project.At this point you have a blank Java project for our code but our project has no awareness of the Minecraft Forge code. ?Click?File > Import?and choose “Existing Projects into workspace”. In the dialog for the import click the “Browse” button and select your C:\MinecraftModding\Forge directory as the source to import from. Then click finish. Ensure that a project named “Forge” is in the list of projects and is checked.?Press ‘Finish’. ? The import linked the Forge workspace to your project’s workspace so you now have access to the Forge code.Although Forge has been linked to the workspace it can’t be used yet. Forge must be added to your project’s buildpath?so that the?Java compiler compiles your mod and Forge together. Right-click on your Project in the Package Explorer on the left. Then click on?Build Path > Configure. Go to the tab “Projects” and click “Add”. Select Forge as the project and click OK.Finally you?have to create Run Configurations. Select your project in the Package Explorer and click on the drop-down arrow next to the green “Run” button in the top tool bar. In the drop-down menu click on “Run Configurations”. Right-click on “Java Application” and click “New”. This creates a new Run Configuration of the type “Java Application”, so it will be a program that runs on your?PC.Name the Configuration ‘Launch Client’ with the following settings:Main Class:GradleStartProgram Arguments:–username=<Username>?–password=<Password>The <Username> and <Password> are for your regular Minecraft game. ?Click?Apply.Now you can click on the green run button in the top of Eclipse and Minecraft should eventually start. ?Now Minecraft is running as a modified version and will load any code that you create.Setting up Eclipse ProjectOur code needs to be organized in a logical way. You will be creating packages that act in a similar fashion to folders and will hold our code files. Right-click on the ‘src’ folder in your Eclipse project and click New->Package. For this tutorial we’ve named ours com.techwise.tutorial. Click Finish. Right-click on the newly created package and click New->Class. Enter ‘Main’ as the name and click Finish. Your newly created Main.java file should look like this:Notice that the package is the one that you just created. This is how you distinguish this particular Main class versus any other Main class that you create in our code. Add the following line of code directly above public class Main:@Mod(modid=Main.MODID, name=Main.MODNAME, version=Main.VERSION)This special code tells Forge that this class (Main) is supposed to be a mod. When the code is run, Forge goes through all of our classes and searches for this. If one is found, it is added to a list of all mods. The arguments to the @Mod annotation (MODID, MODNAME, and VERSION) should be defined inside your Main.java class. You’ll also click ctrl+shift+o to resolve references that you may be missing in our code. Your Main.java class should now look like:You now need to add Event Handlers in the class. These are methods that have the @EventHandler annotation above them. Forge recognizes the arguments of these methods and uses them in this specific way (from bedrockminer.’s site):The preInit Handler is called at the very beginning of startup. In this method our config file is read, Blocks, Items, etc. are created and registered with the GameRegistry.The init Handler is called after the preInit Handler. In this method you can build up data structures, add Crafting recipes, and register new handlers. The postInit Handler is called at the very end. It is used to communicate with other mods. Forge executes the preInit code for all mods, then the init code, and finally the postInit code. Add the methods and click ctrl+shift+o to resolve all of the references. Your final code should look like:You can now click the Run arrow and “Launch Client.” The above code won’t do anything fancy but you can see the phrases from above in your console window. Custom ItemCreate a new package named com.techwise.tutorial.items and two new classes named ModItems and BasicItem within the package. (Following the same instructions as above) BasicItem will be used to create this particular custom item while ModItems will be used as a way to many items at once (if you choose). BasicItem looks like this (you can take notes as you go through each section):ModItems looks like:Before running, you need to call the ModItems.createItems() method from within the preInit method in your Main class. You can now run the game via the “Launch Client” run configuration. Start a New World in Creative Mode. Bring up your Inventory and select the Materials tab (scroll to the bottom). You’ll see that it has the default texture at this point (a purple and black cube). Next you’ll add a texture for the item by creating a model file. Create a new package named com.techwise.tutorial.client.render.items and a new class ItemRenderer in the package. This file will look like this:Call the registerItemRenderer() method from your Main class’ init method. For this tutorial, you’ll use the basic model that every normal item is using. You can find more information about the structure of the item model on the minecraft wiki: a new folder src->resources. Create a new package assets.tutorial.item.models.item (tutorial equals our modid in Main.java) and a .json file in the package: techwise_item.json. Add the following contents to the file:{ "parent":"builtin/generated", "textures": { "layer0":"tutorial:items/techwise_item" }, "display": { "thirdperson": { "rotation": [ -90, 0, 0 ], "translation": [ 0, 1, -3 ], "scale": [ 0.55, 0.55, 0.55 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } }}Note that this model file is a copy from a normal Minecraft item (in this case redstone). Create a new package under the ‘resources’ folder entitled assets.tutorial.textures.items. Place the file named techwise_item.png in the folder in the file system. The file can be downloaded here: minecraftlevel1 . (My file system path is C:\MinecraftModding\workspace\TechWiseMinecraft\resources\assets\tutorial\textures\items)Refresh your project by right-clicking on it and clicking Refresh. The .png file now shows up in your project. Launch Client. Congrats. You’ve created your first full Minecraft item.Custom Weapons/Tools – SwordToolMaterialEvery tool (or sword) in Minecraft needs to have a material that defines how much hits it can take before it breaks, the mining speed, the damage it does, and a few other things. So, in order to create a sword, we must first create a ToolMaterial. Go into your ModItems class to create a ToolMaterial. Forge opens up a great helper to help us define the ToolMaterial :public static ToolMaterial TECH_SWORD = EnumHelper.addToolMaterial("TECH_SWORD", harvestLevel, durability, miningSpeed, damageVsEntities, enchantability); This definition above tells us the parameters that we need to pass in order to make our ToolMaterial. From bedrockminer., here’s some definitions for each of those parameters:Name – “TECH_SWORD” – this should match our variable name.harvestLevel – A value between 0 and 3 that defines which blocks can be mined with this tool. Common values: Wood/Gold Tool: 0, Stone Tool: 1, Iron Tool: 2, Diamond Tool: 3durability – How often you can use the tool before it mon values: Wood Tool: 59, Stone Tool: 131, Iron Tool: 250, Diamond Tool: 1561, Gold Tool: 32miningSpeed – How much faster you are with this tool than with your mon values: Hand: 1.0F, Wood Tool: 2.0F, Stone Tool: 4.0F, Iron Tool: 6.0F, Diamond Tool: 8.0F, Gold Tool: 12.0FdamageVsEntities – Value used to calculate the damage an entity takes if you hit it with this sword. This value defines basic damage and the tool type adds additional damage. For instance, a sword always causes 4 more damage than the mon values: Wood Tools: 0.0F (Sword adds 4.0), Stone Tool: 1.0F, Iron Tool: 2.0F, Diamond Tool: 3.0F, Gold Tool: 0.0Fenchantability – This value is used in a calculation together with the enchantment level to calculate the result of the enchantment. Common values: Wood Tool:15, Stone Tool: 5, Iron Tool: 14, Diamond Tool: 10, Gold Tool: 22You can create a ToolMaterial with the following parameters: public static ToolMaterial TECH_MATERIAL = EnumHelper.addToolMaterial("TECH_MATERIAL", 3, 1000, 15.0F, 4.0F, 30);Now that you have the material you can create the sword itself.SwordCreate a class in the package com.techwise.tutorial.items named ItemModSword. Add extends ItemSword after the class declaration to look like:public class ItemModSword extends ItemSwordCtrl+shift+o will resolve the error under ItemSword. Notice that ItemModSword still has an error under it. Hover over the error and Eclipse will give you an option to resolve the error. A constructor has been added. Inside the constructor, you can give a name to your sword to display during the game. Use this.setUnlocalizedName(“TechWise_Sword”);Go to the ModItems class and register the sword with the class we just created. ModItems should now look like:You’ll now need to create model files and register them in order to get a display for the sword. Similar to above, you’ll need to create a techwise_sword.json file in the assets.tutorial.models.item package. The contents of the file will need to be modified slightly since a sword changes perspectives more often as you use it during the game. { "parent": "builtin/generated", "textures": { "layer0": "tutorial:items/techwise_sword" }, "display": { "thirdperson": { "rotation": [ 0, 90, -35 ], "translation": [ 0, 1.25, -3.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } }}Place the techwise_sword.png file from minecraftlevel1 in the same directory as earlier and refresh your project. (Mine is C:\MinecraftModding\workspace\TechWiseMinecraft\src\resources\assets\tutorial\textures\items)Update code in com.techwise.tutorial.client.render.items.ItemRenderRegister to include the sword with your basic item.Launch Client. You’ve created your first weapon! Custom ArmorJust like you had to create a ToolMaterial for your sword, you now have to create an ArmorMaterial for your custom armor. Again, Forge gives us some code in the following form:public static ArmorMaterial ARMOR = EnumHelper.addArmorMaterial("ARMOR", texture, durability, damageReduction[], enchantability);Name – “ARMOR” – this should match our variable name.texture – This is used to get the right armor model texture. You’ll enter it in this format: <modid>:<chosen_name>durability – This value is multiplied by the following list to give different durabilities for each armor item:helmet: durability * 11chestplate: durability * 16leggings: durability *15boots: durability *13Common durability values: leather: 5, chain and iron: 15, gold: 7, diamond: 33damageReduction[] – A list of numbers that define the number of armor points for helmet, chestplate, leggings, and boots that are added to the player’s hotbar when the armor is worn. Common values: new int[]{1,3,2,1} for leathernew int[]{2,5,4,1} for chainnew int[]{2,6,5,2} for ironnew int[]{2,5,3,1} for gold armornew int[]{3,8,6,3} for diamond armor (if you use more than diamond, your hotbar will overflow and your character will become invincible)enchantability – This value determines the enchantments you get on average per level. Common values: leather:15, chain: 12, iron: 9, gold: 25, diamond:10Your code should use the following for this tutorial:public static ArmorMaterial ARMOR = EnumHelper.addArmorMaterial("ARMOR", "tutorial:techwise_armor", 16, new int[] {3, 8, 6, 3}, 30);Create an ItemModArmor file exactly like you created ItemModSword earlier except extend ItemArmor and change the name within the constructor. Note that the constructor that you’re overriding is a bit more complex than the sword:Now you can create and register a full set of armor in the ModItems class:You’ll need to create a model class as above for each of the four pieces of armor and add them to the ItemRenderRegister.registerItemRenderer() method. The files can be downloaded from minecraftlevel1 and should be placed in assets.tutorial.textures.items.For armor, though, we’ll also need to add some special texture layer files that will be used when the armor is placed on the player. Create a new package under src/resources: assets.tutorial.textures.models.armor Save the images from minecraftlevel1 and place in the newly created package. The names here are very important. techwise_armor_layer_1.png and techwise_armor_layer_2.pngLaunch client. Your armor is now complete!References: - Contains ton more tutorials and was the best source that I found while learning mods. Much of the above tutorial was adapted from this online resource. ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- level 1 reading books printables
- dod fm level 1 certification
- level 1 readers printables
- minecraft unblocked minecraft jar 1.8
- minecraft java 1 8 1 free download
- minecraft forge 1 15 1 free download
- minecraft forge 1 16 1 download
- algebra 1 khan academy video
- minecraft unblocked minecraft jar 1 8
- minecraft bedrock 1 16 1 hacked client
- pearson edexcel level 1 level 2 gcse 9 1 mathematics
- pearson edexcel level 1 level 2 gcse 9 1