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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Are you playing with mods? This usually happens to me when certain mods clash. I would recommend looking through the game logs (found in the file of the modpack) to see what errors have occurred. I hope this helps!
    • For the HoneyBottleItem class, would I just copy/paste my Lemon Juice item into the class or would I have to make other changes? Also, for what you first said, I have copied the "getEatingSound" and the "getDrinkingSound" from the class into my ModFoods class (I could link the whole class if that would help you understand more), though nothing seems to have been done. I also do not see a way to prevent particles from appearing when the item is drank. (Could you also post some examples if possible, that would be a great help to see where I went wrong).   I am at a point where I am quite clueless as the tutorials on YouTube do not cover the area I am needing to go into. I do hope that this is not too much of a bother for you. 
    • "An unexpected problem occurred and the game crashed" "Exit code: 1" I don't know what to do. Please help
    • https://mclo.gs/iVJZfGm https://privatebin.net/?442243857e9dcaca#5MhV8JAuhNJnN587jbG2pcVQi8VnvgAVafmpAd6Gnv91
    • So im making a mod for minecraft and i want to add custom fishing rods... aka fishing rods with different bait, depending on the bait you can have a higher chance of getting other fish. I want to make basically custom fishing rods with at least one custom loot table for each (so that i can choose which fish have a higher chance of being caught in a simpler way with said loot table) Problem is i dont know even where to start with doing this, like at all. Im very beginner with modding minecraft, any help (links to any source which could help me with this is also very helpful) would be great. 1.20 forge(of course)
  • Topics

×
×
  • Create New...

Important Information

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