use of net.minecraft.client.renderer.entity.EntityRenderDispatcher in project JustEnoughResources by way2muchnoise.
the class RenderHelper method renderEntity.
public static void renderEntity(PoseStack poseStack, int x, int y, double scale, double yaw, double pitch, LivingEntity livingEntity) {
if (livingEntity.level == null)
livingEntity.level = Minecraft.getInstance().level;
PoseStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.pushPose();
modelViewStack.mulPoseMatrix(poseStack.last().pose());
modelViewStack.translate(x, y, 50.0F);
modelViewStack.scale((float) -scale, (float) scale, (float) scale);
PoseStack mobPoseStack = new PoseStack();
mobPoseStack.mulPose(Vector3f.ZP.rotationDegrees(180.0F));
IMobRenderHook.RenderInfo renderInfo = MobRegistryImpl.applyRenderHooks(livingEntity, new IMobRenderHook.RenderInfo(x, y, scale, yaw, pitch));
x = renderInfo.x;
y = renderInfo.y;
scale = renderInfo.scale;
yaw = renderInfo.yaw;
pitch = renderInfo.pitch;
mobPoseStack.mulPose(Vector3f.XN.rotationDegrees(((float) Math.atan((pitch / 40.0F))) * 20.0F));
livingEntity.yo = (float) Math.atan(yaw / 40.0F) * 20.0F;
float yRot = (float) Math.atan(yaw / 40.0F) * 40.0F;
float xRot = -((float) Math.atan(pitch / 40.0F)) * 20.0F;
livingEntity.setYRot(yRot);
livingEntity.setYRot(yRot);
livingEntity.setXRot(xRot);
livingEntity.yHeadRot = yRot;
livingEntity.yHeadRotO = yRot;
mobPoseStack.translate(0.0F, livingEntity.getY(), 0.0F);
RenderSystem.applyModelViewMatrix();
EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher();
entityRenderDispatcher.setRenderShadow(false);
MultiBufferSource.BufferSource bufferSource = Minecraft.getInstance().renderBuffers().bufferSource();
RenderSystem.runAsFancy(() -> {
entityRenderDispatcher.render(livingEntity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, mobPoseStack, bufferSource, 15728880);
});
bufferSource.endBatch();
entityRenderDispatcher.setRenderShadow(true);
modelViewStack.popPose();
RenderSystem.applyModelViewMatrix();
}
use of net.minecraft.client.renderer.entity.EntityRenderDispatcher in project AlexsMobs by Alex-the-666.
the class AMItemstackRenderer method drawEntityOnScreen.
public static void drawEntityOnScreen(PoseStack matrixstack, int posX, int posY, float scale, boolean follow, double xRot, double yRot, double zRot, float mouseX, float mouseY, Entity entity) {
float f = (float) Math.atan(-mouseX / 40.0F);
float f1 = (float) Math.atan(mouseY / 40.0F);
matrixstack.scale(scale, scale, scale);
entity.setOnGround(false);
float partialTicks = Minecraft.getInstance().getFrameTime();
Quaternion quaternion = Vector3f.ZP.rotationDegrees(180.0F);
Quaternion quaternion1 = Vector3f.XP.rotationDegrees(20.0F);
float partialTicksForRender = Minecraft.getInstance().isPaused() || entity instanceof EntityMimicOctopus ? 0 : partialTicks;
int tick = Minecraft.getInstance().player.tickCount;
if (Minecraft.getInstance().isPaused()) {
tick = ticksExisted;
}
if (follow) {
float yaw = f * 45.0F;
entity.setYRot(yaw);
entity.tickCount = tick;
if (entity instanceof LivingEntity) {
((LivingEntity) entity).yBodyRot = yaw;
((LivingEntity) entity).yBodyRotO = yaw;
((LivingEntity) entity).yHeadRot = yaw;
((LivingEntity) entity).yHeadRotO = yaw;
}
quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
quaternion.mul(quaternion1);
}
matrixstack.mulPose(quaternion);
matrixstack.mulPose(Vector3f.XP.rotationDegrees((float) (-xRot)));
matrixstack.mulPose(Vector3f.YP.rotationDegrees((float) yRot));
matrixstack.mulPose(Vector3f.ZP.rotationDegrees((float) zRot));
EntityRenderDispatcher entityrenderdispatcher = Minecraft.getInstance().getEntityRenderDispatcher();
quaternion1.conj();
entityrenderdispatcher.overrideCameraOrientation(quaternion1);
entityrenderdispatcher.setRenderShadow(false);
MultiBufferSource.BufferSource multibuffersource$buffersource = Minecraft.getInstance().renderBuffers().bufferSource();
RenderSystem.runAsFancy(() -> {
entityrenderdispatcher.render(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicksForRender, matrixstack, multibuffersource$buffersource, 15728880);
});
multibuffersource$buffersource.endBatch();
entityrenderdispatcher.setRenderShadow(true);
entity.setYRot(0.0F);
entity.setXRot(0.0F);
if (entity instanceof LivingEntity) {
((LivingEntity) entity).yBodyRot = 0.0F;
((LivingEntity) entity).yHeadRotO = 0.0F;
((LivingEntity) entity).yHeadRot = 0.0F;
}
RenderSystem.applyModelViewMatrix();
Lighting.setupFor3DItems();
}
use of net.minecraft.client.renderer.entity.EntityRenderDispatcher in project AlexsMobs by Alex-the-666.
the class LayerKangarooBaby method renderEntity.
public <E extends Entity> void renderEntity(E entityIn, double x, double y, double z, float yaw, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int packedLight) {
EntityRenderer<? super E> render = null;
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
try {
render = manager.getRenderer(entityIn);
if (render != null) {
try {
render.render(entityIn, yaw, partialTicks, matrixStack, bufferIn, packedLight);
} catch (Throwable throwable1) {
throw new ReportedException(CrashReport.forThrowable(throwable1, "Rendering entity in world"));
}
}
} catch (Throwable throwable3) {
CrashReport crashreport = CrashReport.forThrowable(throwable3, "Rendering entity in world");
CrashReportCategory crashreportcategory = crashreport.addCategory("Entity being rendered");
entityIn.fillCrashReportCategory(crashreportcategory);
CrashReportCategory crashreportcategory1 = crashreport.addCategory("Renderer details");
crashreportcategory1.setDetail("Assigned renderer", render);
crashreportcategory1.setDetail("Rotation", Float.valueOf(yaw));
crashreportcategory1.setDetail("Delta", Float.valueOf(partialTicks));
throw new ReportedException(crashreport);
}
}
use of net.minecraft.client.renderer.entity.EntityRenderDispatcher in project pollen by MoonflowerTeam.
the class PollenForge method clientInit.
private static void clientInit(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
EntityRenderDispatcher entityRenderDispatcher = event.getMinecraftSupplier().get().getEntityRenderDispatcher();
Map<EntityType<?>, EntityRenderer<?>> renderers = ((EntityRenderDispatcherAccessor) entityRenderDispatcher).getRenderers();
Map<String, PlayerRenderer> playerRenderers = ((EntityRenderDispatcherAccessor) entityRenderDispatcher).getPlayerRenderers();
AddRenderLayersEvent.EVENT.invoker().addLayers(new AddRenderLayersEvent.Context() {
@Override
public Set<String> getSkins() {
return playerRenderers.keySet();
}
@Nullable
@Override
public PlayerRenderer getSkin(String skinName) {
return playerRenderers.get(skinName);
}
@SuppressWarnings("unchecked")
@Nullable
@Override
public <T extends LivingEntity, R extends LivingEntityRenderer<T, ? extends EntityModel<T>>> R getRenderer(EntityType<? extends T> entityType) {
return (R) renderers.get(entityType);
}
});
});
}
use of net.minecraft.client.renderer.entity.EntityRenderDispatcher in project Create by Creators-of-Create.
the class PonderWorld method renderEntity.
private void renderEntity(Entity entity, double x, double y, double z, float pt, PoseStack ms, MultiBufferSource buffer) {
double d0 = Mth.lerp((double) pt, entity.xOld, entity.getX());
double d1 = Mth.lerp((double) pt, entity.yOld, entity.getY());
double d2 = Mth.lerp((double) pt, entity.zOld, entity.getZ());
float f = Mth.lerp(pt, entity.yRotO, entity.getYRot());
EntityRenderDispatcher renderManager = Minecraft.getInstance().getEntityRenderDispatcher();
int light = renderManager.getRenderer(entity).getPackedLightCoords(entity, pt);
renderManager.render(entity, d0 - x, d1 - y, d2 - z, f, pt, ms, buffer, light);
}
Aggregations