Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi,

I am trying to create a Mod which can show "Ghost-Items" in the world and cover them with a colored glowing effect. NOTICE: clientside only!

 

Here you can see how the "Ghost-Items" are generated: 

 

ghostEntity = new EntityItem(mc.player.getEntityWorld(), 0, 70, 0, new ItemStack(Blocks.COBBLESTONE));

 

To render the Ghost-Items, I created a custom renderer which can render the Ghost-Item at a specific location in the world: (based on RenderEntityItem.class)

 

public void doRender(EntityItem entity, double xPos, double yPos, double zPos, float entityYaw, float partialTicks) {
		
		ItemStack itemstack = entity.getItem();
		
		// Noetig damit Item keine Defaulttextur bekommt
		bindEntityTexture(entity);

		GlStateManager.enableRescaleNormal();
		GlStateManager.alphaFunc(516, 0.1F);
		GlStateManager.enableBlend();
		RenderHelper.enableStandardItemLighting();
		GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
		GlStateManager.pushMatrix();
		
		IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(itemstack, entity.world, (EntityLivingBase) null);
		
		boolean forceGlowing = true;
		
		if (forceGlowing) { // FORCE ENTITY GLOWING
			GlStateManager.enableColorMaterial();
			GlStateManager.enableOutlineMode(this.getTeamColor(entity));
		}
		
		Minecraft mc = Minecraft.getMinecraft();
		float playerX = (float) (mc.player.lastTickPosX + (mc.player.posX - mc.player.lastTickPosX) * partialTicks);
		float playerY = (float) (mc.player.lastTickPosY + (mc.player.posY - mc.player.lastTickPosY) * partialTicks);
		float playerZ = (float) (mc.player.lastTickPosZ + (mc.player.posZ - mc.player.lastTickPosZ) * partialTicks);

		float dx = (float) (xPos - playerX);
		float dy = (float) (yPos - playerY);
		float dz = (float) (zPos - playerZ);
		GlStateManager.translate(dx, dy, dz);

		// Groesse aendern! wenn auskommentiert, wird voller Block gerendert
		ibakedmodel.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GROUND);
		// Item Rendern
		itemRenderer.renderItem(itemstack, ibakedmodel);
		
		if (forceGlowing) { // FORCE ENTITY GLOWING
			GlStateManager.disableOutlineMode();
			GlStateManager.disableColorMaterial();
		}
		
		GlStateManager.popMatrix();
		GlStateManager.disableRescaleNormal();
		GlStateManager.disableBlend();
    }

 

To add the colored glowing effect, I created a custom team and added the Ghost-Item

 

			Scoreboard scoreboard = mc.player.getWorldScoreboard();
			if(scoreboard != null){
				if(scoreboard.getTeam("Test1") == null){
					System.out.println("create Team");
					scoreboard.createTeam("Test1");
					scoreboard.getTeam("Test1").setColor(TextFormatting.GOLD);
					ghostEntity = new EntityItem(mc.player.getEntityWorld(), 0, 70, 0, new ItemStack(Blocks.COBBLESTONE));
					ghostEntity.setGlowing(true);
					scoreboard.addPlayerToTeam(ghostEntity.getCachedUniqueIdString(), "Test1");
				}
			}

 

The problem is, that if the glowing effect is enabled, the whole Ghost-Item is rendered white.

 

Picture 1: Ghost-Item at a specific location in the world without glowing effect: CLICK

 

Picture 2: Ghost-Item at a specific location in the world with glowing effect: CLICK

 

How can I fix this? The teamcolor is e.g GOLD.

 

Thank you for your help.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Edited by badner

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.