Search in sources :

Example 26 with ItemSword

use of net.minecraft.item.ItemSword in project SpongeCommon by SpongePowered.

the class MixinEntityPlayer method attackTargetEntityWithCurrentItem.

/**
 * @author gabizou - April 8th, 2016
 * @author gabizou - April 11th, 2016 - Update for 1.9 - This enitre method was rewritten
 *
 * @reason Rewrites the attackTargetEntityWithCurrentItem to throw an {@link AttackEntityEvent} prior
 * to the ensuing {@link DamageEntityEvent}. This should cover all cases where players are
 * attacking entities and those entities override {@link EntityLivingBase#attackEntityFrom(DamageSource, float)}
 * and effectively bypass our damage event hooks.
 *
 * LVT Rename Table:
 * float f        | damage               |
 * float f1       | enchantmentDamage    |
 * float f2       | attackStrength       |
 * boolean flag   | isStrongAttack       |
 * boolean flag1  | isSprintingAttack    |
 * boolean flag2  | isCriticalAttack     | Whether critical particles will spawn and of course, multiply the output damage
 * boolean flag3  | isSweapingAttack     | Whether the player is sweaping an attack and will deal AoE damage
 * int i          | knockbackModifier    | The knockback modifier, must be set from the event after it has been thrown
 * float f4       | targetOriginalHealth | This is initially set as the entity original health
 * boolean flag4  | litEntityOnFire      | This is an internal flag to where if the attack failed, the entity is no longer set on fire
 * int j          | fireAspectModifier   | Literally just to check that the weapon used has fire aspect enchantments
 * double d0      | distanceWalkedDelta  | This checks that the distance walked delta is more than the normal walking speed to evaluate if you're making a sweaping attack
 * double d1      | targetMotionX        | Current target entity motion x vector
 * double d2      | targetMotionY        | Current target entity motion y vector
 * double d3      | targetMotionZ        | Current target entity motion z vector
 * boolean flag5  | attackSucceeded      | Whether the attack event succeeded
 *
 * @param targetEntity The target entity
 */
@Overwrite
public void attackTargetEntityWithCurrentItem(Entity targetEntity) {
    // Sponge Start - Add SpongeImpl hook to override in forge as necessary
    if (!SpongeImplHooks.checkAttackEntity((EntityPlayer) (Object) this, targetEntity)) {
        return;
    }
    // Sponge End
    if (targetEntity.canBeAttackedWithItem()) {
        if (!targetEntity.hitByEntity((EntityPlayer) (Object) this)) {
            // Sponge Start - Prepare our event values
            // float damage = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
            final double originalBaseDamage = this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
            float damage = (float) originalBaseDamage;
            // Sponge End
            float enchantmentDamage = 0.0F;
            // Spogne Start - Redirect getting enchantments for our damage event handlers
            // if (targetEntity instanceof EntityLivingBase) {
            // enchantmentDamage = EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) targetEntity).getCreatureAttribute());
            // } else {
            // enchantmentDamage = EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), EnumCreatureAttribute.UNDEFINED);
            // }
            float attackStrength = this.getCooledAttackStrength(0.5F);
            final List<ModifierFunction<DamageModifier>> originalFunctions = new ArrayList<>();
            final EnumCreatureAttribute creatureAttribute = targetEntity instanceof EntityLivingBase ? ((EntityLivingBase) targetEntity).getCreatureAttribute() : EnumCreatureAttribute.UNDEFINED;
            final List<DamageFunction> enchantmentModifierFunctions = DamageEventHandler.createAttackEnchantmentFunction(this.getHeldItemMainhand(), creatureAttribute, attackStrength);
            // This is kept for the post-damage event handling
            final List<DamageModifier> enchantmentModifiers = enchantmentModifierFunctions.stream().map(ModifierFunction::getModifier).collect(Collectors.toList());
            enchantmentDamage = (float) enchantmentModifierFunctions.stream().map(ModifierFunction::getFunction).mapToDouble(function -> function.applyAsDouble(originalBaseDamage)).sum();
            originalFunctions.addAll(enchantmentModifierFunctions);
            // Sponge End
            originalFunctions.add(DamageEventHandler.provideCooldownAttackStrengthFunction((EntityPlayer) (Object) this, attackStrength));
            damage = damage * (0.2F + attackStrength * attackStrength * 0.8F);
            enchantmentDamage = enchantmentDamage * attackStrength;
            this.resetCooldown();
            if (damage > 0.0F || enchantmentDamage > 0.0F) {
                boolean isStrongAttack = attackStrength > 0.9F;
                boolean isSprintingAttack = false;
                boolean isCriticalAttack = false;
                boolean isSweapingAttack = false;
                int knockbackModifier = 0;
                knockbackModifier = knockbackModifier + EnchantmentHelper.getKnockbackModifier((EntityPlayer) (Object) this);
                if (this.isSprinting() && isStrongAttack) {
                    // Sponge - Only play sound after the event has be thrown and not cancelled.
                    // this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.entity_player_attack_knockback, this.getSoundCategory(), 1.0F, 1.0F);
                    ++knockbackModifier;
                    isSprintingAttack = true;
                }
                isCriticalAttack = isStrongAttack && this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(MobEffects.BLINDNESS) && !this.isRiding() && targetEntity instanceof EntityLivingBase;
                isCriticalAttack = isCriticalAttack && !this.isSprinting();
                if (isCriticalAttack) {
                    // Sponge Start - add critical attack tuple
                    // damage *= 1.5F; // Sponge - This is handled in the event
                    originalFunctions.add(DamageEventHandler.provideCriticalAttackTuple((EntityPlayer) (Object) this));
                // Sponge End
                }
                // damage = damage + enchantmentDamage; // Sponge - We don't need this since our event will re-assign the damage to deal
                double distanceWalkedDelta = (double) (this.distanceWalkedModified - this.prevDistanceWalkedModified);
                final ItemStack heldItem = this.getHeldItem(EnumHand.MAIN_HAND);
                if (isStrongAttack && !isCriticalAttack && !isSprintingAttack && this.onGround && distanceWalkedDelta < (double) this.getAIMoveSpeed()) {
                    ItemStack itemstack = heldItem;
                    if (itemstack.getItem() instanceof ItemSword) {
                        isSweapingAttack = true;
                    }
                }
                // Sponge Start - Create the event and throw it
                final DamageSource damageSource = DamageSource.causePlayerDamage((EntityPlayer) (Object) this);
                final boolean isMainthread = !this.world.isRemote;
                if (isMainthread) {
                    Sponge.getCauseStackManager().pushCause(damageSource);
                }
                final Cause currentCause = isMainthread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(), damageSource);
                final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(currentCause, originalFunctions, EntityUtil.fromNative(targetEntity), knockbackModifier, originalBaseDamage);
                SpongeImpl.postEvent(event);
                if (isMainthread) {
                    Sponge.getCauseStackManager().popCause();
                }
                if (event.isCancelled()) {
                    return;
                }
                damage = (float) event.getFinalOutputDamage();
                // sponge - need final for later events
                final double attackDamage = damage;
                knockbackModifier = event.getKnockbackModifier();
                enchantmentDamage = (float) enchantmentModifiers.stream().mapToDouble(event::getOutputDamage).sum();
                // Sponge End
                float targetOriginalHealth = 0.0F;
                boolean litEntityOnFire = false;
                int fireAspectModifier = EnchantmentHelper.getFireAspectModifier((EntityPlayer) (Object) this);
                if (targetEntity instanceof EntityLivingBase) {
                    targetOriginalHealth = ((EntityLivingBase) targetEntity).getHealth();
                    if (fireAspectModifier > 0 && !targetEntity.isBurning()) {
                        litEntityOnFire = true;
                        targetEntity.setFire(1);
                    }
                }
                double targetMotionX = targetEntity.motionX;
                double targetMotionY = targetEntity.motionY;
                double targetMotionZ = targetEntity.motionZ;
                boolean attackSucceeded = targetEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) (Object) this), damage);
                if (attackSucceeded) {
                    if (knockbackModifier > 0) {
                        if (targetEntity instanceof EntityLivingBase) {
                            ((EntityLivingBase) targetEntity).knockBack((EntityPlayer) (Object) this, (float) knockbackModifier * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
                        } else {
                            targetEntity.addVelocity((double) (-MathHelper.sin(this.rotationYaw * 0.017453292F) * (float) knockbackModifier * 0.5F), 0.1D, (double) (MathHelper.cos(this.rotationYaw * 0.017453292F) * (float) knockbackModifier * 0.5F));
                        }
                        this.motionX *= 0.6D;
                        this.motionZ *= 0.6D;
                        this.setSprinting(false);
                    }
                    if (isSweapingAttack) {
                        for (EntityLivingBase entitylivingbase : this.world.getEntitiesWithinAABB(EntityLivingBase.class, targetEntity.getEntityBoundingBox().grow(1.0D, 0.25D, 1.0D))) {
                            if (entitylivingbase != (EntityPlayer) (Object) this && entitylivingbase != targetEntity && !this.isOnSameTeam(entitylivingbase) && this.getDistanceSq(entitylivingbase) < 9.0D) {
                                // Sponge Start - Do a small event for these entities
                                // entitylivingbase.knockBack(this, 0.4F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
                                // entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage(this), 1.0F);
                                final EntityDamageSource sweepingAttackSource = EntityDamageSource.builder().entity(this).type(DamageTypes.SWEEPING_ATTACK).build();
                                try (final StackFrame frame = isMainthread ? Sponge.getCauseStackManager().pushCauseFrame() : null) {
                                    if (isMainthread) {
                                        Sponge.getCauseStackManager().pushCause(sweepingAttackSource);
                                    }
                                    final ItemStackSnapshot heldSnapshot = ItemStackUtil.snapshotOf(heldItem);
                                    if (isMainthread) {
                                        Sponge.getCauseStackManager().addContext(EventContextKeys.WEAPON, heldSnapshot);
                                    }
                                    final DamageFunction sweapingFunction = DamageFunction.of(DamageModifier.builder().cause(Cause.of(EventContext.empty(), heldSnapshot)).item(heldSnapshot).type(DamageModifierTypes.SWEEPING).build(), (incoming) -> EnchantmentHelper.getSweepingDamageRatio((EntityPlayer) (Object) this) * attackDamage);
                                    final List<DamageFunction> sweapingFunctions = new ArrayList<>();
                                    sweapingFunctions.add(sweapingFunction);
                                    AttackEntityEvent sweepingAttackEvent = SpongeEventFactory.createAttackEntityEvent(currentCause, sweapingFunctions, EntityUtil.fromNative(entitylivingbase), 1, 1.0D);
                                    SpongeImpl.postEvent(sweepingAttackEvent);
                                    if (!sweepingAttackEvent.isCancelled()) {
                                        entitylivingbase.knockBack((EntityPlayer) (Object) this, sweepingAttackEvent.getKnockbackModifier() * 0.4F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
                                        entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) (Object) this), (float) sweepingAttackEvent.getFinalOutputDamage());
                                    }
                                }
                            // Sponge End
                            }
                        }
                        this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0F, 1.0F);
                        this.spawnSweepParticles();
                    }
                    if (targetEntity instanceof EntityPlayerMP && targetEntity.velocityChanged) {
                        ((EntityPlayerMP) targetEntity).connection.sendPacket(new SPacketEntityVelocity(targetEntity));
                        targetEntity.velocityChanged = false;
                        targetEntity.motionX = targetMotionX;
                        targetEntity.motionY = targetMotionY;
                        targetEntity.motionZ = targetMotionZ;
                    }
                    if (isCriticalAttack) {
                        this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0F, 1.0F);
                        this.onCriticalHit(targetEntity);
                    }
                    if (!isCriticalAttack && !isSweapingAttack) {
                        if (isStrongAttack) {
                            this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0F, 1.0F);
                        } else {
                            this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0F, 1.0F);
                        }
                    }
                    if (enchantmentDamage > 0.0F) {
                        this.onEnchantmentCritical(targetEntity);
                    }
                    this.setLastAttackedEntity(targetEntity);
                    if (targetEntity instanceof EntityLivingBase) {
                        EnchantmentHelper.applyThornEnchantments((EntityLivingBase) targetEntity, (EntityPlayer) (Object) this);
                    }
                    EnchantmentHelper.applyArthropodEnchantments((EntityPlayer) (Object) this, targetEntity);
                    ItemStack itemstack1 = this.getHeldItemMainhand();
                    Entity entity = targetEntity;
                    if (targetEntity instanceof MultiPartEntityPart) {
                        IEntityMultiPart ientitymultipart = ((MultiPartEntityPart) targetEntity).parent;
                        if (ientitymultipart instanceof EntityLivingBase) {
                            entity = (EntityLivingBase) ientitymultipart;
                        }
                    }
                    if (!itemstack1.isEmpty() && targetEntity instanceof EntityLivingBase) {
                        itemstack1.hitEntity((EntityLivingBase) targetEntity, (EntityPlayer) (Object) this);
                        if (itemstack1.isEmpty()) {
                            this.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
                        }
                    }
                    if (targetEntity instanceof EntityLivingBase) {
                        float f5 = targetOriginalHealth - ((EntityLivingBase) targetEntity).getHealth();
                        this.addStat(StatList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
                        if (fireAspectModifier > 0) {
                            targetEntity.setFire(fireAspectModifier * 4);
                        }
                        if (this.world instanceof WorldServer && f5 > 2.0F) {
                            int k = (int) ((double) f5 * 0.5D);
                            ((WorldServer) this.world).spawnParticle(EnumParticleTypes.DAMAGE_INDICATOR, targetEntity.posX, targetEntity.posY + (double) (targetEntity.height * 0.5F), targetEntity.posZ, k, 0.1D, 0.0D, 0.1D, 0.2D, new int[0]);
                        }
                    }
                    this.addExhaustion(0.3F);
                } else {
                    this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F);
                    if (litEntityOnFire) {
                        targetEntity.extinguish();
                    }
                }
            }
        }
    }
}
Also used : EventContextKeys(org.spongepowered.api.event.cause.EventContextKeys) Item(net.minecraft.item.Item) Inject(org.spongepowered.asm.mixin.injection.Inject) GameProfile(com.mojang.authlib.GameProfile) EnumHand(net.minecraft.util.EnumHand) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) SpongeCommonEventFactory(org.spongepowered.common.event.SpongeCommonEventFactory) ItemStackUtil(org.spongepowered.common.item.inventory.util.ItemStackUtil) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) SlotTransaction(org.spongepowered.api.item.inventory.transaction.SlotTransaction) Mixin(org.spongepowered.asm.mixin.Mixin) DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) LockCode(net.minecraft.world.LockCode) SoundCategory(net.minecraft.util.SoundCategory) DamageSourceRegistryModule(org.spongepowered.common.registry.type.event.DamageSourceRegistryModule) At(org.spongepowered.asm.mixin.injection.At) IMixinEntityPlayer(org.spongepowered.common.interfaces.entity.player.IMixinEntityPlayer) EntityItem(net.minecraft.entity.item.EntityItem) InventoryEnderChest(net.minecraft.inventory.InventoryEnderChest) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SPacketEntityVelocity(net.minecraft.network.play.server.SPacketEntityVelocity) AttackEntityEvent(org.spongepowered.api.event.entity.AttackEntityEvent) StackFrame(org.spongepowered.api.event.CauseStackManager.StackFrame) Team(net.minecraft.scoreboard.Team) Sponge(org.spongepowered.api.Sponge) StatBase(net.minecraft.stats.StatBase) DamageTypes(org.spongepowered.api.event.cause.entity.damage.DamageTypes) SpongeHealthData(org.spongepowered.common.data.manipulator.mutable.entity.SpongeHealthData) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) EnchantmentHelper(net.minecraft.enchantment.EnchantmentHelper) PacketPhase(org.spongepowered.common.event.tracking.phase.packet.PacketPhase) EntityUtil(org.spongepowered.common.entity.EntityUtil) Cause(org.spongepowered.api.event.cause.Cause) List(java.util.List) PhaseContext(org.spongepowered.common.event.tracking.PhaseContext) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Shadow(org.spongepowered.asm.mixin.Shadow) LegacyTexts(org.spongepowered.common.text.serializer.LegacyTexts) EnumParticleTypes(net.minecraft.util.EnumParticleTypes) MobEffects(net.minecraft.init.MobEffects) Container(net.minecraft.inventory.Container) Scoreboard(net.minecraft.scoreboard.Scoreboard) EventContext(org.spongepowered.api.event.cause.EventContext) PlayerCapabilities(net.minecraft.entity.player.PlayerCapabilities) ModifierFunction(org.spongepowered.api.event.cause.entity.ModifierFunction) SpongeImpl(org.spongepowered.common.SpongeImpl) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) PlayerInventory(org.spongepowered.api.item.inventory.entity.PlayerInventory) IEntityMultiPart(net.minecraft.entity.IEntityMultiPart) SpongeImplHooks(org.spongepowered.common.SpongeImplHooks) ITargetedLocation(org.spongepowered.common.interfaces.ITargetedLocation) SpongeTexts(org.spongepowered.common.text.SpongeTexts) Vector3d(com.flowpowered.math.vector.Vector3d) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) CooldownTracker(net.minecraft.util.CooldownTracker) DamageModifierTypes(org.spongepowered.api.event.cause.entity.damage.DamageModifierTypes) Overwrite(org.spongepowered.asm.mixin.Overwrite) ExperienceHolderUtils(org.spongepowered.common.data.processor.common.ExperienceHolderUtils) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) IMixinWorld(org.spongepowered.common.interfaces.world.IMixinWorld) IMixinInventoryPlayer(org.spongepowered.common.interfaces.entity.player.IMixinInventoryPlayer) MultiPartEntityPart(net.minecraft.entity.MultiPartEntityPart) WorldServer(net.minecraft.world.WorldServer) ItemSword(net.minecraft.item.ItemSword) Nullable(javax.annotation.Nullable) Entity(net.minecraft.entity.Entity) MixinEntityLivingBase(org.spongepowered.common.mixin.core.entity.MixinEntityLivingBase) SoundEvents(net.minecraft.init.SoundEvents) StatList(net.minecraft.stats.StatList) Items(net.minecraft.init.Items) World(net.minecraft.world.World) Redirect(org.spongepowered.asm.mixin.injection.Redirect) SpongeEventFactory(org.spongepowered.api.event.SpongeEventFactory) BlockPos(net.minecraft.util.math.BlockPos) InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) Slot(org.spongepowered.api.item.inventory.Slot) DamageSource(net.minecraft.util.DamageSource) SharedMonsterAttributes(net.minecraft.entity.SharedMonsterAttributes) TextComponentString(net.minecraft.util.text.TextComponentString) DamageEventHandler(org.spongepowered.common.event.damage.DamageEventHandler) FoodStats(net.minecraft.util.FoodStats) DamageFunction(org.spongepowered.api.event.cause.entity.damage.DamageFunction) DamageModifier(org.spongepowered.api.event.cause.entity.damage.DamageModifier) EntityLivingBase(net.minecraft.entity.EntityLivingBase) MathHelper(net.minecraft.util.math.MathHelper) VecHelper(org.spongepowered.common.util.VecHelper) EnumCreatureAttribute(net.minecraft.entity.EnumCreatureAttribute) SlotIndex(org.spongepowered.api.item.inventory.property.SlotIndex) SoundEvent(net.minecraft.util.SoundEvent) Entity(net.minecraft.entity.Entity) ArrayList(java.util.ArrayList) MultiPartEntityPart(net.minecraft.entity.MultiPartEntityPart) WorldServer(net.minecraft.world.WorldServer) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) AttackEntityEvent(org.spongepowered.api.event.entity.AttackEntityEvent) DamageModifier(org.spongepowered.api.event.cause.entity.damage.DamageModifier) SPacketEntityVelocity(net.minecraft.network.play.server.SPacketEntityVelocity) DamageFunction(org.spongepowered.api.event.cause.entity.damage.DamageFunction) Cause(org.spongepowered.api.event.cause.Cause) ItemSword(net.minecraft.item.ItemSword) EnumCreatureAttribute(net.minecraft.entity.EnumCreatureAttribute) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) DamageSource(net.minecraft.util.DamageSource) StackFrame(org.spongepowered.api.event.CauseStackManager.StackFrame) MixinEntityLivingBase(org.spongepowered.common.mixin.core.entity.MixinEntityLivingBase) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IMixinEntityPlayer(org.spongepowered.common.interfaces.entity.player.IMixinEntityPlayer) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) ModifierFunction(org.spongepowered.api.event.cause.entity.ModifierFunction) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IEntityMultiPart(net.minecraft.entity.IEntityMultiPart) ItemStack(net.minecraft.item.ItemStack) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 27 with ItemSword

use of net.minecraft.item.ItemSword in project Charset by CharsetMC.

the class CharsetTweakZorro method doTheZorroThing.

@SubscribeEvent
public void doTheZorroThing(PlayerInteractEvent.EntityInteract event) {
    EntityPlayer player = event.getEntityPlayer();
    if (player.world.isRemote)
        return;
    if (player.isRiding())
        return;
    if (!(event.getTarget() instanceof EntityHorse))
        return;
    EntityHorse horse = (EntityHorse) event.getTarget();
    if (player.fallDistance <= 2)
        return;
    if (!horse.isHorseSaddled())
        return;
    if (horse.getLeashed()) {
        if (!(horse.getLeashHolder() instanceof EntityLeashKnot))
            return;
        horse.getLeashHolder().processInitialInteract(player, EnumHand.MAIN_HAND);
    }
    boolean awesome = false;
    ItemStack heldStack = player.getHeldItem(EnumHand.MAIN_HAND);
    if (player.fallDistance > 5 && !heldStack.isEmpty()) {
        Item held = heldStack.getItem();
        boolean has_baby = false;
        if (player.getRidingEntity() instanceof EntityAgeable) {
            EntityAgeable ea = (EntityAgeable) player.getRidingEntity();
            has_baby = ea.isChild();
        }
        awesome = held instanceof ItemSword || held instanceof ItemBow || player.getRidingEntity() instanceof EntityPlayer || has_baby;
        if (!awesome) {
            Set<String> classes = held.getToolClasses(heldStack);
            awesome |= classes.contains("axe");
        }
    }
    if (awesome) {
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("speed"), 20 * 40, 2, false, false));
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("resistance"), 20 * 40, 1, true, true));
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("jump_boost"), 20 * 40, 1, true, true));
    } else {
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("speed"), 20 * 8, 1, false, false));
    }
    horse.playLivingSound();
}
Also used : EntityLeashKnot(net.minecraft.entity.EntityLeashKnot) ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) EntityHorse(net.minecraft.entity.passive.EntityHorse) PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityAgeable(net.minecraft.entity.EntityAgeable) ItemBow(net.minecraft.item.ItemBow) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 28 with ItemSword

use of net.minecraft.item.ItemSword in project Tropicraft by Tropicraft.

the class BlockEvents method handlePineappleBreakEvent.

@SubscribeEvent
public void handlePineappleBreakEvent(HarvestDropsEvent event) {
    EntityPlayer player = event.getHarvester();
    ItemStack held = ItemStack.EMPTY;
    if (player != null)
        held = player.getHeldItemMainhand();
    IBlockState state = event.getState();
    if (state.getBlock() != BlockRegistry.pineapple) {
        return;
    }
    IBlockState stateUp = event.getWorld().getBlockState(event.getPos().up());
    IBlockState stateDown = event.getWorld().getBlockState(event.getPos().down());
    boolean isTop = state.getValue(BlockPineapple.HALF) == PlantHalf.UPPER;
    boolean isGrown = isTop || (state.getValue(BlockPineapple.HALF) == PlantHalf.LOWER && stateUp.getBlock() instanceof BlockPineapple && stateUp.getValue(BlockPineapple.HALF) == PlantHalf.UPPER);
    if (isGrown) {
        if (!held.isEmpty() && held.getItem() instanceof ItemSword) {
            event.getDrops().add(new ItemStack(ItemRegistry.pineappleCubes, event.getWorld().rand.nextInt(3) + 2));
        } else {
            event.getDrops().add(new ItemStack(BlockRegistry.pineapple));
        }
    }
    // If the stem remains after a block break, reset its growth stage so it doesn't insta-create a pineapple
    if (isTop && stateDown.getBlock() instanceof BlockPineapple) {
        event.getWorld().setBlockState(event.getPos().down(), BlockRegistry.pineapple.getDefaultState().withProperty(BlockPineapple.STAGE, Integer.valueOf(1)));
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) BlockPineapple(net.tropicraft.core.common.block.BlockPineapple) IBlockState(net.minecraft.block.state.IBlockState) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 29 with ItemSword

use of net.minecraft.item.ItemSword in project Tropicraft by Tropicraft.

the class ItemRegistry method registerItems.

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
    blockItemRegistry.entrySet().forEach(e -> {
        Item item = e.getValue().getItem(e.getKey());
        item.setRegistryName(e.getKey().getRegistryName());
        event.getRegistry().register(item);
        e.getValue().postRegister(e.getKey(), item);
    });
    IForgeRegistry<Item> registry = event.getRegistry();
    diveComputer = registerItem(registry, new ItemDiveComputer(), "dive_computer");
    pinkWeightBelt = registerItem(registry, new ItemTropicraft(), "pink_weight_belt");
    pinkPonyBottle = registerItem(registry, new ItemPonyBottle(), "pink_pony_bottle");
    pinkBCD = registerItem(registry, new ItemBCD(), "pink_bcd");
    pinkRegulator = registerItem(registry, new ItemTropicraft(), "pink_regulator");
    pinkScubaTank = registerItem(registry, new ItemScubaTank(), "pink_scuba_tank");
    pinkFlippers = registerItem(registry, new ItemScubaFlippers(materialPinkSuit, ScubaMaterial.PINK, 0, EntityEquipmentSlot.FEET), "pink_flippers");
    pinkChestplateGear = registerItem(registry, new ItemScubaChestplateGear(materialPinkSuit, ScubaMaterial.PINK, 0, EntityEquipmentSlot.CHEST), "pink_chestplate_gear");
    pinkScubaGoggles = registerItem(registry, new ItemScubaHelmet(materialPinkSuit, ScubaMaterial.PINK, 0, EntityEquipmentSlot.HEAD), "pink_scuba_goggles");
    yellowWeightBelt = registerItem(registry, new ItemTropicraft(), "yellow_weight_belt");
    yellowPonyBottle = registerItem(registry, new ItemPonyBottle(), "yellow_pony_bottle");
    yellowBCD = registerItem(registry, new ItemBCD(), "yellow_bcd");
    yellowRegulator = registerItem(registry, new ItemTropicraft(), "yellow_regulator");
    yellowScubaTank = registerItem(registry, new ItemScubaTank(), "yellow_scuba_tank");
    yellowFlippers = registerItem(registry, new ItemScubaFlippers(materialYellowSuit, ScubaMaterial.YELLOW, 0, EntityEquipmentSlot.FEET), "yellow_flippers");
    yellowChestplateGear = registerItem(registry, new ItemScubaChestplateGear(materialYellowSuit, ScubaMaterial.YELLOW, 0, EntityEquipmentSlot.CHEST), "yellow_chestplate_gear");
    yellowScubaGoggles = registerItem(registry, new ItemScubaHelmet(materialYellowSuit, ScubaMaterial.YELLOW, 0, EntityEquipmentSlot.HEAD), "yellow_scuba_goggles");
    recordBuriedTreasure = registerItem(registry, new ItemMusicDisc("buried_treasure", "Punchaface", TropicraftSounds.BURIED_TREASURE), "buried_treasure");
    recordEasternIsles = registerItem(registry, new ItemMusicDisc("eastern_isles", "Frox", TropicraftSounds.EASTERN_ISLES), "eastern_isles");
    recordSummering = registerItem(registry, new ItemMusicDisc("summering", "Billy Christiansen", TropicraftSounds.SUMMERING), "summering");
    recordTheTribe = registerItem(registry, new ItemMusicDisc("the_tribe", "Emile Van Krieken", TropicraftSounds.THE_TRIBE), "the_tribe");
    recordLowTide = registerItem(registry, new ItemMusicDisc("low_tide", "Punchaface", TropicraftSounds.LOW_TIDE), "low_tide");
    recordTradeWinds = registerItem(registry, new ItemMusicDisc("trade_winds", "Frox", TropicraftSounds.TRADE_WINDS), "trade_winds");
    azurite = registerItem(registry, new ItemTropicsOre(), "azurite");
    OreDictionary.registerOre("gemAzurite", azurite);
    eudialyte = registerItem(registry, new ItemTropicsOre(), "eudialyte");
    OreDictionary.registerOre("gemEudialyte", eudialyte);
    zircon = registerItem(registry, new ItemTropicsOre(), "zircon");
    OreDictionary.registerOre("gemZircon", zircon);
    grapefruit = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "grapefruit");
    lemon = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "lemon");
    lime = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "lime");
    orange = registerItem(registry, new ItemTropicraftFood(2, 0.2F), "orange");
    hoeEudialyte = registerItem(registry, new ItemHoe(materialEudialyteTools), "hoe_eudialyte");
    hoeZircon = registerItem(registry, new ItemHoe(materialZirconTools), "hoe_zircon");
    pickaxeEudialyte = registerItem(registry, new ItemTropicraftPickaxe(materialEudialyteTools), "pickaxe_eudialyte");
    pickaxeZircon = registerItem(registry, new ItemTropicraftPickaxe(materialZirconTools), "pickaxe_zircon");
    shovelEudialyte = registerItem(registry, new ItemSpade(materialEudialyteTools), "shovel_eudialyte");
    shovelZircon = registerItem(registry, new ItemSpade(materialZirconTools), "shovel_zircon");
    axeEudialyte = registerItem(registry, new ItemTropicraftAxe(materialEudialyteTools, 6.0F, -3.1F), "axe_eudialyte");
    axeZircon = registerItem(registry, new ItemTropicraftAxe(materialZirconTools, 6.0F, -3.2F), "axe_zircon");
    swordEudialyte = registerItem(registry, new ItemSword(materialEudialyteTools), "sword_eudialyte");
    swordZircon = registerItem(registry, new ItemSword(materialZirconTools), "sword_zircon");
    fishingNet = registerItem(registry, new ItemTropicraft(), "fishing_net");
    bambooStick = registerItem(registry, new ItemTropicraft(), "bamboo_stick");
    // Note: Commented out because bamboo ladder recipe would make wooden ladders
    // OreDictionary.registerOre("stickWood", bambooStick);
    bambooMug = registerItem(registry, new ItemTropicraft().setMaxStackSize(16), "bamboo_mug");
    freshMarlin = registerItem(registry, new ItemTropicraftFood(2, 0.3F), "fresh_marlin");
    searedMarlin = registerItem(registry, new ItemTropicraftFood(8, 0.65F), "seared_marlin");
    tropicsWaterBucket = registerItem(registry, (new ItemBucket(BlockRegistry.tropicsWater)).setContainerItem(Items.BUCKET), "tropics_water_bucket");
    fishBucket = registerItem(registry, new ItemFishBucket(), "fish_bucket");
    coconutChunk = registerItem(registry, new ItemTropicraftFood(1, 0.1F), "coconut_chunk");
    pineappleCubes = registerItem(registry, new ItemTropicraftFood(1, 0.1F), "pineapple_cubes");
    coffeeBeans = registerMultiItem(registry, new ItemCoffeeBean(Names.COFFEE_NAMES, BlockRegistry.coffeePlant), "coffee_beans", Names.COFFEE_NAMES);
    frogLeg = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "frog_leg");
    cookedFrogLeg = registerItem(registry, new ItemTropicraftFood(2, 0.15F), "cooked_frog_leg");
    poisonFrogSkin = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "poison_frog_skin");
    scale = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "scale");
    scaleBoots = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.FEET), "scale_boots");
    scaleLeggings = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.LEGS), "scale_leggings");
    scaleChestplate = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.CHEST), "scale_chestplate");
    scaleHelmet = registerItem(registry, new ItemScaleArmor(materialScaleArmor, 0, EntityEquipmentSlot.HEAD), "scale_helmet");
    fireBoots = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.FEET), "fire_boots");
    fireLeggings = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.LEGS), "fire_leggings");
    fireChestplate = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.CHEST), "fire_chestplate");
    fireHelmet = registerItem(registry, new ItemFireArmor(materialFireArmor, 0, EntityEquipmentSlot.HEAD), "fire_helmet");
    chair = registerMultiItem(registry, new ItemChair(), "chair", ItemDye.DYE_COLORS.length);
    umbrella = registerMultiItem(registry, new ItemUmbrella(), "umbrella", ItemDye.DYE_COLORS.length);
    beach_float = registerMultiItem(registry, new ItemBeachFloat(), "float", ItemDye.DYE_COLORS.length);
    portalEnchanter = registerItem(registry, new ItemPortalEnchanter(), "portal_enchanter");
    shell = registerMultiItem(registry, new ItemShell(), "shell", TropicraftShells.values());
    cocktail = registerMultiItem(registry, new ItemCocktail(), "cocktail", Drink.drinkList.length);
    whitePearl = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "white_pearl");
    blackPearl = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "black_pearl");
    fertilizer = registerItem(registry, new ItemFertilizer(), "fertilizer");
    encyclopedia = registerItem(registry, new ItemEncyclopediaTropica(), "encyclopedia_tropica");
    dagger = registerItem(registry, new ItemDagger(materialZirconTools), "dagger");
    bambooSpear = registerItem(registry, new ItemSword(materialBambooTools), "bamboo_spear");
    coconutBomb = registerItem(registry, new ItemCoconutBomb(), "coconut_bomb");
    flowerPot = registerItem(registry, new ItemTropicraftBlockSpecial(BlockRegistry.flowerPot), "flower_pot");
    bambooDoor = registerItem(registry, new ItemDoor(BlockRegistry.bambooDoor), "bamboo_door");
    bambooItemFrame = registerItem(registry, new ItemBambooItemFrame(EntityBambooItemFrame.class), "bamboo_item_frame");
    Tropicraft.proxy.registerArbitraryBlockVariants("bamboo_item_frame", "normal", "map");
    waterWand = registerItem(registry, new ItemWaterWand(), "water_wand");
    seaUrchinRoe = registerItem(registry, new ItemTropicraftFood(3, 0.3F), "sea_urchin_roe");
    mobEgg = registerMultiItemPrefixed(registry, new ItemMobEgg(), "spawn_egg", Names.EGG_NAMES);
    iguanaLeather = registerItem(registry, new ItemTropicraft().setMaxStackSize(64), "iguana_leather");
    OreDictionary.registerOre("leather", iguanaLeather);
    trimix = registerItem(registry, new ItemTropicraft().setMaxStackSize(1), "trimix");
    maskSquareZord = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.SQUARE_ZORD), "mask_square_zord");
    maskHornMonkey = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.HORN_MONKEY), "mask_horn_monkey");
    maskOblongatron = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.OBLONGATRON), "mask_oblongatron");
    maskHeadinator = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.HEADINATOR), "mask_headinator");
    maskSquareHorn = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.SQUARE_HORN), "mask_square_horn");
    maskScrewAttack = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.SCREW_ATTACK), "mask_screw_attack");
    maskTheBrain = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.THE_BRAIN), "mask_the_brain");
    maskBatBoy = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.BAT_BOY), "mask_bat_boy");
    mask1 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK1), "mask_ashen_mask1");
    mask2 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK2), "mask_ashen_mask2");
    mask3 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK3), "mask_ashen_mask3");
    mask4 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK4), "mask_ashen_mask4");
    mask5 = registerItem(registry, new ItemAshenMask(materialMaskArmor, 0, EntityEquipmentSlot.HEAD, AshenMasks.ASHEN_MASK5), "mask_ashen_mask5");
    fishingRod = registerItem(registry, new ItemFishingRod(), "fishing_rod");
    ltShell = registerMultiItem(registry, new ItemLoveTropicsShell(), "ltshell", Names.LOVE_TROPICS_NAMES.length);
}
Also used : ItemPortalEnchanter(net.tropicraft.core.common.item.ItemPortalEnchanter) ItemDoor(net.minecraft.item.ItemDoor) ItemFertilizer(net.tropicraft.core.common.item.ItemFertilizer) ItemCocktail(net.tropicraft.core.common.item.ItemCocktail) ItemScubaChestplateGear(net.tropicraft.core.common.item.scuba.ItemScubaChestplateGear) ItemBCD(net.tropicraft.core.common.item.scuba.ItemBCD) ItemTropicraftBlockSpecial(net.tropicraft.core.common.item.ItemTropicraftBlockSpecial) ItemDiveComputer(net.tropicraft.core.common.item.scuba.ItemDiveComputer) ItemCoconutBomb(net.tropicraft.core.common.item.ItemCoconutBomb) ItemAshenMask(net.tropicraft.core.common.item.armor.ItemAshenMask) ItemWaterWand(net.tropicraft.core.common.item.ItemWaterWand) ItemChair(net.tropicraft.core.common.item.ItemChair) Item(net.minecraft.item.Item) ItemHoe(net.minecraft.item.ItemHoe) ItemSpade(net.minecraft.item.ItemSpade) ItemTropicraftPickaxe(net.tropicraft.core.common.item.ItemTropicraftPickaxe) ItemScaleArmor(net.tropicraft.core.common.item.armor.ItemScaleArmor) ItemShell(net.tropicraft.core.common.item.ItemShell) ItemCoffeeBean(net.tropicraft.core.common.item.ItemCoffeeBean) ItemFishBucket(net.tropicraft.core.common.item.ItemFishBucket) ItemTropicraft(net.tropicraft.core.common.item.ItemTropicraft) ItemMusicDisc(net.tropicraft.core.common.item.ItemMusicDisc) ItemSword(net.minecraft.item.ItemSword) ItemFireArmor(net.tropicraft.core.common.item.armor.ItemFireArmor) ItemTropicsOre(net.tropicraft.core.common.item.ItemTropicsOre) ItemFishingRod(net.tropicraft.core.common.item.ItemFishingRod) ItemScubaTank(net.tropicraft.core.common.item.scuba.ItemScubaTank) ItemTropicraftFood(net.tropicraft.core.common.item.ItemTropicraftFood) ItemBucket(net.minecraft.item.ItemBucket) ItemBeachFloat(net.tropicraft.core.common.item.ItemBeachFloat) ItemScubaFlippers(net.tropicraft.core.common.item.scuba.ItemScubaFlippers) ItemLoveTropicsShell(net.tropicraft.core.common.item.ItemLoveTropicsShell) ItemUmbrella(net.tropicraft.core.common.item.ItemUmbrella) ItemTropicraftAxe(net.tropicraft.core.common.item.ItemTropicraftAxe) ItemEncyclopediaTropica(net.tropicraft.core.common.item.ItemEncyclopediaTropica) ItemMobEgg(net.tropicraft.core.common.item.ItemMobEgg) ItemScubaHelmet(net.tropicraft.core.common.item.scuba.ItemScubaHelmet) ItemPonyBottle(net.tropicraft.core.common.item.scuba.ItemPonyBottle) ItemBambooItemFrame(net.tropicraft.core.common.item.ItemBambooItemFrame) ItemDagger(net.tropicraft.core.common.item.ItemDagger) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 30 with ItemSword

use of net.minecraft.item.ItemSword in project Hyperium by HyperiumClient.

the class HyperiumItemRenderer method renderItemInFirstPerson.

public void renderItemInFirstPerson(float partialTicks, float prevEquippedProgress, float equippedProgress, ItemStack itemToRender) {
    float f = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks);
    EntityPlayerSP entityPlayerSP = mc.thePlayer;
    float f1 = entityPlayerSP.getSwingProgress(partialTicks);
    float f2 = entityPlayerSP.prevRotationPitch + (entityPlayerSP.rotationPitch - entityPlayerSP.prevRotationPitch) * partialTicks;
    float f3 = entityPlayerSP.prevRotationYaw + (entityPlayerSP.rotationYaw - entityPlayerSP.prevRotationYaw) * partialTicks;
    ((IMixinItemRenderer) parent).callRotateArroundXAndY(f2, f3);
    ((IMixinItemRenderer) parent).callSetLightMapFromPlayer(entityPlayerSP);
    ((IMixinItemRenderer) parent).callRotateWithPlayerRotations(entityPlayerSP, partialTicks);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();
    if (itemToRender != null) {
        if (itemToRender.getItem() == Items.filled_map) {
            ((IMixinItemRenderer) parent).callRenderItemMap(entityPlayerSP, f2, f, f1);
        } else if ((itemToRender.getItem() instanceof ItemSword) && !mc.thePlayer.isBlocking() && Settings.CUSTOM_SWORD_ANIMATION) {
            transformFirstPersonItem(f, f1);
        } else if (entityPlayerSP.getItemInUseCount() > 0) {
            EnumAction enumaction = itemToRender.getItemUseAction();
            switch(enumaction) {
                case NONE:
                    transformFirstPersonItem(f, 0.0F);
                    break;
                case EAT:
                case DRINK:
                    ((IMixinItemRenderer) parent).callPerformDrinking(entityPlayerSP, partialTicks);
                    if (Settings.OLD_EATING) {
                        transformFirstPersonItem(f, f1);
                    } else {
                        transformFirstPersonItem(f, 0.0F);
                    }
                    break;
                case BLOCK:
                    if (Settings.OLD_BLOCKHIT) {
                        transformFirstPersonItem(f, f1);
                        ((IMixinItemRenderer) parent).callDoBlockTransformations();
                        GlStateManager.scale(0.83f, 0.88f, 0.85f);
                        GlStateManager.translate(-0.3f, 0.1f, 0.0f);
                    } else {
                        transformFirstPersonItem(f, 0f);
                        ((IMixinItemRenderer) parent).callDoBlockTransformations();
                    }
                    break;
                case BOW:
                    if (Settings.OLD_BOW) {
                        transformFirstPersonItem(f, f1);
                        ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
                        GlStateManager.translate(0.0F, 0.1F, -0.15F);
                    } else {
                        transformFirstPersonItem(f, 0.0F);
                        ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
                    }
            }
        } else {
            ((IMixinItemRenderer) parent).callDoItemUsedTransformations(f1);
            transformFirstPersonItem(f, f1);
        }
        parent.renderItem(entityPlayerSP, itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
    } else if (!entityPlayerSP.isInvisible()) {
        ((IMixinItemRenderer) parent).callRenderPlayerArm(entityPlayerSP, f, f1);
    }
    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
}
Also used : ItemSword(net.minecraft.item.ItemSword) IMixinItemRenderer(cc.hyperium.mixins.client.renderer.IMixinItemRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EnumAction(net.minecraft.item.EnumAction)

Aggregations

ItemSword (net.minecraft.item.ItemSword)76 ItemStack (net.minecraft.item.ItemStack)53 Item (net.minecraft.item.Item)25 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)23 EntityPlayer (net.minecraft.entity.player.EntityPlayer)22 ItemTool (net.minecraft.item.ItemTool)21 ItemHoe (net.minecraft.item.ItemHoe)18 IBlockState (net.minecraft.block.state.IBlockState)17 ItemBow (net.minecraft.item.ItemBow)15 Entity (net.minecraft.entity.Entity)13 Block (net.minecraft.block.Block)9 EntityLivingBase (net.minecraft.entity.EntityLivingBase)8 ItemAxe (net.minecraft.item.ItemAxe)8 ItemBlock (net.minecraft.item.ItemBlock)8 World (net.minecraft.world.World)7 ItemArmor (net.minecraft.item.ItemArmor)6 ItemFishingRod (net.minecraft.item.ItemFishingRod)6 DamageSource (net.minecraft.util.DamageSource)6 ItemDoor (net.minecraft.item.ItemDoor)5 ItemShield (net.minecraft.item.ItemShield)5