米米的博客

做了一点微小的工作

是否厌倦了 Minecraft 中单调的默认材质?选择一个合适的材质包,对于提升游戏体验有着巨大的帮助。得益于 Minecraft Java 版强大的玩家社区,各种优秀的材质包层出不穷。本文旨在推荐一些笔者体验过的材质包,并介绍其下载和安装的方法。
文中的预览图片均来自作品的官方网站,版权属于原作者。

Realistico

Realistico

笔者推荐使用 Realistico,不过,这个材质包的官方 512x 版本是付费的,可以自行到国内或国外的玩家论坛上寻找资源。

Stratum

Stratum

本文更新于 2019 年 5 月 1 日:
除了前面提到的 Realistico 材质包,还有一个名为 Stratum 的材质也很不错。笔者在 Reddit 上找到了一个讨论帖:[Request] Tier 3 of the stratum resource pack,不过已经因为版权问题被删除了。后来发现可以通过把 www.reddit.com 替换为 www.removeddit.com 查看所有被和谐的内容,于是就找到了这个 Mediafire 上的存储库:Stratum

本文更新于 2019 年 9 月 8 日:
不幸的是,在这篇文章完成后不久,文中提到的 Stratum 材质包存储库就因为版权问题被处理了。

UMSOEA

UMSOEA

除此之外,笔者又找到了另一个高质量的材质包:UMSOEA。这是专门为 SEUS 光影设计的,需要在 Patreon 上付费订阅才能下载,可以作为替代方案。当然,你可以从 yiff.party 网站上搜索并免费下载。

Euphora

Euphora

Project Euphora 是一个新诞生的项目:https://www.patreon.com/arcanecustoms
同样也需要在 Patreon 上付费下载。

在常见的 JavaScript 代码中,一般会通过 console 向控制台输出简单的文字信息。为了把信息输出得更优雅更便于阅读,除了 console.log() 方法外,还可以调用 console.warn() 来输出警告信息,在输出信息前面会有一个带感叹号的黄色三角警告符号。
另外经常用到的是输出错误信息,可以通过调用 console.error() 来实现,信息前面会出现一个带叉的红色圆形图标。
在某些浏览器下,还可以按以下格式,为输出到控制台的文字进行 CSS 控制,添加样式:

1
console.log("%c需要输出的信息", "css代码");

这样可以显示缤纷的颜色,甚至图片,简直爽翻了。
下面是 Chrome 中 console.log() 的官方文档摘要,也适用于一些其它浏览器:

Format SpecifierDescription
%sFormats the value as a string.
%d or %iFormats the value as an integer.
%fFormats the value as a floating point value.
%oFormats the value as an expandable DOM element (as in the Elements panel).
%OFormats the value as an expandable JavaScript object.
%cFormats the output string according to CSS styles you provide.

下面是一些例子:

为控制台添加样式

3D Text

1
2
console.log("%c3D Text", "text-shadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0, 0, 0, .1), 0 0 5px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .3), 0 3px 5px rgba(0, 0, 0, .2), 0 5px 10px rgba(0, 0, 0, .25), 0 10px 10px rgba(0, 0, 0, .2), 0 20px 20px rgba(0, 0, 0, .15);\
font-size: 5em;");

Colorful CSS

1
2
3
4
5
6
7
8
9
console.log("%cColorful CSS", "background: rgba(252, 234, 187, 1);\
background: -moz-linear-gradient(left, rgba(252, 234, 187, 1) 0%, rgba(175, 250, 77, 1) 12%, rgba(0, 247, 49, 1) 28%, rgba(0, 210, 247, 1) 39%, rgba(0, 189, 247, 1) 51%, rgba(133, 108, 217, 1) 64%, rgba(177, 0, 247, 1) 78%, rgba(247, 0, 189, 1) 87%, rgba(245, 22, 52, 1) 100%);\
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(252, 234, 187, 1)), color-stop(12%, rgba(175, 250, 77, 1)), color-stop(28%, rgba(0, 247, 49, 1)), color-stop(39%, rgba(0, 210, 247, 1)), color-stop(51%, rgba(0, 189, 247, 1)), color-stop(64%, rgba(133, 108, 217, 1)), color-stop(78%, rgba(177, 0, 247, 1)), color-stop(87%, rgba(247, 0, 189, 1)), color-stop(100%, rgba(245, 22, 52, 1)));\
background: -webkit-linear-gradient(left, rgba(252, 234, 187, 1) 0%, rgba(175, 250, 77, 1) 12%, rgba(0, 247, 49, 1) 28%, rgba(0, 210, 247, 1) 39%, rgba(0, 189, 247, 1) 51%, rgba(133, 108, 217, 1) 64%, rgba(177, 0, 247, 1) 78%, rgba(247, 0, 189, 1) 87%, rgba(245, 22, 52, 1) 100%);\
background: -o-linear-gradient(left, rgba(252, 234, 187, 1) 0%, rgba(175, 250, 77, 1) 12%, rgba(0, 247, 49, 1) 28%, rgba(0, 210, 247, 1) 39%, rgba(0, 189, 247, 1) 51%, rgba(133, 108, 217, 1) 64%, rgba(177, 0, 247, 1) 78%, rgba(247, 0, 189, 1) 87%, rgba(245, 22, 52, 1) 100%);\
background: -ms-linear-gradient(left, rgba(252, 234, 187, 1) 0%, rgba(175, 250, 77, 1) 12%, rgba(0, 247, 49, 1) 28%, rgba(0, 210, 247, 1) 39%, rgba(0, 189, 247, 1) 51%, rgba(133, 108, 217, 1) 64%, rgba(177, 0, 247, 1) 78%, rgba(247, 0, 189, 1) 87%, rgba(245, 22, 52, 1) 100%);\
background: linear-gradient(to right, rgba(252, 234, 187, 1) 0%, rgba(175, 250, 77, 1) 12%, rgba(0, 247, 49, 1) 28%, rgba(0, 210, 247, 1) 39%, rgba(0, 189, 247, 1) 51%, rgba(133, 108, 217, 1) 64%, rgba(177, 0, 247, 1) 78%, rgba(247, 0, 189, 1) 87%, rgba(245, 22, 52, 1) 100%);\
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#f51634', GradientType=1);\
font-size: 5em;");

Rainbow Text

1
2
3
4
console.log("%cRainbow Text", "background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2), color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22));\
color: transparent;\
-webkit-background-clip: text;\
font-size: 5em;");

Image

设置背景图片

1
console.log("%c", "padding: 50px 300px; line-height: 120px; background: url('/images/icon.gif') no-repeat;");

更多内容可以参考 Chrome 控制台新玩法 - console 显示图片以及为文字加样式

Mac 版 Chrome 自带双指手势前进后退功能,也就是在一个页面已经水平滑动到尽头后,继续向前 / 向后滑动,就会触发前进 / 后退。这个功能名为「Overscroll history navigation」,其设计初衷不错,只是容易误操作,笔者一直想把它关闭了。但 Chrome 的设置里没有该选项,也没有从 chrome://flags/ 中找到相关内容。
在网上搜索一番后,发现有两种方法可以进行设置。

系统设置

其实 Chrome 对于手势的默认行为是遵循 Mac 的系统偏好设置的。在「系统偏好设置」 → 「触控板」 → 「更多手势」中,禁用「在页面之间轻扫」即可。

禁用「在页面之间轻扫」

命令行设置

前一种方法的设置也会影响到其它的应用。如果只想修改 Chrome 的行为,那么可以通过命令行禁用手势。操作方法是:

禁用鼠标手势

1
defaults write com.google.Chrome AppleEnableMouseSwipeNavigateWithScrolls -bool false

禁用触控板手势

1
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false

然后重启 Chrome 即可生效。


参考文章:How to Disable Swipe Navigation Gestures in Google Chrome for Mac

今天是圆周率日,我们就来讲一讲关于圆周率的故事吧。
很久以前,笔者看到了一段惊为天人的代码,可以求出圆周率的前 800 位(修改参数可以实现任意精度):

1
2
3
int a=10000,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)for(b=c;d+=f[b]*a,
f[b]=d%--g,d/=g--,--b;d*=b);}

经过考证,这段代码的作者是 Dik T. Winter。下面我们来看看它是如何工作的。

在 C 语言中,for 循环和 while 循环可以互相代替。这里涉及到 for 循环的执行顺序。例如

1
2
3
for (statement1; statement2; statement3) {
statements;
}

上面的 for 语句可以用下面的 while 语句来代替:

1
2
3
4
5
statement1;
while (statement2) {
statements;
statement3;
}

而逗号运算符和 -- 运算符的功能也是需要注意的。要写出这样怪异的 C 程序,逗号运算符无疑是一个好的助手,它的作用是:从左到右依次计算各个表达式的值,并且返回最右边表达式的值。

了解这些内容后,我们将这段代码中的 for 循环展开,等价地写为 while 的形式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
int a = 10000, b, c = 2800, d, e, f[2801], g;
main() {
for (int i = 0; i < c; i++) {
f[i] = a / 5;
}
while (c != 0) {
d = 0;
g = c * 2;
b = c;
while (1) {
d += f[b] * a;
g--;
f[b] = d % g;
d /= g;
g--;
b--;
if (b == 0) break;
d *= b;
}
c -= 14;
printf("%.4d", e + d / a);
e = d % a;
}
}
阅读全文 »
0%