Search in sources :

Example 1 with ShieldItem

use of net.minecraft.item.ShieldItem in project bioplethora by AquexTheSeal.

the class BioItemModelProvider method grylynenShield.

public void grylynenShield(Item items) {
    String name = items.getRegistryName().getPath();
    ResourceLocation datagenLoc = new ResourceLocation(Bioplethora.MOD_ID, "item/" + name);
    ModelFile.ExistingModelFile modelType = getBioLoc("item/grylynen_shield_base");
    ModelFile.ExistingModelFile blockingModelType = getBioLoc("item/grylynen_shield_base_blocking");
    if (items instanceof ShieldItem) {
        if (!existingFileHelper.exists(datagenLoc, TEXTURE) || existingFileHelper.exists(datagenLoc, MODEL)) {
            this.getBuilder(name).parent(modelType).texture("layer0", ITEM_FOLDER + "/" + name).override().predicate(new ResourceLocation("blocking"), 1).model(getBuilder(name + "_blocking"));
            this.getBuilder(name + "_blocking").parent(blockingModelType).texture("layer0", ITEM_FOLDER + "/" + name);
            Bioplethora.LOGGER.info("Generate Shield Item Successful: " + name);
        }
    } else {
        throw new IllegalStateException(name + " is not a Shield!");
    }
}
Also used : ShieldItem(net.minecraft.item.ShieldItem) ModelFile(net.minecraftforge.client.model.generators.ModelFile) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with ShieldItem

use of net.minecraft.item.ShieldItem in project ChocolateQuestRepoured by TeamChocoQuest.

the class ContainerCQREntity method quickMoveStack.

@Override
public ItemStack quickMoveStack(PlayerEntity playerIn, int index) {
    Slot slot = this.slots.get(index);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        ItemStack itemstack = itemstack1.copy();
        // MAINHAND -> OFFHAND (other) -> HEAD (other)
        if (index > 35) {
            if (this.moveItemStackTo(itemstack1, 0, 36, false)) {
                return itemstack;
            }
        } else {
            if (this.moveItemStackTo(itemstack1, 36, 39, false)) {
                return itemstack;
            } else if (this.isHelmet(itemstack1) && this.moveItemStackTo(itemstack1, 39, 40, false)) {
                return itemstack;
            } else if (this.moveItemStackTo(itemstack1, 42, 45, false)) {
                return itemstack;
            } else if (itemstack1.getItem() instanceof ShieldItem && this.moveItemStackTo(itemstack1, 41, 42, false)) {
                return itemstack;
            } else if (this.moveItemStackTo(itemstack1, 40, 42, false)) {
                return itemstack;
            } else {
                if (index > 26) {
                    if (this.moveItemStackTo(itemstack1, 0, 27, false)) {
                        return ItemStack.EMPTY;
                    }
                } else {
                    if (this.moveItemStackTo(itemstack1, 27, 36, false)) {
                        return ItemStack.EMPTY;
                    }
                }
            }
        }
    }
    return ItemStack.EMPTY;
}
Also used : ShieldItem(net.minecraft.item.ShieldItem) Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ShieldItem

use of net.minecraft.item.ShieldItem in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQRWalkerKing method hurt.

@Override
public boolean hurt(DamageSource source, float amount, boolean sentFromPart) {
    if (source == DamageSource.WITHER) {
        this.heal(amount / 2);
        return true;
    }
    if (source == DamageSource.FALL) {
        return true;
    }
    if (source == DamageSource.IN_WALL && this.hasAttackTarget() && this.isServerWorld()) {
        EntityWalkerKingIllusion illusion = new EntityWalkerKingIllusion(1200, this, this.getWorld());
        illusion.setPos(this.getX(), this.getY(), this.getZ());
        this.level.addFreshEntity(illusion);
        this.teleportBehindEntity(this.getTarget(), true);
        this.canAttack(this.getTarget());
        return false;
    }
    /*
		 * boolean spectralFlag = false;
		 * if (source.getTrueSource() instanceof EntityLivingBase) {
		 * if (EnchantmentHelper.getEnchantmentLevel(CQREnchantments.SPECTRAL, ((EntityLivingBase)
		 * source.getTrueSource()).getHeldItemMainhand()) > 0 ||
		 * EnchantmentHelper.getEnchantmentLevel(CQREnchantments.SPECTRAL, ((EntityLivingBase)
		 * source.getTrueSource()).getHeldItemOffhand()) > 0) {
		 * amount *= 2;
		 * spectralFlag = true;
		 * }
		 * }
		 */
    if (/* !spectralFlag && */
    ((source.getDirectEntity() == null) || !(source.getDirectEntity() instanceof SpectralArrowEntity)) && !CQRConfig.bosses.armorForTheWalkerKing) {
        amount *= 0.5F;
    }
    if (source.getDirectEntity() != null) {
        if (source.getDirectEntity() instanceof SpectralArrowEntity) {
            amount *= 2;
            super.hurt(source, amount, sentFromPart);
            return true;
        }
        if ((source.getDirectEntity() instanceof ThrowableEntity || source.getDirectEntity() instanceof AbstractArrowEntity) && !this.level.isClientSide) {
            // STAB HIM IN THE BACK!!
            this.backStabAttacker(source);
            return false;
        }
    }
    this.handleActivation();
    if (source.getEntity() != null && !this.level.isClientSide) {
        ResourceLocation resLoc = EntityList.getKey(source.getEntity());
        if (resLoc != null) {
            // Start IceAndFire compatibility
            boolean flag = resLoc.getNamespace().equalsIgnoreCase("iceandfire") && CQRConfig.advanced.enableSpecialFeatures;
            if (flag) {
                amount /= 2;
            }
            // End IceAndFire compatibility
            Faction fac = FactionRegistry.instance(this).getFactionOf(source.getEntity());
            boolean dragonFactionFlag = fac != null && (fac.getName().equalsIgnoreCase("DRAGON") || fac.getName().equalsIgnoreCase("DRAGONS"));
            // If we are attacked by a dragon: KILL IT
            if (this.dragonAttackCooldown <= 0 && (dragonFactionFlag || resLoc.getPath().contains("dragon") || resLoc.getPath().contains("wyrm") || resLoc.getPath().contains("wyvern") || flag)) {
                this.dragonAttackCooldown = 80;
                this.handleAttackedByDragon(source.getEntity());
            }
        }
    }
    if (!this.level.isClientSide && source.getEntity() instanceof LivingEntity) {
        // How about killing the one who tries with the axe?
        // Maybe move this whole ability to the king shield itself??
        ItemStack shieldStack = this.getItemBySlot(EquipmentSlotType.OFFHAND);
        if (amount > 0F && this.canBlockDamageSource(source) && shieldStack != null && !shieldStack.isEmpty() && shieldStack.getItem() instanceof ShieldItem) {
            this.playSound(CQRSounds.WALKER_KING_LAUGH, 10.0F, 1.0F);
            if (source.getDirectEntity() instanceof LivingEntity && /* && (source.getImmediateSource() instanceof EntityPlayer) */
            ((LivingEntity) source.getDirectEntity()).getMainHandItem().getItem() instanceof AxeItem) {
                if (DungeonGenUtils.percentageRandom(0.75, this.getRandom())) {
                    Vector3d v = source.getDirectEntity().position().subtract(this.position()).normalize().scale(1.25);
                    v = v.add(0, 0.75, 0);
                    LivingEntity attacker = (LivingEntity) source.getDirectEntity();
                    /*attacker.motionX = v.x;
						attacker.motionY = v.y;
						attacker.motionZ = v.z;
						attacker.velocityChanged = true;*/
                    attacker.setDeltaMovement(v);
                    attacker.hasImpulse = true;
                    this.swing(Hand.OFF_HAND);
                    return false;
                }
            }
        }
        if (this.getRandom().nextDouble() < 0.2 && source.getEntity() != null) {
            // Revenge Attack
            if (this.getRandom().nextDouble() < 0.7) {
                this.canAttack((LivingEntity) source.getEntity());
                this.playSound(CQRSounds.WALKER_KING_LAUGH, 10.0F, 1.0F);
                this.teleportBehindEntity(source.getEntity());
            }
        }
    }
    return super.hurt(source, amount, sentFromPart);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EntityWalkerKingIllusion(team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion) ShieldItem(net.minecraft.item.ShieldItem) Vector3d(net.minecraft.util.math.vector.Vector3d) SpectralArrowEntity(net.minecraft.entity.projectile.SpectralArrowEntity) ThrowableEntity(net.minecraft.entity.projectile.ThrowableEntity) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) AxeItem(net.minecraft.item.AxeItem) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) Faction(team.cqr.cqrepoured.faction.Faction) EDefaultFaction(team.cqr.cqrepoured.faction.EDefaultFaction)

Example 4 with ShieldItem

use of net.minecraft.item.ShieldItem in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQRGiantTortoise method doPush.

@Override
protected void doPush(Entity entityIn) {
    if (this.isSpinning()) {
        boolean blocked = false;
        if (entityIn instanceof LivingEntity) {
            if (((LivingEntity) entityIn).getUseItem().getItem() instanceof ShieldItem || ((LivingEntity) entityIn).getUseItem().getItem().isShield(((LivingEntity) entityIn).getUseItem(), (LivingEntity) entityIn)) {
                if (this.getRandom().nextBoolean()) {
                    this.spinsBlocked++;
                }
                this.spinsBlocked++;
                blocked = true;
            }
        }
        if (!blocked) {
            entityIn.hurt(DamageSource.thorns(this), 4F * (Math.max(1, this.level.getDifficulty().getId()) * 1.5F));
        }
        Vector3d v = entityIn.position().subtract(this.position());
        v = v.normalize();
        if (blocked) {
            v = v.scale(0.8D);
        } else {
            v = v.scale(1.5D);
        }
        /*entityIn.motionX = v.x;
			entityIn.motionY = v.y + 0.75;
			entityIn.motionZ = v.z;
			entityIn.velocityChanged = true;*/
        entityIn.setDeltaMovement(v.add(0, 0.75, 0));
        entityIn.hasImpulse = true;
        if (blocked) {
            v = v.scale(1.7D);
            /*this.motionX = -v.x;
				this.motionY = v.y + 0.25;
				this.motionZ = -v.z;
				this.velocityChanged = true;*/
            this.setDeltaMovement(-v.x, v.y + 0.25, -v.z);
            this.hasImpulse = true;
            this.playSound(SoundEvents.BLAZE_HURT, 1.0F, 1.0F);
        }
    } else {
        super.doPush(entityIn);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ShieldItem(net.minecraft.item.ShieldItem) Vector3d(net.minecraft.util.math.vector.Vector3d)

Example 5 with ShieldItem

use of net.minecraft.item.ShieldItem in project ChocolateQuestRepoured by TeamChocoQuest.

the class ProjectileBubble method applyEntityCollision.

@Override
public void applyEntityCollision(Entity entityHit) {
    if (entityHit == this.shooter) {
        return;
    }
    if (entityHit instanceof EntityBubble || entityHit instanceof ProjectileBubble) {
        return;
    }
    if (entityHit.isRiding() && entityHit.getRidingEntity() instanceof EntityBubble) {
        return;
    }
    if (entityHit instanceof MobEntity && ((MobEntity) entityHit).getActiveItemStack().getItem() instanceof ShieldItem) {
        return;
    }
    entityHit.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this.shooter, this), this.damage);
    float pitch = (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F;
    this.world.playSound(this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_SWIM, SoundCategory.PLAYERS, 4, pitch, true);
    EntityBubble bubbles = new EntityBubble(this.world);
    bubbles.moveToBlockPosAndAngles(entityHit.getPosition().add(0, 0.25, 0), entityHit.rotationYaw, entityHit.rotationPitch);
    this.world.spawnEntity(bubbles);
    entityHit.startRiding(bubbles, true);
    this.setDead();
}
Also used : ShieldItem(net.minecraft.item.ShieldItem) EntityBubble(team.cqr.cqrepoured.entity.misc.EntityBubble) MobEntity(net.minecraft.entity.MobEntity)

Aggregations

ShieldItem (net.minecraft.item.ShieldItem)6 LivingEntity (net.minecraft.entity.LivingEntity)3 AxeItem (net.minecraft.item.AxeItem)2 ItemStack (net.minecraft.item.ItemStack)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Lists (com.google.common.collect.Lists)1 FriendManager (dev.hypnotic.config.friends.FriendManager)1 EventTarget (dev.hypnotic.event.EventTarget)1 EventMotionUpdate (dev.hypnotic.event.events.EventMotionUpdate)1 EventRender3D (dev.hypnotic.event.events.EventRender3D)1 EventSendPacket (dev.hypnotic.event.events.EventSendPacket)1 PlayerMoveC2SPacketAccessor (dev.hypnotic.mixin.PlayerMoveC2SPacketAccessor)1 Category (dev.hypnotic.module.Category)1 Mod (dev.hypnotic.module.Mod)1 ModuleManager (dev.hypnotic.module.ModuleManager)1 Scaffold (dev.hypnotic.module.player.Scaffold)1 OldBlock (dev.hypnotic.module.render.OldBlock)1 BooleanSetting (dev.hypnotic.settings.settingtypes.BooleanSetting)1 ColorSetting (dev.hypnotic.settings.settingtypes.ColorSetting)1 ModeSetting (dev.hypnotic.settings.settingtypes.ModeSetting)1