Jump to content

Recommended Posts

Posted

The last problem is solved, directly after this the next one comes up:

My shurikens are all rendered same; all of them have the same texture...  :-\

 

What have I done wrong?

 

The corresponding Item class:

public class MoreToolsShuriken extends Item {

private int damage = 6;
private int shurikenType = 0;

public MoreToolsShuriken(int ID) {
	super(ID);
}

public MoreToolsShuriken(int ID, int Damage, int ShurikenType) {
	super(ID);
	this.damage = Damage;
	this.shurikenType = ShurikenType;
}

public MoreToolsShuriken setDamage(int Damage){
	this.damage = Damage;
	return this;
}

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
     
	EntityShuriken shuriken;

	switch (this.shurikenType){ 
	case 1: shuriken = new EntityShurikenGold(world, player, this, damage);
	case 2: shuriken = new EntityShurikenCopper(world, player, this, damage);
	case 3: shuriken = new EntityShurikenGlass(world, player, this, damage);
	case 4: shuriken = new EntityShurikenDiamond(world, player, this, damage);
	case 5: shuriken = new EntityShurikenBloodCrystal(world, player, this, damage);

	default: shuriken = new EntityShuriken(world, player, this, damage); 
	}

	world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F);
     	
     if (!world.isRemote)
     {
    	 world.spawnEntityInWorld(shuriken);
     }
     
     if (!player.capabilities.isCreativeMode){
    	 if (-- stack.stackSize == 0)
    		 return null;
     }
     return stack;
}

}

The Intialzation of these Items:

 

shurikenIron 			= new MoreToolsShuriken(shurikenIronID, 4, 0).setUnlocalizedName(PicInit + "shurikenIron").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenGold			= new MoreToolsShuriken(shurikenGoldID, 6, 1).setUnlocalizedName(PicInit + "shurikenGold").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenCopper 			= new MoreToolsShuriken(shurikenCopperID, 5, 2).setUnlocalizedName(PicInit + "shurikenCopper").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenDiamond			= new MoreToolsShuriken(shurikenDiamondID, 7, 4).setUnlocalizedName(PicInit + "shurikenDiamond").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenBloodCrystal	= new MoreToolsShuriken(shurikenBloodCrystalID, 9, 5).setUnlocalizedName(PicInit + "shurikenBloodCrystal").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenGlass 			= new MoreToolsShuriken(shurikenGlassID, 4, 3).setUnlocalizedName(PicInit + "shurikenGlass").setCreativeTab(MoreTools.tabMoreWeapons);

The EntityShurkien Class:

 

public class EntityShuriken extends EntityThrowable
{
private int damage = 2;
private Item itemDrop;

    public EntityShuriken(World par1World)
    {
        super(par1World);
    }

    public EntityShuriken(World par1World, EntityLiving par2EntityLiving)
    {
        super(par1World, par2EntityLiving);
    }
    
    public EntityShuriken(World world, EntityLiving shotBy, Item itemDrop, int Damage)
    {
        super(world, shotBy);
        this.damage = Damage;
        this.itemDrop = itemDrop;
    }

public EntityShuriken(World par1World, double par2, double par4, double par6)
    {
        super(par1World, par2, par4, par6);
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    {
        if (par1MovingObjectPosition.entityHit != null)
        {
        	par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (byte)damage);
        } else {
        	if (!this.worldObj.isRemote)
            {
                if (itemDrop != null){
                	this.dropItem(itemDrop.itemID, 1);
                }
            }
        }
        if (!this.worldObj.isRemote)
        {
            this.setDead();
        }
    }
}

The Render Class:

 

@SideOnly(Side.CLIENT)
public class RenderShuriken extends Render
{
    private Item itemIcon;
    private int field_94150_f = 0;

    public RenderShuriken(Item par1, int par2)
    {
        this.itemIcon = par1;
        this.field_94150_f = par2;
    }

    public RenderShuriken(Item par1)
    {
        this(par1, 0);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {    	
        Icon icon = itemIcon.getIconFromDamage(this.field_94150_f);
    	
    	if (icon != null)
        {
            GL11.glPushMatrix();
            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.loadTexture("/gui/items.png");
            Tessellator tessellator = Tessellator.instance;

            this.func_77026_a(tessellator, icon);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
        }
    }

    private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon)
    {
        float f = par2Icon.getMinU();
        float f1 = par2Icon.getMaxU();
        float f2 = par2Icon.getMinV();
        float f3 = par2Icon.getMaxV();
        float f4 = 1.0F;
        float f5 = 0.5F;
        float f6 = 0.25F;
        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        par1Tessellator.startDrawingQuads();
        par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
        par1Tessellator.draw();
    }
}

And last but not least the initialization of the renderer:

 

public static void registerEntities() {
	setUpEntity(EntityShuriken.class, "Iron Shuriken", 0, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenIron));
	setUpEntity(EntityShurikenCopper.class, "Copper Shuriken", 1, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenCopper));
	setUpEntity(EntityShurikenGold.class, "Gold Shuriken", 2, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenGold));
	setUpEntity(EntityShurikenDiamond.class, "Diamond Shuriken", 3, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenDiamond));
	setUpEntity(EntityShurikenBloodCrystal.class, "Blood Crystal Shuriken", 4, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenBloodCrystal));
	setUpEntity(EntityShurikenGlass.class, "Glass Shuriken", 5, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenGlass));
	}

private static void setUpEntity(Class<? extends Entity> EntityClass, String EntityName, int ModID, Object ModObject, int trackingRange, int updateFrequency, boolean sendsVelocityUpdate, Render renderer){
	EntityRegistry.registerGlobalEntityID(EntityClass, EntityName, EntityRegistry.findGlobalUniqueEntityId());
	EntityRegistry.registerModEntity(EntityClass, EntityName, ModID, ModObject, trackingRange, updateFrequency, sendsVelocityUpdate);
	RenderingRegistry.registerEntityRenderingHandler(EntityClass, renderer);
}

 

 

I hope, somebody can help me with this problem...

Thanks in advance!!!  :D

 

(If you need more source code, please tell me!)

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

    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • Same issue - I have no idea
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
    • un server de armas realista.  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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