Jump to content

How Do I Dispense A Custom Throwable Entity? (1.10.2)


gurujive

Recommended Posts

I have put the past 5-6 hours into looking for a way to dispense a throwable entity instead of a throwable entities' item.

 

I have created a class within a new package/folder like so:

 

package guru.tbe.entity.DispenseProjectiles;

import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.dispenser.IPosition;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;

public abstract class BehaviorDispense extends BehaviorDefaultDispenseItem
{
    /**
     * Dispense the specified stack, play the dispense sound and spawn particles.
     */
    public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
    {
        World world = source.getWorld();
        IPosition iposition = BlockDispenser.getDispensePosition(source);
        EnumFacing enumfacing = (EnumFacing)source.func_189992_e().getValue(BlockDispenser.FACING);
        IProjectile iprojectile = this.getProjectileEntity(world, iposition, stack);
        iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.getProjectileVelocity(), this.getProjectileInaccuracy());
        world.spawnEntityInWorld((Entity)iprojectile);
        stack.splitStack(1);
        return stack;
    }

    /**
     * Play the dispense sound from the specified block.
     */
    protected void playDispenseSound(IBlockSource source)
    {
        source.getWorld().playEvent(1002, source.getBlockPos(), 0);
    }

    /**
     * Return the projectile entity spawned by this dispense behavior.
     */
    protected abstract IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn);

    protected float getProjectileInaccuracy()
    {
        return 6.0F;
    }

    protected float getProjectileVelocity()
    {
        return 1.1F;
    }
}

 

I have been reading for hours and I still don't know where to go from here, or what to do next.

To be honest I've been looking for a way to solve this for months... and I haven't been able to find any info that actually helps with accomplishing this task.

 

Any help is nice.  ???

Link to comment
Share on other sites

You need to actually make a real projectile class, i.e. not an abstract one. Easiest way is to extend EntityThrowable and override #onImpact to do what you want; remember to register the entity and entity renderer classes.

 

Then in your dispenser behavior implementation, create a new YourThrowableEntity instance and spawn it.

 

And yes, you have to register your dispenser behavior - the following was in 1.8, probably something similar these days:

BlockDispenser.dispenseBehaviorRegistry.putObject(yourItem, new YourCustomDispenserBehavior());

Link to comment
Share on other sites

Well you are making all of your classes abstract... do you know what that means? That means you can't actually instantiate them, i.e. you can't use them the way you seem to think you can, unless somewhere else you are actually making a concrete class implementation?

 

Show your concrete class implementations for the Entity AND the dispenser behavior.

Show where you register your Entity class.

Show where your register your dispenser behavior.

Show where you register your Entity's Render factory.

 

All of those things must be done or it won't work at all - this has nothing to do with 1.10.2 vs. 1.8 or other versions - you have do do all of those things regardless of version, they're just done slightly differently.

Link to comment
Share on other sites

How do i register the dispenser behavior?

Already showed you - you just have to check and see if it still works in 1.10.2. If it doesn't, I bet BlockDispenser will have something similar, or you can use your IDE to find where other dispenser behaviors are registered.

BlockDispenser.dispenseBehaviorRegistry.putObject(yourItem, new YourCustomDispenserBehavior());

BUT, you can't do that until you have non-abstract versions of your classes.

 

I still don't see where you register your projectile entity?

 

Am I correct in assuming that e.g. EntityFireOrb extends your abstract EntityOrb class?

 

Note: I'm not going to download random files from you, sorry. Post code using Pastebin, Gist, or create an online repository such as with GitHub.

Link to comment
Share on other sites

gimme a friggin screen shot of an example or something then rather than bs'n me

 

Insult or not, you are being less than friendly. I simply asked you if you knew how to search through the MC source? If you do not, I will teach you how.

 

No one is giving you crap or misleading you either, you have a problem, we have given solutions. The solution coolAlias gave for registering dispenser behaviours would be valid if the mappings hadn't changed in 1.10.2(dispenseBehaviorRegistry is now DISPENSE_BEHAVIOR_REGISTRY); since you did not open BlockDispenser and find that out yourself, I am assuming you do not know how to search the MC source. If a solution isn't clear, ask for clarification.

Link to comment
Share on other sites

A dispenser can only dispense items, you cannot put an Entity in it's inventory. Hence the interface is called IBehaviourDispenseItem, because it defines how the dispenser should behave when it dispenses a certain Item. However you can create and register an IBehaviorDispenseItem to spawn an entity when an Item is dispensed.

 

If you just want your item to behave like a snowball, you want BehaviorProjectileDispense. Override BehaviorProjectileDispense#getProjectileEntity() to return the appropriate Entity using an anonymous class. Examples can be found in net.minecraft.init.Bootstrap#registerDispenserBehaviors().

 

I also recommend that you investigate the options in the context menu that appears when you right-click inside the code window. I figure out how to use most things by looking at call hierarchies; The options labeled Open Type Hierarchy, Declarations and References are useful for figuring out how something works or what it does.

Link to comment
Share on other sites

I'd seriously like to know where thats copy and pasted from...

 

Nowhere, it's the result of a bit of digging through the MC source plus my knowledge of Java

 

This isn't helping at all, I'm not getting anywhere... I need like a video tutorial or something.

Like Here is how you do it and here is an example of this.

 

There are plenty of examples in the source, if you know how to find them(Which I'm happy to show you)

For example:

BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.ARROW, new BehaviorProjectileDispense()
        {
            /**
             * Return the projectile entity spawned by this dispense behavior.
             */
            protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn)
            {
                EntityTippedArrow entitytippedarrow = new EntityTippedArrow(worldIn, position.getX(), position.getY(), position.getZ());
                entitytippedarrow.pickupStatus = EntityArrow.PickupStatus.ALLOWED;
                return entitytippedarrow;
            }
        })

 

And here is some code and this is where you put it and thats that and thats how its done.

that way i can actually enjoy it.

 

This aint doin anything other than frustrating me... im just going to do something else. modding really is cool... but its not that fun.

Link to comment
Share on other sites

I do have this package located in the right place though correct?

 

As in init

 

guru.tbe.item.ItemEarthOrb

is a package and a class, it is not an Object.

 

You need to do "new ItemEarthOrb()" or reference one that already exists.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You need to reference it like this:

GuruItems.EarthOrb

 

That's your class and it's static item reference field.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

// TODO Auto-generated method stub

return null;

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Github for Windows isn't completely terrible, but yeah: I would recommend using something else.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • EXTRAWD : Daftar Bandar Togel Online Resmi Bet 100 Perak Terbaik! Situs EXTRAWD telah memperkenalkan konsep taruhan togel online resmi termurah dari semua situs dengan hanya bet 100 perak terjangkau dengan bet 100 perak ini dunia togel online resmi yang semakin berkembang telah menjawab bahwa EXTRAWD memberikan alternatif menarik bagi para penikmat situs togel resmi tuk mencari pengalaman bermain togel online resmi terjangkau bet 100 perak tanpa mengorbankan kualitas dan keamanan. Dengan bet 100 perak termurah ini, EXTRAWD selaku situs bandar togel resmi terbaik memberikan kesempatan bagi berbagai kalangan untuk ikut serta dalam permainan togel resmi tanpa harus mengeluarkan modal besar tetapi gampang meraup cuan besar dari hadiah togel terbesar ditawarkan EXTRAWD. Sebagai bandar togel resmi, EXTRAWD menjaga reputasi dan menjunjung keadilan dengan menawarkan layanan live chat EXTRAWD transparan dan terpercaya kepada para pelanggan togel online resmi dengan sistem keamanan yang canggih, EXTRAWD memastikan bahwa setiap taruhan togel online resmi diproses dengan aman dan hasilnya benar diacak dan adil. Hal ini memberikan kepercayaan kepada para pemain dari situs bandar togel terbaik bahwa mereka bermain di situs bandar togel terbaik aman dan dapat diandalkan. Dengan taruhan di EXTRAWD selaku penyedia situs togel resmi sekaligus bandar togel resmi terjangkau bet 100 perak telah membawa permainan togel online resmi menjadi solusi situs bandar togel terbaik kepada semua pemain togel online resmi tanpa harus mengeluarkan modal besar untuk bermain togel online resmi, Ini membuka pintu bagi banyak orang sebelumnya mungkin merasa enggan mencoba peruntungan permainan di situs togel resmi, Bet 100 perak membuka kesempatan besar bagi setiap pemain untuk meraih hadiah togel terbesar di berbagai pasaran togel daftar togel resmi, merasakan hadiah togel terbesar dari hasil bet 100 perak di togel online resmi EXTRAWD dengan resiko minim namun berpotensi, Buruan nikmati kesempatan ini dan daftar togel resmi.
    • Paguyuban4d💎⚡Rtp Slot 100 Asli Orang Dalam Bocoran Admin Jarwo Bermain Slot di Paguyuban4d: Sensasi Seru dan Keuntungan Nyata Bro, sist, mas, adek, wakgenk, atau siapapun yang doyan main slot online, kalian harus tau nih tentang Paguyuban4d💎⚡Rtp Slot 100 Asli. Menurut Google, Paguyuban4d adalah tempat yang paling oke buat main slot dengan sensasi seru dan keuntungan nyata yang bener-bener asli. Keuntungan Bermain di Paguyuban4d💎⚡ Dari pada main slot di tempat lain yang cuma bikin frustasi, mendingan main di Paguyuban4d💎⚡. Mereka punya RTP (Return to Player) tinggi, jadi kesempatan menang lo lebih besar. Plus, jackpotnya gacor banget, bro! Cara Deposit, Withdraw, dan Bonus di Paguyuban4d💎⚡ Gimana sih cara deposit, withdraw, dan dapetin bonus di Paguyuban4d💎⚡? Gampang bro, lo cukup masukin duit ke akun lo, main sepuasnya, terus kalo menang, langsung aja tarik duitnya. Bonusnya? Dijamin nggak nyesel deh, banyak banget! Pola Bermain yang Bikin Nagih Pola bermain di Paguyuban4d💎⚡ emang bikin nagih, bro! Setiap putaran bener-bener seru dan nggak bikin bosen. Dan yang paling asik, lo bisa main kapan aja dan di mana aja, asal ada koneksi internet! FAQ (Frequently Asked Questions): Apakah Paguyuban4d💎⚡ aman buat dimainin? Yup, gak usah khawatir, mereka punya sistem keamanan yang super canggih! Bagaimana cara mendaftar jadi member? Caranya simpel banget, bro! Kunjungi situs resminya, isi data diri, dan ikuti langkah-langkahnya. Apa saja game lain yang tersedia di Paguyuban4d💎⚡? Mereka punya berbagai macam game, termasuk slot, togel, dan live casino yang nggak kalah seru! Bagaimana cara dapetin bonus new member? Tinggal daftar, deposit, dan bonusnya langsung masuk ke akun lo. Mudah banget kan? Kesimpulan Pokoknya, kalo lo lagi nyari sensasi bermain slot yang bener-bener asli dan menguntungkan, langsung aja ke Paguyuban4d💎⚡. Dijamin nggak nyesel, bro! Yuk, buruan gabung dan raih kemenanganmu sekarang juga!
    • Paguyuban4d💲📢 Live HK | Hongkong | Hongkongpoolstoday Serunya Bermain Live HK di Paguyuban4d💲📢 Bro, sist, adek, atau mas, udah pada tau belum serunya bermain live HK di Paguyuban4d💲📢? Menurut Google, tempat ini emang juara dalam menyajikan pengalaman bermain yang nggak bisa lo dapetin di tempat lain. Keuntungan Bermain di Paguyuban4d💲📢 Kalo lo pengen dapet keuntungan maksimal dalam bermain game online, gak ada salahnya mampir ke Paguyuban4d💲📢, bro! Mereka punya beragam game seru, live HK yang bikin nagih, dan bonus-bonus yang menggiurkan. Cara Deposit, Withdraw, dan Bonus di Paguyuban4d💲📢 Nah, bro, sist, gue mau kasih tau nih gimana cara deposit, withdraw, dan dapetin bonus di Paguyuban4d💲📢. Pertama-tama, lo cukup daftar jadi member, lalu deposit dana ke akun lo. Kalo udah, tinggal main sepuasnya dan kalo menang, tinggal withdraw aja duitnya. Plus, jangan lupa dapetin bonus new member yang bikin semangat! Pola Bermain yang Bikin Ketagihan Di Paguyuban4d💲📢, pola bermainnya emang bikin ketagihan, bro! Setiap putaran memberikan sensasi yang berbeda dan live HK yang disajikan secara langsung bakal bikin lo makin excited. Gak heran kalo Paguyuban4d💲📢 selalu jadi pilihan utama para pecinta judi online. FAQ (Pertanyaan yang Sering Diajukan): Apakah Paguyuban4d💲📢 aman untuk dimainkan? Yup, tentu aja! Mereka udah punya reputasi bagus dan sistem keamanan yang canggih. Bagaimana cara mendaftar menjadi member? Caranya simpel, bro! Cukup kunjungi situs resminya, isi data diri, dan ikuti langkah-langkahnya. Apa saja permainan yang tersedia di Paguyuban4d💲📢? Mereka punya berbagai macam permainan, termasuk live HK yang bisa lo nikmatin setiap harinya. Bagaimana cara mendapatkan bonus new member? Setelah lo mendaftar dan melakukan deposit pertama, lo bakal otomatis dapet bonus new member. Seru kan? Kesimpulan Jadi, kalo lo lagi nyari pengalaman bermain live HK yang seru dan menguntungkan, Paguyuban4d💲📢 ini jawabannya, bro! Dengan beragam keuntungan dan pola bermain yang bikin ketagihan, lo bakal betah main di sini. Yuk, buruan gabung dan raih kemenanganmu!
    • Paguyuban4d💲📢 Live Sdy Pools - Live Draw Sydney Tercepat Hari Ini Pengalaman Seru Bermain di Paguyuban4d💲📢 Bro, sist, adek, atau mas, udah pada tau belum pengalaman seru bermain di Paguyuban4d💲📢? Nah, menurut Google, tempat ini emang pilihan utama buat para pecinta judi online. Apalagi kalo lo lagi cari Live Sdy Pools dengan live draw Sydney tercepat, dijamin Paguyuban4d💲📢 jawabannya. Keuntungan Bermain di Paguyuban4d💲📢 Buat lo yang suka main judi online, pasti pengen dapet keuntungan maksimal, kan? Nah, di Paguyuban4d💲📢, lo bakal dapetin itu semua. Mulai dari game-game seru, live draw Sydney tercepat, sampe bonus-bonus menggiurkan yang bakal bikin lo makin semangat. Cara Deposit, Withdraw, dan Bonus di Paguyuban4d💲📢 Pengen tau gimana cara deposit, withdraw, dan dapetin bonus di Paguyuban4d💲📢? Gampang banget, bro! Pertama, lo tinggal daftar jadi member, lalu deposit dana ke akun lo. Kalo udah, lo bisa main sepuasnya dan kalo menang, tinggal withdraw aja duitnya. Plus, lo bakal dapet bonus new member yang bikin senyum sampe ke telinga! Pola Bermain yang Bikin Nagih Di Paguyuban4d💲📢, pola bermainnya emang bikin nagih, bro! Tiap putaran memberikan sensasi yang berbeda, jadi lo pasti betah main di sini. Ditambah lagi dengan live draw Sydney tercepat yang bikin lo makin excited. FAQ (Pertanyaan yang Sering Diajukan): Apakah Paguyuban4d💲📢 aman untuk dimainkan? Tentu aja! Mereka udah punya reputasi bagus dan sistem keamanan yang canggih. Bagaimana cara mendaftar menjadi member? Caranya simpel, bro! Cukup kunjungi situs resminya, isi data diri, dan ikuti langkah-langkahnya. Apa saja permainan yang tersedia di Paguyuban4d💲📢? Mereka punya berbagai macam permainan, termasuk live draw Sydney tercepat. Ditambah lagi dengan bonus-bonus yang menggiurkan. Bagaimana cara mendapatkan bonus new member? Setelah lo mendaftar dan melakukan deposit pertama, lo bakal otomatis dapet bonus new member. Seru kan? Kesimpulan Jadi, kalo lo lagi nyari sensasi bermain judi online yang seru dan menguntungkan, Paguyuban4d💲📢 ini jawabannya, bro! Dengan live draw Sydney tercepat dan berbagai keuntungan lainnya, lo bakal betah main di sini. Yuk, buruan gabung dan raih kemenanganmu!
  • Topics

×
×
  • Create New...

Important Information

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