Jump to content

Bow Renderer - Change time to pull?


Bedrock_Miner

Recommended Posts

Heyho Guys!

 

I want to create a new bow which can be pulled twice as fast as the normal vanilla bow. I created a bow renderer which renders it exactly like the normal one, so it has the three changing textures etc.

The problem is now: I need to change the duration of the animation which rescales the bow while pulling, because this is now much to slow. Also I want to make this shaking effect when the bow is fully pulled out appear when my bow is ready and not after the second which is needed to pull a vanilla bow.

 

Is there a way to change the speed of these animations? If nothing else works, it would be ok to reverse the GL Matrix transformations and apply new ones, but I only want to do this if nothing else works. And even if I have to, I have no idea how.

 

Thanks for your help!

Link to comment
Share on other sites

OK, here is the renderer:

 

package com.bedrockminer.magicum.client.renderer.items;

import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;

import com.bedrockminer.magicum.item.classes.ItemMagicBow;
import com.bedrockminer.magicum.item.materials.MagicBowMaterial;
import com.bedrockminer.minersbasic.client.render.ObjectRenderer;

public class MagicBowRenderer implements IItemRenderer {

private static ObjectRenderer o = ObjectRenderer.instance; //Rendering utility created by myself

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
	return false;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	if (item != null && item.getItem() != null && item.getItem() instanceof ItemMagicBow) {
		if (type == ItemRenderType.EQUIPPED) {
			o.scale(1.5, 1.5, 1.5);
			o.rotate(-80, 0, 1, 0);
			o.translate(0, 0, -0.4);
			o.rotate(-45, 0, 0, 1);
			o.translate(-0.6, -0.6, 0);
		}
		MagicBowMaterial material = ((ItemMagicBow)item.getItem()).getBowMaterial();
		int use = Minecraft.getMinecraft().thePlayer.getItemInUseDuration();
		IIcon icon = ((ItemMagicBow)item.getItem()).getItemIconForUseDuration(use);
		o.renderSolidifiedFaceWithGlint(icon, 1.0f/16.0f, item.hasEffect(0));
	}
}
}

 

The animation I want to change is applied because of the itemUseAction of the Bow which is EnumAction.bow (I don't want to change this).

BowClass:

 

public class ItemMagicBow extends ItemBow {

public MagicBowMaterial material;

public ItemMagicBow(String unlocalizedName, MagicBowMaterial material) {
	super();
	this.material = material;
	this.setUnlocalizedName(unlocalizedName);
	this.setTextureName(Magicum.MODID + ":" + unlocalizedName);
	this.setCreativeTab(ModCreativeTabs.weapons);
}

@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int duration) {
	super.onPlayerStoppedUsing(stack, world, player, duration);
}

@Override
public IIcon getItemIconForUseDuration(int time) {
	if (time > 0) {
		int pic = time * 2 / this.getBowMaterial().getDrawDuration();
		if (pic > 2)
			pic = 2;
		return super.getItemIconForUseDuration(pic);
	}
	return this.itemIcon;
}

@Override
public int getItemEnchantability() {
	return this.material.getEnchantability();
}

@Override
public int getMaxDamage() {
	return this.material.getDurability();
}

public MagicBowMaterial getBowMaterial() {
	return this.material;
}
}

This class extends ItemBow, so everything else is defined in vanilla source code (Not sure, where exactly the rendering code is)

Link to comment
Share on other sites

You can change itemInUseCount with PlayerUseItemEvent$Tick Event, by its duration.

Decreasing the duration value will make the bow animation faster.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

  • 1 year later...

You can change itemInUseCount with PlayerUseItemEvent$Tick Event, by its duration.

Decreasing the duration value will make the bow animation faster.

Thank you, this worked for me in 1.10.

I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java.

 

Follow me on GitHub: https://github.com/yooksi

Contact me on Twitter: https://twitter.com/yooksi

Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/

Link to comment
Share on other sites

You can change itemInUseCount with PlayerUseItemEvent$Tick Event, by its duration.

Decreasing the duration value will make the bow animation faster.

Thank you, this worked for me in 1.10.

You do know this post is almost 2 years old? Don't reply to it then.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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