Jump to content

[Solved]FOV multiplier


Noah_Beech

Recommended Posts

recently I've been optimizing my custom bows and now everything about them is good (Right size, you hold them correctly, no more floppy arrows) But For the final part I've ran into a problem. The regular bow uses an FOV multiplier in EntityplayerSP to give a little zoom when you hold down the right click. The code looks something like this.

 

public float getFOVMultiplier()
    {
        float f = 1.0F;

        if (this.capabilities.isFlying)
        {
            f *= 1.1F;
        }

        f *= (this.landMovementFactor * this.getSpeedModifier() / this.speedOnGround + 1.0F) / 2.0F;

        if (this.isUsingItem() && this.getItemInUse().itemID == Item.bow.itemID)
        {
            int i = this.getItemInUseDuration();
            float f1 = (float)i / 20.0F;

            if (f1 > 1.0F)
            {
                f1 = 1.0F;
            }
            else
            {
                f1 *= f1;
            }

            f *= 1.0F - f1 * 0.15F;
        }

        return f;
    }

 

This FOV multiplier cannot seem to be used without modifying the class (A dumb idea haha) And I've heard maybe that reflection can do this? However I don't think so because it returns a local variable :/. Any help would be appreciated, thanks in advance!

 

~Noah

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

recently I've been optimizing my custom bows and now everything about them is good (Right size, you hold them correctly, no more floppy arrows) But For the final part I've ran into a problem. The regular bow uses an FOV multiplier in EntityplayerSP to give a little zoom when you hold down the right click. The code looks something like this.

 

public float getFOVMultiplier()
    {
        float f = 1.0F;

        if (this.capabilities.isFlying)
        {
            f *= 1.1F;
        }

        f *= (this.landMovementFactor * this.getSpeedModifier() / this.speedOnGround + 1.0F) / 2.0F;

        if (this.isUsingItem() && this.getItemInUse().itemID == Item.bow.itemID)
        {
            int i = this.getItemInUseDuration();
            float f1 = (float)i / 20.0F;

            if (f1 > 1.0F)
            {
                f1 = 1.0F;
            }
            else
            {
                f1 *= f1;
            }

            f *= 1.0F - f1 * 0.15F;
        }

        return f;
    }

 

This FOV multiplier cannot seem to be used without modifying the class (A dumb idea haha) And I've heard maybe that reflection can do this? However I don't think so because it returns a local variable :/. Any help would be appreciated, thanks in advance!

 

~Noah

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Okay, after looking at it for awhile, there is a variable in EntityRenderer called || private float fovMultiplierTemp; || And it obtains the value that is returned in getFOVMultiplier in this bit of code.

 

if (mc.renderViewEntity instanceof EntityPlayerSP)
        {
            EntityPlayerSP entityplayersp = (EntityPlayerSP)this.mc.renderViewEntity;
            this.fovMultiplierTemp = entityplayersp.getFOVMultiplier();
        }
        else
        {
            this.fovMultiplierTemp = mc.thePlayer.getFOVMultiplier();
        }

(Lines 345-370 in EntityRenderer)

 

This value is private, so would it be possible via reflection to make this variable change around (Possibly every tick, BTW)? It would be nice if there was a way to do this without reflection, as the value will constantly be changing (Possible lag?) 

 

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Okay, after looking at it for awhile, there is a variable in EntityRenderer called || private float fovMultiplierTemp; || And it obtains the value that is returned in getFOVMultiplier in this bit of code.

 

if (mc.renderViewEntity instanceof EntityPlayerSP)
        {
            EntityPlayerSP entityplayersp = (EntityPlayerSP)this.mc.renderViewEntity;
            this.fovMultiplierTemp = entityplayersp.getFOVMultiplier();
        }
        else
        {
            this.fovMultiplierTemp = mc.thePlayer.getFOVMultiplier();
        }

(Lines 345-370 in EntityRenderer)

 

This value is private, so would it be possible via reflection to make this variable change around (Possibly every tick, BTW)? It would be nice if there was a way to do this without reflection, as the value will constantly be changing (Possible lag?) 

 

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

recently I've been optimizing my custom bows and now everything about them is good (Right size, you hold them correctly, no more floppy arrows) But For the final part I've ran into a problem. The regular bow uses an FOV multiplier in EntityplayerSP to give a little zoom when you hold down the right click. The code looks something like this.

 

public float getFOVMultiplier()
    {
        float f = 1.0F;

        if (this.capabilities.isFlying)
        {
            f *= 1.1F;
        }

        f *= (this.landMovementFactor * this.getSpeedModifier() / this.speedOnGround + 1.0F) / 2.0F;

        if (this.isUsingItem() && this.getItemInUse().itemID == Item.bow.itemID)
        {
            int i = this.getItemInUseDuration();
            float f1 = (float)i / 20.0F;

            if (f1 > 1.0F)
            {
                f1 = 1.0F;
            }
            else
            {
                f1 *= f1;
            }

            f *= 1.0F - f1 * 0.15F;
        }

        return f;
    }

 

This FOV multiplier cannot seem to be used without modifying the class (A dumb idea haha) And I've heard maybe that reflection can do this? However I don't think so because it returns a local variable :/. Any help would be appreciated, thanks in advance!

 

~Noah

 

I did it as following:

1. In your bow, override the onUsingItemTick method

2. Create a method in your CommonProxy class, which can hold the ItemStack, the Player and the count parameter from the above overridden method as its own parameters (here I call it onBowFOVZoom):

onBowFOVZoom(ItemStack stack, EntityPlayer player, int count)

3. call the proxy method created before in your onUsingItemTick method, like this:

MyMod.proxy.onBowFOVZoom(stack, player, count);

4. Leave the method onBowFOVZoom in your CommonProxy blank, go to the ClientProxy and override that method there, here will be the neccessary code

5. copy the code inside the getFOVMultiplier() method (except the return statement) and paste it in the ClientProxy FOV method. Replace every "this" with the player parameter. WARNING: You need Reflection to access the speedOnGround variable. Here I suggest you use the ObfuscationReflectionHelper class. To access the field, do this:

float speedOnGround = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class, player, "speedOnGround", "field_71108_cd");

The parameters are as following: Class to access - instance to access - decompiled variable name (for usage inside MCP) - "SRG-name" (for usage outside MCP, as an actual mod).

float f1 = (float)i / 20.0F;

This line determines how many ticks the bow needs to be fully charged. If your bow needs only 10 ticks, change the last float to 10F, if it needs 40, then to 40F. get it?

6. Go into the EntityRenderer class and find the method called "updateFovModifierHand()". Copy its code below the code you've already copied inside your ClientProxy method. But don't copy the first if-else statement, you don't need that. The block you would need is this one:

this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F;

        if (this.fovModifierHand > 1.5F)
        {
            this.fovModifierHand = 1.5F;
        }

        if (this.fovModifierHand < 0.1F)
        {
            this.fovModifierHand = 0.1F;
        }

this.fovModifierHand and this.fovMultiplierTemp are private in EntityRenderer. this.fovMultiplierTemp is just the float variable f inside your method, so replace this.fovMultiplierTemp with f.

Now you need some more Reflection. Get the current fovModifierHand from the EntityRenderer instance you get with Minecraft.getMinecraft().entityRenderer _before_ the block this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; like this:

float fovModifierHand = ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, "fovModifierHand", "field_78507_R");

You see how I used the ObfuscationReflectionHelper class again?

After doing that, you can remove every "this." in front of every fovModifierHand reference.

7. Now the final step: set the calculated FOV to the actual fovModifierHand variable inside Minecrafts EntityRenderer instance. To do this, use the ObfuscationReflectionHelper class again, but instead of getting a private value, you set one:

ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, fovModifierHand, "fovModifierHand", "field_78507_R");

 

 

Note that this is really hacky and somehow "ugly", since the code is called every tick, but it works quite well and it doesn't impact the performance (I didn't noticed any difference, you have to test it out for yourself though). Also you have to keep track of variable name changes when you use the ObfuscationReflectionHelper, since inside the MCP environment, those name changes. The SRG-names are very unlikely to change, so you don't have to keep track on them as much as for the deobf-names. But nevertheless, you should test your stuff first before you publish your mod, not that the users get crashes :P

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

recently I've been optimizing my custom bows and now everything about them is good (Right size, you hold them correctly, no more floppy arrows) But For the final part I've ran into a problem. The regular bow uses an FOV multiplier in EntityplayerSP to give a little zoom when you hold down the right click. The code looks something like this.

 

public float getFOVMultiplier()
    {
        float f = 1.0F;

        if (this.capabilities.isFlying)
        {
            f *= 1.1F;
        }

        f *= (this.landMovementFactor * this.getSpeedModifier() / this.speedOnGround + 1.0F) / 2.0F;

        if (this.isUsingItem() && this.getItemInUse().itemID == Item.bow.itemID)
        {
            int i = this.getItemInUseDuration();
            float f1 = (float)i / 20.0F;

            if (f1 > 1.0F)
            {
                f1 = 1.0F;
            }
            else
            {
                f1 *= f1;
            }

            f *= 1.0F - f1 * 0.15F;
        }

        return f;
    }

 

This FOV multiplier cannot seem to be used without modifying the class (A dumb idea haha) And I've heard maybe that reflection can do this? However I don't think so because it returns a local variable :/. Any help would be appreciated, thanks in advance!

 

~Noah

 

I did it as following:

1. In your bow, override the onUsingItemTick method

2. Create a method in your CommonProxy class, which can hold the ItemStack, the Player and the count parameter from the above overridden method as its own parameters (here I call it onBowFOVZoom):

onBowFOVZoom(ItemStack stack, EntityPlayer player, int count)

3. call the proxy method created before in your onUsingItemTick method, like this:

MyMod.proxy.onBowFOVZoom(stack, player, count);

4. Leave the method onBowFOVZoom in your CommonProxy blank, go to the ClientProxy and override that method there, here will be the neccessary code

5. copy the code inside the getFOVMultiplier() method (except the return statement) and paste it in the ClientProxy FOV method. Replace every "this" with the player parameter. WARNING: You need Reflection to access the speedOnGround variable. Here I suggest you use the ObfuscationReflectionHelper class. To access the field, do this:

float speedOnGround = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class, player, "speedOnGround", "field_71108_cd");

The parameters are as following: Class to access - instance to access - decompiled variable name (for usage inside MCP) - "SRG-name" (for usage outside MCP, as an actual mod).

float f1 = (float)i / 20.0F;

This line determines how many ticks the bow needs to be fully charged. If your bow needs only 10 ticks, change the last float to 10F, if it needs 40, then to 40F. get it?

6. Go into the EntityRenderer class and find the method called "updateFovModifierHand()". Copy its code below the code you've already copied inside your ClientProxy method. But don't copy the first if-else statement, you don't need that. The block you would need is this one:

this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F;

        if (this.fovModifierHand > 1.5F)
        {
            this.fovModifierHand = 1.5F;
        }

        if (this.fovModifierHand < 0.1F)
        {
            this.fovModifierHand = 0.1F;
        }

this.fovModifierHand and this.fovMultiplierTemp are private in EntityRenderer. this.fovMultiplierTemp is just the float variable f inside your method, so replace this.fovMultiplierTemp with f.

Now you need some more Reflection. Get the current fovModifierHand from the EntityRenderer instance you get with Minecraft.getMinecraft().entityRenderer _before_ the block this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; like this:

float fovModifierHand = ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, "fovModifierHand", "field_78507_R");

You see how I used the ObfuscationReflectionHelper class again?

After doing that, you can remove every "this." in front of every fovModifierHand reference.

7. Now the final step: set the calculated FOV to the actual fovModifierHand variable inside Minecrafts EntityRenderer instance. To do this, use the ObfuscationReflectionHelper class again, but instead of getting a private value, you set one:

ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, fovModifierHand, "fovModifierHand", "field_78507_R");

 

 

Note that this is really hacky and somehow "ugly", since the code is called every tick, but it works quite well and it doesn't impact the performance (I didn't noticed any difference, you have to test it out for yourself though). Also you have to keep track of variable name changes when you use the ObfuscationReflectionHelper, since inside the MCP environment, those name changes. The SRG-names are very unlikely to change, so you don't have to keep track on them as much as for the deobf-names. But nevertheless, you should test your stuff first before you publish your mod, not that the users get crashes :P

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Thanks! But why do I need the ongroundspeed variable? lol I only want the FOV for the bows, or is there something I'm missing? Is that variable needed for something else?

 

~Noah

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Thanks! But why do I need the ongroundspeed variable? lol I only want the FOV for the bows, or is there something I'm missing? Is that variable needed for something else?

 

~Noah

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Thanks! But why do I need the ongroundspeed variable? lol I only want the FOV for the bows, or is there something I'm missing? Is that variable needed for something else?

 

~Noah

 

hm, now that you say it... I don't know xD

It has the value 0.1F in the EntityPlayer class and I don't see any modification to that value, so I guess you can use the actual value :P

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Thanks! But why do I need the ongroundspeed variable? lol I only want the FOV for the bows, or is there something I'm missing? Is that variable needed for something else?

 

~Noah

 

hm, now that you say it... I don't know xD

It has the value 0.1F in the EntityPlayer class and I don't see any modification to that value, so I guess you can use the actual value :P

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Is it normal for the zoom to start jiggling around when you reach the most amount of zoom? :P

 

It's because the zoom tries to reset every time. I have to improve this stuff (or wait for a hack, or make one myself and do a PR to Forge)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Is it normal for the zoom to start jiggling around when you reach the most amount of zoom? :P

 

It's because the zoom tries to reset every time. I have to improve this stuff (or wait for a hack, or make one myself and do a PR to Forge)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Yeah that is what I concluded too, Right now Im trying to make some sort of logic that fixes that but a PR would be nice, doing all of this just for a little FOV zoom is ridiculous... Last night I was going to make a PR but I was afraid Id screw something up and look like an ass :P

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Yeah that is what I concluded too, Right now Im trying to make some sort of logic that fixes that but a PR would be nice, doing all of this just for a little FOV zoom is ridiculous... Last night I was going to make a PR but I was afraid Id screw something up and look like an ass :P

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Okay, so I tried to do make it so the variable wouldn't attempt to change once you reach the max amount of zoom, with no luck, this is what I did...

 

if(72000-count <= 16)
    	{
        int i = player.getItemInUseDuration();
        float f1 = (float)i / 16.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
            
        }
        else
        {
            f1 *= f1;
        }
    	
        f *= 1.0F - f1 * 0.15F;
    	}
    	else if(72000-count > 16){
    		
    		f= 0.85F;
    		
    	}
    }

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Okay, so I tried to do make it so the variable wouldn't attempt to change once you reach the max amount of zoom, with no luck, this is what I did...

 

if(72000-count <= 16)
    	{
        int i = player.getItemInUseDuration();
        float f1 = (float)i / 16.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
            
        }
        else
        {
            f1 *= f1;
        }
    	
        f *= 1.0F - f1 * 0.15F;
    	}
    	else if(72000-count > 16){
    		
    		f= 0.85F;
    		
    	}
    }

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Okay, so I tried to do make it so the variable wouldn't attempt to change once you reach the max amount of zoom, with no luck, this is what I did...

 

if(72000-count <= 16)
    	{
        int i = player.getItemInUseDuration();
        float f1 = (float)i / 16.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
            
        }
        else
        {
            f1 *= f1;
        }
    	
        f *= 1.0F - f1 * 0.15F;
    	}
    	else if(72000-count > 16){
    		
    		f= 0.85F;
    		
    	}
    }

 

I now made it with a tick handler. It works like a charm. You know the code you did in your bow? You don't need that. Create a client-side tick handler with TickType RENDER, then go to the tickStart method, check if it's TickType.RENDER, the player is using an item and if the used item ID equals with your bow. If yes, execute the method from the proxy.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Okay, so I tried to do make it so the variable wouldn't attempt to change once you reach the max amount of zoom, with no luck, this is what I did...

 

if(72000-count <= 16)
    	{
        int i = player.getItemInUseDuration();
        float f1 = (float)i / 16.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
            
        }
        else
        {
            f1 *= f1;
        }
    	
        f *= 1.0F - f1 * 0.15F;
    	}
    	else if(72000-count > 16){
    		
    		f= 0.85F;
    		
    	}
    }

 

I now made it with a tick handler. It works like a charm. You know the code you did in your bow? You don't need that. Create a client-side tick handler with TickType RENDER, then go to the tickStart method, check if it's TickType.RENDER, the player is using an item and if the used item ID equals with your bow. If yes, execute the method from the proxy.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Okay, could you please at least give me a few pointers to what Im doing wrong? I've been trying the past 2 hours to get this to work but no luck so far :/.

 

Tickhandler

package mod_Rareores;

import java.util.EnumSet;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ClientTickHandler implements ITickHandler {


private void onPlayerTick(EntityPlayer player) {
if (player.isUsingItem() && player.getItemInUse().itemID == mod_rareores.ItemPherithiumBow.itemID){
	System.out.println("This works 10");
	mod_rareores.proxy.onBowFOVZoom(player);
}
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	if(type.equals(EnumSet.of(TickType.RENDER))){
		System.out.println("This works 1");
		this.onPlayerTick((EntityPlayer)tickData[0]);


}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub

}

@Override
public EnumSet<TickType> ticks() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getLabel() {
	// TODO Auto-generated method stub
	return null;
}

}

 

Commonproxy

package rareores.Common;

import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import mod_Rareores.ClientTickHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

public class CommonProxyRareores {

public void registerRenderers(){


}
public void onBowFOVZoom(EntityPlayer player){


}
public void registerClientTickHandler()
 {
  TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
 }
}

 

Main File

//Declaring init
@Init
public void load(FMLInitializationEvent event){
	proxy.registerClientTickHandler();

 

But thanks for all the help, I'm really close to getting this done and I'm pretty excited :D (But a tiny bit stressed)

 

EDIT:

 

I change my tickhandler to this

package mod_Rareores;

import java.util.EnumSet;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ClientTickHandler implements ITickHandler {


private void onPlayerTick(EntityPlayer player) {

if (player.isUsingItem() && player.getItemInUse().itemID == mod_rareores.ItemPherithiumBow.itemID){
	System.out.println("This works 10");
	mod_rareores.proxy.onBowFOVZoom(player);
}
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	if(type.equals(EnumSet.of(TickType.RENDER))){
		System.out.println("This works 1");
		this.onPlayerTick((EntityPlayer)tickData[0]);


}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub

}

@Override
public EnumSet<TickType> ticks() {
	// TODO Auto-generated method stub
	 return EnumSet.of(TickType.RENDER, TickType.CLIENT);
}

@Override
public String getLabel() {
	// TODO Auto-generated method stub
	return null;
}

}

 

And got this crash

java.lang.ClassCastException: java.lang.Float cannot be cast to net.minecraft.entity.player.EntityPlayer
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at mod_Rareores.ClientTickHandler.tickStart(ClientTickHandler.java:24)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:121)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLCommonHandler.onRenderTickStart(FMLCommonHandler.java:374)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:865)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:756)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)

At least I know my code is being ran >.>

 

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

Okay, could you please at least give me a few pointers to what Im doing wrong? I've been trying the past 2 hours to get this to work but no luck so far :/.

 

Tickhandler

package mod_Rareores;

import java.util.EnumSet;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ClientTickHandler implements ITickHandler {


private void onPlayerTick(EntityPlayer player) {
if (player.isUsingItem() && player.getItemInUse().itemID == mod_rareores.ItemPherithiumBow.itemID){
	System.out.println("This works 10");
	mod_rareores.proxy.onBowFOVZoom(player);
}
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	if(type.equals(EnumSet.of(TickType.RENDER))){
		System.out.println("This works 1");
		this.onPlayerTick((EntityPlayer)tickData[0]);


}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub

}

@Override
public EnumSet<TickType> ticks() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getLabel() {
	// TODO Auto-generated method stub
	return null;
}

}

 

Commonproxy

package rareores.Common;

import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import mod_Rareores.ClientTickHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

public class CommonProxyRareores {

public void registerRenderers(){


}
public void onBowFOVZoom(EntityPlayer player){


}
public void registerClientTickHandler()
 {
  TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
 }
}

 

Main File

//Declaring init
@Init
public void load(FMLInitializationEvent event){
	proxy.registerClientTickHandler();

 

But thanks for all the help, I'm really close to getting this done and I'm pretty excited :D (But a tiny bit stressed)

 

EDIT:

 

I change my tickhandler to this

package mod_Rareores;

import java.util.EnumSet;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ClientTickHandler implements ITickHandler {


private void onPlayerTick(EntityPlayer player) {

if (player.isUsingItem() && player.getItemInUse().itemID == mod_rareores.ItemPherithiumBow.itemID){
	System.out.println("This works 10");
	mod_rareores.proxy.onBowFOVZoom(player);
}
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	if(type.equals(EnumSet.of(TickType.RENDER))){
		System.out.println("This works 1");
		this.onPlayerTick((EntityPlayer)tickData[0]);


}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub

}

@Override
public EnumSet<TickType> ticks() {
	// TODO Auto-generated method stub
	 return EnumSet.of(TickType.RENDER, TickType.CLIENT);
}

@Override
public String getLabel() {
	// TODO Auto-generated method stub
	return null;
}

}

 

And got this crash

java.lang.ClassCastException: java.lang.Float cannot be cast to net.minecraft.entity.player.EntityPlayer
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at mod_Rareores.ClientTickHandler.tickStart(ClientTickHandler.java:24)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:121)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLCommonHandler.onRenderTickStart(FMLCommonHandler.java:374)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:865)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:756)
2013-04-21 12:27:04 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)

At least I know my code is being ran >.>

 

This is the creator of the Rareores mod! Be sure to check it out at

Link to comment
Share on other sites

replace this:

(EntityPlayer)tickData[0]

with this:

Minecraft.getMinecraft().thePlayer

 

tickData[0] is the partialTickTime, which is a float.

 

Also you should check if Minecraft.getMinecraft().thePlayer is not null before executing your code.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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

    • Use Temu Coupon Code $100 Off [act965193] if you are living in California USA. Temu doesn't let you use many coupons at once, but you can still save more. New users get an extra 10% off the 30% discount. Also, text alerts give you 20% off. Using these with Temu's 90% off Daily Deals helps you save a lot. How to use Temu Coupon Code $100 Off [act965193] Both new and existing users at Temu can save a lot by using coupon codes and bundles. New users get a $200 discount with the code aci384098 on their first buy. This is a big welcome bonus that helps them save right away. Follow below steps to apply Temu Coupon Code $100 Off [act965193] Choose Your Items: Pick the products you want to buy from TEMU. Go to Checkout: When you are ready to pay, go to the checkout page. Enter the Code: Type (act847220) into the coupon code box. Enjoy Your Savings: Your total will be reduced, and you'll save money on your purchase. Keep an eye on new deals to save more. Check the Temu app, sign up for newsletters, and follow Temu on social media. Sites like RetailMeNot or Coupons.com also list Temu coupon codes, so you won't miss out.   Using these tips, shopping on Temu can be a smart way to save money. Plan your buys with sale cycles in mind, stack coupons wisely, and watch for new deals. This will make your shopping trips more rewarding.   Temu Coupon Codes & Bundles: New Installs and Existing Users For existing customers, the code aci384098 also gives $200 off. The Temu $200 Coupon Bundle is great for both new and current users. It includes $120 worth of coupons. Plus, Temu offers a 40% discount with certain codes for everyone.   Temu also has special app discounts. By signing up with the code aci384098 and spending $200 or more, customers can save $200 plus get 30% off on their purchase. The code aci384098 also gives a $200 discount and an extra 50% off on the next buy. This is a great way to thank users for their engagement.   Shopping at Temu can lead to big savings. The average discount is an impressive 59%, with 84% of orders getting free shipping or gifts. About 48% of discounts have a time limit, encouraging shoppers to act fast. With deals like a $100 coupon bundle for new users and savings from the code aci384098, Temu offers many ways to save.   Existing customers also have many ways to save, like app alerts, website coupons, and referral programs. There are also games, seasonal sales, and discounts on certain items. This means both new and current users have lots of options to save, showing Temu's dedication to rewarding users.   Comparing Temu Coupon Codes with Other Retailers   Looking at the world of online shopping, comparing Temu coupon codes with others shows Temu's big competitive advantages.   Advantages of Temu Coupons   Temu's coupons offer big discounts, often more than other stores. This means customers save a lot of money. Temu also throws in freebies, making their coupons even more valuable.   Temu's coupons work on many products, not just a few. This makes it easy for customers to save on what they buy.   How Temu Stands Out in the Market   When we look at Temu vs. other retailers, Temu's deals are made with the customer in mind. They focus on what shoppers want and need. This makes Temu's coupons not just competitive but also very attractive to many buyers.   Our benchmarking deals show Temu leading in coupon offers. They offer big discounts and special perks. This makes Temu stand out in the online shopping world.   Conclusion   Using Temu coupon codes and bundles helps save money and make shopping better. For new and returning customers, codes like "acr880792" and "aci384098" offer big discounts. New users get £20 off their first order and up to 50% off on various deals.   Temu offers many coupons for smart shoppers to save more. Whether it's standalone discounts, special deals, or loyalty rewards, using these codes can cut down costs. This way, shoppers get quality products at great prices, from $1 phone cases to discounted electronics.   It's important to keep up with new discounts and promotions. By watching daily deals and signing up for alerts, shoppers won't miss out on great offers. Temu connects manufacturers directly with consumers, leading to lower costs. This unique approach, along with big savings from coupons, makes Temu a top choice for budget-friendly shopping. Start your Temu shopping today for unmatched savings and satisfaction.  
    • Use Temu coupon code $100 off [acq783769] for Belgium and special 30% discount plus get 3 free itemsTemu has always been a shopper's paradise, offering a vast collection of trending items at unbeatable prices. With fast delivery and free shipping to 67 countries, it's no wonder Temu has become a go-to platform for savvy shoppers. Now, with these exclusive Temu coupon codes, you can enjoy even more savings: act581784: Temu coupon code 40% off for existing users act581784: $100 off Temu coupon for new customers act581784: $100 off Temu coupon for existing customers act581784: 40% discount for new users act581784: Temu coupon code 40 off for existing and new users Why You Shouldn't Miss Out on the Temu Coupon Code 40% Off The Temu coupon code 40% off is a game-changer for both new and existing customers. Whether you're a first-time user or a loyal Temu shopper, these codes offer substantial savings on your purchases. With a flat 40% extra off, you can stretch your budget further and indulge in more of your favorite items. Maximizing Your Savings with Temu 40 Off Coupon Code To make the most of your Temu shopping experience, it's crucial to understand how to apply these coupon codes effectively. When you use the Temu coupon code 40 off, you're not just saving money – you're unlocking a world of possibilities. From fashion to home decor, electronics to beauty products, your 40% discount applies across a wide range of categories. How to Apply Your Temu Coupon Code 40% Off Using your Temu coupon code 40% off is a breeze. Here's a step-by-step guide to ensure you don't miss out on these incredible savings: Browse through Temu's extensive collection and add your desired items to your cart. Proceed to checkout when you're ready to make your purchase. Look for the "Promo Code" or "Coupon Code" field. Enter your Temu coupon code 40 off [act581784]. Watch as your total amount gets reduced by a whopping 40%! The Power of Temu Coupon Code 40 Off First Order For those new to Temu, the Temu coupon code 40% off first order is an excellent opportunity to experience the platform's offerings at a discounted price. This introductory offer allows you to explore Temu's vast catalog while enjoying significant savings on your inaugural purchase.Be sure to use it before it expires!
    • Use Temu coupon code $100 off [acq783769] and special 30% discount Plus get 90% on cleranceTemu has always been a shopper's paradise, offering a vast collection of trending items at unbeatable prices. With fast delivery and free shipping to 67 countries, it's no wonder Temu has become a go-to platform for savvy shoppers. Now, with these exclusive Temu coupon codes, you can enjoy even more savings: act581784: Temu coupon code 40% off for existing users act581784: $100 off Temu coupon for new customers act581784: $100 off Temu coupon for existing customers act581784: 40% discount for new users act581784: Temu coupon code 40 off for existing and new users Why You Shouldn't Miss Out on the Temu Coupon Code 40% Off The Temu coupon code 40% off is a game-changer for both new and existing customers. Whether you're a first-time user or a loyal Temu shopper, these codes offer substantial savings on your purchases. With a flat 40% extra off, you can stretch your budget further and indulge in more of your favorite items. Maximizing Your Savings with Temu 40 Off Coupon Code To make the most of your Temu shopping experience, it's crucial to understand how to apply these coupon codes effectively. When you use the Temu coupon code 40 off, you're not just saving money – you're unlocking a world of possibilities. From fashion to home decor, electronics to beauty products, your 40% discount applies across a wide range of categories. How to Apply Your Temu Coupon Code 40% Off Using your Temu coupon code 40% off is a breeze. Here's a step-by-step guide to ensure you don't miss out on these incredible savings: Browse through Temu's extensive collection and add your desired items to your cart. Proceed to checkout when you're ready to make your purchase. Look for the "Promo Code" or "Coupon Code" field. Enter your Temu coupon code 40 off [act581784]. Watch as your total amount gets reduced by a whopping 40%! The Power of Temu Coupon Code 40 Off First Order For those new to Temu, the Temu coupon code 40% off first order is an excellent opportunity to experience the platform's offerings at a discounted price. This introductory offer allows you to explore Temu's vast catalog while enjoying significant savings on your inaugural purchase.Be sure to use it before it expires!
    • Use Temu coupon code $100 off [ACQ783769] for Bahrain and special 30% discount Plus get free shipping Temu has always been a shopper's paradise, offering a vast collection of trending items at unbeatable prices. With fast delivery and free shipping to 67 countries, it's no wonder Temu has become a go-to platform for savvy shoppers. Now, with these exclusive Temu coupon codes, you can enjoy even more savings: ACQ783769: Temu coupon code 40% off for existing users act581784: $100 off Temu coupon for new customers act581784: $100 off Temu coupon for existing customers act581784: 40% discount for new users act581784: Temu coupon code 40 off for existing and new users Why You Shouldn't Miss Out on the Temu Coupon Code 40% Off The Temu coupon code 40% off is a game-changer for both new and existing customers. Whether you're a first-time user or a loyal Temu shopper, these codes offer substantial savings on your purchases. With a flat 40% extra off, you can stretch your budget further and indulge in more of your favorite items. Maximizing Your Savings with Temu 40 Off Coupon Code To make the most of your Temu shopping experience, it's crucial to understand how to apply these coupon codes effectively. When you use the Temu coupon code 40 off, you're not just saving money – you're unlocking a world of possibilities. From fashion to home decor, electronics to beauty products, your 40% discount applies across a wide range of categories. How to Apply Your Temu Coupon Code 40% Off Using your Temu coupon code 40% off is a breeze. Here's a step-by-step guide to ensure you don't miss out on these incredible savings: Browse through Temu's extensive collection and add your desired items to your cart. Proceed to checkout when you're ready to make your purchase. Look for the "Promo Code" or "Coupon Code" field. Enter your Temu coupon code 40 off [act581784]. Watch as your total amount gets reduced by a whopping 40%! The Power of Temu Coupon Code 40 Off First Order For those new to Temu, the Temu coupon code 40% off first order is an excellent opportunity to experience the platform's offerings at a discounted price. This introductory offer allows you to explore Temu's vast catalog while enjoying significant savings on your inaugural purchase.Be sure to use it before it expires!
    • Use Temu coupon code $200 off [act965193] for Bahrain and special 30% discount Plus get free shipping Temu has always been a shopper's paradise, offering a vast collection of trending items at unbeatable prices. With fast delivery and free shipping to 67 countries, it's no wonder Temu has become a go-to platform for savvy shoppers. Now, with these exclusive Temu coupon codes, you can enjoy even more savings: act965193: Temu coupon code 40% off for existing users act965193: $100 off Temu coupon for new customers act965193: $100 off Temu coupon for existing customers act965193: 40% discount for new users act965193: Temu coupon code 40 off for existing and new users Why You Shouldn't Miss Out on the Temu Coupon Code 40% Off The Temu coupon code 40% off is a game-changer for both new and existing customers. Whether you're a first-time user or a loyal Temu shopper, these codes offer substantial savings on your purchases. With a flat 40% extra off, you can stretch your budget further and indulge in more of your favorite items. Maximizing Your Savings with Temu 40 Off Coupon Code To make the most of your Temu shopping experience, it's crucial to understand how to apply these coupon codes effectively. When you use the Temu coupon code 40 off, you're not just saving money – you're unlocking a world of possibilities. From fashion to home decor, electronics to beauty products, your 40% discount applies across a wide range of categories. How to Apply Your Temu Coupon Code 40% Off Using your Temu coupon code 40% off is a breeze. Here's a step-by-step guide to ensure you don't miss out on these incredible savings: Browse through Temu's extensive collection and add your desired items to your cart. Proceed to checkout when you're ready to make your purchase. Look for the "Promo Code" or "Coupon Code" field. Enter your Temu coupon code 40 off [act581784]. Watch as your total amount gets reduced by a whopping 40%! The Power of Temu Coupon Code 40 Off First Order For those new to Temu, the Temu coupon code 40% off first order is an excellent opportunity to experience the platform's offerings at a discounted price. This introductory offer allows you to explore Temu's vast catalog while enjoying significant savings on your inaugural purchase.Be sure to use it before it expires!
  • Topics

×
×
  • Create New...

Important Information

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