Search in sources :

Example 1 with SpellRing

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

the class PacketWorktableUpdate method manualSaveSetter.

@SaveMethodGetter(saveName = "manual_saver")
private NBTTagCompound manualSaveSetter() {
    NBTTagCompound compound = new NBTTagCompound();
    if (components == null || links == null)
        return compound;
    NBTTagList list = new NBTTagList();
    for (Map.Entry<SpellRing, UUID> entrySet : components.entrySet()) {
        NBTTagCompound compound1 = new NBTTagCompound();
        compound1.setTag("ring", entrySet.getKey().serializeNBT());
        compound1.setString("uuid", entrySet.getValue().toString());
        list.appendTag(compound1);
    }
    compound.setTag("components", list);
    list = new NBTTagList();
    for (Map.Entry<UUID, UUID> entrySet : links.entrySet()) {
        NBTTagCompound compound1 = new NBTTagCompound();
        compound1.setString("uuid1", entrySet.getKey().toString());
        compound1.setString("uuid2", entrySet.getValue().toString());
        list.appendTag(compound1);
    }
    compound.setTag("links", list);
    return compound;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map) SaveMethodGetter(com.teamwizardry.librarianlib.features.saving.SaveMethodGetter)

Example 2 with SpellRing

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

the class WorktableGui method sync.

public void sync() {
    if (!Minecraft.getMinecraft().world.isBlockLoaded(worktablePos))
        return;
    IBlockState state = Minecraft.getMinecraft().world.getBlockState(worktablePos);
    if (state.getBlock() != ModBlocks.MAGICIANS_WORKTABLE)
        return;
    TileEntity table = Minecraft.getMinecraft().world.getTileEntity(worktablePos);
    if (!(table instanceof TileMagiciansWorktable))
        return;
    HashMap<SpellRing, UUID> convertComponents = new HashMap<>();
    for (Map.Entry<GuiComponent, UUID> entrySet : paperComponents.entrySet()) {
        Module module1 = getModule(entrySet.getKey());
        if (module1 == null)
            continue;
        SpellRing ring = new SpellRing(module1);
        ring.getInformationTag().setDouble("worktable_x", entrySet.getKey().getPos().getX());
        ring.getInformationTag().setDouble("worktable_y", entrySet.getKey().getPos().getY());
        convertComponents.put(ring, entrySet.getValue());
    }
    ((TileMagiciansWorktable) table).componentLinks = componentLinks;
    ((TileMagiciansWorktable) table).paperComponents = convertComponents;
    PacketHandler.NETWORK.sendToServer(new PacketWorktableUpdate(Minecraft.getMinecraft().world.provider.getDimension(), worktablePos, convertComponents, componentLinks));
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PacketWorktableUpdate(com.teamwizardry.wizardry.common.network.PacketWorktableUpdate) TileMagiciansWorktable(com.teamwizardry.wizardry.common.tile.TileMagiciansWorktable) IBlockState(net.minecraft.block.state.IBlockState) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) GuiComponent(com.teamwizardry.librarianlib.features.gui.component.GuiComponent) Module(com.teamwizardry.wizardry.api.spell.module.Module) BiMap(com.google.common.collect.BiMap) HashBiMap(com.google.common.collect.HashBiMap)

Example 3 with SpellRing

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

the class EventHandler method fairyAmbush.

@SubscribeEvent
public void fairyAmbush(SpellCastEvent event) {
    Entity caster = event.getSpellData().getData(SpellData.DefaultKeys.CASTER);
    int chance = 5;
    for (SpellRing spellRing : SpellUtils.getAllSpellRings(event.getSpellRing())) if (spellRing instanceof IContinuousModule) {
        chance = 1000;
        break;
    }
    if (RandUtil.nextInt(chance) == 0 && caster != null) {
        List<EntityFairy> fairyList = event.getSpellData().world.getEntitiesWithinAABB(EntityFairy.class, new AxisAlignedBB(caster.getPosition()).grow(64, 64, 64));
        if (fairyList.isEmpty())
            return;
        EntityFairy fairy = fairyList.get(RandUtil.nextInt(fairyList.size() - 1));
        if (fairy == null)
            return;
        fairy.ambush = true;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) IContinuousModule(com.teamwizardry.wizardry.api.spell.IContinuousModule) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with SpellRing

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

the class RenderSpellProjectile method doRender.

@Override
public void doRender(@Nonnull EntitySpellProjectile entity, double x, double y, double z, float entityYaw, float partialTicks) {
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
    if (entity.spellRing != null)
        for (SpellRing ring : SpellUtils.getAllSpellRings(entity.spellRing)) {
            if (ring.overrideParentRenders()) {
                return;
            }
        }
    Color color = new Color(entity.getDataManager().get(DATA_COLOR), true);
    Color color2 = new Color(entity.getDataManager().get(DATA_COLOR2), true);
    ParticleBuilder glitter = new ParticleBuilder(10);
    glitter.setAlphaFunction(new InterpFadeInOut(0f, 0.3f));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    glitter.enableMotionCalculation();
    glitter.setCollision(true);
    glitter.setCanBounce(true);
    glitter.setColorFunction(new InterpColorHSV(color, color2));
    glitter.setAcceleration(new Vec3d(0, -0.015, 0));
    ParticleSpawner.spawn(glitter, entity.world, new StaticInterp<>(entity.getPositionVector().add(new Vec3d(entity.motionX, entity.motionY, entity.motionZ))), 5, 0, (aFloat, particleBuilder) -> {
        particleBuilder.setScaleFunction(new InterpScale((float) RandUtil.nextDouble(0.3, 0.8), 0));
        particleBuilder.setLifetime(RandUtil.nextInt(40, 60));
        particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.03, 0.03), RandUtil.nextDouble(-0.01, 0.05), RandUtil.nextDouble(-0.03, 0.03)));
    });
    glitter.disableMotionCalculation();
    glitter.setMotion(Vec3d.ZERO);
    glitter.setLifetime(20);
    glitter.setScaleFunction(new InterpFadeInOut(0f, 1f));
    glitter.setAlphaFunction(new InterpFadeInOut(0f, 1f));
    ParticleSpawner.spawn(glitter, entity.world, new StaticInterp<>(entity.getPositionVector()), 5, 0, (aFloat, particleBuilder) -> {
        particleBuilder.setScale(RandUtil.nextFloat(0.5f, 2));
        particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
    // particleBuilder.addMotion()
    });
}
Also used : InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 5 with SpellRing

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

the class ItemNacrePearl method getItemStackDisplayName.

@Nonnull
@Override
public String getItemStackDisplayName(@Nonnull ItemStack stack) {
    if (!stack.hasTagCompound())
        return super.getItemStackDisplayName(stack);
    StringBuilder finalName = null;
    List<SpellRing> spellChains = SpellUtils.getSpellChains(stack);
    for (SpellRing spellRing : spellChains) {
        if (finalName == null) {
            finalName = new StringBuilder();
        } else
            finalName.append(" / ");
        finalName.append(spellRing.toString());
    }
    if (finalName == null)
        return super.getItemStackDisplayName(stack);
    else
        return finalName.toString();
}
Also used : SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) Nonnull(javax.annotation.Nonnull)

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