Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • Author

I have a basic EntityFile and i added the possibility that u can load vehicles from a .txt file. Now i need to register a new instance of my generic vehicle rendering class to an entityclass. This entityclass should be a slightly changed version of the basic VehicleClass. So i need to add the vehiclename to the class to make it anotherclass with a new renderer. Since Entityclasses can only have one bound renderer. Sorry if i missspell something im german ( half german -half english)

  • Author

But somehow the Flansmod maker makes this too. He just need the vehiclefile and then it generates everything by itself. Probably like if i just make new instances and load the models to a global list and search for them in the renderer every time.

Like Map<String,IModelCustom>=new HashMap<String,IModelCustom>

While the String takes in the VehicleName and then when the entityvehicle.class is rendered, it will get the IModelCustom from a method?

Renderer is assigned to Entity.class, not an instance. Period.

 

If you are loading other entities from .txt you should STILL have one renderer for all of them, you will just make renderer correspond to given name of entity. (e.g return model from entity's NBT).

 

What you can do is to use Forge's class loader to load new classes into your mod (like an non-@Mod addon to your mod).

You can use reflection to load any .class in runtime and then register it.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

  • Author

No - you don't understand me. DAMN - I have one renderer. Only thing i need is to have a possibility to save different cars with their values. Cuz if i load new cars from .txt every time i need to somehow keep the data. SO what to do? Okay wit - probably im wrong so - i tried some reflection and it didn't work properly.

It's either me not getting what you need, or you not describing what you need correctly.

Java is not dynamic language (okay, reflection kinda is, but that is not 'simple java'), you can't "just" grab something and modify it (talking about classes).

 

Anyway, what you probably need is to change your design.

Loading part:

1. You read .txt files

2. You save that data to some class that will hold it for you, e.g "VehicleStructure".

3. You save those objects in some Map<String, VehicleStructure>.

5. You make some nice wrapping for getting that data.

 

Entity part (your VaehicleBase):

1. When player spawns vehicle, you search your map for name player provided and you apply that loaded-from-txt data (stored in VehicleStructure) to your VehicleBase.

2. Your Renderer is asigned to VehicleBase and uses VehicleStructure field (assigned to VehicleBase instance) to render stuff.

3. And yes - you need to synchronize it. (spawn packet).

 

Also - you can then save that VehicleStructure to world (WorldSaveData) or even entity itself. So that would answer your:

  On 8/6/2015 at 2:38 PM, ItsAMysteriousOfficial said:

i need to somehow keep the data.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Okay - ill try to describe it in detail what i do right now:

 

1. I load the files

2. The data from the files is stored in a VehicleFile.class

3. The VehicleFile classes are stored in the VehicleList

4. The ClientProxy loops through the list and generates a new item for each vehicle, generating a json file with the containing texture etc.

 

From there i don't know how to carry on...

 

 

I was just going through this thought process myself. I'm making a bunch of entities that look different (different textures and slightly different models) but otherwise mostly act the same.

 

You basically have two different approaches that I can think of to handle this:

 

1) create one "super" renderer class, and one "super" model class. For each of these you make a constructor that takes in all the things that would make an entity different. For example, your constructor to the renderer can have different textures, your constructor to the model could have an enum to indicate whether your car should be a minivan, truck, etc. Then the code for each of these classes would take that information and change behavior accordingly. So creating different instances would be as easy as just passing different textures and other parameters when you register the renderer with the model in your proxy.

 

2) Create a renderer and/or model class for every different case. While this sounds like a bit of work, it actually only takes a couple seconds to copy a class in Eclipse. My only tip is to make sure you get the original class working well before copying it a bunch of times, otherwise each time you have to fix a bug it will require editing more classes. But anyway, it really isn't that much work to copy classes and edit to your liking.

 

In your case of customizing the vehicles based on a txt file resource, I would suggest the first approach. You can simply make your renderer and model classes to have constructors that take the info from the txt file.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

Yea im doing that look:

SuperEntityClass:

 

Reveal hidden contents

 

 

SuperRenderer

 

Reveal hidden contents

 

 

Class that stores the VehicleFiles:

 

Reveal hidden contents

 

 

  • Author

Okay, now im getting that strange error:

 

Reveal hidden contents

 

Jabelar,

I tended to go your option 2, but I am finding updating to 1.8 is making me second guess that.  It is annoying to go into each one and adjust it.  With a master one, I could just fix it in one place.

Long time Bukkit & Forge Programmer

Happy to try and help

  • Author

Heres a version without debug println's

 

Reveal hidden contents

 

  • Author

So i know have fixed all possible bugs in th loading process and this error seems to appear at any other entity of mine too. Somehow Minecraft can't render the shadow/fire of the entity.Any suggestions?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.