Jump to content

(1.16.5 MCP) render player effects


ElTotisPro50

Recommended Posts

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();
        }
    }

 

Link to comment
Share on other sites

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();
        }
    }

)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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;
	}

}

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm opening the forge 1.8.9 installer properly I click install with the client option selected, it says it installs properly but when I go into my files and also when I go into the minecraft launcher, it's just not there.  JVM info: Oracle Corporation - 1.8.0_431 - 25.431-b10 java.net.preferIPv4Stack=true Found java version 1.8.0_431 Considering minecraft client jar Considering library net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9: Not Downloading {Wrong Side} Considering library net.minecraft:launchwrapper:1.12: Not Downloading {Wrong Side} Considering library org.ow2.asm:asm-all:5.0.3: Not Downloading {Wrong Side} Considering library jline:jline:2.13: Not Downloading {Wrong Side} Considering library com.typesafe.akka:akka-actor_2.11:2.3.3 Considering library com.typesafe:config:1.2.1 Considering library org.scala-lang:scala-actors-migration_2.11:1.1.0 Considering library org.scala-lang:scala-compiler:2.11.1 Considering library org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2 Considering library org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2 Considering library org.scala-lang:scala-library:2.11.1 Considering library org.scala-lang:scala-parser-combinators_2.11:1.0.1 Considering library org.scala-lang:scala-reflect:2.11.1 Considering library org.scala-lang:scala-swing_2.11:1.0.1 Considering library org.scala-lang:scala-xml_2.11:1.0.2 Considering library lzma:lzma:0.0.1: Not Downloading {Wrong Side} Considering library net.sf.jopt-simple:jopt-simple:4.6: Not Downloading {Wrong Side} Considering library java3d:vecmath:1.5.2 Considering library net.sf.trove4j:trove4j:3.0.3 Extracting: /forge-1.8.9-11.15.1.2318-1.8.9-universal.jar To: C:\Users\Ian\AppData\Roaming\.minecraft\libraries\net\minecraftforge\forge\1.8.9-11.15.1.2318-1.8.9\forge-1.8.9-11.15.1.2318-1.8.9.jar That's the installer log and I have no idea if anything is wrong.
    • https://mclo.gs/NQ786zI   I don’t understand what I need to do.
    • I am wanting to give the armour in my mod special properties, but I have no idea how to do so.   For the first armour set I want it to be the case that when the full set is worn it has the properties of a carved pumpkin, making it so you won't aggravate endermen when you look at them.    The second, and presumably harder property is that for the second set I would like it to be the case that when the full set is worn, you can walk over the void without falling. (I was considering using the levitation to accomplish this but I wanted to check beforehand).   Would both of these specialities be achievable for each armour set and how exactly would they both be done? Help would be much appreciated. 
    • I finally got my Forge server up and running thanks to the help of the people on this forum and played fine for a day. Now since I started playing today, the server runs for 20-30 minutes then freezes and kicks everyone out but stays up and running but won't let anyone connect. Here is the latest debug log and crashlog from the server. Thank you for reading & helping   https://gist.github.com/Dwolfwoood/d0410e581c86772694f1d8007431c409   https://gist.github.com/Dwolfwoood/b5d521fd071dbfcc816949924757fef9
    • I got the infamous crash log that you get when you have a mod or multiple mods that are incompatible with the version being used. however.. I have no idea which ones are wrong. I was hoping the forums could help me figure it out. does the crsh report tell me and im just dumb?  
  • Topics

×
×
  • Create New...

Important Information

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