The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
I have been trying to make an item in a mod that upon right clicking it will zoom in like in Optifine and after 3 days or so of searching for a way to do it i have yet to find one is there anyone out there who knows how?
this is the code i have so far for the item:
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
ok it looks like the FOVUpdateEvent method in the FOVUpdateEvent class might be what im looking for but i cant figure out how to set the FOV as an event like i did with the world.playSoundAtEntity in the code above
FOVUpdateEvent is posted from EntityPlayerSP, and typically returns a value of 1.0F for normal view. The fov is modified of course by movement speed and items such as the bow, the code for which you will find in EntityPlayerSP.
Subscribe to the event and check for your special item, then either leave the original fov as is, or modify it according to your item being in use or whatever conditions you require.
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
OK I FINALLY GOT IT, i sent BarracudaATA a message the other day and he suggested the java reflection as well and gave a link to the source code to one of his mods showing how to use it
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
I couldn't get the forge events to work :/ probably because of an obvious mistake ill take another look into it and the only put the event handler in the item class for testing purposes. what do I need to do to put it into a client proxy?
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
OK THE CODE IS COMPLETE i made the zoom toggleable which wasn't my original intention but it works just as well
i also turned the setCameraZoom into 2 events a ZoomEvent and a ResetZoomEvent like you guys suggested( or at lease this is what you guys were suggesting idk ether way it works now)
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
double cameraZoom = EntityRendererAccessor.getCameraZoom(MC.entityRenderer);
if (cameraZoom != 1.0 && !world.isRemote){
ResetZoomEvent event = new ResetZoomEvent(player, itemStack);
MinecraftForge.EVENT_BUS.post(event);
world.playSoundAtEntity(player, "fire.ignite", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
//take note that the soundEffect is just for fun and isnt required
}else{
That is not at all what we meant. Use the FOVUpdateEvent already provided by Forge, like I showed in my example code which I linked to in the 5th post. The code you have right now is overly convoluted, unnecessarily uses reflection (never recommended), and will crash if you try to run it on a server (accessing client-only classes/methods/fields on the server crashes the game).
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
ok so i attempted to make the forge events work again based on your example code and i still couldn't get it to work :/
anyone know what im doing wrong?
/**
*
* Interface for items that should zoom in like the bow when in use
*
*/
public interface IZoom {
/**
* The factor by which the field of view will be modified;
* vanilla bow uses 0.15F, with higher values giving higher magnification
*/
@SideOnly(Side.CLIENT)
public float getZoomFactor();
Also, your Spyglass item doesn't implement the IZoom interface, but I see you hacked it in with a check nonetheless. Register your event handling class and it should work fine as is.
/**
*
* Interface for items that should zoom in like the bow when in use
*
*/
public interface IZoom {
/**
* The factor by which the field of view will be modified;
* vanilla bow uses 0.15F, with higher values giving higher magnification
*/
@SideOnly(Side.CLIENT)
public float getZoomFactor();
}
and i dont know what you mean by i hacked the IZoom interface in with a check i didnt hack anything on purpose
ok i registered the event and added an event handler to register in the postinit and now whenever i try and load up a test world my game crashes
Post the crash report.
[quote]and i dont know what you mean by i hacked the IZoom interface in with a check i didnt hack anything on purpose You should make your Spyglass item implement IZoom, then remove the explicit check for item == Spyglass in your updateFOV event handler method.
If every item that needs to zoom in implements IZoom, you can keep the item-specific logic in each item's class and avoid checking for specific items in the event handler.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
here is the first half of the crash report
---- Minecraft Crash Report ----
// Everything's going to plan. No, really, that was supposed to happen.
Time: 10/11/14 10:15 AM
Description: Unexpected error
java.lang.NullPointerException: Unexpected error
at com.planetaryalignmentmod.lib.ModEvents.updateFOV(ModEvents.java:14)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_ModEvents_updateFOV_FOVUpdateEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(ForgeHooksClient.java:370)
at net.minecraft.client.entity.EntityPlayerSP.getFOVMultiplier(EntityPlayerSP.java:346)
at net.minecraft.client.renderer.EntityRenderer.updateFovModifierHand(EntityRenderer.java:450)
at net.minecraft.client.renderer.EntityRenderer.updateRenderer(EntityRenderer.java:273)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2068)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1029)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:55)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
this is the code i have so far for the item:
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
public class Spyglass extends Item {
private String name = "spyglass";
public Spyglass(){
this.setUnlocalizedName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerItem(this, name);
this.setTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setMaxStackSize(1);
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
return itemStack;
}
public boolean isItemTool(ItemStack p_77616_1_)
{
return super.isItemTool(p_77616_1_);
}
}
Subscribe to the event and check for your special item, then either leave the original fov as is, or modify it according to your item being in use or whatever conditions you require.
Here's an example.
thanks to all of you
package com.planetaryalignmentmod.items;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.client.event.FOVUpdateEvent;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
public class Spyglass extends Item {
private String name = "spyglass";
public Spyglass(){
this.setUnlocalizedName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerItem(this, name);
this.setTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setMaxStackSize(1);
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (!world.isRemote)
{
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
}
else{
}
return itemStack;
}
public interface IZoom {
@SideOnly(Side.CLIENT)
public float getZoomFactor();
}
@SubscribeEvent
public void updateFOV(FOVUpdateEvent event) {
ItemStack stack = (event.entity.isUsingItem() ? event.entity.getItemInUse() : null);
if (stack != null) {
boolean flag = stack.getItem() instanceof IZoom;
if (flag || stack.getItem() == ModItems.spyglass) {
float magify = 1.0F;
if (flag) {
float factor = 25.0F;
float fov = (event.entity.capabilities.isFlying ? 1.1F : 1.0F);
event.newfov = fov * (1.0F - factor * magify);
}
}
}
}
}
i'm still a pretty new modder so there's probably something completely obvious i'm missing...
here is the code:
the item:
package com.planetaryalignmentmod.items;
import com.planetaryalignmentmod.lib.EntityRendererAccessor;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.client.event.FOVUpdateEvent;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
public class Spyglass extends Item {
private String name = "spyglass";
private static final Minecraft MC = Minecraft.getMinecraft();
EntityRenderer entityRenderer = MC.entityRenderer;
public Spyglass(){
this.setUnlocalizedName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerItem(this, name);
this.setTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setMaxStackSize(1);
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (!world.isRemote)
{
EntityRendererAccessor.setCameraZoom(entityRenderer, 20.0);
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
}
return itemStack;
}
}
EntityRendererAccessor courtesy of BarracudaATA from his MineShot mod
package com.planetaryalignmentmod.lib;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.renderer.EntityRenderer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class EntityRendererAccessor {
private static final Logger L = LogManager.getLogger();
private static final String[] FIELD_CAMERA_ZOOM = new String[] {"cameraZoom", "field_78503_V"};
private EntityRendererAccessor() {
}
public static void setCameraZoom(EntityRenderer renderer, double zoom) {
try {
ReflectionHelper.setPrivateValue(EntityRenderer.class, renderer, zoom, FIELD_CAMERA_ZOOM);
} catch (Exception ex) {
L.error("setCameraZoom() failed", ex);
}
}
public static double getCameraZoom(EntityRenderer renderer) {
try {
return ReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, FIELD_CAMERA_ZOOM);
} catch (Exception ex) {
L.error("getCameraZoom() failed", ex);
return 0;
}
}
}
and now i just have to figure out how to make it return to the original zoom after the player has stopped using it (or right clicking with it)
i also turned the setCameraZoom into 2 events a ZoomEvent and a ResetZoomEvent like you guys suggested( or at lease this is what you guys were suggesting idk ether way it works now)
Item Code:
// Code by Jared_Brian_ use as you wish
import com.planetaryalignmentmod.Zoom.EntityRendererAccessor;
import com.planetaryalignmentmod.Zoom.ResetZoomEvent;
import com.planetaryalignmentmod.Zoom.ZoomEvent;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityFishHook;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.client.event.FOVUpdateEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
public class Spyglass extends Item {
private String name = "spyglass";
private static final Minecraft MC = Minecraft.getMinecraft();
public Spyglass(){
this.setUnlocalizedName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerItem(this, name);
this.setTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setMaxStackSize(1);
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
double cameraZoom = EntityRendererAccessor.getCameraZoom(MC.entityRenderer);
if (cameraZoom != 1.0 && !world.isRemote){
ResetZoomEvent event = new ResetZoomEvent(player, itemStack);
MinecraftForge.EVENT_BUS.post(event);
world.playSoundAtEntity(player, "fire.ignite", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
//take note that the soundEffect is just for fun and isnt required
}else{
if (!world.isRemote){
ZoomEvent event = new ZoomEvent(player, itemStack, 15.0);
MinecraftForge.EVENT_BUS.post(event);
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
}
}
return itemStack;
}
public boolean isItemTool(ItemStack p_77616_1_)
{
return super.isItemTool(p_77616_1_);
}
}
ZoomEvent code:
// Code by Jared_Brian_ use as you wish
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerEvent;
public class ZoomEvent extends PlayerEvent{
private static final Minecraft MC = Minecraft.getMinecraft();
EntityRenderer entityRenderer = MC.entityRenderer;
public ItemStack result;
public ZoomEvent(EntityPlayer player, ItemStack result,double ZoomFactor)
{
super(player);
this.result = result;
EntityRendererAccessor.setCameraZoom(entityRenderer, ZoomFactor);
}
}
ResetZoomEvent code:
// Code by Jared_Brian_ use as you wish
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerEvent;
public class ResetZoomEvent extends PlayerEvent{
private static final Minecraft MC = Minecraft.getMinecraft();
EntityRenderer entityRenderer = MC.entityRenderer;
public ItemStack result;
public ResetZoomEvent(EntityPlayer player, ItemStack result)
{
super(player);
this.result = result;
EntityRendererAccessor.setCameraZoom(entityRenderer, 1.0);
}
}
EntityRendererAccesor code by BarracudaATA:
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.renderer.EntityRenderer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class EntityRendererAccessor {
private static final Logger L = LogManager.getLogger();
private static final String[] FIELD_CAMERA_ZOOM = new String[] {"cameraZoom", "field_78503_V"};
private EntityRendererAccessor() {
}
public static void setCameraZoom(EntityRenderer renderer, double zoom) {
try {
ReflectionHelper.setPrivateValue(EntityRenderer.class, renderer, zoom, FIELD_CAMERA_ZOOM);
} catch (Exception ex) {
L.error("setCameraZoom() failed", ex);
}
}
public static double getCameraZoom(EntityRenderer renderer) {
try {
return ReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, FIELD_CAMERA_ZOOM);
} catch (Exception ex) {
L.error("getCameraZoom() failed", ex);
return 0;
}
}
}
Thanks for all of your guy's help
ill take another crack at that example code and see what I can do.
anyone know what im doing wrong?
item code:
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
public class Spyglass extends Item {
private String name = "spyglass";
public Spyglass(){
this.setUnlocalizedName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerItem(this, name);
this.setTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setMaxStackSize(1);
}
public boolean isItemTool(ItemStack itemStack)
{
return super.isItemTool(itemStack);
}
}
ModEvents
import com.planetaryalignmentmod.items.ModItems;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.FOVUpdateEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ModEvents {
@SubscribeEvent
public void updateFOV(FOVUpdateEvent event) {
ItemStack stack = (event.entity.isUsingItem() ? event.entity.getItemInUse() : null);
boolean flag = stack.getItem() instanceof IZoom;
if (flag || stack.getItem() == ModItems.spyglass) {
float ZoomFactor = (flag ? ((IZoom) stack.getItem()).getZoomFactor() : 0.15F);
if(ZoomFactor != 1.0){
event.newfov = 2.0F;
}
else{
event.newfov = 1.0F;
}
}
}
}
IZoom:
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* Interface for items that should zoom in like the bow when in use
*
*/
public interface IZoom {
/**
* The factor by which the field of view will be modified;
* vanilla bow uses 0.15F, with higher values giving higher magnification
*/
@SideOnly(Side.CLIENT)
public float getZoomFactor();
}
Also, your Spyglass item doesn't implement the IZoom interface, but I see you hacked it in with a check nonetheless. Register your event handling class and it should work fine as is.
Im soooo good at this arnt i?
item class:
package com.planetaryalignmentmod.items;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
public class Spyglass extends Item {
private String name = "spyglass";
public Spyglass(){
this.setUnlocalizedName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerItem(this, name);
this.setTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setMaxStackSize(1);
}
public boolean isItemTool(ItemStack itemStack)
{
return super.isItemTool(itemStack);
}
}
ModEvents:
package com.planetaryalignmentmod.lib;
import com.planetaryalignmentmod.items.ModItems;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.FOVUpdateEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ModEvents {
@SubscribeEvent
public void updateFOV(FOVUpdateEvent event) {
ItemStack stack = (event.entity.isUsingItem() ? event.entity.getItemInUse() : null);
boolean flag = stack.getItem() instanceof IZoom;
if (flag || stack.getItem() == ModItems.spyglass) {
float ZoomFactor = (flag ? ((IZoom) stack.getItem()).getZoomFactor() : 0.15F);
if(ZoomFactor != 1.0){
event.newfov = 2.0F;
}
else{
event.newfov = 1.0F;
}
}
}
}
ModEventHandler:
package com.planetaryalignmentmod.lib;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.common.MinecraftForge;
public class ModEventHandler {
@EventHandler
public static void init(FMLInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(new ModEvents());
}
}
Planetary Alignment Mod class:
package com.planetaryalignmentmod.lib;
import com.planetaryalignmentmod.blocks.ModBlocks;
import com.planetaryalignmentmod.items.ModItems;
import com.planetaryalignmentmod.lib.ModRecipes;
import net.minecraft.init.Blocks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = PlanetaryAlignmentMod.MODID, version = PlanetaryAlignmentMod.VERSION)
public class PlanetaryAlignmentMod {
public static final String MODID = "planetaryAlignmentMod";
public static final String VERSION = "1.0";
@EventHandler
public void preinit(FMLInitializationEvent event){
ModBlocks.init();
ModItems.init();
ModRecipes.init();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
System.out.println("HELLO HUMAN");
}
@EventHandler
public void postinit(FMLInitializationEvent event){
ModEventHandler.init(event);
}
}
IZoom:
package com.planetaryalignmentmod.lib;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* Interface for items that should zoom in like the bow when in use
*
*/
public interface IZoom {
/**
* The factor by which the field of view will be modified;
* vanilla bow uses 0.15F, with higher values giving higher magnification
*/
@SideOnly(Side.CLIENT)
public float getZoomFactor();
}
and i dont know what you mean by i hacked the IZoom interface in with a check i didnt hack anything on purpose
Post the crash report.
[quote]and i dont know what you mean by i hacked the IZoom interface in with a check i didnt hack anything on purpose You should make your Spyglass item implement IZoom, then remove the explicit check for item == Spyglass in your updateFOV event handler method.
If every item that needs to zoom in implements IZoom, you can keep the item-specific logic in each item's class and avoid checking for specific items in the event handler.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
// Everything's going to plan. No, really, that was supposed to happen.
Time: 10/11/14 10:15 AM
Description: Unexpected error
java.lang.NullPointerException: Unexpected error
at com.planetaryalignmentmod.lib.ModEvents.updateFOV(ModEvents.java:14)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_ModEvents_updateFOV_FOVUpdateEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(ForgeHooksClient.java:370)
at net.minecraft.client.entity.EntityPlayerSP.getFOVMultiplier(EntityPlayerSP.java:346)
at net.minecraft.client.renderer.EntityRenderer.updateFovModifierHand(EntityRenderer.java:450)
at net.minecraft.client.renderer.EntityRenderer.updateRenderer(EntityRenderer.java:273)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2068)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1029)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:55)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at com.planetaryalignmentmod.lib.ModEvents.updateFOV(ModEvents.java:14)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_ModEvents_updateFOV_FOVUpdateEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(ForgeHooksClient.java:370)
at net.minecraft.client.entity.EntityPlayerSP.getFOVMultiplier(EntityPlayerSP.java:346)
at net.minecraft.client.renderer.EntityRenderer.updateFovModifierHand(EntityRenderer.java:450)
at net.minecraft.client.renderer.EntityRenderer.updateRenderer(EntityRenderer.java:273)
-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player820'/357, l='MpServer', x=4.50, y=75.62, z=1.50]]
Chunk stats: MultiplayerChunkCache: 78, 78
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options:
Level spawn location: World: (0,64,0), Chunk: (at 0,4,0 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 100193 game time, 19562 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 153 total; [EntityChicken['Chicken'/258, l='MpServer', x=50.66, y=71.44, z=-43.16], EntityChicken['Chicken'/259, l='MpServer', x=55.44, y=70.00, z=46.44], EntityChicken['Chicken'/260, l='MpServer', x=55.19, y=67.00, z=68.22], EntityChicken['Chicken'/270, l='MpServer', x=73.56, y=62.56, z=26.53], EntityChicken['Chicken'/39, l='MpServer', x=-65.47, y=65.00, z=6.06], EntityBat['Bat'/46, l='MpServer', x=-61.63, y=23.41, z=29.09], EntityChicken['Chicken'/47, l='MpServer', x=-59.47, y=67.00, z=34.44], EntityChicken['Chicken'/50, l='MpServer', x=-59.69, y=72.00, z=79.56], EntityChicken['Chicken'/49, l='MpServer', x=-50.44, y=67.00, z=50.41], EntityChicken['Chicken'/48, l='MpServer', x=-58.44, y=66.00, z=34.16], EntityChicken['Chicken'/55, l='MpServer', x=-38.38, y=66.00, z=-36.22], EntityCreeper['Creeper'/58, l='MpServer', x=-33.47, y=71.00, z=66.00], EntityChicken['Chicken'/57, l='MpServer', x=-43.53, y=67.00, z=46.94], EntityChicken['Chicken'/56, l='MpServer', x=-47.19, y=64.00, z=3.59], EntityChicken['Chicken'/69, l='MpServer', x=-22.59, y=68.00, z=-56.53], EntityChicken['Chicken'/70, l='MpServer', x=-16.09, y=69.00, z=-61.03], EntityChicken['Chicken'/71, l='MpServer', x=-26.47, y=67.00, z=-47.47], EntitySpider['Spider'/72, l='MpServer', x=-17.94, y=69.00, z=-44.34], EntitySkeleton['Skeleton'/73, l='MpServer', x=-28.63, y=68.00, z=-17.38], EntityChicken['Chicken'/74, l='MpServer', x=-25.44, y=68.00, z=50.53], EntityCow['Cow'/75, l='MpServer', x=-29.41, y=72.00, z=69.63], EntityMooshroom['Mooshroom'/92, l='MpServer', x=-10.84, y=68.00, z=35.31], EntityChicken['Chicken'/89, l='MpServer', x=-12.56, y=69.00, z=-55.63], EntityChicken['Chicken'/91, l='MpServer', x=-15.22, y=69.00, z=-44.63], EntityCreeper['Creeper'/90, l='MpServer', x=-8.88, y=69.00, z=-54.28], EntityLargeFireball['Fireball'/103, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/110, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/111, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/108, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/109, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/106, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/107, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/104, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/105, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/119, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/118, l='MpServer', x=0.00, y=0.00, z=0.00], EntityClientPlayerMP['Player820'/357, l='MpServer', x=4.50, y=75.62, z=1.50], EntityLargeFireball['Fireball'/117, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/116, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/115, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/114, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/113, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/112, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/127, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/126, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/125, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/124, l='MpServer', x=0.00, y=0.00, z=0.00], EntityLargeFireball['Fireball'/123, l='MpServer', x=0.00, y=0.00, z=0.00],
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2556)
at net.minecraft.client.Minecraft.run(Minecraft.java:980)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:55)
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows XP (x86) version 5.1
Java Version: 1.7.0_67, Oracle Corporation
Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
Memory: 893061168 bytes (851 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP v9.05 FML v7.10.18.1180 Minecraft Forge 10.13.0.1180 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.10.18.1180} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.13.0.1180} [Minecraft Forge] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
planetaryAlignmentMod{1.0} [Planetary Alignment Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: ATI Radeon HD 5450 GL version 4.2.11762 Compatibility Profile Context, ATI Technologies Inc.
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)
and how would i implement IZoom into the item class?