In this section of Entity Tutorial, i will be adding multiple things, such as too follow:
No.1 ~ Saddled Entity
No.2 ~ Ride able Entity ("Without Saddle Item Use")
No.3 ~ Evolve Entity on Item Use
No.4 ~ Evolve Entity on Death
No.5 ~ Evolve Entity on Temperature ("how bright an area is")
No.6 ~ Gui Opening on Interaction
No.7 ~ Gui Opening on Interaction ("With a Certain Object")
Split off No.1:Saddled Entity
Split off No.2: Ride able Entity
Split off No.3: Evolution on Item Use
EntityNameHere (This Chunk of Code goes into your Entity File, below the top stats.)
package net.minecraft.src;
import java.util.Random;
public class ItemBowIron extends Item
{
public ItemBowIron(int par1)
{
super(par1);
maxStackSize = 1;
setMaxDamage(5000);
this.setTabToDisplayOn(CreativeTabs.tabCombat);
}
public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
{
EntityPlayer entityplayer = (EntityPlayer)entity;
ItemStack itemstack1 = entityplayer.inventory.getCurrentItem();
if(entityplayer.isUsingItem() && itemstack1.itemID == mod_EmeraldPlus.bowIron.shiftedIndex)
{
int k = itemstack.getMaxItemUseDuration() - entityplayer.getItemInUseCount();
if (k >= 18) {
iconIndex = mod_EmeraldPlus.bowIron4;} else if(k > 13) {
iconIndex = mod_EmeraldPlus.bowIron3;} else if(k > 0) {
iconIndex = mod_EmeraldPlus.bowIron2;}
} else {
iconIndex = mod_EmeraldPlus.bowIron1;}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
boolean var5 = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
if (var5 || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(par2World, par3EntityPlayer, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.func_70243_d(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0)
{
var8.setFire(100);
}
par1ItemStack.damageItem(1, par3EntityPlayer);
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (var5)
{
var8.canBePickedUp = 2;
}
else
{
par3EntityPlayer.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
}
if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(var8);
}
}
}
public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return par1ItemStack;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex))
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
}
return par1ItemStack;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
Rollback Post to RevisionRollBack
"A sound soul, dwells within a sound mind, and a sound body."
Could you possibly create that furnace tutorial soon? I've been looking everywhere for a proper and updated furnace tutorial, but I haven't found one yet...
no it isnt for 1.3.2 nor 1.3.1, its for 1.2.5 D: i shall however start updating.
Im modding 2 games at this very moment haha (Minecraft + Skyrim) so i shall take some time to upload some new tutorials!
Also, im going to update the op soon to show a sneak peak at what ive been playing around with for a minecraft mod
I Will not explain much for now, i jus want to get all of the new tutorials up, then explain them all. so this will just be a copy & paste tutorial for now, just replace things as usual.
Mod_Fixeruperrer
//Coded/Tutorial by GoldenClawStudio Representatives Hawkz and 3vil_Squirrel
package net.minecraft.src;
import java.util.Random;
public class mod_Fixeruperrer extends BaseMod{
public mod_Fixeruperrer()
{
//TODO List
addNames();
setTextures();
registerBlocks();
addRecipes();
addSmelting();
}
public void addNames()
{
//***
//* This adds the name for your Item/Block then the in game name.
//***
ModLoader.addName(LimestoneBow, "Limestone Bow");
}
public void setTextures()
{
//***
//* This adds the Textures for you Item's/Block's
//***
LimestoneBow.iconIndex = ModLoader.addOverride("/gui/items.png", "/Fixeruperrer/LimestoneBow.png");
}
public void registerBlocks()
{
//***
//* This will register the block. (This Has to be added if you're making a block no items go here)
//***
}
public void addRecipes()
{
//***
//* Be Creative! This part will be how you craft your Item's/Block's
//***
ModLoader.addRecipe(new ItemStack(LimestoneBow, 1), new Object[] {
"ab ", "a b", "ab ", Character.valueOf('a'), Block.dirt, Character.valueOf('b'), Item.stick
});
}
public void addSmelting()
{
//***
//* This part is where we add our Smelting Recipes.
//***
}
//***
//* This is where we Register our Items/Blocks for the part below.
//***
public static Item LimestoneBow;
public static int LimestoneBow1 = ModLoader.addOverride("/gui/items.png", "/Fixeruperrer/LimestoneBow1.png");
public static int LimestoneBow2 = ModLoader.addOverride("/gui/items.png", "/Fixeruperrer/LimestoneBow2.png");
public static int LimestoneBow3 = ModLoader.addOverride("/gui/items.png", "/Fixeruperrer/LimestoneBow3.png");
public static int LimestoneBow4 = ModLoader.addOverride("/gui/items.png", "/Fixeruperrer/LimestoneBow4.png");
static
{
//***
//* This is where the fun begins with some food and blocks.
//***
LimestoneBow = (new ItemLimestoneBow(1001)).setItemName("LimestoneBow");
}
public String getVersion()
{
//***
//* This is where we name our mod.
//***
return "Fixer Uper'er - 1.2.5";
}
public void load()
{
//***
//* This is where Some NPC Stuff will go.
//***
}
}
ItemLimestoneBow
package net.minecraft.src;
import java.util.Random;
public class ItemLimestoneBow extends Item
{
public ItemLimestoneBow(int par1)
{
super(par1);
maxStackSize = 1;
setMaxDamage(384);
}
public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
{
EntityPlayer entityplayer = (EntityPlayer)entity;
ItemStack itemstack1 = entityplayer.inventory.getCurrentItem();
if(entityplayer.isUsingItem() && itemstack1.itemID == mod_Fixeruperrer.LimestoneBow.shiftedIndex)
{
int k = itemstack.getMaxItemUseDuration() - entityplayer.getItemInUseCount();
if (k >= 18) {
iconIndex = mod_Fixeruperrer.LimestoneBow4;} else if(k > 13) {
iconIndex = mod_Fixeruperrer.LimestoneBow3;} else if(k > 0) {
iconIndex = mod_Fixeruperrer.LimestoneBow2;}
} else {
iconIndex = mod_Fixeruperrer.LimestoneBow1;}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex))
{
int i = getMaxItemUseDuration(par1ItemStack) - par4;
float f = (float)i / 20F;
f = (f * f + f * 2.0F) / 3F;
if ((double)f < 0.10000000000000001D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);
if (f == 1.0F)
{
entityarrow.arrowCritical = true;
}
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack);
if (j > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack);
if (k > 0)
{
entityarrow.func_46023_b(k);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0)
{
entityarrow.setFire(100);
}
par1ItemStack.damageItem(1, par3EntityPlayer);
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (!flag)
{
par3EntityPlayer.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
}
else
{
entityarrow.doesArrowBelongToPlayer = false;
}
if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(entityarrow);
}
}
}
public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return par1ItemStack;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 0x11940;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex))
{
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
}
return par1ItemStack;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
ItemTutorialNo# 2 - Fertilizer
I Will not explain much for now, i jus want to get all of the new tutorials up, then explain them all. so this will just be a copy & paste tutorial for now, just replace things as usual.
Mod_Fixeruperrer
//Coded/Tutorial by GoldenClawStudio Representatives Hawkz and 3vil_Squirrel
package net.minecraft.src;
import java.util.Random;
public class mod_Fixeruperrer extends BaseMod{
public mod_Fixeruperrer()
{
//TODO List
addNames();
setTextures();
registerBlocks();
addRecipes();
addSmelting();
}
public void addNames()
{
//***
//* This adds the name for your Item/Block then the in game name.
//***
ModLoader.addName(LimestoneF, "Limestone Fertilizer");
}
public void setTextures()
{
//***
//* This adds the Textures for you Item's/Block's
//***
LimestoneF.iconIndex = ModLoader.addOverride("/gui/items.png", "/Fixeruperrer/LimestoneF.png");
}
public void registerBlocks()
{
//***
//* This will register the block. (This Has to be added if you're making a block no items go here)
//***
}
public void addRecipes()
{
//***
//* Be Creative! This part will be how you craft your Item's/Block's
//***
ModLoader.addRecipe(new ItemStack(LimestoneF, 1), new Object[] {
"aa", Character.valueOf('a'), Block.dirt
});
}
public void addSmelting()
{
//***
//* This part is where we add our Smelting Recipes.
//***
}
//***
//* This is where we Register our Items/Blocks for the part below.
//***
public static Item LimestoneBow;
static
{
//***
//* This is where the fun begins with some food and blocks.
//***
LimestoneF = (new ItemLimestoneF(1002)).setItemName("LimestoneF");
}
public String getVersion()
{
//***
//* This is where we name our mod.
//***
return "Fixer Uper'er - 1.2.5";
}
public void load()
{
//***
//* This is where Some NPC Stuff will go.
//***
}
}
Well isnt that helpful...
Sorry haha!
I Keep forgetting to update that! *facepalm*
Im currently working on other stuff, when i get back into mc i will update them!
Im modding 2 games at this very moment haha (Minecraft + Skyrim) so i shall take some time to upload some new tutorials!
Also, im going to update the op soon to show a sneak peak at what ive been playing around with for a minecraft mod
~GCS
I don't understand how i implement my own custom Draw Back "animation"!
I have no idea if this works.