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

V0idWa1k3r

Members
  • Joined

  • Last visited

Everything posted by V0idWa1k3r

  1. You do not need to find a name of a method. The method you used is client-only which crashes the game, reflection isn't going to magically recreate a method for you, and the other one is public anyway. You need to modify the the FoodStats.foodSaturationLevel field. Also field_71147_cj is EntityPlayerMP.wasHungry. It makes no sense for a method to be named field_xxxxx
  2. An example of what? Overriding a method? Adding things to a list? Invoking List#sort? This is all basic java.
  3. Alternatively don't let the base implementation take care of the list for you and populate it manually in that method with your desired items in your desired order.
  4. Define "organize". Do you mean change the order of things in the tab? By default they are arranged in their registry order. You can use custom sorters by overriding CreativeTabs#displayAllRelevantItems and performing sorting on the list you get as a parameter. Obviously only do that once the list is populated with items(after the super invocation)
  5. Create a new field that will hold the reference to the foodSaturationLevel field, instantinate it as ReflectionHelper.findField and then use that field just as you would with normal java reflection. public static final Field foodStats_foodSaturationLevel = ReflectionHelper.findField(FoodStats.class, "MCPNAME", "SRGNAME"); You can learn the field's SRG name with MCPBot or locally on your computer in %user_home%/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_snapshot/%snapshot_date%/fields.csv.
  6. Well you could read forge's official docs. They are not exactly a tutorial though. Apart from that not really, I haven't seen any good tutorial. Even praised modders like McJty make numerous mistakes in their tutorials and enforce cargo-cult programming. I guess the best way to learn is to consult forge docs, look at some open-source mods that are trustworthy, look at vanilla and ask on these forums. I could recommend some repositories I've looked at and they look fine to me - here, here, here, here is mine. Anyone is also welcome to cotribute their repositories if they want to and they feel confident enough in them. Yeah, this just screams instantinating at wrong time & place. Also it likely calls client-side only code in a common environment which will crash the server. Yeah, this is the outdated way to register your entities. Entities are now registered with EntityEntry which is a IForgeRegistryEntry itself so it has a propper registry event fired for it. Basically subscribe to RegistryEvent.Register<EntityEntry> and use EntityEntryBuilder to register your entities in that event directly. Like this: @SubscribeEvent public static void onEntityRegistry(RegistryEvent.Register<EntityEntry> event) { event.getRegistry().register(EntityEntryBuilder.create().entity(YourEntity.class).id(new ResourceLocation(MODID, NAME), NETWORK_ID).name(NAME).tracker(RANGE, FREQUENCY, SEND_VELOCITY).spawn(EnumCreatureType.WANTED_TYPE, WEIGHT, MIN, MAX, BIOMES).egg(COLOR_FORE, COLOR_BACK).build()); }
  7. This is true and this is exactly why you provide 2 names for the field/method you are looking up. One is a MCP name, that works in your dev environment. The other is an SRG name for the normal "obfuscated"-ish environment. It doesn't prevent you from using reflection, just makes you do an extra lookup. Or a check for the environment.
  8. The version doesn't matter. Reflection always worked just fine. You always had to supply 2 names to it and it would always work. There is no "magic" in minecraft that makes it somehow not work with basics of the language it is written it. Minecraft is just as valid of a java application as any other one and as such is completely compatible with java's API. I have no idea what MDC is or who UpcraftLP is but they are not telling you the truth.
  9. When registering(or rather creating EntityEntry for your entity but if you are doing things correctly you are doing both on the same line of code anyway) your entities use the EntityEntryBuilder#spawn to add your entity entry to biomes listed in order for your entity to spawn in them. ...Although I suspect that whatever tutorial you are watching is telling you to use EntityRegistry. Which is an outdated way of registering entities and you should not be using it. Am I correct? As a side note I would also recommend not using tutorials on youtube at all. They are created by people who also just started modding, picked up all the wrong ideas and practices but are eager to share their discoveries with the world. I have yet to see a modern, good tutorial on youtube.
  10. There isn't even such a class in all the libraries forge uses including forge itself. This is absolute and total bollocks. I have no idea where you got that impression from but regular reflections work absolutely fine. The only catch is that you have to search 2 methods/fields at the same time - the one with the DEV name and the one with the SRG name. Forge has a utility class ReflectionHelper that allows you to pass multiple names for a field/method when getting it.
  11. Do you need a tutorial on java's reflections? What is your question here?
  12. I do not think this is possible because you don't have a reference to the entity which initiates the pathing check whatsoever. I suppose you might be able to replace the basic EntityMoveHelper with your wrapper that does the check for your specific block but this might cause incompatibilities with mods that attempt to do the same.
  13. No it isn't. FoodStats#setFoodSaturationLevel is though. So in order to modify saturation you indeed need reflection. Or I guess you could write the food stats to the NBT, modify the foodSaturationLevel tag and then read the stats from the modified NBT.
  14. If your code has any reference to that method that is invoked from common code you will crash the server. The client will not observe the model changing as soon as another player comes into range with your current implementation.
  15. Which player? There can be a lot of players on the server... And you have to account for that if your mod isn't client only. You can get the list of all players with World#playerEntities.
  16. EntityPlayerMP is the EntityPlayer of the logical server. EntityPlayer is a base class for players that other classes representing the player derive from. No player would actually be an instance of EntityPlayer. EntityPlayerSP is the player of the client for example.
  17. Depends. Players move on the client and just send the server their new position. Entirely server sided. How would a server even handle mouse clicks if it may not even have a mouse? This is entirely client-side. In general everything rendering or input related is client side only, and pretty much everything else is either common or server sided. Note that when I say server sided I mean the logical server, not the physical server. Every time you need to do something think about it. Could a dedicated server perform it? It has no controlling player, no mouse input, no keyboard input and may not even have any display at all. If it can't - then the thing you are trying to do is client based. Otherwise the server is likely the entity that needs to do it. In general the client doesn't do much at all anyway, it mostly displays stuff. Most logic runs on the server and if you have any custom logic you should run it on a server aswell. Define "not specifying the side".
  18. 1.7.10 is no longer supported on this forum. Update to a modern version of minecraft to receive support.
  19. I am not too familiar with gradle myself but I managed to find this answer on stackoverflow.
  20. Don't use the runClient/runServer gradle task. Edit your launch configurations. The ones under the "application" tab.
  21. Show what you have done and define "does not work". Obviously don't post your password though, replace it with something(*)
  22. Is something wrong with the existing option of the Twitch Launcher? It allows you to do exactly what you've told but not requiring to start the game beforehand.
  23. Click on the run configuration in the top right of the screen, select "Edit Configurations", Select your client/server configurations and put your arguments in the Program Arguments line. yes.
  24. I am pretty sure you can fake mouse input with java's Robot. From my tests it indeed triggers the MouseInputEvent.

Important Information

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

Account

Navigation

Search

Search

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.