Sunday, January 15, 2017

Simple Coins v.1.0.0 - Release

Minecraft Forum Page - Curse Mods Page

So all in all: this project was an exercise of my ability on using Google. Only two times did I need to ask questions on the Minecraft Forum. I started off by following a guide by _Bedrock_Miner_ but then diverged from it and started to do what I wanted to do, looking up guides, tutorials, code on GitHub, asking questions on the Minecraft Forge Forum.

Of course, I didn't make any extraordinary mod that added 100x more content to the game. What amazed me the most is how easy it is to add extra content to the game, especially items and blocks. Modding for Minecraft is a good project to exercise your Java and Googling skills. I'd recommend giving it a go.

Friday, January 13, 2017

Simple Coins 0.5.2 Build - PriceInfo

So I figured out how to add trades the result in multiple items in ListItemsForEmeralds. PriceInfo needs to contain negative numbers in the constructor. So if I want to spend 1 emerald for 20 to 25 coins, I would type new PriceInfo(-20,-25). Don't agree with the way to set up this type of trade, but I'll roll with it.

Simple Coins 0.5.1 Build - Mobs drop coins now; New Villager; Forge Trading Methods

Simple Coins Curse Page

  • Emeralds cannot be converted to coins properly. This trade option has been removed for the time being. That means this trade is what is left:
  • At Tier 1:
    • 21-27 Iron Coins -> 1 Emerald
    • 24-30 Gold Coins -> 1 Emerald
  • At Tier 2:
    • 21-27 Iron Coins -> 1 Emerald
    • 24-30 Gold Coins -> 1 Emerald
  • Added new type of Villager: Banker. Banker wears a light blue robe.
  • At Tier 1:
    • 21-27 Iron Coins <-> 1 Emerald
    • 24-30 Gold Coins <-> 1 Emerald
  • At Tier 2:
    • 21-27 Iron Coins -> 1 Emerald
    • 24-30 Gold Coins -> 1 Emerald
    • 38-50 Iron Coins <- 2 Emeralds
    • 24-30 Gold Coins <- 2 Emeralds
  • 3 Nuggets are required for 1 coin.
  • 1 coin back crafts to 3 nuggets.
  • Fixed a crafting bug that would not waste nuggets and not give you a coin.
0.4.0 - Coins added to mob drops.
  • Zombies, ZombiePigmen, Husks, and ZombieVillagers have a 20% chance of
  • dropping 4 iron coins, and a 10% chance of dropping 4 coins.
  • Evokers, Vindicators and Villagers all drop 0-3 iron coins and 0-3 gold
  • coins
  • Updated to Forge

Adding Mob Drops

GitHub for this section - Go to "0.4.0 - Coins added to mob drops"

Adding mob drops was relatively easy. I made a class called EventHandlerCommon and wrote a method called onEntityDrop(LivingDropsEvent event){...}. Within the method, I initialized two Entity variables. The first one is to check in the if statements whether the mob is a certain type. For example, if I wanted to check if the mob killed was a zombie, the code would be:
if(entity instanceof EntityZombie){...}
I had two of these if statements. The first was to check if the mob killed was a zombie, zombie villager, husk, or zombie pigman. And using Math.Random() < 0.20, there would be a 20% chance 4 iron coins would drop from any of these mobs.
The second if statement would get a random number between 0-3 to drop that amount of iron coins, then again for gold coins. This would apply for villagers, evokers, and vindicators since they're all types of villagers that can use the coins as currency.

Adding a new Villager 

GitHub for this section

I initialized a VillagerProfession then a VillagerCareer. It's important to initialize the VillagerCareer with the profession in the constructor. Then I created two ITradeList[], with the appropriate possible trades (code in GitHub is self-explanatory). The first piece of the class EmeraldForItems is the item itself. The second piece is the PriceInfo which just sets the minimum and maximum amount of items it would take to receive 1 emerald. 
Afterward, I set up a static void method called initialize. Within the method, it adds the adds the trades to VillagerCareer variable I had set up earlier. The first variable is just the tier the trades appear. The second variable is the ITradeList[] itself. Lastly, the profession is registered in VillagerRegistry.instance().register(professionIsHere).

Unfortunately, I have come across an issue I'm not sure of. I want to be able to trade 1 emerald with a stack of coins. Yet, every time I create a trade (ListItemForEmeralds) and include the ItemStack, the result is a trade where you receive 1 coin instead. I commented out this trade for now.

Wednesday, January 11, 2017

Simple Coins 0.3.1 Build - Curse Page

Simple Coins Curse Page

Build 0.3.1 of Simple Coins doesn't fix any un/known bugs, it only updates the mod to Forge

I released the mod on Curse. From now on any issues should be reported there all download links will be there.

Simple Coins 0.3.0 Build for Minecraft 1.11.2 - Persistence is key

Simple Coins 0.3.0 Download

Quite a few changes. Firstly the Mint block. The crafting recipe has been changed.

In order to make coins, the mint is now required to craft the coins. The crafting recipes for the coins have been removed. Just right click the mint block, and place the nuggets as so:

The coins can also be crafted back to nuggets.



Man, this piece of the build took a while to finish. Firstly was just getting the GUI to correctly work. It kept crashing at first because I assigned nulls to ItemStack variables or methods and that was the deprecated way to do it. Forge now requires ItemStack.EMPTY to be used.

Next issue was getting the custom slots to behave correctly. For some reason, the custom slots would just not let me take the item in the slot unless the cursor was already holding another ItemStack. After doing looking on GitHub as to what other modders' did. I changed the assign of the custom slots, I created an InventoryCrafting variable along with an IInventory variable that would assign to MintCraftResult - A class that extends InventoryCraftResult but returns false every time isItemValidForSlot is called.

This fixed all issues of clicking on the custom slots. But then my next issue was the input doubling when the amount was greater than 1. There was something occurring with the slotClick method, so I had to override it, and super.slotClick and ensure the after crafting, the input would decrease by 1 no matter what.

It took me 3 days to implement a Mint Block that actually works. More experienced modders can probably do this in less than a few hours. There were times when I wanted to give up. But I didn't. Even if I felt like I couldn't figure something out, I just kept going. And sometimes the answer won't come to you when you're working on it. It's good to take a break sometimes. This is all cliche-sounding but there is truth to this.

I'm unsure where I want to take this mod in the future, I thinking of making villagers be able to trade with coins instead of emeralds.

Tuesday, January 10, 2017

Mint GUI Implemented - Simple Coins 0.3.0 Build Delayed

So I've managed to go through and figure out a few issues I've had with ItemStacks. After fixing the overridden onBlockActivated method, I was met by an error that caused the game to crash from the server side. It was a NullPointerException, in which ItemStack.areItemStacksEqual(...) was trying to compare two ItemStacks. After some research online, I couldn't find any solutions, so I brought up the question on the Minecraft Forge forum in the modder support forum. In summary, I had to change any instance of
ItemStack var = null; -> ItemStack var = ItemStack.EMPTY;
ItemStack[] inventory -> NonNullList<ItemStack> inventory;
Afterwords, I was able to right click and bring up a GUI. After some changing of integer values, I was able to the size the GUI to the correct size and bring the slots to their correct places on the GUI. But now an issue I'm present with is removing an item from the two item slots when the cursor is not holding a stack of items.

I also still need to add crafting to the mint. I added a check in the Update() method for the block's TileEntity file so if an iron ingot or gold ingot is in the input slot, it sets 4 coins of iron or gold in the output slot.

GitHub of the Mod

Hopefully, I can get finish Mint block once and for all by tonight.

Monday, January 9, 2017

onBlockActivated() - Not wanting to be Overriden

I solved the issue of onBlockActivated(...) not being accepted by @Override. So I first checked all the variables within onBlockActivated and the tutorial I was using to make sure they were similar. After some thinking I decided to use super.onBlockActivated(...), highlighted the super constructor in Eclipse and it told me the missing variables.

It's always the most stupid issues I get stuck on.

But I had another issue with implementing TileEntity. Immediately tried to extend my existing MintBlock class with BlockContainer instead of Block. However this led to the block being invisible in game. Rather then extend BlockContainer, I extended Block (like originally) and implement ITileEntityProvider.

I still need to add additional GUI classes but I should be able to get Version 0.3.0 Build released today. If you're following these same tutorials hopefully this helps you if you've had similar issues.