
[-52.42685239911796, 88.92741372864917, -249.4581397458882, Midymidy/CREATIVE]
# Sample Per Pixel: 5000
Render Time: 31574166 milliseconds

http://www.pixiv.net/member_illust.php?mode=medium&illust_id=60286621
[455.83962949130677, 72.55133183227652, -515.9317051627162, ENLMC/world]

在 Minecraft 内部,方块也可以看作是可放置的物品,使用 Item 类的静态方法 getItemFromBlock(Block someBlock) 可以获得对应的物品。向游戏内注册该方块也是类似的使用 GameRegistry.registerBlock(Block blockToReg, String unlocalizedName)。然而在处理渲染时需要多额外的一步。
以下为 Item 渲染
String nameToReg = MOD_ID + ':' + item.getUnlocalizedName().substring(5);
Minecraft.getMinecraft()
.getRenderItem().getItemModelMesher()
.register(item, 0,
new ModelResourceLocation(nameToReg, "inventory");
以下为 Block 渲染
Item item = Item.getItemFromBlock(block);
// 从 Block 得到对应的 Item
String nameToReg = MOD_ID + ':' + item.getUnlocalizedName().substring(5);
Minecraft.getMinecraft()
.getRenderItem().getItemModelMesher()
.register(item, 0,
new ModelResourceLocation(nameToReg, "inventory");
区别主要在于多了一句从 Block 获得 Item。虽然是以 Item 注册了渲染,实际上这里和 Item 处理渲染的方法并不相同。
assets/<MOD_ID>/blockstates/<blockUnlocalizedName>.json我所写的 mod 中许多方块都会根据不同的 BlockState 改变渲染模型,而 BlockState 中不同 IProperty 组合所对应状态所对应的模型在这里指定。关于 BlockState,见上一篇 Forge API 详解。我在这里以 TransitRailMod 的电缆架作为例子。
在源代码中,WirePanel 是 CustomDirectionalBlock 的子类,因此继承其 EnumFacing FACING 的属性,这个方块又根据电缆架上是否插了日光灯改变 EnumBool LAMP 属性、是否是封闭的改变 EnumBool SHUT 属性。因此罗列一下: Continue reading Minecraft 1.8 Forge API IBlockState 与渲染
由于网上找到的 Minecraft Forge 文档实在是少的可怜,我决定自己写一份以防未来的自己忘记。具体的实践可以在我的客运铁路 mod 见到。
红石的更新本质上也是方块更新,因此当一个方块想要检测红石信号,处理的代码应当放在 Block 类的 onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) 方法。
BlockState 与 IBlockState可以在方块的 Class 建立 BlockState 以允许方块拥有不同的状态 (IProperty),不同的状态可以在 assets/<MODID>/blockstates/<block_instance_name>.json 中定义不同的方块模型。
每一个 IProperty 拥有自己的 name 和可以取到的有限个值,这些值在 Java 内部以 enum 的形式实现。关于 enum 变量类型,可以在王八壳的 javadoc 上找到。
一个方块的 BlockState 可以包含一个或多个 IProperty,可以使用已经定义好的 IProperty 子类(PropertyDirection, PropertyBool)也可以自己定义 enum 建立 PropertyEnum。
public CustomBlock extends BlockIProperty 及其子类的实例:public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);"facing" ,可以取的值为平面方向的朝向,为 EnumFacing 下的 NORTH,EAST,SOUTH,WEST。public static final PropertyBool POWERED = PropertyBool.create("powered");true 或 false 的方块属性。As implemented in Google Authenticator app, you’ll need:
base32 encodedI’ll use K = GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ and T = 1450235092 (which is Wed, 16 Dec 2015 11:04:52 CST) for example. In the Google Authenticator App, both K and T are passed to TOTP as hexadecimal values (or byte arrays).
Since K is a base32 encoded string, we’ll decode it to byte format. Password changes every 30 seconds, T should be divided by 30, tuncated to integer and converted to hex and padded to 16 hexadecimal digits.
Linux上的守护进程cron能够根据配置好的crontab定时地执行某一个动作,现在用上systemd了想要找一个替代品,于是找到了timer,timer和其他的配置单元结构差不多,只是有一个[Timer]段,在这里可以定义它的行为。基本的写法是Name=Value。
作为一个timer必须要有
[Install] WantedBy=timers.target
[Unit] Description=Value这个字段允许添加对配置单元的描述
[Timer] Unit=Value用于指定该timer触发时要启动的配置单元,如果不写的话,example.timer触发时会执行同名的example.service。
[Timer] 绝对触发时间OnCalendar=Value可以指定在系统时钟的某一特定时刻触发timer。懒的话可以直接使用hourly,monthly这样的词语,也可以输入DAY YYYY-MM-DD HH:MM:SS。比如hourly与*:00:00等价,Wed *:00:00就是每个星期三隔一个小时触发一次。 Continue reading Systemd Timers小结