So, after tons of rage quitting and a short 2-day break, I figured out what was wrong.
I had the exact same issue and here's the solution for anyone who needs it in the future:
Edit: Yeah, no. My old method isn't correct at all (Thanks to diesieben07 for the help). Just add the code below and it should be fine. You can also change "new GenericHeadModel(0, 0, 32, 32)" to a custom model or you can change the last 2 values to modify the texture size.
@SubscribeEvent
public static void registerCustomSkullRenderers(final FMLClientSetupEvent event) {
Field ModelField;
Field SkinField;
try {
ModelField = SkullTileEntityRenderer.class.getDeclaredField("MODEL_BY_TYPE");
ModelField.setAccessible(true);
Map<SkullBlock.ISkullType, GenericHeadModel> Model = (Map<SkullBlock.ISkullType, GenericHeadModel>) ModelField.get(SkullTileEntityRenderer.class);
Model.put(<Insert Custom Skull Type>, new GenericHeadModel(0, 0, 32, 32));
SkinField = SkullTileEntityRenderer.class.getDeclaredField("SKIN_BY_TYPE");
SkinField.setAccessible(true);
Map<SkullBlock.ISkullType, ResourceLocation> Skin = (Map<SkullBlock.ISkullType, ResourceLocation>) SkinField.get(SkullTileEntityRenderer.class);
Skin.put(<Insert Custom Skull Type>, new ResourceLocation("<Mod ID>:<Texture Location>"));
}
catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
Basically, you have to register a custom item renderer. Let's say the block and the tile entities were done properly (Too lazy to check) and the item (more exactly the texture) was the issue.
All you need to do is add the following two methods to your main project class:
public static Item.Properties setupISTER(Item.Properties group) {
return group.setISTER(MainClass::getISTER);
}
@OnlyIn(Dist.CLIENT)
public static Callable<ItemStackTileEntityRenderer> getISTER() {
return ItemRenderer::new;
}
and after that you need to add this to your block item:
MainClass.setupISTER(new Item.Properties())
Item.Properties() is of course your item properties like tab, rarity and etc.
Then finally you're gonna need your Item Renderer class which should be something similar to this:
@OnlyIn(Dist.CLIENT)
public class ItemRenderer extends ItemStackTileEntityRenderer {
public static final ItemStackTileEntityRenderer instance = new PA_ItemRenderer();
@Override
public void renderByItem(ItemStack stack, ItemCameraTransforms.TransformType transform, MatrixStack matrix, IRenderTypeBuffer renderer, int light, int overlay) {
Item item = stack.getItem();
if (item instanceof BlockItem) {
Block block = ((BlockItem) item).getBlock();
if (block instanceof AbstractSkullBlock) {
PA_SkullRenderer.renderSkull(null, 180.0F, ((AbstractSkullBlock) block).getType(), null, 0.0F, matrix, renderer, light);
}
}
}
}
The renderer is a slightly modified version of the vanilla one and all the code was made on 1.16.5.