Jump to content

1.7.10 ---> 1.10.2 - Need a Bit of Assistance Please


HalestormXV

Recommended Posts

Hello. So I am trying to upgrade and recreate a new mod for 1.10.2. I have run into a bit of a snag. One of the items I used in my 1.7.10 mod was actually one that I worked quite hard on and got it to work EXACTLY how I wanted. I seem to run into a snag though. I can't quite figure out how to update my item and convert it for 1.10.2 purposes. Mainly because of the whole item rework. Maybe you can all help me out. Honestly I kind of just need this shove so that I can start moving my items over as they all work in the same way. Quite literally because I am so pleased with how they turned out in 1.7.10 i want to literally move them over into my 1.10.2 mod under different names.

 

This is the 1.7.10 Code: http://pastebin.com/APkiV6M4

I am trying to convert the exact functionality of this code to 1.10.2 and quite frankly....I am lost. All I really did thus far in the 1.10.2 code was copy paste the Bow class and slightly edit the new ModItemBow class. I know how to create items in 1.10.2 and weapons and tools etc (and have moved a chunk of my items over). But this particular item (likely because it is bow based) is giving me a hard time.

 

I really ask if anyone could help or point me into the direction of where I can go to see. I know updating from 1.7.10 --> 1.10.2 is totally different but I know it is for certain possible.

Link to comment
Share on other sites

I believe both onItemRightClick and onPlayerStoppedUsing have been changed.

 

I know they have for sure. Actually here is the 1.10.2 code: http://pastebin.com/rEtUR9jM

 

Not a single error and the code compiles fine and the items registers just fine. But right clicking it does nothing. Doesnt charge it doesn't indicate it is being charged. And no errors thrown out either. I know that code is probably still super wrong, but ideally all i am trying to do is utilzie the item like a bow that you hold down right click on but instead of shoot an arrow it strikes lightning on entities in a certain range around you.

 

It honestly sounds quite simple and is exactly how it worked in my 1.7.10 version of the code but I dont know how to convert it to the 1.10.2 version. Examples would be great because that is how I learn. I am not just looking for answers. I am actually trying to learn how to do it in the new versions.

Link to comment
Share on other sites

Look at onItemRightClick in Item it has changed and instead of EnumAction.BLOCK use EnumAction.BOW

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Hi

 

You could look at this example

https://github.com/TheGreyGhost/MinecraftByExample/tree/1-10-2-inprogress/src/main/java/minecraftbyexample/mbe12_item_nbt_animate

 

It's in progress - the animation doesn't work 100% yet, but the gem does charge up and does something after the player has held the right click for a defined time.  Might give you a few clues.

 

-TGG

 

 

Link to comment
Share on other sites

Hi

 

You could look at this example

https://github.com/TheGreyGhost/MinecraftByExample/tree/1-10-2-inprogress/src/main/java/minecraftbyexample/mbe12_item_nbt_animate

 

It's in progress - the animation doesn't work 100% yet, but the gem does charge up and does something after the player has held the right click for a defined time.  Might give you a few clues.

 

-TGG

 

That actually helped quite a bit. I managed to get significantly further.

Here is the new code now: http://pastebin.com/N2gzJ7bF

 

However, it generates this crash.

http://pastebin.com/z1K6VrZ1

 

I know it means I am getting a null so I messed something up, but what am I doing wrong? This code is actually pulled right from my 1.7.10 and works perfectly there and it seems that none of those have changed significantly, or does it have something to do with the LivingBase?

 

EDIT: I have tried EntityPlayerMP also.

 

 

Link to comment
Share on other sites

Entity#getCollisionBoundingBox

returns

null

unless it's overridden to return something else; only Boats, Minecarts and Shulkers do this.

 

The method you want is

Entity#getEntityBoundingBox

.

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

Nailed it. I don't know how I didn't see that one. I blame staring at it for too long.

 

So now that it works properly here is the next question which once again I feel like is just me being an idiot and not thinking straight. As may see from the pastebin. This class is a base class and other classes extend from it because they have subTypes and each SubType does something different.

 

in other words. The base class is "cards" and "card_Lightning" extends "cards"

 

So in the base class in order to make sure the right "class" is being called to execute the code. (IE using the lighting card to do this effect) how should I go about doing that? Should I go with:

 

if stack.getItemDamage() == 1  (subType of Lighting)

Do the lightning function that I made above that is now working?

 

Or is there another way to do this?

 

Hopefully that makes sense. Here is the code:

http://pastebin.com/jZhEtnK0  - This is the base class that just handles all of the registering of the names and snazzy client side only text etc. etc.

 

http://pastebin.com/CB1Uddtu  - This is the lightning code that we just worked on above and is now working (when tested alone). What i need to do is call that from the base class. So that if the person is using: (stack.getItemDamage() == 3) - the lighting will happen.

 

I know it sounds like rudimentary Java and to be honest it probably is. But my brain seems to be in freeze mode atm.

Link to comment
Share on other sites

Are the cards metadata values of the same

Item

or are they separate

Item

s?

 

If they're metadata values, don't create a separate

Item

class for each one and handle all the effects in one class. If they're separate

Item

s, you don't need to check the metadata value; just handle each effect in its own class.

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

Are the cards metadata values of the same

Item

or are they separate

Item

s?

 

If they're metadata values, don't create a separate

Item

class for each one and handle all the effects in one class. If they're separate

Item

s, you don't need to check the metadata value; just handle each effect in its own class.

 

I made them as metadata values, this way in the future adding more cards will be much simpler. As I automated the registration and name generation process.

 

Yes I could handle them all in the base class and that's what it looks like I am going to do. I was trying to avoid that and I was just wondering if there is another way to do it to make the code look neater so I don't have a ton in one class. But in going over the code a number of times it really looks like there is no other way.

 

Granted commenting it neatly will make the code easily readable, however I was mainly just thinking sheer amount of scrolling through the base class lol.

 

Mainly I got the idea because in my 1.7.10 mod I used reflection to create unique living entities on the fly specific to how a player used them. But it seems no such luck with items.

 

However, I suppose I can make some helper functions in another class and just call out to them generate the lists (of like enemies, or potion effects, etc.) and stuff like that to tidy things up significantly in the base class file.

Link to comment
Share on other sites

If they're metadata values with complex effects, create a separate

Card

class with the required methods and extend this for each card type. Don't create

Item

instances/classes that are never registered.

 

In your

ItemCard

class, store an array of

Card

objects. Use the

ItemStack

's metadata value to look up the

Card

in this array and call the required methods on it.

 

If you want the card system to be extensible by other mods, you can make

Card

extend

IForgeRegistryEntry.Impl

and create an

IForgeRegistry

to store the

Card

s using

RegistryBuilder

. To store the

Card

in the

ItemStack

, either use NBT (i.e. store the registry name) or a capability (i.e. store the

Card

object).

 

Edit: I thought this thread seemed familiar. I offered you similar advice a couple of months ago.

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

If they're metadata values with complex effects, create a separate

Card

class with the required methods and extend this for each card type. Don't create

Item

instances/classes that are never registered.

 

In your

ItemCard

class, store an array of

Card

objects. Use the

ItemStack

's metadata value to look up the

Card

in this array and call the required methods on it.

 

If you want the card system to be extensible by other mods, you can make

Card

extend

IForgeRegistryEntry.Impl

and create an

IForgeRegistry

to store the

Card

s using

RegistryBuilder

. To store the

Card

in the

ItemStack

, either use NBT (i.e. store the registry name) or a capability (i.e. store the

Card

object).

 

Edit: I thought this thread seemed familiar. I offered you similar advice a couple of months ago.

 

Yes I had the other thread a few months back, i couldn't find it and plus it wasn't 1.10.2. Then summer happened so I stepped out of the field for a bit. Little did I know that 1.9.2 and later --> 1.10.2 carried over perfectly.

 

With respect to your reply/suggestion/advice, do you have any guides or tutorials that show actual implementation of this? Or perhaps know of any OpenSource projects that I can peak at to learn? The card system is in its infant stages at the moment and does only basic things, however I would for sure like to expand on it.

 

Granted the way I am doing it now works fine so far. But I always like to improve myself.

Link to comment
Share on other sites

Closest I can recommend:

https://github.com/Draco18s/Artifacts

 

Look at the ItemArtifact class.

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

There aren't many examples of the new registry system, but you can search GitHub for

net.minecraftforge.fml.common.registry.RegistryBuilder

to find mods that use it.

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

Thank you both for the tips and Draco i will study that the best I can. Last question I have rather than create a whole new thread for it is what is the new way to do potions now?

 

It appears the old method is no longer in practice or has been changed?

 

I used to use the: player.addPotionEffect(new PotionEffect(Potion.waterBreathing.getId(), 300, 10));

 

What is the new method?

 

EDIT: In parsing through the code it seems that all potion effects are now stored in something called MobEffects. So, unfortunately I am not at my computer to test this atm, but just going from that will the "new" potion method to apply effects to armor and entities be the following? Or did I miss something?

 

entityPlayer.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 300, 3));

 

I'm not looking to create new effects yet or new potions for that matter. Just looking to recycle the vanilla ones atm.

Link to comment
Share on other sites

MobEffects

stores the vanilla

Potion

instances, yes. The

PotionEffect

constructor takes the

Potion

instance directly instead of taking the numeric ID.

 

There's also the new concept of a

PotionType

, which is a collection of

PotionEffect

s. These are mainly used for potion items.

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

Ahhh  I see. Excellent. Makes sense with the way it is done now. I thank you.

 

By the way. I have finished the Cards file by applying the help everyone in this thread gave me and it works exactly as it should. So, thank you to all who helped me in this thread.

 

Here is the full code: http://pastebin.com/6St33JY2

 

One final little tid-bit that has popped up is if a player holds down the right-mouse button and doesnt have the proper reagents, the chat log SPAMS with the error message. Or if they player is not sneaking (which is a requirement to "cast an order") it will spam that error message.

 

Now I know I can fix this by writing a cooldown into the NBT of the item. But before I do that can anyone thing of or know of any other methods to do this so that the error message doesn't spam? I really can only think of writing a cooldown into the NBT of the item but perhaps someone has a better idea?

Link to comment
Share on other sites

EnderCore has an implementation of "no spam" chat messages here. Each time a "no spam" message is added to the chat, it removes any previous "no spam" messages.

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

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.



×
×
  • Create New...

Important Information

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