Jump to content

1.10.2 Problems with making mob shearable.


TheRPGAdventurer

Recommended Posts

Hello Forge, My problem is that "ret.add(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, this.getFleeceColor().getMetadata()));" and the Item I want my mob to drop when sheared is not a block(because of Item.getItemFromBlock) but a pure Item itself,  I tried setting it to my Item according to breed but when I shear my mob it drops and untexured block with the same en_US.lang name, when I place it on the ground game crashes.

Link to comment
Share on other sites

You've been here long enough to know that without code, we can't help you.

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

Just now, Draco18s said:

You've been here long enough to know that without code, we can't help you.

@Override
    public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos) {
        return !this.isChild();
    }

    @Override
    public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
        this.setTamed(true);
        int i = 1 + this.rand.nextInt(3);

        java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
        for (int j = 0; j < i; ++j)
            ret.add(new ItemStack(Item.getItemFromBlock(ModItems.JadeDragonScales), 1, this.getBreedType().getMeta()));

        this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F);
        return ret;
    }

 

Also I want to know what to replace getItemFromBlock to make it use an Item instead of a block.

Link to comment
Share on other sites

4 minutes ago, TheRPGAdventurer said:

Item.getItemFromBlock(ModItems.JadeDragonScales)

Item::getItemFromBlock as the name implies gets you an Item from a Block. Unless ModItems.JadeDragonScales is a Block(and if it is why is it located in the ModItems class?) you are not doing things correctly.

 

4 minutes ago, TheRPGAdventurer said:

I want to know what to replace getItemFromBlock to make it use an Item instead of a block.

Just pass your ModItems.JadeDragonScales to the ItemStack constructor directly, it will figure everything out for you.

  • Like 1
Link to comment
Share on other sites

Just now, V0idWa1k3r said:

Item::getItemFromBlock as the name implies gets you an Item from a Block. Unless ModItems.JadeDragonScales is a Block(and if it is why is it located in the ModItems class?) you are not doing things correctly.

 

Just pass your ModItems.JadeDragonScales to the ItemStack constructor directly, it will figure everything out for you.

If I fixed It i will try to reply with the code to make kids or unexperienced Modders understand, also how do I change the title of this post so it can be easily found by other modders?

Link to comment
Share on other sites

9 minutes ago, TheRPGAdventurer said:

also how do I change the title of this post so it can be easily found by other modders?

 

Edit the first post of a thread to edit the thread's title.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

Item::getItemFromBlock as the name implies gets you an Item from a Block. Unless ModItems.JadeDragonScales is a Block(and if it is why is it located in the ModItems class?) you are not doing things correctly.

 

Just pass your ModItems.JadeDragonScales to the ItemStack constructor directly, it will figure everything out for you.

also what does that 1 number do?

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

Look at the constructor of the ItemStack, the names of parameters are pretty descriptive. That 1 in particular is the amount of items in the stack

dude

public boolean getSheared()
    {
        return (((Byte)this.dataManager.get(DYE_COLOR)).byteValue() & 16) != 0;
    }

    /**
     * make a sheep sheared if set to true
     */
   

 

public void setSheared(boolean sheared)
    {
        byte b0 = ((Byte)this.dataManager.get(DYE_COLOR)).byteValue();

        if (sheared)
        {
            this.dataManager.set(DYE_COLOR, Byte.valueOf((byte)(b0 | 16)));
        }
        else
        {
            this.dataManager.set(DYE_COLOR, Byte.valueOf((byte)(b0 & -17)));
        }
    }

 

what do I do with these methods, I don't have some sort of data for them, but I still want it to be sheared and wait 3 ints,

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

Please elaborate on what you are trying to achieve.

I want to make it shear once and wait another time using this on onSheared method,

                this.setSheared(true);
                int i = 1 + this.rand.nextInt(3);

 without knowing what to put on set Sheared method above and getSheared above, it doesn't work

Link to comment
Share on other sites

What is you problem exactly? Just store the delay value somewhere, decrement it each tick/time period and as it reaches 0 set the mob as not sheared(presumably by calling setSheared(false)). You don't even need a DataManager for that as the client does not need to know about the delay(unless you want it to for some rendering or something, then you need another DataParameter).  Kinda how sheep does it at EntitySheep::eatGrassBonus. 

Link to comment
Share on other sites

Just now, TheRPGAdventurer said:

I want to make it shear once and wait another time using this on onSheared method,

                this.setSheared(true);
                int i = 1 + this.rand.nextInt(3);

 without knowing what to put on set Sheared method above and getSheared above, it doesn't work

because I don't have the data like the wool block;

 

Edit: delayed

Edited by TheRPGAdventurer
Delayed
Link to comment
Share on other sites

3 minutes ago, TheRPGAdventurer said:

I don't have the data like the wool block

I assume that you can't use these methods as you do not have the DYE_COLOR data parameter as you manage your sheared items differently and don't exatcly store the wool color anywhere, correct? You do not need these methods then. Simply store your delay and it can be your isSheared indicator aswell - if it is at 0 the mob is not sheared and if it is anything else then the mob was sheared.

  • Like 1
Link to comment
Share on other sites

Just now, V0idWa1k3r said:

I assume that you can't use these methods as you do not have the DYE_COLOR data parameter as you manage your sheared items differently and don't exatcly store the wool color anywhere, correct? You do not need these methods then. Simply store your delay and it can be your isSheared indicator aswell - if it is at 0 the mob is not sheared and if it is anything else then the mob was sheared.

sorry sir it was delayed; bad typhoon in our country causing slow Internet, I was programming in the middle of the storm, while my family is panicking from lightnings and thunders,

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

I assume that you can't use these methods as you do not have the DYE_COLOR data parameter as you manage your sheared items differently and don't exatcly store the wool color anywhere, correct? You do not need these methods then. Simply store your delay and it can be your isSheared indicator aswell - if it is at 0 the mob is not sheared and if it is anything else then the mob was sheared.

How do I make my mob shift right clicking to ride it, it was conflicting with my shearing method because right clicking to shear and right clicking to ride and I want my mob to be right clicked when riding it,

Link to comment
Share on other sites

Just now, TheRPGAdventurer said:

it was conflicting with my shearing method because right clicking to shear and right clicking to ride

In what way? You can simply check if the player is holding shears or not. If they are - run the shearing code, if they are not - ride your entity.

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

In what way? You can simply check if the player is holding shears or not. If they are - run the shearing code, if they are not - ride your entity.

when my dragon is saddled and tamed and right clicked it with a shear I actually ride the dragon, I want to make it in a way that I need to Shift right click or press middle mouse when riding the saddled dragon,

Link to comment
Share on other sites

Just now, TheRPGAdventurer said:

when my dragon is saddled and tamed and right clicked it with a shear I actually ride the dragon, I want to make it in a way that I need to Shift right click or press middle mouse when riding the saddled dragon,

also can you tell me what's wrong with this 

    public boolean setSheared(boolean sheared)  {
        return false;
    }
    
    public boolean getSheared() {
        return false;
    }

    @Override 
    public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos) { 
        return !this.getSheared() && !this.isChild(); }
    @Override
    public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
    {
        this.setSheared(true);
        int i = 1 + this.rand.nextInt(3);

        java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
        for (int j = 0; j < i; ++j)
            ret.add(new ItemStack(this.getDropItem(), 1));

        this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F);
        return ret;
    }
}

 

it gives me in the console a FATAL ERROR yet it still drops the item I set to it.         

Link to comment
Share on other sites

If you want a custom keybind you can't use the default methods, you will need custom packets. 

The problem with shift-right clicking is that shift is the default keybind to stop riding an entity(or rather it is a sneak keybind and sneaking is what makes you dismount) and that is defined in EntityPlayer so you can't change that.

 

6 minutes ago, TheRPGAdventurer said:

public boolean setSheared(boolean sheared)  {
        return false;
    }

?

 

6 minutes ago, TheRPGAdventurer said:

public boolean getSheared() {
        return false;
    }

If you are creating getters and setters make them have a purpose. 

 

6 minutes ago, TheRPGAdventurer said:

it gives me in the console a FATAL ERROR

Post the log then.

Edited by V0idWa1k3r
Link to comment
Share on other sites

Just now, V0idWa1k3r said:

If you want a custom keybind you can't use the default methods, you will need custom packets. 

The problem with shift-right clicking is that shift is the default keybind to stop riding an entity(or rather it is a sneak keybind and sneaking is what makes you dismount) and that is defined in EntityPlayer so you can't change that.

 

?

 

If you are creating getters and setters make them have a purpose. 

 

Post the log then.

1. what do you mean give them a purpose? I  don't have the data like in the wool blocks of the sheep, some sort of return them to true?

 

Link to comment
Share on other sites

Just now, TheRPGAdventurer said:

what do you mean give them a purpose?

I literally mean to give them a purpose. Why do you have a method that does nothing? If you do not need them - drop them, you are returning false to begin with and that is a constant value. If you want them to do something - introduce the code to do so. 

2 minutes ago, TheRPGAdventurer said:

I  don't have the data like in the wool blocks of the sheep

That is irrelevant. The names of methods imply that they are getters and setters for whether your entity was sheared or not. If you do not need them - delete them, this is your own code. If they are supposed to be setters and getters for a value - introduce that value with a field or a DataParameter in the DataManager. This is a basic java concept.

 

I'm not telling you to do that because of code cleanup or something like that. I'm telling you to do so because you are still using those methods as getters and setters which they are not in their current implementation and that can lead to potential issues.

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

I literally mean to give them a purpose. Why do you have a method that does nothing? If you do not need them - drop them, you are returning false to begin with and that is a constant value. If you want them to do something - introduce the code to do so. 

That is irrelevant. The names of methods imply that they are getters and setters for whether your entity was sheared or not. If you do not need them - delete them, this is your own code. If they are supposed to be setters and getters for a value - introduce that value with a field or a DataParameter in the DataManager. This is a basic java concept.

 

I'm not telling you to do that because of code cleanup or something like that. I'm telling you to do so because you are still using those methods as getters and setters which they are not in their current implementation and that can lead to potential issues.

how abut this one?

private boolean getSheared() {
        return true;
    }
    
    public boolean setSheared(boolean sheared) {
        return sheared;
    }

Link to comment
Share on other sites

Just now, TheRPGAdventurer said:

how abut this one?

private boolean getSheared() {
        return true;
    }
    
    public boolean setSheared(boolean sheared) {
        return sheared;
    }

Okay now I fixed it's riding and shearing ability without changing the controls.

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

    • DAFTAR DAN LOGIN DISINI   Hantogel atau handogel adalah bentuk pengumpulan duka uang yang populer di dunia judi online, khususnya dalam permainan slot gacor. Banyak situs judi online yang menawarkan handogel slot gacor, dan sebagai pemain, penting untuk mengetahui cara memilih dan mengakses situs tersebut dengan aman dan amanah. Dalam artikel ini, kami akan membahas cara memilih situs slot gacor online yang berkualitas dan tahu cara mengakses handogelnya.
    • DAFTAR & LOGIN SIRITOGEL Siritogel adalah kumpulan kata yang mungkin baru saja dikenal oleh masyarakat, namun dengan perkembangan teknologi dan banyaknya informasi yang tersedia di internet, kalau kita siritogel (mencari informasi dengan cara yang cermat dan rinci) tentang situs slot gacor online, maka kita akan menemukan banyak hal yang menarik dan membahayakan sama sekali. Dalam artikel ini, kita akan mencoba menjelaskan apa itu situs slot gacor online dan bagaimana cara mengatasi dampaknya yang negatif.
    • This honestly might just work for you @SubscribeEvent public static void onScreenRender(ScreenEvent.Render.Post event) { final var player = Minecraft.getInstance().player; if(!hasMyEffect(player)) return; // TODO: You provide hasMyEffect float f = Mth.lerp(event.getPartialTick(), this.minecraft.player.oSpinningEffectIntensity, this.minecraft.player.spinningEffectIntensity); float f1 = ((Double)this.minecraft.options.screenEffectScale().get()).floatValue(); if(f <= 0F || f1 >= 1F) return; float p_282656_ = f * (1.0F - f1); final var p_282460_ = event.getGuiGraphics(); int i = p_282460_.guiWidth(); int j = p_282460_.guiHeight(); p_282460_.pose().pushPose(); float f = Mth.lerp(p_282656_, 2.0F, 1.0F); p_282460_.pose().translate((float)i / 2.0F, (float)j / 2.0F, 0.0F); p_282460_.pose().scale(f, f, f); p_282460_.pose().translate((float)(-i) / 2.0F, (float)(-j) / 2.0F, 0.0F); float f1 = 0.2F * p_282656_; float f2 = 0.4F * p_282656_; float f3 = 0.2F * p_282656_; RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(SourceFactor.ONE, DestFactor.ONE, SourceFactor.ONE, DestFactor.ONE); p_282460_.setColor(f1, f2, f3, 1.0F); p_282460_.blit(NAUSEA_LOCATION, 0, 0, -90, 0.0F, 0.0F, i, j, i, j); p_282460_.setColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.defaultBlendFunc(); RenderSystem.disableBlend(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); p_282460_.pose().popPose(); }   Note: Most of this is directly copied from GameRenderer as you pointed out you found. The only thing you'll have to likely do is update the `oSpinningEffectIntensity` + `spinningEffectIntensity` variables on the player when your effect is applied. Which values should be there? Not 100% sure, might be a game of guess and check, but `handleNetherPortalClient` in LocalPlayer has some hard coded you might be able to start with.
    • Dalam dunia perjudian online yang berkembang pesat, mencari platform yang dapat memberikan kemenangan maksimal dan hasil terbaik adalah impian setiap penjudi. OLXTOTO, dengan bangga, mempersembahkan dirinya sebagai jawaban atas pencarian itu. Sebagai platform terbesar untuk kemenangan maksimal dan hasil optimal, OLXTOTO telah menciptakan gelombang besar di komunitas perjudian online. Satu dari banyak keunggulan yang dimiliki OLXTOTO adalah koleksi permainan yang luas dan beragam. Dari togel hingga slot online, dari live casino hingga permainan kartu klasik, OLXTOTO memiliki sesuatu untuk setiap pemain. Dibangun dengan teknologi terkini dan dikembangkan oleh para ahli industri, setiap permainan di platform ini dirancang untuk memberikan pengalaman yang tak tertandingi bagi para penjudi. Namun, keunggulan OLXTOTO tidak hanya terletak pada variasi permainan yang mereka tawarkan. Mereka juga menonjol karena komitmen mereka terhadap keamanan dan keadilan. Dengan sistem keamanan tingkat tinggi dan proses audit yang ketat, OLXTOTO memastikan bahwa setiap putaran permainan berjalan dengan adil dan transparan. Para pemain dapat merasa aman dan yakin bahwa pengalaman berjudi mereka di OLXTOTO tidak akan terganggu oleh masalah keamanan atau keadilan. Tak hanya itu, OLXTOTO juga terkenal karena layanan pelanggan yang luar biasa. Tim dukungan mereka selalu siap sedia untuk membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan respon cepat dan solusi yang efisien, OLXTOTO memastikan bahwa pengalaman berjudi para pemain tetap mulus dan menyenangkan. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi pilihan utama bagi jutaan penjudi online di seluruh dunia. Jika Anda mencari platform yang dapat memberikan kemenangan maksimal dan hasil optimal, tidak perlu mencari lebih jauh dari OLXTOTO. Bergabunglah dengan OLXTOTO hari ini dan mulailah petualangan Anda menuju kemenangan besar dan hasil terbaik!
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.   Kesimpulan OLXTOTO adalah situs slot gacor terbaik yang memberikan pengalaman bermain judi slot online yang tak terlupakan. Dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering, OLXTOTO menjadi pilihan terbaik bagi para pemain yang mencari kesenangan dan kemenangan besar dalam perjudian online. Di samping itu, OLXTOTO juga menawarkan layanan pelanggan yang ramah dan responsif, siap membantu setiap pemain dalam mengatasi masalah teknis atau pertanyaan seputar perjudian online. Kami menjaga integritas game dan memberikan lingkungan bermain yang adil serta menjalankan kebijakan perlindungan pelanggan yang cermat. Bergabunglah dengan OLXTOTO sekarang dan nikmati pengalaman bermain slot online yang luar biasa. Jadilah bagian dari komunitas perjudian yang mengagumkan ini dan raih kesempatan untuk meraih kemenangan besar. Dapatkan akses mudah dan praktis ke situs OLXTOTO dan rasakan sensasi bermain judi slot yang tak terlupakan.  
  • Topics

×
×
  • Create New...

Important Information

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