mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-04-11 03:15:44 +02:00
Add Void Miner w/ recipe
This commit is contained in:
parent
86777ee7b5
commit
230a8d650d
src/main
java/chylex/hee
resources/assets/hee
76
src/main/java/chylex/hee/game/item/ItemVoidMiner.kt
Normal file
76
src/main/java/chylex/hee/game/item/ItemVoidMiner.kt
Normal file
@ -0,0 +1,76 @@
|
||||
package chylex.hee.game.item
|
||||
import chylex.hee.game.item.base.ItemBaseVoidTool
|
||||
import chylex.hee.game.item.util.Tool.Type.AXE
|
||||
import chylex.hee.game.item.util.Tool.Type.PICKAXE
|
||||
import chylex.hee.game.item.util.Tool.Type.SHOVEL
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.enchantment.Enchantment
|
||||
import net.minecraft.enchantment.EnchantmentHelper
|
||||
import net.minecraft.entity.EntityLivingBase
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.init.Enchantments
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.EnumHand.MAIN_HAND
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed
|
||||
import net.minecraftforge.event.world.BlockEvent.BreakEvent
|
||||
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority.HIGHEST
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority.LOWEST
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||
|
||||
class ItemVoidMiner : ItemBaseVoidTool(){
|
||||
init{
|
||||
toolMaterial.harvestLevel.let {
|
||||
setHarvestLevel(PICKAXE, it)
|
||||
setHarvestLevel(AXE, it)
|
||||
setHarvestLevel(SHOVEL, it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDestroySpeed(stack: ItemStack, state: IBlockState): Float{
|
||||
return 1F // need to wait until the event to skip vanilla Efficiency handling
|
||||
}
|
||||
|
||||
override fun onBlockDestroyed(stack: ItemStack, world: World, state: IBlockState, pos: BlockPos, entity: EntityLivingBase): Boolean{
|
||||
guardItemBreaking(stack, entity){ super.onBlockDestroyed(stack, world, state, pos, entity) }
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canApplyAtEnchantingTable(stack: ItemStack, enchantment: Enchantment): Boolean{
|
||||
return enchantment === Enchantments.EFFICIENCY || enchantment === Enchantments.UNBREAKING
|
||||
}
|
||||
|
||||
// Mining events
|
||||
|
||||
private fun getHeldVoidMiner(player: EntityPlayer): ItemStack?{
|
||||
return player.getHeldItem(MAIN_HAND).takeIf { it.item === this }
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = HIGHEST)
|
||||
fun onBreakSpeed(e: BreakSpeed){
|
||||
val heldMiner = getHeldVoidMiner(e.entityPlayer)?.takeIf { it.itemDamage < it.maxDamage } ?: return
|
||||
val state = e.state
|
||||
|
||||
if (getToolClasses(heldMiner).any { state.block.isToolEffective(it, state) }){
|
||||
val efficiencyLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, heldMiner).coerceAtMost(5)
|
||||
e.newSpeed *= toolMaterial.efficiency + (6 * efficiencyLevel)
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = HIGHEST)
|
||||
fun onBlockBreak(e: BreakEvent){
|
||||
if (e.player?.let(::getHeldVoidMiner) != null){
|
||||
e.expToDrop = 0
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = LOWEST)
|
||||
fun onHarvestDrops(e: HarvestDropsEvent){
|
||||
if (e.harvester?.let(::getHeldVoidMiner) != null){
|
||||
e.drops.clear()
|
||||
e.dropChance = 0F
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import chylex.hee.game.item.ItemRingOfPreservation
|
||||
import chylex.hee.game.item.ItemScaleOfFreefall
|
||||
import chylex.hee.game.item.ItemSpatialDashGem
|
||||
import chylex.hee.game.item.ItemTableLink
|
||||
import chylex.hee.game.item.ItemVoidMiner
|
||||
import chylex.hee.init.ModCreativeTabs.OrderedCreativeTab
|
||||
import chylex.hee.system.Resource
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
@ -45,6 +46,9 @@ object ModItems{
|
||||
@JvmField val STATIC_CORE = Item().apply { setup("static_core") }
|
||||
@JvmField val TABLE_LINK = ItemTableLink().apply { setup("table_link") }
|
||||
|
||||
// Items: Tools
|
||||
|
||||
@JvmField val VOID_MINER = ItemVoidMiner().apply { setup("void_miner") }
|
||||
// Items: Buckets
|
||||
|
||||
@JvmField val ENDER_GOO_BUCKET = ItemBucket(ModBlocks.ENDER_GOO).apply { setup("ender_goo_bucket"); containerItem = Items.BUCKET }
|
||||
@ -89,6 +93,7 @@ object ModItems{
|
||||
register(STATIC_CORE)
|
||||
register(TABLE_LINK)
|
||||
|
||||
register(VOID_MINER)
|
||||
register(ENDER_GOO_BUCKET)
|
||||
|
||||
register(ENERGY_ORACLE)
|
||||
|
@ -78,6 +78,8 @@ item.hee.obsidian_rod.name=Obsidian Rod
|
||||
item.hee.static_core.name=Static Core
|
||||
item.hee.table_link.name=Table Link
|
||||
|
||||
item.hee.void_miner.name=Void Miner
|
||||
|
||||
item.hee.ender_goo_bucket.name=Ender Goo Bucket
|
||||
|
||||
item.hee.energy_oracle.name=Energy Oracle
|
||||
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "hee:item/void_miner"
|
||||
}
|
||||
}
|
17
src/main/resources/assets/hee/recipes/void_miner.json
Normal file
17
src/main/resources/assets/hee/recipes/void_miner.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"EGE",
|
||||
"X#X",
|
||||
" # "
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "hee:obsidian_rod" },
|
||||
"X": { "item": "hee:void_essence" },
|
||||
"E": { "item": "hee:endium_ingot" },
|
||||
"G": { "item": "minecraft:gold_ingot" }
|
||||
},
|
||||
"result": {
|
||||
"item": "hee:void_miner"
|
||||
}
|
||||
}
|
BIN
src/main/resources/assets/hee/textures/item/void_miner.png
Normal file
BIN
src/main/resources/assets/hee/textures/item/void_miner.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 190 B |
Loading…
Reference in New Issue
Block a user