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();
}
}
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));
}
}
}
}
}
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();
}
}
}
Aggregations