Jump to content

Recommended Posts

Posted

how can i render effects, overlays, etc in the player model; for example draw eyes(is a texture) in the player face or make some effects with GLStateManager.translate,color,etc

 

i know that i have to use RenderPlayerEvent Pre and Post, but i tried to do a random effect(flickering the player skin) but is FLICKERING THE ENTIRE GAME AND IM INVISIBLE, i wrote that the flick is not too much but still, even the mobs are invisible, the gui flicks a bit, that happens if i put pushMatrix() in .Pre and popMatrix in .Post

@SubscribeEvent
    public static void onRenderPlayer(RenderPlayerEvent.Pre event)
    {
        PlayerEntity player = event.getPlayer();
        GlStateManager.pushMatrix();
    }

    @SubscribeEvent
    public static void onRenderPlayer(RenderPlayerEvent.Post event)
    {
        PlayerEntity player = event.getPlayer();
        PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel();
        for(int i = 0; i < 10; i++) {
            GlStateManager.translatef((rand.nextFloat() - 0.5f) / 15,0,(rand.nextFloat() - 0.5f) / 15);
            GlStateManager.color4f(1,1,1,0.3F);
            GlStateManager.enableBlend();
            Minecraft.getInstance().getRenderManager().textureManager.bindTexture(((AbstractClientPlayerEntity)player).getLocationSkin());
            GlStateManager.disableBlend();
            GlStateManager.popMatrix();
        }
    }

 

but if i put pushmatrix in .Post is not working

@SubscribeEvent
    public static void onRenderPlayer(RenderPlayerEvent.Pre event)
    {
        PlayerEntity player = event.getPlayer();
    }

    @SubscribeEvent
    public static void onRenderPlayer(RenderPlayerEvent.Post event)
    {
        PlayerEntity player = event.getPlayer();
        PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel();
        for(int i = 0; i < 10; i++) {
            GlStateManager.pushMatrix();
            GlStateManager.translatef((rand.nextFloat() - 0.5f) / 15,0,(rand.nextFloat() - 0.5f) / 15);
            GlStateManager.color4f(1,1,1,0.3F);
            GlStateManager.enableBlend();
            Minecraft.getInstance().getRenderManager().textureManager.bindTexture(((AbstractClientPlayerEntity)player).getLocationSkin());
            GlStateManager.disableBlend();
            GlStateManager.popMatrix();
        }
    }

 

Posted
1 hour ago, diesieben07 said:

You need to add a layer to the player renderer.

Call LivingRenderer#addLayer for all player renderers in FMLClientSetupEvent#enqueueWork. 

You can get all player renderers from EntityRendererManager#getSkinMap.

Also, you posted in the wrong forum. Again.

yea but how i draw the eyes :b, and also i "solutioned" the flickering effect by rendering the body, but it duplicates the body ( https://imgur.com/a/9gBxXqR

@SubscribeEvent
    public static void onRenderPlayer(RenderPlayerEvent.Post event)
    {
        PlayerEntity player = event.getPlayer();
        PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel();
        ModelRenderer themodel = model.bipedBody;;
        for(int i = 0; i < 10; i++) {
            GlStateManager.pushMatrix();
            GlStateManager.translatef((rand.nextFloat() - 0.5f) / 15,0,(rand.nextFloat() - 0.5f) / 15);
            GlStateManager.color4f(1,1,1,0.3F);
            GlStateManager.enableBlend();
            Minecraft.getInstance().getRenderManager().textureManager.bindTexture(((AbstractClientPlayerEntity)player).getLocationSkin());
            themodel.render(
                    event.getMatrixStack(),
                    event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())),
                    Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY);
            GlStateManager.disableBlend();
            GlStateManager.popMatrix();
        }
    }

)

Posted
1 hour ago, diesieben07 said:

It will be fixed by not doing it using the render event, but using the solution I told you.

i dont know how to use the solution u gave me(dont hit me please haha), cant i solution it with RenderPlaterEvent.Post?

Posted
1 hour ago, diesieben07 said:

It will be fixed by not doing it using the render event, but using the solution I told you.

i made this but then?: 

Map<String, PlayerRenderer> skinMap = Minecraft.getInstance().getRenderManager().getSkinMap();
PlayerRenderer render;
render = skinMap.get("default");
render.addLayer(); //need something

 

Posted
1 hour ago, diesieben07 said:

You have to loop over all values of the map (there are multiple player renderers).

You need to create a layer class.

I got this from a superheroes mod, but i dont know what i have to use

public class LayerRendererSpeedsterHeroes implements LayerRenderer<EntityPlayer> {

	public RenderLivingBase<?> renderer;

	public static Minecraft mc = Minecraft.getMinecraft();

	public LayerRendererSpeedsterHeroes(RenderLivingBase<?> renderer) {
		this.renderer = renderer;
	}

	@Override
	public void doRenderLayer(EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		ItemStack tachyon = ItemStack.EMPTY;

		if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof IUpgradableArmor && (LucraftCoreUtil.hasArmorThisUpgrade(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST), SHItems.tachyonPrototype) || LucraftCoreUtil.hasArmorThisUpgrade(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST), SHItems.tachyonDevice)))
			tachyon = SpeedsterHeroesUtil.getTachyonDeviceFromArmor(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST));
		else if (!player.getCapability(LucraftCore.EXTENDED_INVENTORY, null).getInventory().getStackInSlot(ExtendedPlayerInventory.SLOT_MANTLE).isEmpty() && player.getCapability(LucraftCore.EXTENDED_INVENTORY, null).getInventory().getStackInSlot(ExtendedPlayerInventory.SLOT_MANTLE).getItem() instanceof ItemTachyonDevice)
			tachyon = player.getCapability(LucraftCore.EXTENDED_INVENTORY, null).getInventory().getStackInSlot(ExtendedPlayerInventory.SLOT_MANTLE);

		if (!tachyon.isEmpty()) {
			TachyonDeviceType tachyonType = ((ItemTachyonDevice) tachyon.getItem()).getTachyonDeviceType();
			if(tachyonType.getModel() == null)
				return;
			GlStateManager.pushMatrix();

			if (player.isSneaking()) {
				GlStateManager.translate(0, 0.18F, 0);
				// GlStateManager.rotate(30, 1, 0, 0);
			}
			((ModelBiped) renderer.getMainModel()).bipedBody.postRender(0.0625F);
			tachyonType.doModelTranslations(player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
			Minecraft.getMinecraft().renderEngine.bindTexture(tachyonType.getTexture());
			tachyonType.getModel().render(null, 0, 0, 0, 0, 0, 0.0625F);

			SpeedforcePlayerHandler data = SuperpowerHandler.getSpecificSuperpowerPlayerHandler(player, SpeedforcePlayerHandler.class);
			if (data != null && data.isInSpeed && SpeedsterHeroesUtil.getSpeedLevelList(player).get(data.speedLevel - 1) instanceof SpeedLevelBarTachyonDevice) {
				Tessellator tes = Tessellator.getInstance();
				VertexBuffer buf = tes.getBuffer();

				GL11.glDisable(3553);
				GL11.glDisable(2896);
				GlStateManager.enableBlend();
				GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
				GlStateManager.blendFunc(770, 1);

				if (tachyonType == TachyonDeviceType.PROTOTYPE) {
					GlStateManager.translate(0, 0, -0.1F);
					LCRenderHelper.setLightmapTextureCoords(240, 240);
					buf.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_COLOR);

					float alpha = ((MathHelper.sin((mc.player.ticksExisted + partialTicks) / 10F) + 1) / 4F) + 0.2F;

					buf.pos(-0.5F, 0F, 0).color(1, 0.5F, 0, alpha).endVertex();
					buf.pos(-0.5F, -0.25F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(-0.25F, -0.45F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0F, -0.45F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.25F, -0.45F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.5F, -0.25F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.5F, 0F, 0).color(1, 0.5F, 0, alpha).endVertex();
					buf.pos(0.5F, 0.25F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.25F, 0.45F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(-0.25F, 0.45F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(-0.5F, 0.25F, 0).color(0, 0, 0, 0).endVertex();

					tes.draw();

					LCRenderHelper.restoreLightmapTextureCoords();
				} else if (tachyonType == TachyonDeviceType.DEVICE) {
					// GlStateManager.translate(0, 0, -0.1F);
					LCRenderHelper.setLightmapTextureCoords(240, 240);
					buf.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_COLOR);

					float alpha = ((MathHelper.sin((mc.player.ticksExisted + partialTicks) / 10F) + 1) / 6F) + 0.2F;

					buf.pos(-0.7F, 0F, 0).color(0.047F, 0.71F, 1, alpha).endVertex();
					buf.pos(-0.6F, -0.25F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(-0.35F, -0.6F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0F, -0.65F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.35F, -0.6F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.6F, -0.25F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.7F, 0F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.6F, 0.25F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(0.35F, 0.6F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(-0F, 0.65F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(-0.35F, 0.6F, 0).color(0, 0, 0, 0).endVertex();
					buf.pos(-0.6F, 0.25F, 0).color(0, 0, 0, 0).endVertex();

					tes.draw();

					LCRenderHelper.restoreLightmapTextureCoords();
				}

				GL11.glEnable(2896);
				GL11.glEnable(3553);
				GlStateManager.disableBlend();
			}

			GlStateManager.popMatrix();
		}

		if (player == mc.player)
			return;

		if (!SuperpowerHandler.hasSuperpower(mc.player) || SuperpowerHandler.getSuperpower(mc.player) != SpeedsterHeroes.speedforce)
			return;

		AbilitySpeedforceVision speedforceVision = Ability.getAbilityFromClass(Ability.getCurrentPlayerAbilities(mc.player), AbilitySpeedforceVision.class);
		if (speedforceVision == null || !speedforceVision.isUnlocked() || !speedforceVision.isEnabled())
			return;

		if (!SuperpowerHandler.hasSuperpower(player) || SuperpowerHandler.getSuperpower(player) != SpeedsterHeroes.speedforce)
			return;

		SpeedforcePlayerHandler data1 = SuperpowerHandler.getSpecificSuperpowerPlayerHandler(player, SpeedforcePlayerHandler.class);
		SpeedforcePlayerHandler data2 = SuperpowerHandler.getSpecificSuperpowerPlayerHandler(mc.player, SpeedforcePlayerHandler.class);

		if (!data1.isInSpeed || !data2.isInSpeed)
			return;

		GlStateManager.pushMatrix();
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		GlStateManager.disableDepth();
		GlStateManager.enableBlend();
		GlStateManager.color(1.0F, 0.0F, 0.0F, 0.5F);
		GlStateManager.blendFunc(770, 771);
		this.renderer.getMainModel().render(player, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
		GlStateManager.blendFunc(771, 770);
		GlStateManager.disableBlend();
		GlStateManager.enableDepth();
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
		GlStateManager.popMatrix();
	}

	@Override
	public boolean shouldCombineTextures() {
		return false;
	}

}

 

Posted
1 hour ago, diesieben07 said:

Don't just randomly copy-paste code you don't understand.

You said you wanted to add eyes. I told you how to add them. Minecraft already has the code for adding an eye layer. Please use it.

what i have to put here: 

Map<String, PlayerRenderer> skinMap = Minecraft.getInstance().getRenderManager().getSkinMap();
PlayerRenderer render;
render = skinMap.get("default");
render.addLayer(new EndermanEyesLayer<LivingEntity>(WHAT I HAVE TO PUT HERE);

and how i do it for the player body(my flickering effect)

Posted
8 hours ago, diesieben07 said:

Look at how vanilla uses EndermanEyesLayer.

And again: You have to loop through the map's values. Otherwise it will not work for the "Alex" skin.

You will have to cancel the whole player rendering for this.

you said that i need another layer for the player for my flickering effect, what does that have in common with cancel the playe rendering?

Posted (edited)
1 hour ago, diesieben07 said:

I did not.

what? so appart of the eyes, what i need for the effect for the player? you said i cant use renderplayerevent for that because there is no solution for the body duplicate

Edited by ElTotisPro50
Posted (edited)
2 hours ago, diesieben07 said:

That is not what I said.

I told you to use a layer for the eyes. For the flickering you need to cancel RenderPlayerEvent.Pre to prevent the default rendering and then render the player yourself. There might be a better solution for this, but I an not a rendering expert.

Should'nt the .render method render at least the chest(now that i canceled .Pre im invisible but why my chest is not rendering if im using that method)?

@SubscribeEvent
    public static void onRenderPlayer(RenderPlayerEvent.Pre event)
    {
        PlayerEntity player = event.getPlayer();
        event.setCanceled(true);
    }

    @SubscribeEvent
    public static void onRenderPlayer(RenderPlayerEvent.Post event)
    {
        PlayerEntity player = event.getPlayer();
        PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel();
        ModelRenderer chestBody = model.bipedBody;
        for(int i = 0; i < 10; i++) {
            GlStateManager.pushMatrix();
            GlStateManager.translatef((rand.nextFloat() - 0.5f) / 15,0,(rand.nextFloat() - 0.5f) / 15);
            GlStateManager.color4f(1,1,1,0.3F);
            GlStateManager.enableBlend();
            Minecraft.getInstance().getRenderManager().textureManager.bindTexture(((AbstractClientPlayerEntity)player).getLocationSkin());
            chestBody.render(
                    event.getMatrixStack(),
                    event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())),
                    Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY);
            GlStateManager.disableBlend();
            GlStateManager.popMatrix();
        }
    }

 

Edited by ElTotisPro50

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.