Jump to content

Flaxbeard

Members
  • Posts

    3
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Flaxbeard's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Alright, weird issue, they don't work until you view your inventory with E? Any idea why this could be? My code: package boiler; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class ItemMusketEmpty extends Item { /** Number of ticks to run while 'EnumAction'ing until result. */ public int itemUseDuration; boolean done; public ItemMusketEmpty(int par1) { super(par1); this.itemUseDuration = 64; this.maxStackSize = 1; done = false; //this.setCreativeTab(CreativeTabs.tabFood); } public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { //par1ItemStack = new ItemStack(BoilerMod.musket); if (!done) { par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F); } done = true; return par1ItemStack; } public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { if (done) { done = false; par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, new ItemStack(BoilerMod.musket)); } } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 64; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.block; } /** * 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) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } public String getTextureFile() { return "/boiler/items.png"; } } package boiler; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; public class ItemMusket extends Item { public ItemMusket(int par1) { super(par1); this.maxStackSize = 1; this.setMaxDamage(384); } public String getTextureFile() { return "/boiler/items.png"; } /** * 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) { int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4; ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, var6); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return; } var6 = event.charge; boolean var5 = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; if (var5 || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { 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.setIsCritical(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.itemID); } if (!par2World.isRemote) { par2World.spawnEntityInWorld(var8); } // par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, new ItemStack(BoilerMod.musketEmpty)); } } public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { return new ItemStack(BoilerMod.musket); } /** * 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) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { 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; } }
  2. Also, just maximized minecraft after having it in the background, it works now, as before, but then it just stopped. Hmm... Alright, I figured it out I think. So I have an item that changes into my bow when it's right clicked. The bow can't fire until I quit and rejoin. Why is this?
  3. I have a custom bow, currently an exact replica, shoots the same arrows as the original, but I have a similar problem to this topic: http://www.minecraftforge.net/forum/index.php?topic=1751.0. When I shoot the bow, no arrow appears. If I get rid of the !isRemote, they spawn but do not act normal similar to that topic. Any ideas?
×
×
  • Create New...

Important Information

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