Jump to content

1.15 Tame Code


ninjawizard

Recommended Posts

Hey guys, i got this code from 1.12 for taming im trying to update to 1.15 here.. got some errors thou (i cant find a replament for the 'hand' variable and others):

PS- this is question about the code only, im not asking questions about MCreator..

 

//TAME CODE
    public void setTamed(boolean tamed)
    {
    	super.setTamed(tamed);
       //whatever you want your mob to do when it's tamed e.g. the wolf's class uses this to increase the mob's max health to 20 if it's tamed

    }

	public boolean processInteract(PlayerEntity player, Hand handIn)
	{
	  ItemStack itemstack = player.getHeldItem(hand);
	  if (!this.isTamed() && itemstack.getItem() == Items.APPLE && !this.isBreedingItem(itemstack))
	    {
	      if (!player.capabilities.isCreativeSettings)
	        {
	            itemstack.shrink(1);
	        }
	     if (!this.world.isRemote)
	        {
	            if (this.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, player))
	            {
	                this.setTamedBy(player);
	                this.navigator.clearPath();
	                this.setAttackTarget((LivingEntity)null);
	                this.sitGoal.setSitting(true);
	                this.setHealth(8.0F);
	                this.playTameEffect(true);
	                this.world.setEntityState(this, (byte)7);
	            }
	            else
	            {
	                this.playTameEffect(false);
	                this.world.setEntityState(this, (byte)6);
	            }
	        }
	        return true;
	    }
	
	    else if (this.isOwner(player) && !this.world.isRemote && !this.isBreedingItem(itemstack))
	    {
	         this.sitGoal.setSitting(!this.isSitting()); 
	         this.isJumping = false;
	         this.navigator.clearPath();
	         this.setAttackTarget((LivingEntity)null); 
	         return true;
	    }
	
	    return super.processInteract(player, hand);
	}

		//TAME CODE END

here is the 4 errors:

java:175: error: cannot find symbol 
     ItemStack itemstack = player.getHeldItem(hand); 
                                              ^ 
  symbol:   variable hand 
  location: class CustomEntity

java:178: error: capabilities has private access in CapabilityProvider 
         if (!player.capabilities.isCreativeSettings)

java:178: error: cannot find symbol 
         if (!player.capabilities.isCreativeSettings)

java:212: error: cannot find symbol 
       return super.processInteract(player, hand); 
                                            ^ 
  symbol:   variable hand 
  location: class CustomEntity 
4 errors 
> Task :compileJava FAILED

 

Edited by ninjawizard
Link to comment
Share on other sites

1 minute ago, diesieben07 said:
  • First of all, please use @Override when overriding methods.
  • The first and last errors are basic Java syntax problems, you are referring to a variable that does not exist. Please learn basic Java before modding.
  • Have you tried looking at the vanilla "tame this animal" code, in e.g. WoflEntity? It is pretty obvious how to change your code.

yes i look on the cow file for the taming code.. im kinda new on this im very sorry for that, im trying to learn it.... i would be greateful if you could teach me what i need to change :)

Link to comment
Share on other sites

well sir just basic, i know the variables, the functions and such, im trying to learn java for my mod, this is my situation; i got this mod for 1.12 with 60,000 downloads and these kids really want the 1.15 version, and i dont want to let them down.. the little fellows have a blast with that mod.. so i really want to update it, i use to be able to edit the code to do pretty much all i wanted on 1.12, but i had to be away for personal disease problems so i lost track off all coding changes... im trying to find a site or something that shows all new commands and such, like for example the scale mob thing i manage to fix with some help, but they removed GlState and now you scale with ms.scale.. things like that... i just cant find basic info for that..

 

the info i need help with for my mod is how to set the new variable names (like 'hand') and the one for capabilties class..

or if you could point me a tutorial for making tameable mobs for 1.15 would be great too... i really apreciate some help thou, im having a really hard time to find help.

 

PS- sorry my english im from Brazil

Link to comment
Share on other sites

13 minutes ago, diesieben07 said:

The variable hand does not exist.

Did you mean "handIn"? Seriously... this is basic programming...

that was what i talking about.. the hand variable does not exist on 1.15 but was on 1.12, thats my problem. So  i replace for hand for 'handIn' ?

Link to comment
Share on other sites

46 minutes ago, diesieben07 said:

It is YOUR CODE. The Minecraft version is irrelevant.

you are you so agressive with me man? its my first time on this forum i dont know all your rules...

anyway i guess that handIn thing fix it, now i still got 2 errors:

 


error: capabilities has private access in CapabilityProvider 
         if (!player.capabilities.isCreativeSettings)

error: cannot find symbol 
         if (!player.capabilities.isCreativeSettings) 
                                 ^ 
  symbol:   variable isCreativeSettings 
  location: variable capabilities of type CapabilityDispatcher 
2 errors

now i know is something on that capabilities thing there... can you help me? i will credit you on my mod i promisse... i got 3 mods on minecraft btw, if you want i can link them so you can take a look, maybe we can make a co-op work!

Edited by ninjawizard
Link to comment
Share on other sites

11 minutes ago, diesieben07 said:

I am "aggressive", because you are lacking basic understanding of programming.

 

I already told you, please look at the vanilla tame code. It is very easy to see how to replace your current code.

yes! i figger it out thanks! was this the correct:

!player.abilities.isCreativeMode instead of !player.capabilities.isCreativeSettings

they changed CreativeSettings to CreativeMode... you see that was what i was talking about; they change all these functions and variables from version to version, i need a place where i can see what they changed, do they make such logs? that would help a lot them i would not have to bother people cause i want to learn.

 

Now i need to make the model Sit when tamed, i got the model code ready and such, as before it worked on 1.12, now i need to update it too.. should i post it here or start a new topic?

 

thanks again!

Link to comment
Share on other sites

I need to update this 1.12 code here for 1.15:

 

public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTickTime)
     {
        CapuchinBlondEntity entitycapuchinBlond = (CapuchinBlondEntity)entitylivingbaseIn;

        
        if (entitycapuchinBlond.isSitting())
        {
            this.Head.setRotationPoint(0.5F, 17F, -1F);
			this.Body.setRotationPoint(0F, 18.5F, -0.5F);
          ...............

its a IF to make the monkey model to sit, i know i need to change EntityLivingBase and entitylivingbaseIn and maybe more, can you help me? thanks!

Link to comment
Share on other sites

i was using the wolf file as model (sit animation) and i end with this code... no luck yet

 

public void setLivingAnimations(entityIn, float limbSwing, float limbSwingAmount, float partialTick) {
        
        	if (entityIn.isSitting()) {

 

there is a 'T' before entityIn on the wolf file, but if i put it, and make the changes for it, it also dont work

Link to comment
Share on other sites

public class ModelCapuchin<T extends CapuchinBlondEntity> extends AgeableModel<T> {
	//public static class ModelCapuchin extends EntityModel<Entity> {

when i do like the wolf mob, with that 'T', i change like the wolf on this part too, but also gimme errors :(

 

 

Link to comment
Share on other sites

9 hours ago, ninjawizard said:

my friend dont be rude with me, this is a forum to help others learn how to code java for minecraft isnt it?

Telling you to learn Java before modding is not rude; it is a prerequisite for modding, and you cannot mod Minecraft without knowing Java.

This is not a Java forum; if you need help learning Java, try some of the other programming-specific forums out there (i.e. StackOverflow).

 

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

and because you use MCreator you got this far and are now bitching because you can't get something to work and you feel we should just do the work for you when you haven't even put in the effort to learn Java.

There is a reason we dislike MCreator and you are only reinforcing that opinion.

 

Learn Java.

  • Like 2
  • Thanks 1

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

1 hour ago, ninjawizard said:

and you think i dont because i use Mcreator... you are just a hater my friend. and a Mcreator-phobic

Sorry but someone had to say it so ima say it. You created a mod with MCreator or what ever it’s called. Now you want to make it work with 1.15 or what ever version you desire. The sad thing is I looked at “the code” and instantly knew how to fix the issues. Just an fwi I don’t even know the java basics and code mods for the memes. To me it seems you know nothing about java or coding for Minecraft if you want to call it that. So you come here asking people what do I gotta type here to make error go away???? All you know is how to open up an ide and paste what the internet tells you. Maybe you know what a Boolean is. Error pops up and keyboard goes brrrrr(obviously typing on safari for help).

Link to comment
Share on other sites

Before I will start commenting, I will share my words of wisdom: MCreator is NOT SUPPORTED in this forum.

 

Well there are really people like this. They think that people will just flat hand type the code for them as if magic. Well sorry to disappoint you, this is the reality. We programmers basically spent a considerable portion of our time learning this and you... you just... oh never mind. I hate MCreator and you just made that hate stronger with your toxic attitude. Go back after you are done learning basic java.

Link to comment
Share on other sites

aight guys chill out i do want to learn Java (only for MC) AND use Mcreator.. sorry but its a good tool, even for vet modders, but i understand your points there, but notice just one thing please, i never asked for Mcreator suport here, just CODE questions, i hope you can apreciate that.

 

This topic is already solved, i manage to edit the code with some help now i need just help with one code line, i will be posting another topic for it.

Link to comment
Share on other sites

52 minutes ago, ninjawizard said:

AND use Mcreator

Stop using that pile of trash immediately, if you want to learn to code stick to Java and ONLY Java. I can't describe how bad the code that abomination generates is.

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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