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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, has anyone dealt with gradlew :runClient crashing on start before? I've currently made a forge 1.18.2 mod with the latest mdk and I use IntelliJ IDEA 2024.1 as my IDE, and now whenever I try to run the `:runClient` command with gradle, it works at first, but then the process stops reporting this issue: `Caused by: java.lang.reflect.InvocationTargetException` and `Caused by: java.lang.NoSuchMethodError: 'int net.minecraft.util.Mth.m_14045_(int, int, int)'`. I've pasted the full runClient gradle log in this message. I investigated this issue further on the forge forums to find that not much people had encountered it, and those who did encounter it somehow fixed it with fixes that does not work for me like deleting cache and let gradle redownload the cache or anything and that this issue is caused by a "Corrupted Cache", or whatever the heck that meant. I tried cloning my entire repo (https://github.com/Type-32/PreciseManufacturing) to another directory to "start fresh" but the same issue persists. I created a new project with a clean forge mod 1.18.2 template but the issue persists. I tried all the fixes I can find but none of them worked. even `.\gradlew --refresh-dependencies` didn't work. I am getting desparate for any help now ~~this is so freaking frustrating~~ This is my build.gradle file plugins { id 'eclipse' id 'idea' id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' id 'org.parchmentmc.librarian.forgegradle' version '1.+' } group = mod_group_id version = mod_version base { archivesName = mod_id } java { toolchain.languageVersion = JavaLanguageVersion.of(17) } minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { // applies to all the run configs below configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { // example of overriding the workingDirectory set in configureEach above workingDirectory project.file('run-data') // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } jarJar.enable() reobf { jarJar { } } tasks.jarJar.finalizedBy('reobfJarJar') // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { maven { name = 'tterrag maven' url = 'https://maven.tterrag.com/' } mavenLocal() } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation fg.deobf("com.simibubi.create:create-${create_minecraft_version}:${create_version}:slim") { transitive = false } implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}") // [MC<minecraft_version>,MC<next_minecraft_version>) jarJar(group: 'com.tterrag.registrate', name: 'Registrate', version: "[MC1.18.2,MC1.19)") // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}") // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}") // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}") // Example mod dependency using a mod jar from ./libs with a flat dir repository // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar // The group id is ignored when searching -- in this case, it is "blank" // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") } tasks.named('processResources', ProcessResources).configure { var replaceProperties = [ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, forge_version: forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, mod_authors: mod_authors, mod_description: mod_description, ] inputs.properties replaceProperties filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { expand replaceProperties + [project: project] }} // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ "Specification-Title": mod_id, "Specification-Vendor": mod_authors, "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": project.jar.archiveVersion, "Implementation-Vendor": mod_authors, "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } // This is the preferred method to reobfuscate your jar file finalizedBy 'reobfJar' } tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation }  
    • pastebin.com and paste.ee couldn't handle the debug and crash log sizes, apologies I have to send it on mega, and I hope it's not a problem Basically, Minecraft turns on normally but when I try to create a world, it goes to 100%, joining world, saving world and crashes   debug log https://mega.nz/file/kP1nGDKZ decryption key: C_VSH-IO6Kpi9IdqUs2Z0KDu0Fpujmen_I3rI1yUyVw crash log https://mega.nz/file/RXVEhRpZ 0r05xiqoGmL8rQEXjYaf8Q8BO-XbJGzpeBDek3aqb0w
  • Topics

×
×
  • Create New...

Important Information

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