哪个 java 类会触发自然生物生成? [英] Which java class triggers natural mob spawns?

查看:60
本文介绍了哪个 java 类会触发自然生物生成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在代码中找出哪些类或哪些类会触发生物生成.例如,如果我想更改史莱姆产生的 Y,或者允许像大象这样的自定义生物在萨凡纳生物群落中产生.

I'm trying to find in the code which class or classes trigger mob spawns. For example if I wanted to change the Y at which slimes spawn or allow a custom mob like an elephant spawn on the Savannah biome.

意图是为锻造模组做这个,但我认为答案是我的世界的标准?

Intent is to do this for a forge mod, but I assume the answer is standard for minecraft?

谢谢!

推荐答案

对于添加模组的实体,EntityRegistry.addSpawn(...) 用于注册实体将在使用中生成的生物群系现有的每个生物群落生成规则.

For mod-added entities, EntityRegistry.addSpawn(...) is used to register which biomes the entity will spawn in using the existing per-biome spawn rules.

对于史莱姆,EntitySlime 类控制允许它生成的 Y 高度,请参阅 getCanSpawnHere() 方法.但是,您不能修改此类.为了覆盖有效的高度,您需要订阅 LivingSpawnEvent(有三个子类,您需要订阅三个中的一个)并将结果设置为 Result.ALLOW 强制实体生成而不管其通常的生成检查(相反,Result.DENY 阻止它).

For slimes, the class EntitySlime controls what Y heights it is allowed to spawn at, see the getCanSpawnHere() method. However, you cannot modify this class. In order to override what heights are valid, you would need to subscribe to the LivingSpawnEvent (there are three subclasses, you would want to subscribe to one of the three) and set the result to Result.ALLOW to force the entity to spawn regardless of its usual spawn checks (conversely, Result.DENY to prevent it).

这篇关于哪个 java 类会触发自然生物生成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆