Jump to content

[1.15.2] Custom Shield Renderer Showing Default Textures


weiblecr

Recommended Posts

I am trying to make a custom shield, right now, I would just like it to render the shield_base from my mod's resources!!

 

Most of the stuff I've take from existing code and started to update ... anything that can help would be greatly appreciated!

 

I'm think it's having issues with the AtlasTextures, this is my first one of those, please be nice :)

 

BlueShieldRenderer.java

package weible.rupeehunt.item.blueshield;

import java.util.Iterator;
import java.util.List;

import org.apache.logging.log4j.Level;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.mojang.datafixers.util.Pair;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.entity.model.ShieldModel;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.tileentity.BannerTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ShieldItem;
import net.minecraft.resources.IResource;
import net.minecraft.tileentity.BannerPattern;
import net.minecraft.tileentity.BannerTileEntity;
import net.minecraft.util.ResourceLocation;
import weible.rupeehunt.RupeeHuntMod;
import weible.rupeehunt.init.ModItems;


public class BlueShieldRenderer extends ItemStackTileEntityRenderer
{
	private final BlueShieldModel modelShield = new BlueShieldModel();
	public static final Material BLUE_SHIELD_BASE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(RupeeHuntMod.modId, "textures/items/blueshield.png"));
	public static final Material MINECRAFT_SHIELD_BASE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(RupeeHuntMod.modId, "textures/items/shield_base.png"));
	
	@Override
	public void render(ItemStack itemStackIn, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) 
	{
		  //RupeeHuntMod.LOGGER.log(Level.INFO, "Inside Blue Shield Renderer");
	      Item item = itemStackIn.getItem();
	      if (item == ModItems.BLUESHIELD) 
	      {
	         //boolean flag = itemStackIn.getChildTag("BlockEntityTag") != null;
	         matrixStackIn.push();
	         matrixStackIn.scale(1.0F, -1.0F, -1.0F);
	         Material material = MINECRAFT_SHIELD_BASE;
	         //RupeeHuntMod.LOGGER.log(Level.INFO, "Shield Base Material:" + MINECRAFT_SHIELD_BASE.getAtlasLocation() + " " + MINECRAFT_SHIELD_BASE.getTextureLocation());
	         RupeeHuntMod.LOGGER.log(Level.INFO, MINECRAFT_SHIELD_BASE.toString());
	         IVertexBuilder ivertexbuilder = material.getSprite().wrapBuffer(ItemRenderer.getBuffer(bufferIn, this.modelShield.getRenderType(material.getAtlasLocation()), false, itemStackIn.hasEffect()));
	         this.modelShield.getHandleModelRenderer().render(matrixStackIn, ivertexbuilder, combinedLightIn, combinedOverlayIn, 1.0F, 1.0F, 1.0F, 1.0F);
             this.modelShield.getPlateModelRenderer().render(matrixStackIn, ivertexbuilder, combinedLightIn, combinedOverlayIn, 1.0F, 1.0F, 1.0F, 1.0F);
	         matrixStackIn.pop();
	       } 

	 }
	   
}

 

BlueShieldModel.java

package weible.rupeehunt.item.blueshield;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.model.Model;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class BlueShieldModel extends Model 
{
   private final ModelRenderer plate;
   private final ModelRenderer handle;

   public BlueShieldModel() {
      super(RenderType::getEntitySolid);
      this.textureWidth = 64;
      this.textureHeight = 64;
      this.plate = new ModelRenderer(this, 0, 0);
      this.plate.addBox(-6.0F, -11.0F, -2.0F, 12.0F, 22.0F, 1.0F, 0.0F);
      this.handle = new ModelRenderer(this, 26, 0);
      this.handle.addBox(-1.0F, -3.0F, -1.0F, 2.0F, 6.0F, 6.0F, 0.0F);
   }

   public ModelRenderer getPlateModelRenderer() {
      return this.plate;
   }

   public ModelRenderer getHandleModelRenderer() {
      return this.handle;
   }

   public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
      this.plate.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
      this.handle.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
   }
}

 

 

2020-05-31_22.04.23.png

2020-05-31_22.04.28.png

Link to comment
Share on other sites

ok, so:

  1. Does your texture exist where you told the game to find it?
  2. Does the log say anything?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You should really try using the forums search function. It works well, and would save you lots of time, especially for commonly asked questions

I did a search for "shield", and found a solution in the first 4 links. (might be more than that now that I've posted on here)

 

Asking for help isn't bad, but give a go at finding your own solutions. The forums search and google are great :), plus you don't have to wait for an answer

Link to comment
Share on other sites

I searched all of the place getting it as far as it was ... mainly for ItemStackTileEntity and "Custom Shield" ... I hadn't searched just for Shield.  

 

I'll give this a look, looks promising .... Darco18s ... my texture does exist, log doesn't say much if anything about it.  Will follow up with more detail if the below topic doesn't help!

 

 

Link to comment
Share on other sites

15 hours ago, weiblecr said:

I'll give this a look, looks promising .... Darco18s ... my texture does exist, log doesn't say much if anything about it.

Your texture does not exist, at least not the way you are expecting.

You need to stitch the texture to the place where you told the game to look in (AtlasTexture.LOCATION_BLOCKS_TEXTURE). You need to stitch the texture onto the texture atlas.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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



×
×
  • Create New...

Important Information

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