版本信息
你使用的IDE:Eclipse
你使用的IDE版本:Eclipse IDE for Java Developers - 2019-12
Forge版本: forge-1.12.2-14.23.5.2768
Minecraft版本: 1.12
错误情况简述
游戏里面没有渲染出我要的模型
相关代码
static RenderManager Render_Test_Manager = Minecraft.getMinecraft().getRenderManager();
static EntityPlayer players = Minecraft.getMinecraft().player;
@SubscribeEvent
public static void get_an_player(PlayerLoggedInEvent event) {
players = event.player;
}
@SubscribeEvent
public static void render_test(RenderPlayerEvent.Post event) {
if (players != null) {
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Entity_test entity_test = new Entity_test(players.getEntityWorld());
Render_Test_Manager.renderEntity(entity_test, 0, 0, 0, 0, 0, false);
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
}
}
上面这串代码运行起来是没有问题的,能在玩家脚下看到渲染的模型,但是由于第一人称的时候不渲染玩家,也就没法看到我要渲染的东西了,因此我换了一个事件,如下代码
static RenderManager Render_Test_Manager = Minecraft.getMinecraft().getRenderManager();
static EntityPlayer players = Minecraft.getMinecraft().player;
@SubscribeEvent
public static void get_an_player(PlayerLoggedInEvent event) {
players = event.player;
}
@SubscribeEvent
public static void render_test(RenderWorldLastEvent event) {
if (players != null) {
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Entity_test entity_test = new Entity_test(players.getEntityWorld());
Render_Test_Manager.renderEntity(entity_test, 0, 80.0D, 0, 0, 0, false);
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
}
}
就仅仅只是把RenderPlayerEvent.Post改成了RenderWorldLastEvent,但是进游戏之后在x=0 y=80 z=0 的位置并没有看到要渲染的模型,我还试过RenderTickEvent,但是结果都是失败,这是咋回事?