Jump to content

Recommended Posts

Posted

i add a shield to my mod it works but i haven't a model and a texture

 

1. where can I set the model for the shield

2. in which folder do I have to put the texture

 

this is my shield class:

 

package net.luis.cave.items;

import net.luis.cave.Cave;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShieldItem;

public class EnderiteShield extends ShieldItem {

	public EnderiteShield(Properties properties) {
		
		super(new Item.Properties().group(Cave.WEAPONS)
				.maxDamage(865));
		
	}
	
	@Override
	public boolean isShield(ItemStack stack, LivingEntity entity) {
		
		return true;
		
	}

}

 

and this is the register class

 

	public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Cave.Mod_Id);
	
	public static final RegistryObject<ShieldItem> ENDERITE_SHIELD = ITEMS.register("enderite_shield", 
			() -> new EnderiteShield(new Item.Properties().group(Cave.WEAPONS)));

 

 

Posted
10 minutes ago, Luis_ST said:

i add a shield to my mod it works but i haven't a model and a texture

Do you want the model to be like regular items, or similar to how the vanilla shield is? In the latter case you would need an item stack tile entity renderer (and maybe a model class too). Here is the slightly outdated official documentation on ItemStackTileEntityRenderer. I also recommend checking out the ItemStackTileEntityRenderer vanilla class to see how vanilla does it.

Posted

the shield should be like the minecraft shield

 

and is the model class corect

 

package net.luis.cave.models;

import net.minecraft.client.renderer.entity.model.*;
import net.minecraft.block.*;
import net.minecraft.util.*;
import java.util.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.client.renderer.model.*;

public class EnderiteShieldModel extends ShieldModel implements IBakedModel {

	@Override
	public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand) {
		
		return null;
		
	}

	@Override
	public boolean isAmbientOcclusion() {
		
		return false;
		
	}

	@Override
	public boolean isGui3d() {
		
		return false;
		
	}

	@Override
	public boolean isBuiltInRenderer() {
		
		return false;
		
	}

	@Override
	public TextureAtlasSprite getParticleTexture() {
		
		return null;
		
	}

	@Override
	public ItemOverrideList getOverrides() {
		
		return null;
		
	}

	@Override
	public boolean func_230044_c_() {
		
		return false;
		
	}
    
}

 

Posted

I got this from a friend, but there are func_ and field_ and I don't know the actual names of the functions is there a way to get the current names

 

 

package net.luis.cave.render;

import net.minecraftforge.api.distmarker.*;
import net.minecraft.util.*;
import com.mojang.blaze3d.matrix.*;
import net.minecraft.util.math.vector.*;
import net.luis.cave.models.EnderiteShieldModel;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.tileentity.*;
import java.util.*;
import com.mojang.blaze3d.vertex.*;
import com.mojang.datafixers.util.*;
import net.minecraft.tileentity.*;
import net.minecraft.item.*;
import org.apache.logging.log4j.*;

public class EnderiteShieldRender extends ItemStackTileEntityRenderer {
	
    private final EnderiteShieldModel shieldModel;

    
    public EnderiteShieldRender() {
    	
        this.shieldModel = new EnderiteShieldModel();
        
    }
    
    public void func_239207_a_(final ItemStack stack, final ItemCameraTransforms.TransformType transformType, final MatrixStack matrices, final IRenderTypeBuffer bufferIn, final int light, final int overlay) {
    	
        matrices.func_227860_a_();
        matrices.func_227863_a_(Vector3f.field_229179_b_.func_229187_a_(180.0f));
        final RenderMaterial spriteIdentifier = new RenderMaterial(AtlasTexture.field_110575_b, new ResourceLocation("cave:entity/enderite_shield"));
        final IVertexBuilder vertexConsumer3 = spriteIdentifier.getTextureLocation().func_229230_a_(ItemRenderer.func_239391_c_(bufferIn, this.shieldModel.func_228282_a_(ModelBakery.field_229317_h_.func_229310_a_()), true, stack.func_77962_s()));
        this.shieldModel.func_228294_b_().func_228309_a_(matrices, vertexConsumer3, light, overlay, 1.0f, 1.0f, 1.0f, 1.0f);
        final List<Pair<BannerPattern, DyeColor>> list = (List<Pair<BannerPattern, DyeColor>>)BannerTileEntity.func_230138_a_(ShieldItem.getColor(stack), BannerTileEntity.func_230139_a_(stack));
        BannerTileEntityRenderer.func_241717_a_(matrices, bufferIn, light, overlay, this.shieldModel.func_228293_a_(), spriteIdentifier, false, (List)list, stack.func_77962_s());
        matrices.func_227865_b_();
        
    }

}

 

Posted
1 hour ago, Luis_ST said:

and is the model class corect

Well, if you want your shield to have the exact same model as the vanilla shield, you don't need to subclass it at all, just create a new instance of the ShieldModel in your item stack tile entity renderer.

 

34 minutes ago, Luis_ST said:

I got this from a friend, but there are func_ and field_ and I don't know the actual names of the functions is there a way to get the current names

I think the easiest approach to this is to look how the vanilla ItemStackTileEntityRenderer renders the shield, and do something similar.

 

On a slightly unrelated note, you should refrain from hardcoding your modid in strings as you have done in the ResourceLocation constructor, since that makes it less readable, and harder to change (which you probably should, since 'cave' is way too short).

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.