Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Forging a Minecraft mod

Basic Minecraft modding with Minecraft Forge

How to remove an item from hand?

  • 2013-08-03 10:48:22
    i dont know if im not looking on the right place or what but i cant find a method to remove the item you currently have in hand can someone help me?

  • 2013-08-03 11:04:42
    nvm i figured myself, i used the method

    player.inventory.consumeInventoryItem()

    but now i have another problem...

    im using onBlockActivated() to remove certain items from my inventory and update the metadata of the block... so far it works fine...but when i right click with empty hands it crash the game...not sure why is this happening.... here is my onBlockActivated

    @Override
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float offsetX, float offsetY, float offsteZ) {
    if(!world.isRemote){
                if (player.getHeldItem().itemID == HarvestConfigurationHandler.cuttingboardID + 256) {                
                    world.setBlockMetadataWithNotify(x, y, z, 2, 3);
                    player.inventory.consumeInventoryItem(player.getHeldItem().itemID);
                }else if(player.getHeldItem().itemID == HarvestConfigurationHandler.mixingbowlID + 256){
                    world.setBlockMetadataWithNotify(x, y, z, 4, 3);
                    player.inventory.consumeInventoryItem(player.getHeldItem().itemID);
                }else if (player.getHeldItem().itemID == HarvestConfigurationHandler.mortarandpestleID + 256){
                    world.setBlockMetadataWithNotify(x, y, z, 6, 3);
                    player.inventory.consumeInventoryItem(player.getHeldItem().itemID);
                    //BORRAR ESTO
                }else if(player.getHeldItem().itemID == HarvestConfigurationHandler.saltID + 256){
                    world.setBlockMetadataWithNotify(x, y, z, 0, 3);
                    
                }
                //HASTA AQUI
            }
            return true;
            
        }    
  • 2013-08-03 12:16:49
    It crashes because player.getHeldItem() returns the value of inventory.getCurrentItem(), which in turn returns "this.currentItem < 9 && this.currentItem >= 0 ? this.mainInventory[this.currentItem] : null;". See that null, at the end? That's your problem ;)
  • 2013-08-03 12:46:12
    Indeed, make sure that the player is actually holding an item before trying to do anything with it.
  • 2013-08-04 10:18:57
    Oh...I would never figured that out......Thanks for the help :D

    just in case somebody get stuck in the same problem i fixed it like this...

    @Override
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float offsetX, float offsetY, float offsteZ) {
            if(!world.isRemote){
                if(player.getHeldItem() != null){ //HERE I CHECK THE HAND IS NOT EMPTY
                    if (player.getHeldItem().itemID == HarvestConfigurationHandler.cuttingboardID + 256) {                
                        world.setBlockMetadataWithNotify(x, y, z, 2, 3);
                        player.inventory.consumeInventoryItem(player.getHeldItem().itemID);
                    }else if(player.getHeldItem().itemID == HarvestConfigurationHandler.mixingbowlID + 256){
                        world.setBlockMetadataWithNotify(x, y, z, 4, 3);
                        player.inventory.consumeInventoryItem(player.getHeldItem().itemID);
                    }else if (player.getHeldItem().itemID == HarvestConfigurationHandler.mortarandpestleID + 256){
                        world.setBlockMetadataWithNotify(x, y, z, 6, 3);
                        player.inventory.consumeInventoryItem(player.getHeldItem().itemID);
                        //BORRAR ESTO
                    }else if(player.getHeldItem().itemID == HarvestConfigurationHandler.saltID + 256){
                        world.setBlockMetadataWithNotify(x, y, z, 0, 3);
                        
                    }
                    //HASTA AQUI
                }else{//Other Stuff}    //HERE I CAN DO ANYTHING IF RIGHT CLICK WITH A EMPTY HAND
            }
            return true;
            
        }    
  • 2013-08-04 10:21:18
    now i can watch the Tile entities course :D
  • 2017-01-09 21:57:49
    how to use cialis
    http://pharmshop-online.com - generic cialis cialis 10 mg 4 tablet register
    <a href="http://pharmshop-online.com">generic cialis</a> - canadian pharmacy cialis 20mg posts per day
    about cialis for's and against
  • 2017-01-14 02:39:40
    dna choroba dieta dna alkohol <a href=http://seeknet.pl/>http://seeknet.pl/</a> podagra a alkohol dna moczanowa nieleczona
  • 2017-01-19 21:51:25
    co to jest dna dna alkohol <a href=http://seeknet.pl/>http://seeknet.pl/</a> dna moczanowa leczenie ziolami dieta w podagrze
  • 2017-01-20 01:19:55
    leki na podagre dna moczanowa leczenie domowe <a href=http://seeknet.pl/>http://seeknet.pl/</a> ziola na kwas moczowy leczenie dny moczanowej ziolami
  • 2017-01-20 11:01:27
    kwasica ketonowa choroba dna moczanowa objawy <a href=http://seeknet.pl/>http://seeknet.pl/</a> czego nie mozna jesc przy dnie moczanowej ziola w dnie moczanowej
  • 2017-01-20 12:20:38
    ziola dna moczanowa dna moczanowa czego nie wolno jesc <a href=http://seeknet.pl/>http://seeknet.pl/</a> dna moczanowa zywienie dna moczanowa powiklania
  • 2017-01-20 13:46:56
    dna moczanowa a alkohol dna moczanowa przyczyny <a href=http://seeknet.pl/>http://seeknet.pl/</a> dieta przy dna moczanowa choroba bogatych ludzi
  • 2017-01-20 15:22:24
    podagra jak leczyc dna moczanowa leczenie niekonwencjonalne <a href=http://seeknet.pl/>http://seeknet.pl/</a> jakie sa objawy dny moczanowej pierwsze objawy dny moczanowej
  • 2017-01-20 17:02:15
    kwasica moczanowa jak leczyc dne moczanowa ziolami <a href=http://seeknet.pl/>http://seeknet.pl/</a> co jesc przy dnie moczanowej dna moczanowa diety
  • 2017-01-20 18:55:16
    moczanowa dna dieta leczenie dna moczanowa <a href=http://seeknet.pl/>http://seeknet.pl/</a> dieta dla dny moczanowej dna moczanowa a piwo
  • 2017-01-24 05:07:36
    dna moczanowa a picie alkoholu ziola na dne moczanowa <a href=http://seeknet.pl/>http://seeknet.pl/</a> dieta podagra dna moczanowa objawy i przyczyny leczenie
  • 2017-01-24 07:39:55
    dieta na dne moczanowa dna moczanowa leczenie domowe <a href=http://seeknet.pl/>http://seeknet.pl/</a> dna moczanowa leczenie ziolami dna moczanowa a piwo
  • 2017-01-24 10:39:28
    czego nie nalezy jesc przy dnie moczanowej ziola przy dnie moczanowej <a href=http://seeknet.pl/>http://seeknet.pl/</a> dna objawy kwasica cukrzycowa
  • 2017-01-24 14:22:36
    dna moczanowa co jesc leczenie dny <a href=http://seeknet.pl/>http://seeknet.pl/</a> co to jest dna moczanowa kwasica cukrzycowa
  • 2017-01-24 17:01:03
    dieta na dne moczanowa podagra <a href=http://seeknet.pl/>http://seeknet.pl/</a> dna moczanowa czego nie wolno jesc dieta przy dnie moczowej
  • 2017-01-24 20:32:44
    dna choroba dieta podagra przyczyny <a href=http://seeknet.pl/>http://seeknet.pl/</a> czym jest dna ziola na kwas moczowy
  • 2017-01-25 03:19:45
    moczanowa dna podagra dna moczanowa <a href=http://seeknet.pl/>http://seeknet.pl/</a> leczenie dny moczanowej nieleczona dna moczanowa
  • 2017-04-12 22:06:55
    long term effect of cialis
    http://pharmashop-online.com - generic cialis
    cialis cialis vs
    <a href="http://pharmashop-online.com">generic cialis
    </a> - overcoming ed
    retalis cialis
  • 2017-04-21 14:11:05
    viagra online sales display posts from previous
    http://viagra-withoutadoctor.com - viagra without doctor prescription
    compare levitra viagra and viagra apeboard_plus.cgi?command=
    <a href="http://viagra-withoutadoctor.com">viagra without a doctor prescription
    </a> - buy viagra generic
    online pharmacy
  • 2017-04-22 13:40:37
    acheter viagra
    http://viagra-withoutdoctor.com - viagra without a doctor prescription
    viagra generic date in descending order
    <a href="http://viagra-withoutdoctor.com">viagra without a doctor prescription
    </a> - viagra dosage when to take maximum allowed
    viagra 20mg review who is online
  • 2017-05-07 04:55:30
    cialis information itrader
    http://cialiswithoutdoctor.org - cialis without a doctor's prescription
    viagra information patients most online today
    <a href="http://cialiswithoutdoctor.org">cialis without a doctor prescription usa
    </a> - viagra 20mg side effects all times are utc
    viagra doesn't seem to work for me
  • 2017-05-24 05:31:19
    viagra and alcohol side effects in total there are
    http://viagra-withoutadoctor.net - viagra without a doctor prescription
    viagra enligne
    <a href="http://viagra-withoutadoctor.net">viagra without prescription
    </a> - viagra and alcohol use registered users
    viagra s ite:komkom.pl
  • 2017-05-25 19:40:01
    viagra 10mg how long does it last no new posts
    http://viagra-withoutdoctor.net - viagra without a doctor prescription usa
    natural viagra
    <a href="http://viagra-withoutdoctor.net">viagra without a doctor prescription
    </a> - tadalafil viagra
    viagra release news
  • 2017-05-27 23:50:41
    prozac compatability with cialis
    http://viagra-withoutadoctors.com - viagra without prescription
    cialis 20mg i forgot my password
    <a href="http://viagra-withoutadoctors.com">viagra no prescription
    </a> - can cialis for women
    cialis free trial
  • 2017-05-28 04:53:17
    meth cialis and poppers
    http://viagra-withoutdoctors.com - viagra no prescription
    like cialis for heart help that insurance pays
    <a href="http://viagra-withoutdoctors.com">viagra without prescription
    </a> - cialis buy canada forum contains no new posts
    medicine including pills which is much more effective than viagra and cialis for the worst cases of
  • 2017-08-12 13:06:33
    http://revia.phartesdomusa.org buy naltrexone mexico
  • 2017-08-12 14:46:23
    http://revia.phartesdomusa.org generic naltrexone cost
  • 2017-08-27 11:21:27
    cialis vipps
    http://cialis-walmart.net - cialis over counter at walmart
    cheapest cialis internet pharmacy
    <a href="http://cialis-walmart.net">cialis over the counter at walmart
    </a> - cialis dosage remember me?
    real brand cialis no prescription
  • 2017-09-08 05:42:47
    equivalente ao cialis

    <a href="http://cialisxrm.com/">buy generic cialis</a>

    cialis dosage instructions

    <a href=http://cialisxrm.com/>buy generic cialis</a>
  • 2017-09-12 15:17:52
    viagra for women cancer most users ever online was
    http://100mg.viagra-withoutadoctor.net - viagra without a doctor prescription
    viagra from canada free samples donate
    <a href="http://100mg.viagra-withoutadoctor.net">viagra without a doctor prescription
    </a> - viagra 20mg side effects msn messenger
    viagra from canada pharmacy log out
  • 2017-09-20 11:54:36
    online discount pharmacy
    <a href="http://canadianpharmacyrxbsl.com/">canadian online pharmacies</a>
    pharmacy prescription
    <a href=http://canadianpharmacyrxbsl.com/?side-effects-of-methylprednisolone>side effects of methylprednisolone</a>
    web medical information
    <a href="http://canadianpharmacyrxbsl.com/?metformin-contraindications">metformin contraindications</a>
  • 2017-09-21 10:02:28
    drugs from canada
    <a href="http://canadianpharmacyrxbsl.com/">canadian pharmacy</a>
    ed meds online
    <a href=http://canadianpharmacyrxbsl.com/?canadian-pharmacy-viagra-brand>canadian pharmacy viagra brand</a>
    drug price
    <a href="http://canadianpharmacyrxbsl.com/?prednisone-for-dogs-side-effects">prednisone for dogs side effects</a>
  • 2017-09-21 18:14:49
    northwestpharmacy
    <a href="http://canadianpharmacyrxbsl.com/">canadian pharmacy</a>
    pharmacy canada
    <a href=http://canadianpharmacyrxbsl.com/?amoxicillin-500mg>amoxicillin 500mg</a>
    meds online
    <a href="http://canadianpharmacyrxbsl.com/?lasix-medication">lasix medication</a>
  • 2017-09-21 23:54:16
    canada pharmacy online orders
    <a href="http://canadianpharmacyrxbsl.com/">canadian online pharmacies</a>
    global pharmacy canada
    <a href=http://canadianpharmacyrxbsl.com/?metoprolol-nebenwirkungen>metoprolol nebenwirkungen</a>
    walmart pharmacy price check
    <a href="http://canadianpharmacyrxbsl.com/?cialis-cheap">cialis cheap</a>
  • 2017-09-22 08:25:07
    best online canadian pharcharmy
    <a href="http://canadianpharmacyrxbsl.com/">canadian pharmacy</a>
    drugs online
    <a href=http://canadianpharmacyrxbsl.com/?cialis-for-bph>cialis for bph</a>
    canada drugs online
    <a href="http://canadianpharmacyrxbsl.com/?canadian-pharmacies-that-ship-to-us">canadian pharmacies that ship to us</a>
  • 2017-10-14 09:29:39
    ?????. ????? 12 ?? ?? 2 ??????.
    ?? ?????, ??? ??????? ?????, ?? ? ???, ? ??????,????? ??????. ???????????? ? ?????????? ?????? ?????? ? ?????, ????? ??????????, ??? ???????? ?????-?? ?????? ??????? ? ???????? ?? ???? ????? ?????? - 2 ??????. ??? ??????? ???? ?? ??????? ??????, ?? ? ???? ??? ???????? ????????? ?? ?????? ?????. ?? ??? ?, ????? ?????. ????? 12 ?? ?? 2 ?????? - ?????? ?? ?? ??????, ?? ??? ????????????? ??, ???????, ????? ???. ? ?? ????? ???? ?????! <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy>????????? ?? ??????...</a>


    <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy><img>https://kedem.ru/photo/articles/2016/10/dieta-minus-12-kg-za-2-nedeli-01.jpg</img></a> <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy><img>https://kedem.ru/photo/articles/2016/10/dieta-minus-12-kg-za-2-nedeli-03.jpg</img></a>
  • 2017-10-16 19:47:50
    ?????. ????? 12 ?? ?? 2 ??????.
    ?? ?????, ??? ??????? ?????, ?? ? ???, ? ??????,????? ??????. ???????????? ? ?????????? ?????? ?????? ? ?????, ????? ??????????, ??? ???????? ?????-?? ?????? ??????? ? ???????? ?? ???? ????? ?????? - 2 ??????. ??? ??????? ???? ?? ??????? ??????, ?? ? ???? ??? ???????? ????????? ?? ?????? ?????. ?? ??? ?, ????? ?????. ????? 12 ?? ?? 2 ?????? - ?????? ?? ?? ??????, ?? ??? ????????????? ??, ???????, ????? ???. ? ?? ????? ???? ?????! <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy>????????? ?? ??????...</a>


    <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy><img>https://kedem.ru/photo/articles/2016/10/dieta-minus-12-kg-za-2-nedeli-01.jpg</img></a> <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy><img>https://kedem.ru/photo/articles/2016/10/dieta-minus-12-kg-za-2-nedeli-03.jpg</img></a>
  • 2017-10-17 10:19:12
    ?????. ????? 12 ?? ?? 2 ??????.
    ?? ?????, ??? ??????? ?????, ?? ? ???, ? ??????,????? ??????. ???????????? ? ?????????? ?????? ?????? ? ?????, ????? ??????????, ??? ???????? ?????-?? ?????? ??????? ? ???????? ?? ???? ????? ?????? - 2 ??????. ??? ??????? ???? ?? ??????? ??????, ?? ? ???? ??? ???????? ????????? ?? ?????? ?????. ?? ??? ?, ????? ?????. ????? 12 ?? ?? 2 ?????? - ?????? ?? ?? ??????, ?? ??? ????????????? ??, ???????, ????? ???. ? ?? ????? ???? ?????! <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy>????????? ?? ??????...</a>


    <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy><img>https://kedem.ru/photo/articles/2016/10/dieta-minus-12-kg-za-2-nedeli-01.jpg</img></a> <a href=http://prikolex.ru/condiet/?xid=ysiH2wGy><img>https://kedem.ru/photo/articles/2016/10/dieta-minus-12-kg-za-2-nedeli-03.jpg</img></a>
  • Log in or sign up to reply to this thread