Jump to content

Recommended Posts

Posted

Ok, so I've been trying to make this simple rock throwable.  My problem is this: Why isn't it working?  :o

 

Here's my code thus far:

 

Mod Class:

package genfrogking.supercraft;

import genfrogking.supercraft.init.SupercraftBlocks;
import genfrogking.supercraft.init.SupercraftEntities;
import genfrogking.supercraft.init.SupercraftItems;
import genfrogking.supercraft.init.SupercraftRecipes;
import genfrogking.supercraft.proxy.CommonProxy;
import genfrogking.supercraft.worldGen.WorldRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class SupercraftMod {

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;

public static final SupercraftTab tabSupercraft = new SupercraftTab("tabSupercraft");

@EventHandler
// This is called when Forge is setting up.
public void preInit(FMLPreInitializationEvent PreEvent)
{
	// Object init and registering
	// Config handling
	SupercraftBlocks.init();
	SupercraftBlocks.register();
	SupercraftItems.init();
	SupercraftItems.register();
	SupercraftEntities.init();
	SupercraftEntities.register();
	SupercraftRecipes.addRecipes();
	WorldRegister.MainRegistry();
}

@EventHandler
public void Init(FMLInitializationEvent Event)
{
	// Proxy, TileEntity, entity, GUI, Sounds, Packet Registering
	proxy.registerRenders();
	proxy.registerSounds();
}

@EventHandler
public void PostInit(FMLPostInitializationEvent PostEvent)
{

}
}

 

Entities Class:

package genfrogking.supercraft.init;

import genfrogking.supercraft.Reference;
import genfrogking.supercraft.client.renderer.entity.RenderStoneRock;
import genfrogking.supercraft.init.entity.projectile.EntityStoneRock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;

public class SupercraftEntities 
{
public static Entity stone_rock;

public static void init()
{

}

public static void register()
{
	EntityRegistry.registerModEntity(EntityStoneRock.class, "stone_rock", 4, 0, 80, 3, true);
}

public static void registerRenders()
{
	RenderingRegistry.registerEntityRenderingHandler(EntityStoneRock.class, new RenderStoneRock(stone_rock));
}

public static void registerRender(Entity entity)
{

}
}

 

In that last class, Eclipse is throwing a red flag on line 30 (where I start with RenderingRegistry) and is underlining RenderStoneRock(stone_rock) as the problem source at the moment.  It says that there is no constructor that takes the same parameters which is true; I'm guessing things changed in 1.8.  (I've been following a 1.7.10- tutorial on throwable items).  Here is the RenderStoneRock class.

 

RenderStone Rock class:

 

package genfrogking.supercraft.client.renderer.entity;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderStoneRock extends Render
{
protected final Item something;
private final RenderItem somethingElse;
private static final String  reallyDontKnow = "someString";

public RenderStoneRock(RenderManager renderManager, Item item, RenderItem renderItem)
{
	super(renderManager);
	this.something = item;
	this.somethingElse = renderItem;
}

public ItemStack func_177082_d(Entity entity)
{
	return new ItemStack(this.something, 1, 0);
}

    public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks)
    {
        GlStateManager.pushMatrix();
        GlStateManager.translate((float)x, (float)y, (float)z);
        GlStateManager.enableRescaleNormal();
        GlStateManager.scale(0.5F, 0.5F, 0.5F);
        GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        this.bindTexture(TextureMap.locationBlocksTexture);
        this.somethingElse.renderItemModel(this.func_177082_d(entity));
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        super.doRender(entity, x, y, z, p_76986_8_, partialTicks);
    }

@Override
protected ResourceLocation getEntityTexture(Entity entity) 
{
	return null;
        //return TextureMap.locationBlocksTexture;
}

}

 

So the RenderStoneRock() method now takes three objects.  How do I account for these in my Entities class file?

 

I can provide more code of what's going on in my other class files if need be.  However, since the red flag is in the Entities class, I'm guessing once that's solved, it will work.

Posted

Thanks for the reply.  Upon getting the RenderManager, the error disappeared.

 

However, the item is still not rendering upon right clicking.  In fact, only while I'm in creative mode does my avatar's arm twitch at all.  I've scanned and compared my Item's class to other's.  I can't seem to find an error.

 

Stone Rock Entity class:

 

  Reveal hidden contents

 

 

I really don't think the problem is in this class, but rather in the way I'm handling the rendering of the entity.  The problem must still lie in one of my main mod classes.  :P

 

Main mod class:

 

  Reveal hidden contents

 

 

Common Proxy class:

 

  Reveal hidden contents

 

 

Server Proxy Class:

 

  Reveal hidden contents

 

 

Client Proxy Class:

 

  Reveal hidden contents

 

 

Entities Class:

 

  Reveal hidden contents

 

 

Stone Rock Item:

 

  Reveal hidden contents

 

 

Any help is greatly appreciated!

Posted

Why do you set the item in use if you are spawning it upon right click?

 

Setting the item in use is so you can "charge up" the item, like a bow.

 

Try removing that and see if it corrects it.

Posted

Thank you very much for the replies!

 

Okay, so upon searching for onRightClick in Item class, I discovered that it didn't exist.  I scrolled down and found onItemRightClick.  Quite a silly blunder!  :o  I bet you guys saw it and were just waiting to see how long it would take me.  ;)  I also commented out the part TrashCaster mentioned.  The rock is mostly throw-able now.

 

However, now my rock isn't rendering properly.  It's just a black and purple checker box when it leaves the character's hands.  It probably has something to do with the Entities class.  I suspect I'm registering the renders wrong.  It also could very well have something to do with the way my proxies relate to the Main class.

 

Either way, somehow RenderStoneRock isn't being called right.  I'm troubleshooting, but will have more time this coming weekend to really look into it if I don't solve it tonight.

Posted
  On 5/8/2015 at 8:56 AM, GenFrogKing said:

Thank you very much for the replies!

 

Okay, so upon searching for onRightClick in Item class, I discovered that it didn't exist.  I scrolled down and found onItemRightClick.  Quite a silly blunder!  :o  I bet you guys saw it and were just waiting to see how long it would take me.  ;)  I also commented out the part TrashCaster mentioned.  The rock is mostly throw-able now.

 

However, now my rock isn't rendering properly.  It's just a black and purple checker box when it leaves the character's hands.  It probably has something to do with the Entities class.  I suspect I'm registering the renders wrong.  It also could very well have something to do with the way my proxies relate to the Main class.

 

Either way, somehow RenderStoneRock isn't being called right.  I'm troubleshooting, but will have more time this coming weekend to really look into it if I don't solve it tonight.

If it's rendering a purple and black checker box, that means it cannot find the texture..
Posted
  On 5/8/2015 at 8:56 AM, GenFrogKing said:

Thank you very much for the replies!

 

Okay, so upon searching for onRightClick in Item class, I discovered that it didn't exist.  I scrolled down and found onItemRightClick.  Quite a silly blunder!  :o  I bet you guys saw it and were just waiting to see how long it would take me.  ;)  I also commented out the part TrashCaster mentioned.  The rock is mostly throw-able now.

This is exactly why you should ALWAYS use the @Override annotation on any inherited method - it will tell you right away in your IDE that the method does not exist if the signature is incorrect, which you fix not by removing @Override, but by finding the correct method signature ;)

Posted

Hey, thanks all again for the replies.

 

  Quote
If it's rendering a purple and black checker box, that means it cannot find the texture..

 

If what you're saying is true, then the problem should be in how I'm calling the texture in my Render class, right?

 

RenderStoneRock class:

 

  Reveal hidden contents

 

 

Upon putting an Override annotation on the first getEntityTexture method, I receive an error stating that that specific method is nonexistent in the extended class for the given parameters.  That should be fine for custom methods, though... right?  I tested this class with several System.out.println's and I know for a fact that everything here is being called including this unrecognized method.

 

However, there is an error upon "throwing" the rock:

 

 

  Reveal hidden contents

 

 

It would appear you're right, gegy1000.  I've tried modifying the load path with no success thus far.  I'm sure it's something simple from here, though.  I'm investigating.

 

  Quote

Or use your IDE to override for you in the first place ;)

 

Alright, alright, you caught me again, but I thought you said Eclipse didn't offer automated overriding... ;)

Posted
  Quote

I am not going into the Eclipse vs IntelliJ discussion, but Source > Override/Implement Methods sucks when you have Ctrl-O :P

 

Lol, I don't wish a heated debate this early in my Java career.

 

  Quote

For your error, you forgot your ModID in the ResourceLocation.

 

Included it, but still no go.

 

private static final ResourceLocation stoneRockTexture = new ResourceLocation(Main.MOD_ID + "/textures/items/stone_rock.png");

 

Hmmmm...  :-\

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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