mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-04-11 03:15:44 +02:00
Add Infused Ender Pearl item & infusion list to the entity
This commit is contained in:
parent
cd3948b981
commit
e1de134d35
src/main
java/chylex/hee
game
init
resources/assets/hee/models/item
@ -1,5 +1,7 @@
|
||||
package chylex.hee.game.entity.projectile
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.game.item.infusion.InfusionList
|
||||
import chylex.hee.game.item.infusion.InfusionTag
|
||||
import chylex.hee.game.mechanics.damage.Damage
|
||||
import chylex.hee.game.mechanics.damage.IDamageProcessor.Companion.ALL_PROTECTIONS_WITH_SHIELD
|
||||
import chylex.hee.game.mechanics.damage.IDamageProcessor.Companion.PEACEFUL_EXCLUSION
|
||||
@ -30,7 +32,7 @@ class EntityProjectileEnderPearl : EntityEnderPearl{
|
||||
|
||||
if (original is EntityEnderPearl && original !is EntityProjectileEnderPearl){
|
||||
e.isCanceled = true
|
||||
e.world.spawnEntity(EntityProjectileEnderPearl(original.thrower!!))
|
||||
e.world.spawnEntity(EntityProjectileEnderPearl(original.thrower!!, InfusionList.EMPTY))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,11 +40,20 @@ class EntityProjectileEnderPearl : EntityEnderPearl{
|
||||
@Suppress("unused")
|
||||
constructor(world: World) : super(world)
|
||||
|
||||
constructor(thrower: EntityLivingBase) : super(thrower.world, thrower){
|
||||
constructor(thrower: EntityLivingBase, infusions: InfusionList) : super(thrower.world, thrower){
|
||||
loadInfusions(infusions)
|
||||
shoot(thrower, thrower.rotationPitch, thrower.rotationYaw, 0F, 1.5F, 1F)
|
||||
}
|
||||
|
||||
// Impact
|
||||
private var infusions = InfusionList.EMPTY
|
||||
// Initialization
|
||||
|
||||
private fun loadInfusions(infusions: InfusionList){
|
||||
this.infusions = infusions
|
||||
}
|
||||
|
||||
// Behavior
|
||||
|
||||
|
||||
override fun onImpact(result: RayTraceResult){
|
||||
val thrower: EntityLivingBase? = thrower
|
||||
@ -76,9 +87,13 @@ class EntityProjectileEnderPearl : EntityEnderPearl{
|
||||
|
||||
override fun writeEntityToNBT(nbt: NBTTagCompound) = with(nbt.heeTag){
|
||||
super.writeEntityToNBT(nbt)
|
||||
|
||||
InfusionTag.setList(this, infusions)
|
||||
}
|
||||
|
||||
override fun readEntityFromNBT(nbt: NBTTagCompound) = with(nbt.heeTag){
|
||||
super.readEntityFromNBT(nbt)
|
||||
|
||||
loadInfusions(InfusionTag.getList(this))
|
||||
}
|
||||
}
|
||||
|
60
src/main/java/chylex/hee/game/item/ItemInfusedEnderPearl.kt
Normal file
60
src/main/java/chylex/hee/game/item/ItemInfusedEnderPearl.kt
Normal file
@ -0,0 +1,60 @@
|
||||
package chylex.hee.game.item
|
||||
import chylex.hee.game.entity.projectile.EntityProjectileEnderPearl
|
||||
import chylex.hee.game.item.infusion.IInfusableItem
|
||||
import chylex.hee.game.item.infusion.Infusion
|
||||
import chylex.hee.game.item.infusion.InfusionTag
|
||||
import chylex.hee.system.util.nextFloat
|
||||
import chylex.hee.system.util.playServer
|
||||
import chylex.hee.system.util.posVec
|
||||
import net.minecraft.client.util.ITooltipFlag
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.init.SoundEvents
|
||||
import net.minecraft.item.ItemEnderPearl
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.stats.StatList
|
||||
import net.minecraft.util.ActionResult
|
||||
import net.minecraft.util.EnumActionResult.SUCCESS
|
||||
import net.minecraft.util.EnumHand
|
||||
import net.minecraft.util.SoundCategory
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
|
||||
class ItemInfusedEnderPearl : ItemEnderPearl(), IInfusableItem{
|
||||
init{
|
||||
creativeTab = null
|
||||
}
|
||||
|
||||
override fun onItemRightClick(world: World, player: EntityPlayer, hand: EnumHand): ActionResult<ItemStack>{
|
||||
val heldItem = player.getHeldItem(hand)
|
||||
|
||||
if (!player.capabilities.isCreativeMode){
|
||||
heldItem.shrink(1)
|
||||
}
|
||||
|
||||
SoundEvents.ENTITY_ENDERPEARL_THROW.playServer(world, player.posVec, SoundCategory.NEUTRAL, volume = 0.5F, pitch = 0.4F / itemRand.nextFloat(0.8F, 1.2F))
|
||||
player.cooldownTracker.setCooldown(this, 20)
|
||||
|
||||
if (!world.isRemote){
|
||||
world.spawnEntity(EntityProjectileEnderPearl(player, InfusionTag.getList(heldItem)))
|
||||
}
|
||||
|
||||
player.addStat(StatList.getObjectUseStats(this)!!)
|
||||
return ActionResult(SUCCESS, heldItem)
|
||||
}
|
||||
|
||||
override fun canApplyInfusion(infusion: Infusion): Boolean{
|
||||
return ItemAbstractInfusable.onCanApplyInfusion(this, infusion)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override fun addInformation(stack: ItemStack, world: World?, lines: MutableList<String>, flags: ITooltipFlag){
|
||||
super.addInformation(stack, world, lines, flags)
|
||||
ItemAbstractInfusable.onAddInformation(stack, lines)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override fun hasEffect(stack: ItemStack): Boolean{
|
||||
return super.hasEffect(stack) || ItemAbstractInfusable.onHasEffect(stack)
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import chylex.hee.system.util.nbtOrNull
|
||||
import chylex.hee.system.util.size
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraft.init.Items
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
@ -47,7 +48,8 @@ enum class Infusion(
|
||||
|
||||
private companion object{
|
||||
private val TRANSFORMATIONS = arrayOf(
|
||||
Item.getItemFromBlock(Blocks.TNT) to Item.getItemFromBlock(ModBlocks.INFUSED_TNT)
|
||||
Item.getItemFromBlock(Blocks.TNT) to Item.getItemFromBlock(ModBlocks.INFUSED_TNT),
|
||||
Items.ENDER_PEARL to ModItems.INFUSED_ENDER_PEARL
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import chylex.hee.game.item.ItemElytraOverride
|
||||
import chylex.hee.game.item.ItemEnergyOracle
|
||||
import chylex.hee.game.item.ItemEnergyReceptacle
|
||||
import chylex.hee.game.item.ItemIgneousRock
|
||||
import chylex.hee.game.item.ItemInfusedEnderPearl
|
||||
import chylex.hee.game.item.ItemRingOfHunger
|
||||
import chylex.hee.game.item.ItemRingOfPreservation
|
||||
import chylex.hee.game.item.ItemScaleOfFreefall
|
||||
@ -83,9 +84,10 @@ object ModItems{
|
||||
@JvmField val ENERGY_ORACLE = ItemEnergyOracle().apply { setup("energy_oracle") }
|
||||
@JvmField val ENERGY_RECEPTACLE = ItemEnergyReceptacle().apply { setup("energy_receptacle") }
|
||||
|
||||
// Items: Gems
|
||||
// Items: Gems & teleportation
|
||||
|
||||
@JvmField val SPATIAL_DASH_GEM = ItemSpatialDashGem().apply { setup("spatial_dash_gem") }
|
||||
@JvmField val INFUSED_ENDER_PEARL = ItemInfusedEnderPearl().apply { setup("infused_ender_pearl", translationKey = "enderPearl", inCreativeTab = false) }
|
||||
@JvmField val SPATIAL_DASH_GEM = ItemSpatialDashGem().apply { setup("spatial_dash_gem") }
|
||||
|
||||
// Items: Trinkets
|
||||
|
||||
@ -138,6 +140,7 @@ object ModItems{
|
||||
register(ENERGY_ORACLE)
|
||||
register(ENERGY_RECEPTACLE)
|
||||
|
||||
register(INFUSED_ENDER_PEARL)
|
||||
register(SPATIAL_DASH_GEM)
|
||||
|
||||
register(TRINKET_POUCH)
|
||||
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "minecraft:items/ender_pearl"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user