Jump to content

Recommended Posts

Posted

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!

Posted

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)

Posted

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.

  • 1 year later...
Posted

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/

Posted

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/

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://mclo.gs/46Xf7Sq thanks
    • That seems to have fixed it, thank you!
    • I am having some issues starting an RLCraft server on a minimal install of Debian 12. I have Java installed and I'm able to start the vanilla Minecraft server jar no problem and people can join and play without any issues, as soon as I try to create a new directory with the Forge jar the initial install with the INSTALLER jar works when I use the java command with the --installServer flag, but as soon as I try to start the server using the forge jar that is NOT labelled with installer I get the following error: A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:569)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more   I have tried using newer versions of Java directly from Oracle as well. Has anybody been successful in starting and running a RLCraft server from the terminal on a Linux machine? I cannot figure out why it doesn't want to work but the vanilla jar works without issue. Thank you in advance!
  • Topics

×
×
  • Create New...

Important Information

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