Search in sources :

Example 1 with EngravedStarMap

use of hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap in project AstralSorcery by HellFirePvP.

the class ScreenRefractionTable method renderDrawnConstellations.

private void renderDrawnConstellations(MatrixStack renderStack, int mouseX, int mouseY, List<ITextProperties> tooltip) {
    ItemStack glass = this.getTile().getGlassStack();
    if (glass.isEmpty()) {
        return;
    }
    World world = this.getTile().getWorld();
    float nightPerc = DayTimeHelper.getCurrentDaytimeDistribution(world);
    WorldContext ctx = SkyHandler.getContext(world, LogicalSide.CLIENT);
    if (ctx == null || !this.getTile().doesSeeSky() || nightPerc <= 0.05F) {
        return;
    }
    EngravedStarMap map = ItemInfusedGlass.getEngraving(glass);
    if (map == null) {
        return;
    }
    for (DrawnConstellation cst : map.getDrawnConstellations()) {
        int whDrawn = DrawnConstellation.CONSTELLATION_DRAW_SIZE;
        Point offset = new Point(cst.getPoint());
        offset.translate(guiLeft, guiTop);
        offset.translate(PLACEMENT_GRID.x, PLACEMENT_GRID.y);
        offset.translate(-whDrawn, -whDrawn);
        RenderSystem.enableBlend();
        Blending.DEFAULT.apply();
        RenderingConstellationUtils.renderConstellationIntoGUI(cst.getConstellation(), renderStack, offset.x, offset.y, this.getGuiZLevel(), whDrawn * 2, whDrawn * 2, 1.6F, () -> DayTimeHelper.getCurrentDaytimeDistribution(world) * 0.8F, true, false);
        RenderSystem.disableBlend();
    }
}
Also used : DrawnConstellation(hellfirepvp.astralsorcery.common.constellation.DrawnConstellation) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) EngravedStarMap(hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap)

Example 2 with EngravedStarMap

use of hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap in project AstralSorcery by HellFirePvP.

the class ItemInfusedGlass method addInformation.

@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
    EngravedStarMap map = getEngraving(stack);
    if (map != null) {
        for (ResourceLocation key : map.getConstellationKeys()) {
            IConstellation cst = ConstellationRegistry.getConstellation(key);
            if (cst != null) {
                String format = "item.astralsorcery.infused_glass.ttip";
                ITextComponent cstName = cst.getConstellationName().mergeStyle(TextFormatting.BLUE);
                if (Minecraft.getInstance().player != null && Minecraft.getInstance().player.isCreative()) {
                    String percent = String.valueOf(Math.round(map.getDistribution(cst) * 100F));
                    ITextComponent creativeHint = new TranslationTextComponent("item.astralsorcery.infused_glass.ttip.creative", percent).mergeStyle(TextFormatting.LIGHT_PURPLE);
                    tooltip.add(new TranslationTextComponent(format, cstName, creativeHint).mergeStyle(TextFormatting.GRAY));
                } else {
                    tooltip.add(new TranslationTextComponent(format, cstName, "").mergeStyle(TextFormatting.GRAY));
                }
            }
        }
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) EngravedStarMap(hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with EngravedStarMap

use of hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap in project AstralSorcery by HellFirePvP.

the class TileRefractionTable method tick.

@Override
public void tick() {
    super.tick();
    if (this.getWorld().isRemote()) {
        playEngravingEffects();
    } else {
        if (DayTimeHelper.isNight(getWorld()) && this.doesSeeSky() && isValidGlassStack(this.getGlassStack())) {
            EngravedStarMap starMap = ItemInfusedGlass.getEngraving(this.getGlassStack());
            if (starMap != null && !this.hasParchment() && !this.getInputStack().isEmpty() && starMap.canAffect(this.getInputStack())) {
                runTick++;
                if (runTick > RUN_TIME) {
                    this.setInputStack(starMap.applyEffects(this.getInputStack()));
                    ItemStack glassStack = this.getGlassStack();
                    if (glassStack.attemptDamageItem(1, rand, null)) {
                        glassStack.shrink(1);
                        this.setGlassStack(glassStack);
                        SoundHelper.playSoundAround(SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, this.getWorld(), this.getPos(), rand.nextFloat() * 0.5F + 1F, rand.nextFloat() * 0.2F + 0.8F);
                    }
                    this.resetWorkTick();
                }
                markForUpdate();
            } else {
                this.resetWorkTick();
            }
        } else {
            this.resetWorkTick();
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) EngravedStarMap(hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap)

Aggregations

EngravedStarMap (hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap)3 ItemStack (net.minecraft.item.ItemStack)2 DrawnConstellation (hellfirepvp.astralsorcery.common.constellation.DrawnConstellation)1 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)1 WorldContext (hellfirepvp.astralsorcery.common.constellation.world.WorldContext)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1 World (net.minecraft.world.World)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1