Jump to content

Recommended Posts

Posted
59 minutes ago, TheRPGAdventurer said:

how abut this one?

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

This does nothing useful.

You're saying "this dragon is now sheared" and the function goes "Ok!" and the state of the dragon (whether or not it has been sheared) doesn't change.

There's a reason it's called a setter. It sets a 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.

Posted
Just now, Draco18s said:

This does nothing useful.

You're saying "this dragon is now sheared" and the function goes "Ok!" and the state of the dragon (whether or not it has been sheared) doesn't change.

There's a reason it's called a setter. It sets a field.

@Override 
    public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos) {
        return (item != null && item.getItem() == ModTools.DiamondShears && !this.isChild());
         
    }

    @Override
    public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) {

        java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
            ret.add(new ItemStack(this.getShearDropItem()));

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

It works now but how do I make it like, shear once wait another time to shear agan not comtinously keep shearing it and shearing items.

Posted
50 minutes ago, TheRPGAdventurer said:

It works now but how do I make it like, shear once wait another time to shear agan not comtinously keep shearing it and shearing items.

I am literally telling you how to make it so in this entire thread but you are doing something else and asking why is it not working.

 

1. Create a field/DataManager param that stores the amount of ticks left before the mob can be sheared.

2. Check if this value lequals 0 in your isShearable method

3. Set it to the desired cooldown in onSheared method

4. Decrement it each tick.

And you are done. 

  • 7 months later...
Posted
On 7/8/2017 at 9:32 PM, diesieben07 said:

A better solution would be to store the world time when the entity is sheared and then check how long has passed by calculating the difference to the current time. 

Sorry for necroing but the time I posted this I didn't really understand java and modding itself and didn't obey the advice to learn java before modding minecraft, I improved now. So can I ask the question, if world.getWorldTime to get the World time how do I get the current time.

Posted
54 minutes ago, diesieben07 said:

I really don't understand that sentence, sorry.

World::getTotalWorldTime will always give you the current world age in ticks. getWorldTime will reset when people sleep or use /time. getTotalWorldTime will not, it always ticks up.

damn one of those misleading names again, these arent that misleading tho.

Posted
On 2/26/2018 at 5:48 PM, diesieben07 said:

I really don't understand that sentence, sorry.

World::getTotalWorldTime will always give you the current world age in ticks. getWorldTime will reset when people sleep or use /time. getTotalWorldTime will not, it always ticks up.

can you give me some examples tho?

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



×
×
  • Create New...

Important Information

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