Skip to content

jcranky/scalax-2017-mc-workshop

Repository files navigation

Scala eXchange 2017 Workshop

Follow the setup steps at EasyForger setup.

  • While waiting for the setup to complete, understand the environment a bit.

  • Read the name of the tasks being run by gradle, they give a good idea of what is happening.

Follow the first mod steps at Your first mod.

  • Run minecraft.

  • Create a new world in creative mode.

  • Test the new EFCreeper explosion.

  • You can compare the explosion radius by exploding a normal Creeper.

Add a custom held item for zombies

  • Not all items can be held, experiment!
  zombie(
    common(
      heldItemMainHand = Items.DIAMOND_SWORD
    )
  )
  • Now make the skeleton hold something.

Configure the items dropped by the Skeleton

  • Copy the json files to the proper asset location.

Json file: Skeleton Drop Json

Copy to folder: src/main/resources/assets/$mod_id/loot_tables/entities

  • Setup our skeleton to use that drop definition:
dropJson = s"$modId:entities/ef_skeleton"
  • Do the same for the zombie.

Create a new custom smelting recipe

  • Run the game and try our some existing smelting recipes in the Furnace, to understand the game mechanics around that:

  • Create a new smelting recipe to smelt an apple into a cake:

smelting(
  Items.APPLE to Items.CAKE
)

Create a new custom crafting recipe

  • Run the game and try out some existing recipes in the Crafting Table, to understand the game mechanics around that:

  • Create a new crafting recipe to turn coal into diamond:

crafting(
  Items.COAL to Items.DIAMOND
)
  • Change the recipe to be a shaped recipe:
crafting(
  Items.COAL to Items.DIAMOND withShape(
    """
      |.cc
      |..c
      |...
    """.stripMargin
  )
)
  • Create some other new recipes as you wish.

Create a new custom Item: Explosion Rod

  • Create a new class for the item:
class ItemExplosionRod(modId: String) extends EFItem(modId, "explosionrod") {
}
  • Set the creative tab we will use to find the item inside the game:
setCreativeTab(CreativeTabs.MISC)
  • Create the event handling that will trigger the explosion:
override def onEntitySwing(entity: EntityLivingBase, stack: ItemStack): Boolean = {
}
  • Implement the explosion logic:
val target = entity.rayTrace(100, 1f)
    
entity.world.createExplosion(
  entity, target.getBlockPos.getX, target.getBlockPos.getY, target.getBlockPos.getZ, 4f, true)

false
  • Instantiate the new item:
val explosionRod = new ItemExplosionRod(modId)
  • Inside init, register your item:
explosionRod.register()
  • Open the game and test the rod.

  • Missing texture! Copy the texture file:

Texture file: Explosion Rod Texture

Copy to folder: src/main/resources/assets/$mod_id/textures/items

  • Also copy the json texture model:
    • double check the model id inside the file

Texture model: Explosion Rod Texture Model

Copy to folder: src/main/resources/assets/$mod_id/models/item

  • Test it again!

  • Add a proper name to the item, copying the i18n file:

i18n file: i18n file

Copy to folder: src/main/resources/assets/$mod_id/lang

  • Add a custom recipe to allow creating an Explosion Rod with the crafting table.

Create a new Item, a Banana

  • Create the new item class:
class ItemBanana(modId: String) extends EFItemFood(modId, "banana", 5, 0.4f, false) {
}
  • Add two potion effects to the item:
setPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 9 * 20, 1), 1f)
addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, 5 * 20, 0), 0.5f)
  • Copy the texture and texture model files to the assets folder:

Copy files: Banana texture and Banana model json

Note: don't forget to double check the mod id in the model json.

  • Instantiate the new item:
val banana = new ItemBanana(modId)
  • In the init method, register the new item:
banana.register()
  • Start the game and test the new item.

Create a new Sword

  • Create the class for the Sword:
class ItemVenomSword(modId: String) extends EFItemSword(modId, "venomsword", ToolMaterial.IRON) {
}
  • Add the custom logic to run when hitting an enemy:
override def hitEntity(stack: ItemStack, target: EntityLivingBase, attacker: EntityLivingBase): Boolean = {
  target.addPotionEffect(new PotionEffect(MobEffects.POISON, 3 * 20, 1, false, true))
  super.hitEntity(stack, target, attacker)
}
  • Copy the texture and the texture model files:

Copy files: Sword texture and Sword model json.

  • Instantiate the item:
val venomSword = new ItemVenomSword(modId)
  • And in the init method, register the item:
venomSword.register()
  • Open the game and test it!

  • Sad news: potion effect if not being correct applied at this moment, bug?

Create a new Block:

  • Create the class for the block and set it up:
class BlockCloth(modId: String) extends EFBlock(modId, "clothblock", Material.CLOTH) {
  setHardness(0.5f)
  setResistance(1.0f)
  setSoundType(SoundType.WOOD)

  dropItem = Items.BOOK
  quantityDropped = 3
}
  • Copy the block texture file:

Copy file: Block texture

To folder: src/main/resources/assets/$mod_id/textures/blocks

  • Copy the model json files:

Copy item json model: Block item json

To Folder: src/main/resources/assets/$mod_id/models/item

Copy Block json model: Block model

To Folder: src/main/resources/assets/$mod_id/models/block

Copy Block states model: Block model

To Folder: src/main/resources/assets/$mod_id/blockstates

Note: double check the mod id in all json files!

  • Instantiate the block:
val cloth = new BlockCloth(modId)
  • Register the block and add a recipe to create it:
cloth.register()
crafting(
  Items.STRING to cloth withShape
    """
      |sss
      |s.s
      |sss
    """.stripMargin
)
  • Open the game and test it!

About

Scala eXchange 2017 Workshop Tasks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages