Search in sources :

Example 6 with SpellRing

use of com.teamwizardry.wizardry.api.spell.SpellRing in project Wizardry by TeamWizardry.

the class PotionTimeSlow method entityMove.

@SubscribeEvent
public void entityMove(EntityMoveEvent event) {
    if (!(event.entity instanceof EntityLivingBase))
        return;
    EntityLivingBase base = (EntityLivingBase) event.entity;
    if (!base.isPotionActive(ModPotions.TIME_SLOW))
        return;
    PotionEffect effect = base.getActivePotionEffect(ModPotions.TIME_SLOW);
    if (effect == null)
        return;
    ModuleEffectTimeSlow slow = (ModuleEffectTimeSlow) ModuleRegistry.INSTANCE.getModule("effect_time_slow");
    SpellData data = new SpellData(event.entity.world);
    data.processEntity(event.entity, false);
    SpellRing ring = new SpellRing(slow);
    ring.getModule().sendRenderPacket(data, ring);
    event.override = true;
    Entity entity = event.entity;
    double amp = effect.getAmplifier();
    double x = event.x / amp;
    double y = event.y / amp;
    double z = event.z / amp;
    MoverType type = event.type;
    if (entity.noClip) {
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(x, y, z));
        entity.resetPositionToBB();
    } else {
        entity.world.profiler.startSection("move");
        double d10 = entity.posX;
        double d11 = entity.posY;
        double d1 = entity.posZ;
        double d2 = x;
        double d3 = y;
        double d4 = z;
        if ((type == MoverType.SELF || type == MoverType.PLAYER) && entity.onGround && entity.isSneaking() && entity instanceof EntityPlayer) {
            for (; x != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), 0.0D)).isEmpty(); d2 = x) {
                if (x < 0.05D && x >= -0.05D) {
                    x = 0.0D;
                } else if (x > 0.0D) {
                    x -= 0.05D;
                } else {
                    x += 0.05D;
                }
            }
            for (; z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(0.0D, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
                if (z < 0.05D && z >= -0.05D) {
                    z = 0.0D;
                } else if (z > 0.0D) {
                    z -= 0.05D;
                } else {
                    z += 0.05D;
                }
            }
            for (; x != 0.0D && z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
                if (x < 0.05D && x >= -0.05D) {
                    x = 0.0D;
                } else if (x > 0.0D) {
                    x -= 0.05D;
                } else {
                    x += 0.05D;
                }
                d2 = x;
                if (z < 0.05D && z >= -0.05D) {
                    z = 0.0D;
                } else if (z > 0.0D) {
                    z -= 0.05D;
                } else {
                    z += 0.05D;
                }
            }
        }
        List<AxisAlignedBB> list1 = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, y, z));
        AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox();
        if (y != 0.0D) {
            int k = 0;
            for (int l = list1.size(); k < l; ++k) {
                y = list1.get(k).calculateYOffset(entity.getEntityBoundingBox(), y);
            }
            entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y, 0.0D));
        }
        if (x != 0.0D) {
            int j5 = 0;
            for (int l5 = list1.size(); j5 < l5; ++j5) {
                x = list1.get(j5).calculateXOffset(entity.getEntityBoundingBox(), x);
            }
            if (x != 0.0D) {
                entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(x, 0.0D, 0.0D));
            }
        }
        if (z != 0.0D) {
            int k5 = 0;
            for (int i6 = list1.size(); k5 < i6; ++k5) {
                z = list1.get(k5).calculateZOffset(entity.getEntityBoundingBox(), z);
            }
            if (z != 0.0D) {
                entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, 0.0D, z));
            }
        }
        boolean flag = entity.onGround || d3 != y && d3 < 0.0D;
        if (entity.stepHeight > 0.0F && flag && (d2 != x || d4 != z)) {
            double d14 = x;
            double d6 = y;
            double d7 = z;
            AxisAlignedBB axisalignedbb1 = entity.getEntityBoundingBox();
            entity.setEntityBoundingBox(axisalignedbb);
            y = (double) entity.stepHeight;
            List<AxisAlignedBB> list = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(d2, y, d4));
            AxisAlignedBB axisalignedbb2 = entity.getEntityBoundingBox();
            AxisAlignedBB axisalignedbb3 = axisalignedbb2.offset(d2, 0.0D, d4);
            double d8 = y;
            int j1 = 0;
            for (int k1 = list.size(); j1 < k1; ++j1) {
                d8 = list.get(j1).calculateYOffset(axisalignedbb3, d8);
            }
            axisalignedbb2 = axisalignedbb2.offset(0.0D, d8, 0.0D);
            double d18 = d2;
            int l1 = 0;
            for (int i2 = list.size(); l1 < i2; ++l1) {
                d18 = list.get(l1).calculateXOffset(axisalignedbb2, d18);
            }
            axisalignedbb2 = axisalignedbb2.offset(d18, 0.0D, 0.0D);
            double d19 = d4;
            int j2 = 0;
            for (int k2 = list.size(); j2 < k2; ++j2) {
                d19 = list.get(j2).calculateZOffset(axisalignedbb2, d19);
            }
            axisalignedbb2 = axisalignedbb2.offset(0.0D, 0.0D, d19);
            AxisAlignedBB axisalignedbb4 = entity.getEntityBoundingBox();
            double d20 = y;
            int l2 = 0;
            for (int i3 = list.size(); l2 < i3; ++l2) {
                d20 = list.get(l2).calculateYOffset(axisalignedbb4, d20);
            }
            axisalignedbb4 = axisalignedbb4.offset(0.0D, d20, 0.0D);
            double d21 = d2;
            int j3 = 0;
            for (int k3 = list.size(); j3 < k3; ++j3) {
                d21 = list.get(j3).calculateXOffset(axisalignedbb4, d21);
            }
            axisalignedbb4 = axisalignedbb4.offset(d21, 0.0D, 0.0D);
            double d22 = d4;
            int l3 = 0;
            for (int i4 = list.size(); l3 < i4; ++l3) {
                d22 = list.get(l3).calculateZOffset(axisalignedbb4, d22);
            }
            axisalignedbb4 = axisalignedbb4.offset(0.0D, 0.0D, d22);
            double d23 = d18 * d18 + d19 * d19;
            double d9 = d21 * d21 + d22 * d22;
            if (d23 > d9) {
                x = d18;
                z = d19;
                y = -d8;
                entity.setEntityBoundingBox(axisalignedbb2);
            } else {
                x = d21;
                z = d22;
                y = -d20;
                entity.setEntityBoundingBox(axisalignedbb4);
            }
            int j4 = 0;
            for (int k4 = list.size(); j4 < k4; ++j4) {
                y = list.get(j4).calculateYOffset(entity.getEntityBoundingBox(), y);
            }
            entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y, 0.0D));
            if (d14 * d14 + d7 * d7 >= x * x + z * z) {
                x = d14;
                y = d6;
                z = d7;
                entity.setEntityBoundingBox(axisalignedbb1);
            }
        }
        entity.world.profiler.endSection();
        entity.world.profiler.startSection("rest");
        entity.resetPositionToBB();
        entity.collidedHorizontally = d2 != x || d4 != z;
        entity.collidedVertically = d3 != y;
        entity.onGround = entity.collidedVertically && d3 < 0.0D;
        entity.collided = entity.collidedHorizontally || entity.collidedVertically;
        int j6 = MathHelper.floor(entity.posX);
        int i1 = MathHelper.floor(entity.posY - 0.20000000298023224D);
        int k6 = MathHelper.floor(entity.posZ);
        BlockPos blockpos = new BlockPos(j6, i1, k6);
        IBlockState iblockstate = entity.world.getBlockState(blockpos);
        if (iblockstate.getMaterial() == Material.AIR) {
            BlockPos blockpos1 = blockpos.down();
            IBlockState iblockstate1 = entity.world.getBlockState(blockpos1);
            Block block1 = iblockstate1.getBlock();
            if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate) {
                iblockstate = iblockstate1;
                blockpos = blockpos1;
            }
        }
        if (d2 != x) {
            entity.motionX = 0.0D;
        }
        if (d4 != z) {
            entity.motionZ = 0.0D;
        }
        Block block = iblockstate.getBlock();
        if (d3 != y) {
            block.onLanded(entity.world, entity);
        }
        if ((!entity.onGround || !entity.isSneaking() || !(entity instanceof EntityPlayer)) && !entity.isRiding()) {
            double d15 = entity.posX - d10;
            double d16 = entity.posY - d11;
            double d17 = entity.posZ - d1;
            if (block != Blocks.LADDER) {
                d16 = 0.0D;
            }
            if (block != null && entity.onGround) {
                block.onEntityWalk(entity.world, blockpos, entity);
            }
            entity.distanceWalkedModified = (float) ((double) entity.distanceWalkedModified + (double) MathHelper.sqrt(d15 * d15 + d17 * d17) * 0.6D);
            entity.distanceWalkedOnStepModified = (float) ((double) entity.distanceWalkedOnStepModified + (double) MathHelper.sqrt(d15 * d15 + d16 * d16 + d17 * d17) * 0.6D);
        }
        try {
            AxisAlignedBB bb = entity.getEntityBoundingBox();
            BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(bb.minX + 0.001D, bb.minY + 0.001D, bb.minZ + 0.001D);
            BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos1 = BlockPos.PooledMutableBlockPos.retain(bb.maxX - 0.001D, bb.maxY - 0.001D, bb.maxZ - 0.001D);
            BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos2 = BlockPos.PooledMutableBlockPos.retain();
            if (entity.world.isAreaLoaded(blockpos$pooledmutableblockpos, blockpos$pooledmutableblockpos1)) {
                for (int i = blockpos$pooledmutableblockpos.getX(); i <= blockpos$pooledmutableblockpos1.getX(); ++i) {
                    for (int j = blockpos$pooledmutableblockpos.getY(); j <= blockpos$pooledmutableblockpos1.getY(); ++j) {
                        for (int k = blockpos$pooledmutableblockpos.getZ(); k <= blockpos$pooledmutableblockpos1.getZ(); ++k) {
                            blockpos$pooledmutableblockpos2.setPos(i, j, k);
                            IBlockState state = entity.world.getBlockState(blockpos$pooledmutableblockpos2);
                            try {
                                state.getBlock().onEntityCollidedWithBlock(entity.world, blockpos$pooledmutableblockpos2, state, entity);
                            } catch (Throwable throwable) {
                                CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block");
                                CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with");
                                CrashReportCategory.addBlockInfo(crashreportcategory, blockpos$pooledmutableblockpos2, state);
                                throw new ReportedException(crashreport);
                            }
                        }
                    }
                }
            }
            blockpos$pooledmutableblockpos.release();
            blockpos$pooledmutableblockpos1.release();
            blockpos$pooledmutableblockpos2.release();
        } catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision");
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision");
            entity.addEntityCrashInfo(crashreportcategory);
            throw new ReportedException(crashreport);
        }
        entity.world.profiler.endSection();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) MoverType(net.minecraft.entity.MoverType) BlockWall(net.minecraft.block.BlockWall) PotionEffect(net.minecraft.potion.PotionEffect) CrashReport(net.minecraft.crash.CrashReport) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) BlockFenceGate(net.minecraft.block.BlockFenceGate) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ModuleEffectTimeSlow(com.teamwizardry.wizardry.common.module.effects.ModuleEffectTimeSlow) BlockFence(net.minecraft.block.BlockFence) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with SpellRing

use of com.teamwizardry.wizardry.api.spell.SpellRing in project Wizardry by TeamWizardry.

the class TileCraftingPlate method update.

@Override
public void update() {
    super.update();
    if (!((BlockCraftingPlate) getBlockType()).isStructureComplete(getWorld(), getPos()))
        return;
    if (!new CapManager(getWizardryCap()).isManaFull()) {
        for (BlockPos relative : poses) {
            BlockPos target = getPos().add(relative);
            TileEntity tile = world.getTileEntity(target);
            if (tile != null && tile instanceof TilePearlHolder) {
                if (!((TilePearlHolder) tile).isPartOfStructure) {
                    ((TilePearlHolder) tile).isPartOfStructure = true;
                    ((TilePearlHolder) tile).structurePos = getPos();
                    tile.markDirty();
                }
            }
        }
    }
    for (EntityItem entityItem : world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos))) {
        if (hasInputPearl())
            break;
        if (!isInventoryEmpty() && entityItem.getItem().getItem() instanceof IInfusable) {
            ItemStack stack = entityItem.getItem().copy();
            stack.setCount(1);
            entityItem.getItem().shrink(1);
            inputPearl.getHandler().setStackInSlot(0, stack);
        } else if (!(entityItem.getItem().getItem() instanceof IInfusable)) {
            ItemStack stack = entityItem.getItem().copy();
            stack.setCount(1);
            entityItem.getItem().shrink(1);
            for (int i = 0; i < realInventory.getHandler().getSlots(); i++) {
                if (realInventory.getHandler().getStackInSlot(i).isEmpty()) {
                    realInventory.getHandler().setStackInSlot(i, stack);
                    ClientRunnable.run(new ClientRunnable() {

                        @Override
                        @SideOnly(Side.CLIENT)
                        public void runIfClient() {
                            if (renderHandler != null)
                                ((TileCraftingPlateRenderer) renderHandler).addAnimation();
                        }
                    });
                    break;
                }
            }
        }
        markDirty();
    }
    if (hasInputPearl() && !isInventoryEmpty()) {
        CapManager manager = new CapManager(getInputPearl());
        if (manager.isManaFull()) {
            ArrayList<ItemStack> stacks = new ArrayList<>();
            for (int i = 0; i < realInventory.getHandler().getSlots(); i++) {
                if (!realInventory.getHandler().getStackInSlot(i).isEmpty()) {
                    stacks.add(realInventory.getHandler().getStackInSlot(i));
                    realInventory.getHandler().setStackInSlot(i, ItemStack.EMPTY);
                }
            }
            SpellBuilder builder = new SpellBuilder(stacks, true);
            ItemStack infusedPearl = inputPearl.getHandler().getStackInSlot(0).copy();
            inputPearl.getHandler().setStackInSlot(0, ItemStack.EMPTY);
            outputPearl.getHandler().setStackInSlot(0, infusedPearl);
            NBTTagList list = new NBTTagList();
            for (SpellRing spellRing : builder.getSpell()) {
                list.appendTag(spellRing.serializeNBT());
            }
            ItemNBTHelper.setList(infusedPearl, Constants.NBT.SPELL, list);
            // Color lastColor = SpellUtils.getAverageSpellColor(builder.getSpell());
            // float[] hsv = ColorUtils.getHSVFromColor(lastColor);
            // ItemNBTHelper.setFloat(infusedPearl, "hue", hsv[0]);
            // ItemNBTHelper.setFloat(infusedPearl, "saturation", hsv[1]);
            ItemNBTHelper.setFloat(infusedPearl, Constants.NBT.RAND, world.rand.nextFloat());
            ItemNBTHelper.setString(infusedPearl, "type", EnumPearlType.INFUSED.toString());
            // Process spellData multipliers based on nacre quality
            if (infusedPearl.getItem() instanceof INacreProduct) {
                float purity = ((INacreProduct) infusedPearl.getItem()).getQuality(infusedPearl);
                double multiplier;
                if (purity >= 1f)
                    multiplier = ConfigValues.perfectPearlMultiplier * purity;
                else if (purity <= ConfigValues.damagedPearlMultiplier)
                    multiplier = ConfigValues.damagedPearlMultiplier;
                else {
                    double base = purity - 1;
                    multiplier = 1 - (base * base * base * base);
                }
                for (SpellRing spellRing : SpellUtils.getAllSpellRings(infusedPearl)) spellRing.multiplyMultiplierForAll((float) multiplier);
            }
            ClientRunnable.run(new ClientRunnable() {

                @Override
                @SideOnly(Side.CLIENT)
                public void runIfClient() {
                    if (renderHandler != null)
                        ((TileCraftingPlateRenderer) renderHandler).clearAll();
                }
            });
            markDirty();
            PacketHandler.NETWORK.sendToAllAround(new PacketExplode(new Vec3d(pos).addVector(0.5, 0.5, 0.5), Color.CYAN, Color.BLUE, 2, 2, 500, 300, 20, true), new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 256));
            world.playSound(null, getPos(), ModSounds.BASS_BOOM, SoundCategory.BLOCKS, 1f, (float) RandUtil.nextDouble(1, 1.5));
            List<Entity> entityList = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos).grow(32, 32, 32));
            for (Entity entity1 : entityList) {
                double dist = entity1.getDistance(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
                final double upperMag = 3;
                final double scale = 0.8;
                double mag = upperMag * (scale * dist / (-scale * dist - 1) + 1);
                Vec3d dir = entity1.getPositionVector().subtract(new Vec3d(pos).addVector(0.5, 0.5, 0.5)).normalize().scale(mag);
                entity1.motionX = (dir.x);
                entity1.motionY = (dir.y);
                entity1.motionZ = (dir.z);
                entity1.fallDistance = 0;
                entity1.velocityChanged = true;
                if (entity1 instanceof EntityPlayerMP)
                    ((EntityPlayerMP) entity1).connection.sendPacket(new SPacketEntityVelocity(entity1));
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) PacketExplode(com.teamwizardry.wizardry.common.network.PacketExplode) ArrayList(java.util.ArrayList) SpellBuilder(com.teamwizardry.wizardry.api.spell.SpellBuilder) IInfusable(com.teamwizardry.wizardry.api.item.IInfusable) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) SPacketEntityVelocity(net.minecraft.network.play.server.SPacketEntityVelocity) NetworkRegistry(net.minecraftforge.fml.common.network.NetworkRegistry) BlockPos(net.minecraft.util.math.BlockPos) TileCraftingPlateRenderer(com.teamwizardry.wizardry.client.render.block.TileCraftingPlateRenderer) EntityItem(net.minecraft.entity.item.EntityItem) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) Vec3d(net.minecraft.util.math.Vec3d) CapManager(com.teamwizardry.wizardry.api.capability.CapManager) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) INacreProduct(com.teamwizardry.wizardry.api.item.INacreProduct) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 8 with SpellRing

use of com.teamwizardry.wizardry.api.spell.SpellRing in project Wizardry by TeamWizardry.

the class ModuleEffectSubstitution method render.

@Override
@SuppressWarnings("unused")
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Entity caster = spell.getCaster();
    BlockPos targetBlock = spell.getTargetPos();
    Entity targetEntity = spell.getVictim();
    if (targetEntity != null && caster != null) {
        ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(20, 30));
        glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
        glitter.setColorFunction(new InterpColorHSV(getPrimaryColor(), getSecondaryColor()));
        ParticleSpawner.spawn(glitter, spell.world, new StaticInterp<>(new Vec3d(targetEntity.posX, targetEntity.posY, targetEntity.posZ)), 50, RandUtil.nextInt(20, 30), (aFloat, particleBuilder) -> {
            glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
            glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
            glitter.setLifetime(RandUtil.nextInt(10, 20));
            glitter.setScaleFunction(new InterpScale(1, 0));
            glitter.setPositionFunction(new InterpHelix(new Vec3d(0, 0, 0), new Vec3d(0, 2, 0), 0.5f, 0f, 1, RandUtil.nextFloat()));
        });
        glitter.setColorFunction(new InterpColorHSV(getSecondaryColor(), getPrimaryColor()));
        ParticleSpawner.spawn(glitter, spell.world, new StaticInterp<>(new Vec3d(caster.posX, caster.posY, caster.posZ)), 50, RandUtil.nextInt(20, 30), (aFloat, particleBuilder) -> {
            glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
            glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
            glitter.setLifetime(RandUtil.nextInt(10, 20));
            glitter.setScaleFunction(new InterpScale(1, 0));
            glitter.setPositionFunction(new InterpHelix(new Vec3d(0, 0, 0), new Vec3d(0, 4, 0), 1f, 0f, 1, RandUtil.nextFloat()));
        });
    } else if (targetBlock != null) {
        ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(20, 30));
        glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
        glitter.setColorFunction(new InterpColorHSV(getPrimaryColor(), getSecondaryColor()));
        ParticleSpawner.spawn(glitter, spell.world, new StaticInterp<>(new Vec3d(targetBlock).addVector(0.5, 0.5, 0.5)), 20, RandUtil.nextInt(20, 30), (aFloat, particleBuilder) -> {
            glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
            glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
            glitter.setLifetime(RandUtil.nextInt(10, 20));
            glitter.setScaleFunction(new InterpScale(1, 0));
            glitter.setMotion(new Vec3d(RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001)));
        });
    }
}
Also used : InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) RegisterModule(com.teamwizardry.wizardry.api.spell.module.RegisterModule) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ModuleModifier(com.teamwizardry.wizardry.api.spell.module.ModuleModifier) ModuleEffect(com.teamwizardry.wizardry.api.spell.module.ModuleEffect) PosUtils(com.teamwizardry.wizardry.api.util.PosUtils) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) ModSounds(com.teamwizardry.wizardry.init.ModSounds) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) SoundCategory(net.minecraft.util.SoundCategory) Nonnull(javax.annotation.Nonnull) Entity(net.minecraft.entity.Entity) FACE_HIT(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.FACE_HIT) IBlockSelectable(com.teamwizardry.wizardry.api.spell.IBlockSelectable) World(net.minecraft.world.World) Wizardry(com.teamwizardry.wizardry.Wizardry) ModuleModifierIncreaseRange(com.teamwizardry.wizardry.common.module.modifiers.ModuleModifierIncreaseRange) EnumFacing(net.minecraft.util.EnumFacing) InterpHelix(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix) BlockPos(net.minecraft.util.math.BlockPos) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) IBlockState(net.minecraft.block.state.IBlockState) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) BlockUtils(com.teamwizardry.wizardry.api.util.BlockUtils) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) ItemBlock(net.minecraft.item.ItemBlock) NBTUtil(net.minecraft.nbt.NBTUtil) Constants(com.teamwizardry.wizardry.api.Constants) Entity(net.minecraft.entity.Entity) InterpHelix(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) World(net.minecraft.world.World) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with SpellRing

use of com.teamwizardry.wizardry.api.spell.SpellRing in project Wizardry by TeamWizardry.

the class RenderCodex method getSpellStructureLines.

public String[] getSpellStructureLines(ItemStack stack) {
    NBTTagList spellList = ItemNBTHelper.getList(stack, Constants.NBT.SPELL, net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND);
    if (spellList == null)
        return new String[0];
    List<SpellRing> spellChains = SpellUtils.getSpellChains(spellList);
    int widthOfSpace = Minecraft.getMinecraft().fontRenderer.getStringWidth(" ");
    StringBuilder builder = new StringBuilder("Spell Structure:\n");
    for (SpellRing chainHead : spellChains) {
        String margin = null;
        List<SpellRing> allSpellRings = SpellUtils.getAllSpellRings(chainHead);
        for (SpellRing ring : allSpellRings) {
            if (margin == null) {
                margin = " - ";
                builder.append(margin).append(ring.getModuleReadableName()).append("\n");
            } else {
                int realLength = Minecraft.getMinecraft().fontRenderer.getStringWidth(margin);
                int nbOfSpace = MathHelper.clamp(realLength / widthOfSpace, 0, 20);
                margin = StringUtils.repeat(" ", nbOfSpace) + "|_ ";
                builder.append(margin).append(ring.getModuleReadableName()).append("\n");
            }
        }
    }
    return builder.toString().split("\n");
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing)

Example 10 with SpellRing

use of com.teamwizardry.wizardry.api.spell.SpellRing in project Wizardry by TeamWizardry.

the class ItemNacrePearl method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
    if (!stack.hasTagCompound())
        return;
    List<SpellRing> spellRings = SpellUtils.getSpellChains(stack);
    SpellRing lastRing = null;
    for (SpellRing ring : spellRings) {
        if (lastRing == null)
            lastRing = ring;
        if (ring != null) {
            if (ring != lastRing)
                tooltip.add("");
            // tooltip.add("Final " + TextFormatting.BLUE + "Mana" + TextFormatting.GRAY + "/" + TextFormatting.RED + "Burnout" + TextFormatting.GRAY + " Cost: " + TextFormatting.BLUE + module.finalManaDrain + TextFormatting.GRAY + "/" + TextFormatting.RED + module.finalBurnoutFill);
            SpellRing tmpRing = ring;
            int i = 0;
            while (tmpRing != null) {
                tooltip.add(StringUtils.repeat("-", i) + "> " + TextFormatting.GRAY + tmpRing.getModuleReadableName() + " - " + TextFormatting.BLUE + Math.round(tmpRing.getManaDrain() * tmpRing.getManaMultiplier()) + TextFormatting.GRAY + "/" + TextFormatting.RED + Math.round(tmpRing.getBurnoutFill() * tmpRing.getBurnoutMultiplier()));
                if (GuiScreen.isShiftKeyDown()) {
                    for (String key : tmpRing.getInformationTag().getKeySet()) {
                        double value = tmpRing.getInformationTag().getDouble(key);
                        String valueString;
                        if (value < 10)
                            valueString = String.format("%.2f", value);
                        else if (value < 100)
                            valueString = String.format("%.1f", value);
                        else
                            valueString = Double.toString(value);
                        tooltip.add(StringUtils.repeat(" ", i + 1) + " | " + TextFormatting.DARK_GRAY + key + " x" + valueString);
                    }
                }
                tmpRing = tmpRing.getChildRing();
                i++;
            }
        }
    }
    if (!GuiScreen.isShiftKeyDown() && !spellRings.isEmpty()) {
        TooltipHelper.addToTooltip(tooltip, "wizardry.misc.sneak_expanded");
    }
    if (spellRings.isEmpty() && ItemNBTHelper.getFloat(stack, Constants.NBT.PURITY_OVERRIDE, -1f) < 0) {
        float purity = getQuality(stack);
        String desc = super.getUnlocalizedName(stack) + ".";
        if (purity >= 1)
            desc += "perfect";
        else {
            boolean over = ItemNBTHelper.getInt(stack, Constants.NBT.PURITY, 0) > Constants.NBT.NACRE_PURITY_CONVERSION;
            if (purity >= 5 / 6.0)
                if (over)
                    desc += "over_near";
                else
                    desc += "under_near";
            else if (over)
                desc += "overdone";
            else
                desc += "underdone";
        }
        desc += ".desc";
        String used = LibrarianLib.PROXY.canTranslate(desc) ? desc : desc + "0";
        if (LibrarianLib.PROXY.canTranslate(used)) {
            TooltipHelper.addToTooltip(tooltip, used);
            int i = 0;
            while (LibrarianLib.PROXY.canTranslate(desc + (++i))) TooltipHelper.addToTooltip(tooltip, desc + i);
        }
    } else if (spellRings.isEmpty() && getQuality(stack) > 1f) {
        String desc = super.getUnlocalizedName(stack) + ".ancient.desc";
        String used = LibrarianLib.PROXY.canTranslate(desc) ? desc : desc + "0";
        if (LibrarianLib.PROXY.canTranslate(used)) {
            TooltipHelper.addToTooltip(tooltip, used);
            int i = 0;
            while (LibrarianLib.PROXY.canTranslate(desc + (++i))) TooltipHelper.addToTooltip(tooltip, desc + i);
        }
    }
}
Also used : SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)11 Entity (net.minecraft.entity.Entity)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 IBlockState (net.minecraft.block.state.IBlockState)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 BlockPos (net.minecraft.util.math.BlockPos)3 Vec3d (net.minecraft.util.math.Vec3d)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)2 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)2 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)2 SpellData (com.teamwizardry.wizardry.api.spell.SpellData)2 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)2 Nonnull (javax.annotation.Nonnull)2 Block (net.minecraft.block.Block)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2