I got to say… the project had a lot of progress since the last post about it. In fact, I need to see what was included the last time I wrote. Wait please… I’m ready.
As always, the full project is available in GitHub
- Well lets start it simple. A .lang archive was made to give proper names for our blocks in game. This was needed because the previous test_block did evolve to a campfire, and we didn’t like the in-game name was coldcraft.blocks.tile… and it displays just Campfire.
- A recipe to the block was added, called ModCrafting.class. It’s simple. The recipe is defined in a pattern. Everything is added to the common load order in the Init phase.
- The PlayerData.class was made with the objective to create the attribute Temperature. This is a very long class to post and image of everything, so if you want, please click on the link to GitHub to see it all. Still, I will explain it.
Basically, first some properties of the class are stated, along with the constructor of the extended data of the player, and methods to assign the properties to the player. When calling a method of this class, the id of the entity holding the properties must be provided using: public static PlayerData get(EntityPlayer player)
Then we have some methods that save the properties as NBT Data (Where the data regarding of Minecraft is saved). Sadly those doesn’t work as expected or maybe we don’t now what we are doing.
Then, the interactions are stated. I’m just going to write about the first one (The other hasn’t been tested). campTemperature it’s called by the campfire (Explained below), it increases the temperature by 0.001 per tick until a limit of 6.
Lastly, setTemperature and getTemperature methods. SyncTemperature is used everytime the temperature is setted. This is needed to actually display and save the temperature. The syncing is handled by a handler (Too complex, I just need to say that is works)
- The Campfire (Previously named test_block), now it isn’t just a block, is a Tile Entity. This makes available a whole lot of functionality to the block, making available the update() method, which is called every in-game tick so it can do stuff. One important thing is that the block class still exists. This happens on the ModTileEntity.class (Its unique at the moment, thats why the generic name)
Basically, each tick Minecraft gets the location of the block, creates an area with a “apothem” of 4 blocks, checks if and entity of the type EntityPlayer (This means it looks for players) is in that area, and if true, calls the campTemperature() method in the Player Extended Properties, which as explained, increases the temperature.
And well, as always, the tile (Or anything) must be registered into Forge and Minecraft in the ModTileEntities.class… and into the Forge loading order: The TileEntity is added to the Common Proxy in the preInit, and the regular block and textures stayed the same.
- A GUI was made to display information about the temperature (GuiTempBar.class), we can call it thermometer. Currently it displays on real-time the temperature, and has a button that closes the interface.
There is also the ModGuiHandler.class (Basically is gives permission to the server and client to display things) and everything is added to the common load order in the Init phase.
- 4 items were made (3 for testing) in the ModItems.class. The important one is the one that opens the Thermometer/Temperature GUI for the player. Those are added to the common load order in the preInit phase and their textures (which are none) to the client load order in the init phase.
The item uses the event onItemRightClick to do stuff. (More events things explained below)
- Finally, the EventHandlerCommon.class , here when the player joins to world or changes of map (Ender, Nether or regular) loads the temperature attribute, but it doesn’t quite work, we guess is because the playerID changes sometimes the game starts.
LivingUpdateEvent.class is an event that happens every tick if a living entity exist. This will be used to update the temperature of the player depending on the biome he exists, for each tick.
I guess it would be nice a photo of the common load order CommomProxy.class:
And, that is all for now. We are currently working on:
- Updating the temperature of the player according to the biome.
- Deal damage
- Do some armor/sweaters
For more information, you know where to find me… or my team (Santiago Kelley and Arturo Fornes).