Friday, January 13, 2017

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

Simple Coins Curse Page

0.5.1
  • 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
0.5.0
  • 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
0.4.2
  • 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 13.20.0.2212
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.

No comments:

Post a Comment