Search in sources :

Example 1 with IMiscCapability

use of com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability in project Wizardry by TeamWizardry.

the class FairyBindingRenderer method render.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void render(RenderWorldLastEvent event) {
    if (Minecraft.getMinecraft().player == null)
        return;
    if (Minecraft.getMinecraft().world == null)
        return;
    if (Minecraft.getMinecraft().getRenderManager().options == null)
        return;
    if (Minecraft.getMinecraft().objectMouseOver == null)
        return;
    EntityPlayer player = Minecraft.getMinecraft().player;
    World world = Minecraft.getMinecraft().world;
    ItemStack stack = player.getHeldItemMainhand();
    if (stack.getItem() != ModItems.FAIRY_BELL)
        return;
    if (Minecraft.getMinecraft().objectMouseOver.typeOfHit == RayTraceResult.Type.ENTITY) {
        Entity entityHit = Minecraft.getMinecraft().objectMouseOver.entityHit;
        if (entityHit instanceof EntityFairy) {
            EntityFairy fairy = (EntityFairy) entityHit;
            FairyData data = fairy.getDataFairy();
            if (data != null && data.isDepressed) {
                double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks();
                double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks();
                double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks();
                IMiscCapability cap = MiscCapabilityProvider.getCap(Minecraft.getMinecraft().player);
                if (cap == null)
                    return;
                UUID uuid = cap.getSelectedFairyUUID();
                if (uuid != null && uuid.equals(fairy.getUniqueID())) {
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
                    RenderUtils.drawCircle(fairy.getPositionVector().add(0, fairy.height, 0), 0.3, true, false, Color.RED);
                    GlStateManager.popMatrix();
                } else {
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
                    RenderUtils.drawCircle(fairy.getPositionVector().add(0, fairy.height, 0), (Math.sin(ClientTickHandler.getTicks() / 5.0f) + 2.5) / 10.0, true, false);
                    GlStateManager.popMatrix();
                }
            }
        }
    }
    for (EntityFairy entityFairy : world.getEntities(EntityFairy.class, input -> {
        if (input == null)
            return false;
        FairyData dataFairy = input.getDataFairy();
        if (dataFairy == null)
            return false;
        return dataFairy.isDepressed;
    })) {
        FairyData dataFairy = entityFairy.getDataFairy();
        if (dataFairy == null)
            return;
        IMiscCapability cap = MiscCapabilityProvider.getCap(Minecraft.getMinecraft().player);
        if (cap == null)
            return;
        double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks();
        double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks();
        double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks();
        Tessellator tess = Tessellator.getInstance();
        BufferBuilder bb = tess.getBuffer();
        GlStateManager.glLineWidth(2f);
        GlStateManager.pushMatrix();
        GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
        RenderUtils.drawCircle(entityFairy.getPositionVector().add(0, entityFairy.height, 0), 0.25, true, false, Color.YELLOW);
        GlStateManager.popMatrix();
        Vec3d lookTarget = entityFairy.getLookTarget();
        Vec3d fairyPos = entityFairy.getPositionVector().add(0, entityFairy.height, 0);
        if (lookTarget != null) {
            Vec3d to = fairyPos.add(lookTarget);
            GlStateManager.pushMatrix();
            GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
            RenderUtils.drawCircle(to, 0.1, true, false, Color.ORANGE);
            GlStateManager.popMatrix();
            GlStateManager.pushMatrix();
            GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
            GlStateManager.disableLighting();
            GlStateManager.disableCull();
            GlStateManager.enableAlpha();
            GlStateManager.enableBlend();
            GlStateManager.shadeModel(GL11.GL_SMOOTH);
            GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE);
            GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
            GlStateManager.color(1, 1, 1, 1);
            GlStateManager.disableTexture2D();
            GlStateManager.enableColorMaterial();
            GlStateManager.enableDepth();
            bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
            Color c = Color.ORANGE;
            bb.pos(to.x, to.y, to.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
            bb.pos(fairyPos.x, fairyPos.y, fairyPos.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
            tess.draw();
            GlStateManager.enableTexture2D();
            GlStateManager.popMatrix();
        }
        UUID uuid = cap.getSelectedFairyUUID();
        if (uuid != null && uuid.equals(entityFairy.getUniqueID())) {
            boolean movingMode = NBTHelper.getBoolean(stack, "moving_mode", true);
            if (!movingMode) {
                Vec3d hitVec = Minecraft.getMinecraft().objectMouseOver.hitVec;
                Vec3d subtract = hitVec.subtract(fairyPos);
                double length = subtract.length();
                hitVec = entityFairy.getPositionVector().add(0, entityFairy.height, 0).add(subtract.normalize().scale(MathHelper.clamp(length, -3, 3)));
                GlStateManager.pushMatrix();
                GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
                RenderUtils.drawCircle(hitVec, 0.2, true, false, Color.CYAN);
                GlStateManager.popMatrix();
                GlStateManager.pushMatrix();
                GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
                GlStateManager.disableLighting();
                GlStateManager.disableCull();
                GlStateManager.enableAlpha();
                GlStateManager.enableBlend();
                GlStateManager.shadeModel(GL11.GL_SMOOTH);
                GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE);
                GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
                GlStateManager.color(1, 1, 1, 1);
                GlStateManager.disableTexture2D();
                GlStateManager.enableColorMaterial();
                GlStateManager.enableDepth();
                bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
                Color c = Color.GREEN;
                bb.pos(hitVec.x, hitVec.y, hitVec.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
                bb.pos(fairyPos.x, fairyPos.y, fairyPos.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
                tess.draw();
                GlStateManager.enableTexture2D();
                GlStateManager.popMatrix();
            } else {
                if (Minecraft.getMinecraft().objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK) {
                    BlockPos target = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
                    RenderUtils.drawCubeOutline(entityFairy.world, target, entityFairy.world.getBlockState(target), Color.CYAN);
                    GlStateManager.popMatrix();
                    Vec3d tar = new Vec3d(target).add(0.5, 0.5, 0.5).add(new Vec3d(Minecraft.getMinecraft().objectMouseOver.sideHit.getDirectionVec()));
                    PathNavigate navigateFlying = entityFairy.getNavigator();
                    Path path = navigateFlying.getPathToXYZ(tar.x, tar.y, tar.z);
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
                    RenderUtils.drawCircle(tar, 0.25, true, false, Color.CYAN);
                    GlStateManager.popMatrix();
                    if (path != null) {
                        GlStateManager.pushMatrix();
                        GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
                        GlStateManager.disableLighting();
                        GlStateManager.disableCull();
                        GlStateManager.enableAlpha();
                        GlStateManager.enableBlend();
                        GlStateManager.shadeModel(GL11.GL_SMOOTH);
                        GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE);
                        GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
                        GlStateManager.color(1, 1, 1, 1);
                        GlStateManager.disableTexture2D();
                        GlStateManager.enableColorMaterial();
                        GlStateManager.disableDepth();
                        bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
                        Color c = Color.GREEN;
                        Vec3d lastPoint = null;
                        Vec3d center = new Vec3d(entityFairy.posX, entityFairy.posY + entityFairy.height / 2.0, entityFairy.posZ);
                        bb.pos(center.x, center.y, center.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
                        for (int i = 0; i < path.getCurrentPathLength(); i++) {
                            Vec3d vec = path.getVectorFromIndex(entityFairy, i);
                            if (lastPoint != null) {
                                if (i >= path.getCurrentPathLength() - 1) {
                                    continue;
                                }
                                Vec3d from = path.getVectorFromIndex(entityFairy, i - 1);
                                from = from.subtract(from.subtract(vec).scale(0.5));
                                Vec3d to = path.getVectorFromIndex(entityFairy, i + 1);
                                to = to.subtract(to.subtract(vec).scale(0.5));
                                Vec3d fromControl = vec.subtract(from).normalize().scale(0.4);
                                Vec3d toControl = vec.subtract(to).normalize().scale(0.4);
                                InterpBezier3D bezier = new InterpBezier3D(from, to, fromControl, toControl);
                                for (Vec3d dot : bezier.list(20)) {
                                    bb.pos(dot.x, dot.y, dot.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
                                    lastPoint = dot;
                                }
                            } else {
                                bb.pos(vec.x, vec.y, vec.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
                                lastPoint = vec;
                            }
                        }
                        bb.pos(tar.x, tar.y, tar.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
                        tess.draw();
                        GlStateManager.enableTexture2D();
                        GlStateManager.popMatrix();
                    }
                }
            }
        }
    }
}
Also used : Path(net.minecraft.pathfinding.Path) Entity(net.minecraft.entity.Entity) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d) IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) PathNavigate(net.minecraft.pathfinding.PathNavigate) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IMiscCapability

use of com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability in project Wizardry by TeamWizardry.

the class ItemFairyBell method itemInteractionForEntity.

@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand) {
    if (playerIn.world.isRemote || playerIn.isSneaking())
        return super.itemInteractionForEntity(stack, playerIn, target, hand);
    if (target instanceof EntityFairy) {
        EntityFairy targetFairy = (EntityFairy) target;
        FairyData targetData = targetFairy.getDataFairy();
        if (targetData == null)
            return super.itemInteractionForEntity(stack, playerIn, target, hand);
        if (targetData.isDepressed) {
            IMiscCapability cap = MiscCapabilityProvider.getCap(playerIn);
            if (cap != null) {
                UUID selected = cap.getSelectedFairyUUID();
                if (selected != null && selected.equals(targetFairy.getUniqueID())) {
                    cap.setSelectedFairy(null);
                    playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.25f);
                    playerIn.sendStatusMessage(new TextComponentTranslation("item.wizardry:fairy_bell.status.deselected"), true);
                } else if (selected != null && !selected.equals(targetFairy.getUniqueID())) {
                    List<Entity> list = playerIn.world.loadedEntityList;
                    for (Entity entity : list) {
                        if (entity instanceof EntityFairy && entity.getUniqueID().equals(selected)) {
                            if (entity.isDead)
                                continue;
                            ((EntityFairy) entity).setChainedFairy(targetFairy.getUniqueID());
                            targetFairy.setChainedFairy(selected);
                            playerIn.sendStatusMessage(new TextComponentTranslation("item.wizardry:fairy_bell.status.linked_to_fairy"), true);
                            break;
                        }
                    }
                } else {
                    cap.setSelectedFairy(targetFairy.getUniqueID());
                    boolean movingMode = NBTHelper.getBoolean(stack, "moving_mode", true);
                    if (!movingMode) {
                        playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.75f);
                    } else {
                        playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 1.25f);
                    }
                    playerIn.sendStatusMessage(new TextComponentTranslation(movingMode ? "item.wizardry:fairy_bell.status.fairy_moving" : "item.wizardry:fairy_bell.status.fairy_aiming"), true);
                }
                cap.dataChanged(playerIn);
            }
        }
    }
    return super.itemInteractionForEntity(stack, playerIn, target, hand);
}
Also used : Entity(net.minecraft.entity.Entity) IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) List(java.util.List) UUID(java.util.UUID)

Example 3 with IMiscCapability

use of com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability in project Wizardry by TeamWizardry.

the class ItemFairyBell method onItemRightClick.

@NotNull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @NotNull EnumHand handIn) {
    ItemStack stack = playerIn.getHeldItem(handIn);
    if (worldIn.isRemote)
        return super.onItemRightClick(worldIn, playerIn, handIn);
    IMiscCapability cap = MiscCapabilityProvider.getCap(playerIn);
    if (cap == null)
        return super.onItemRightClick(worldIn, playerIn, handIn);
    EntityFairy entityFairy = cap.getSelectedFairyEntity(worldIn);
    double reach = playerIn.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue();
    Vec3d posEyes = playerIn.getPositionVector().add(0, playerIn.getEyeHeight(), 0);
    RayTraceResult rayTraceResult = new RayTrace(worldIn, playerIn.getLook(1f), posEyes, reach).setEntityFilter(input -> input != null && !input.getUniqueID().equals(playerIn.getUniqueID())).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
    if (rayTraceResult.typeOfHit == RayTraceResult.Type.ENTITY && rayTraceResult.entityHit instanceof EntityFairy && entityFairy != null && rayTraceResult.entityHit.getUniqueID().equals(entityFairy.getUniqueID()))
        return super.onItemRightClick(worldIn, playerIn, handIn);
    if (playerIn.isSneaking()) {
        NBTHelper.setBoolean(stack, "moving_mode", !NBTHelper.getBoolean(stack, "moving_mode", true));
        cap.setSelectedFairy(null);
        cap.dataChanged(playerIn);
        return new ActionResult<>(EnumActionResult.PASS, stack);
    } else {
        if (entityFairy == null)
            return super.onItemRightClick(worldIn, playerIn, handIn);
        if (rayTraceResult.hitVec == null || rayTraceResult.typeOfHit != RayTraceResult.Type.BLOCK)
            return super.onItemRightClick(worldIn, playerIn, handIn);
        if (worldIn.isBlockLoaded(rayTraceResult.getBlockPos())) {
            IBlockState state = worldIn.getBlockState(rayTraceResult.getBlockPos());
            if (state.getBlock().isCollidable()) {
                boolean movingMode = NBTHelper.getBoolean(stack, "moving_mode", true);
                if (entityFairy.originPos != null) {
                    if (!movingMode) {
                        Vec3d hitVec = rayTraceResult.hitVec;
                        Vec3d subtract = hitVec.subtract(entityFairy.getPositionVector());
                        subtract = new Vec3d(MathHelper.clamp(subtract.x, -ConfigValues.fairyReach, ConfigValues.fairyReach), MathHelper.clamp(subtract.y, -ConfigValues.fairyReach, ConfigValues.fairyReach), MathHelper.clamp(subtract.z, -ConfigValues.fairyReach, ConfigValues.fairyReach));
                        entityFairy.setLookTarget(subtract);
                        playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.75f);
                        cap.setSelectedFairy(null);
                        cap.dataChanged(playerIn);
                        return new ActionResult<>(EnumActionResult.PASS, stack);
                    }
                }
            }
        }
    }
    return super.onItemRightClick(worldIn, playerIn, handIn);
}
Also used : net.minecraft.util(net.minecraft.util) MiscCapabilityProvider(com.teamwizardry.wizardry.api.capability.player.miscdata.MiscCapabilityProvider) Keyboard(org.lwjgl.input.Keyboard) LibrarianLib(com.teamwizardry.librarianlib.core.LibrarianLib) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) Vec3d(net.minecraft.util.math.Vec3d) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) ModSounds(com.teamwizardry.wizardry.init.ModSounds) Mod(net.minecraftforge.fml.common.Mod) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) ConfigValues(com.teamwizardry.wizardry.api.ConfigValues) Entity(net.minecraft.entity.Entity) PacketHandler(com.teamwizardry.librarianlib.features.network.PacketHandler) World(net.minecraft.world.World) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) BlockPos(net.minecraft.util.math.BlockPos) MouseEvent(net.minecraftforge.client.event.MouseEvent) UUID(java.util.UUID) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) ItemMod(com.teamwizardry.librarianlib.features.base.item.ItemMod) PacketUpdateMiscCapToServer(com.teamwizardry.wizardry.common.network.capability.PacketUpdateMiscCapToServer) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) NBTHelper(com.teamwizardry.librarianlib.features.helpers.NBTHelper) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) NotNull(org.jetbrains.annotations.NotNull) ModItems(com.teamwizardry.wizardry.init.ModItems) IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) IBlockState(net.minecraft.block.state.IBlockState) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with IMiscCapability

use of com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability in project Wizardry by TeamWizardry.

the class ItemFairyBell method onItemUse.

@NotNull
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.isRemote || playerIn.isSneaking())
        return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    IMiscCapability cap = MiscCapabilityProvider.getCap(playerIn);
    if (cap == null)
        return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    EntityFairy entityFairy = cap.getSelectedFairyEntity(worldIn);
    if (entityFairy == null)
        return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    cap.setSelectedFairy(null);
    cap.dataChanged(playerIn);
    if (worldIn.isBlockLoaded(pos) && !worldIn.isAirBlock(pos)) {
        IBlockState state = worldIn.getBlockState(pos);
        if (state.getBlock().isCollidable()) {
            ItemStack stack = playerIn.getHeldItem(hand);
            boolean movingMode = NBTHelper.getBoolean(stack, "moving_mode", true);
            if (entityFairy.originPos != null) {
                if (!movingMode) {
                    Vec3d hitVec = new Vec3d(pos).add(hitX, hitY, hitZ);
                    Vec3d subtract = hitVec.subtract(entityFairy.getPositionVector());
                    subtract = new Vec3d(MathHelper.clamp(subtract.x, -ConfigValues.fairyReach, ConfigValues.fairyReach), MathHelper.clamp(subtract.y, -ConfigValues.fairyReach, ConfigValues.fairyReach), MathHelper.clamp(subtract.z, -ConfigValues.fairyReach, ConfigValues.fairyReach));
                    entityFairy.setLookTarget(subtract);
                    playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.75f);
                    cap.setSelectedFairy(null);
                    cap.dataChanged(playerIn);
                } else {
                    entityFairy.targetPos = pos.offset(facing);
                    entityFairy.setLookTarget(null);
                    playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 1.25f);
                }
            }
        }
    }
    return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
Also used : IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) IBlockState(net.minecraft.block.state.IBlockState) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with IMiscCapability

use of com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability in project Wizardry by TeamWizardry.

the class ModCapabilities method onLogin.

@SubscribeEvent
public static void onLogin(PlayerEvent.PlayerLoggedInEvent event) {
    if (event.player.world.isRemote)
        return;
    IManaCapability manaCap = ManaCapabilityProvider.getCap(event.player);
    if (manaCap != null)
        manaCap.dataChanged(event.player);
    IMiscCapability miscCap = MiscCapabilityProvider.getCap(event.player);
    if (miscCap != null)
        miscCap.dataChanged(event.player);
}
Also used : IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IMiscCapability (com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability)10 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 EntityFairy (com.teamwizardry.wizardry.common.entity.EntityFairy)4 ItemStack (net.minecraft.item.ItemStack)4 IManaCapability (com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability)3 FairyData (com.teamwizardry.wizardry.api.entity.fairy.FairyData)3 UUID (java.util.UUID)3 Entity (net.minecraft.entity.Entity)3 Vec3d (net.minecraft.util.math.Vec3d)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 PacketUpdateMiscCapToServer (com.teamwizardry.wizardry.common.network.capability.PacketUpdateMiscCapToServer)2 List (java.util.List)2 IBlockState (net.minecraft.block.state.IBlockState)2 BlockPos (net.minecraft.util.math.BlockPos)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 World (net.minecraft.world.World)2 NotNull (org.jetbrains.annotations.NotNull)2 LibrarianLib (com.teamwizardry.librarianlib.core.LibrarianLib)1 ItemMod (com.teamwizardry.librarianlib.features.base.item.ItemMod)1