Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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

Posted
  On 4/19/2013 at 5:51 PM, Noah_Beech said:

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

  Quote

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.

Posted
  On 4/19/2013 at 5:51 PM, Noah_Beech said:

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

  Quote

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.

Posted

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

Posted

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

Posted
  On 4/20/2013 at 2:50 PM, Noah_Beech said:

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

  Quote

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.

Posted
  On 4/20/2013 at 2:50 PM, Noah_Beech said:

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

  Quote

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.

Posted

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

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

Posted

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

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

Posted
  On 4/20/2013 at 3:41 PM, Noah_Beech said:

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

  Quote

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.

Posted
  On 4/20/2013 at 3:41 PM, Noah_Beech said:

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

  Quote

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.

Posted

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

Posted

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

Posted

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

Posted

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

Posted
  On 4/20/2013 at 9:27 PM, Noah_Beech said:

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

  Quote

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.

Posted
  On 4/20/2013 at 9:27 PM, Noah_Beech said:

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

  Quote

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.

Posted

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

Posted

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

Posted

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

  Quote

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.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Looking for a massive discount while shopping online? With the Temu coupon code $100 off, you can unlock incredible savings on your favorite products. The exclusive acu729640 Temu coupon code is here to offer maximum benefits to all shoppers across the USA, Canada, and European countries. Whether you're a first-time buyer or a returning customer, this Temu coupon $100 off and Temu 100 off coupon code is your golden ticket to unbeatable deals. What Is The Coupon Code For Temu $100 Off? The best part about our coupon is that it's valid for everyone! Whether you're new to Temu or an existing customer, you can enjoy amazing benefits using the Temu coupon $100 off and $100 off Temu coupon. acu729640 – Get a flat $100 off instantly on your next order. acu729640 – Enjoy a $100 coupon pack with multiple use opportunities. acu729640 – Avail a $100 flat discount for new customers on their first purchase. acu729640 – Existing users can apply this code to receive an extra $100 promo discount. acu729640 – Perfect for shoppers in the USA/Canada looking to save big with a $100 coupon. Temu Coupon Code $100 Off For New Users In 2025 New to Temu? You're in luck because the Temu coupon $100 off and Temu coupon code $100 off are offering unmatched deals just for you. acu729640 – Get a flat $100 discount as a welcome gift. acu729640 – Receive a $100 coupon bundle curated specifically for new users. acu729640 – Enjoy up to $100 coupon benefits for multiple purchases. acu729640 – Benefit from free shipping to over 68 countries. acu729640 – Score an extra 30% off on any purchase as a first-time user. How To Redeem The Temu Coupon $100 Off For New Customers? To activate the Temu $100 coupon and Temu $100 off coupon code for new users, follow these easy steps: Download the Temu app or visit their official website. Create your new account using a valid email address. Browse through the wide range of products and add your favorites to the cart. At checkout, enter the coupon code acu729640. The $100 discount will be instantly applied to your total. Temu Coupon $100 Off For Existing Customers Already a Temu customer? Great! The Temu $100 coupon codes for existing users and Temu coupon $100 off for existing customers free shipping are still valid for you. acu729640 – Redeem a $100 extra discount on any existing account. acu729640 – Unlock a $100 coupon bundle usable across multiple purchases. acu729640 – Get a free gift and enjoy express shipping across the USA and Canada. acu729640 – Save an extra 30% even on discounted products. acu729640 – Take advantage of free shipping to 68 global destinations. How To Use The Temu Coupon Code $100 Off For Existing Customers? To use the Temu coupon code $100 off and Temu coupon $100 off code, follow these steps: Open the Temu app or log in to your existing account on the website. Shop your favorite items and proceed to checkout. Input the code acu729640 in the promo code box. Confirm your order and see the $100 discount applied instantly. Latest Temu Coupon $100 Off First Order Make your first order count with our powerful promo code! The Temu coupon code $100 off first order, Temu coupon code first order, and Temu coupon code $100 off first time user offer unbeatable value. acu729640 – Flat $100 discount on your first order. acu729640 – Access to a $100 Temu coupon code as a first-time buyer. acu729640 – Enjoy up to $100 in coupons for repeated use. acu729640 – Get free global shipping to 68 countries. acu729640 – Bonus 30% off any product for new users. How To Find The Temu Coupon Code $100 Off? Looking for the Temu coupon $100 off or the Temu coupon $100 off Reddit discussions? Here's how you can find verified codes: Sign up for Temu’s newsletter to get access to exclusive and verified promo codes. Follow Temu on their social media pages like Instagram, Facebook, and Twitter for real-time updates on new discounts. Trusted coupon-sharing websites also provide the latest working Temu codes, including our very own acu729640. Is Temu $100 Off Coupon Legit? Worried whether this deal is real? Yes, the Temu $100 Off Coupon Legit and Temu 100 off coupon legit status is fully confirmed. Our Temu coupon code acu729640 is 100% legitimate, tested, and verified. It’s valid for both new and existing customers, worldwide, and does not have an expiration date. How Does Temu $100 Off Coupon Work? The Temu coupon code $100 off first-time user and Temu coupon codes 100 off provide direct value through instant cart discounts. When you apply the coupon code acu729640 at checkout, the system deducts $100 from your total. Whether you're a new user or a returning one, this code adjusts automatically based on your account type and shopping cart value. How To Earn Temu $100 Coupons As A New Customer? The best way to get the Temu coupon code $100 off and 100 off Temu coupon code is by signing up as a new customer on Temu. Once your account is created, use our promo code acu729640 to unlock a $100 coupon bundle, including a first-time order bonus, repeat usage coupons, and exclusive deals for new members. What Are The Advantages Of Using The Temu Coupon $100 Off? Here are the main benefits of using our Temu coupon code 100 off and Temu coupon code $100 off: $100 discount on your first order. $100 coupon bundle for multiple uses. 70% discount on popular items. Extra 30% off for existing Temu customers. Up to 90% off on selected products. Free gift for new users. Free delivery to 68 countries. Temu $100 Discount Code And Free Gift For New And Existing Customers The Temu $100 off coupon code and $100 off Temu coupon code also come with exclusive perks. acu729640 – Get $100 discount for your first order. acu729640 – Enjoy an additional 30% off on any item. acu729640 – Receive a free gift as a new Temu user. acu729640 – Unlock up to 70% discounts on your favorite items. acu729640 – Free gift with free shipping in 68 countries, including the USA and UK. Pros And Cons Of Using The Temu Coupon Code $100 Off This Month Here are the main Temu coupon $100 off code and Temu 100 off coupon pros and cons: Pros: Massive $100 discount on your first order. Works for both new and returning users. No minimum purchase requirement. Valid across 68 countries. Includes free shipping and extra discounts. Cons: Limited availability during high demand. Cannot be combined with some other special promo campaigns. Terms And Conditions Of Using The Temu Coupon $100 Off In 2025 Here are the Temu coupon code $100 off free shipping and latest Temu coupon code $100 off terms and conditions: Coupon code acu729640 is valid worldwide. No expiration date – use it anytime. No minimum purchase required. Available for both new and existing users. Free shipping is applicable to 68 countries. Final Note: Use The Latest Temu Coupon Code $100 Off We encourage you to use the Temu coupon code $100 off to make the most of your online shopping. Apply it today to enjoy the biggest discounts and rewards on Temu. The Temu coupon $100 off is your chance to enjoy premium deals with zero hassle. Don’t miss this verified offer that saves both time and money. FAQs Of Temu $100 Off Coupon What is the Temu $100 off coupon code? The Temu $100 off coupon code is acu729640, which gives users a flat $100 discount, free shipping, and other benefits on the Temu app and website. It works globally. Can existing users use the Temu $100 coupon? Yes, existing users can also use the acu729640 code to get a $100 discount, a coupon bundle, and exclusive deals on selected items. Is the Temu $100 off coupon legit? Absolutely. Our coupon code acu729640 is 100% tested, verified, and has no expiration date. It works for both new and old users worldwide. Can I get free shipping with the Temu coupon code? Yes, the Temu $100 off coupon also includes free shipping to 68 countries, including the USA, Canada, UK, and many European nations. How do I apply the Temu coupon code $100 off? Simply enter the code acu729640 at checkout on the Temu app or website, and the discount will be automatically applied to your cart.  
    • I set up an arclight server with some mods and plugins and it kept crashing, i tried to remove radium but the same errors appeared. Crash log: https://mclo.gs/jO7K1Iz
    • Of the newer versions I have tested, 1.21.5 does work perfectly fine, but the only others I have tried, being 1.12.2 and now 1.16.5 with the mods you suggested showing the same results of crashing with exit code 6.
    • Several client crashes tied to goblin_goo: "Unable to load item model 'goblinmod:item/goblin_goo'". "Referenced from: goblinmod:item/goblin_goo#inventory". Verified correct file paths (.json and .png), with underscore usage consistent across files. Files appeared valid, and paths aligned with expectations.   FMLJavaModLoadingContext.get() marked for removal, triggering a warning. Not currently fatal, but might become an issue in future Forge versions. https://www.mediafire.com/folder/4uh6ytqre4az2/Goblinmod full project files linked
    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

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