Hello, I want to modify the player view point to the one of a custom entity.
So i just do :
public class SoulstickEventListener {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void entityInteract(EntityInteract event) {
if(event.getTarget() != null) {
if(event.getTarget() instanceof EntityPhantom) {
if(event.getItemStack() != null && event.getItemStack().getItem() == ModItems.soulstick) {
Minecraft.getMinecraft().setRenderViewEntity(event.getTarget());
}
}
}
}
}
The viewpoint is correctly change but I can only see the entity face so I want to prevent the render if the pov is from the entity that tries to be rendered. I have a Render class like that :
public class RendererPhantom extends RenderBiped<EntityPhantom> {
public static final ResourceLocation PHANTOM_TEXTURES = new ResourceLocation(References.MOD_ID + ":textures/entities/phantom.png");
public RendererPhantom(RenderManager renderManager) {
super(renderManager, new ModelPlayer(0.0F, false), 0.5F);
}
@Override
protected ResourceLocation getEntityTexture(EntityPhantom entity) {
return PHANTOM_TEXTURES;
}
@Override
public void doRender(EntityPhantom entity, double x, double y, double z, float entityYaw, float partialTicks) {
if(!(getRenderManager().renderViewEntity.isEntityEqual(entity))) {
// DEBUG
System.out.println(getRenderManager().renderViewEntity);
System.out.println(entity);
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
}
}
Now this is where it gets tricky, this does not prevent the render because i get in the log :
So the first call getRenderManager().renderViewEntity gives the entity but says it is in world "New World" (which is right) but the entity given to my doRender is said to be in world "MpServer" (which is weird).
Anyone would know the cause ?