Jump to content

Recommended Posts

Posted

So long story short I was trying to make a ball that you can lob and it hurts things, but it just won't render, the render class looks good, the entity looks good, I even initialize it which I know is the number one reason for things to not show up and I've looked at this long and hard and I just don't know what's wrong, so hopefully someone with a fresh pair of eyes can have a look at it and tell me what could possibly be wrong

 

Main mod class

package fxxcmd.minecraftmods.hardcraft;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraft.src.ModLoader;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

import fxxcmd.minecraftmods.hardcraft.abilities.*;
import fxxcmd.minecraftmods.hardcraft.block.BlockThunderPlate;
import fxxcmd.minecraftmods.hardcraft.entity.EntityPoisonDart;


@Mod(modid="fxxcmdHardCraft", name="HardCraft", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class HardCraft {

        // The instance of your mod that Forge uses.
        @Instance("Generic")
        public static HardCraft instance;
        
        public static CreativeTabs tabCustom = new CreativeTabAbilities("tabAbilities");
        
        public final static Item itemLightningRod = new AbilityLightningRod(5003);
        public final static Item itemThunderPlate = new AbilityThunderPlate(5004);
        public final static Item itemBlowGun = new AbilityBlowGun(5005);
        
        //public final static Block blockFermentationTankWall = new BlockFermentationTankWall(500, Material.wood).setHardness(0).setStepSound(Block.soundWoodFootstep).setBlockName("fermentationTankWall").setCreativeTab(CreativeTabs.tabBrewing);
        
        public final static Block blockThunderPlate = new BlockThunderPlate(500, null, Material.wood).setHardness(0).setStepSound(Block.soundWoodFootstep);
        
        /*{
            public ItemStack getIconItemStack()
            {
            	return new ItemStack(itemThunderPlate, 1, 0);
            }
        };*/
        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="fxxcmd.minecraftmods.hardcraft.ClientProxy", serverSide="fxxcmd.minecraftmods.hardcraft.CommonProxy")
        public static ClientProxy proxy;
        public static CommonProxy sProxy;
        
       
        @PreInit
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
       
        @Init
        public void load(FMLInitializationEvent event) {
                //EntityRegistry.registerModEntity(EntityPoisonDart.class, "PoisonDart", 1, this, 128, 1, true);
                
                proxy.registerRenderers();
                //sProxy.registerRenderers();
                
                LanguageRegistry.addName(itemLightningRod, "Lightning Rod");
                LanguageRegistry.addName(itemThunderPlate, "Thunder Rune");
                LanguageRegistry.addName(itemBlowGun, "Blow Gun");
                
                LanguageRegistry.addName(blockThunderPlate, "Thunder Plate Block");
                
                LanguageRegistry.instance().addStringLocalization("itemGroup.tabAbilities", "en_US", "Abilities");
                
                GameRegistry.registerBlock(blockThunderPlate, "thunderPlate");
                
                //EntityRegistry.registerGlobalEntityID(EntityPoisonDart.class, "PoisonDart", EntityRegistry.findGlobalUniqueEntityId());
                
                //GameRegistry.registerTileEntity(TileEntityBoozeBarrel.class, "tileEntityBoozeBarrel");
                
                //itemLightningRod.setIconIndex(ModLoader.addOverride("/gui/items.png", "/lightningRod.png"));
                               
                //itemThunderPlate.updateIcons
                
                //barrelValveSideTexture = ModLoader.addOverride("/terrain.png", "/fermentationTankWallSealed.png");
                
        }
       
        @PostInit
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
        
}

 

Entity class

package fxxcmd.minecraftmods.hardcraft.entity;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityPoisonDart extends EntityThrowable
{
    public EntityPoisonDart(World par1World)
    {
        super(par1World);
    }

    public EntityPoisonDart(World par1World, EntityLiving par2EntityLiving)
    {
        super(par1World, par2EntityLiving);
    }

    public EntityPoisonDart(World par1World, double par2, double par4, double par6)
    {
        super(par1World, par2, par4, par6);
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    {
        if (par1MovingObjectPosition.entityHit != null)
        {
            byte b0 = 0;

            if (par1MovingObjectPosition.entityHit instanceof EntityBlaze)
            {
                b0 = 3;
            }

            par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0);
        }

        for (int i = 0; i < 8; ++i)
        {
            this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
        }

        if (!this.worldObj.isRemote)
        {
            this.setDead();
        }
    }
}

 

Renderer class

package fxxcmd.minecraftmods.hardcraft.renderers;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPotion;
import net.minecraft.potion.PotionHelper;
import net.minecraft.util.Icon;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

@SideOnly(Side.CLIENT)
public class RenderPoisonDart extends Render
{
    private Item field_94151_a;
    private int field_94150_f;

    public RenderPoisonDart(Item par1, int par2)
    {
        this.field_94151_a = par1;
        this.field_94150_f = par2;
    }

    public RenderPoisonDart(Item par1)
    {
        this(par1, 0);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        Icon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f);

        if (icon != null)
        {
            GL11.glPushMatrix();
            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.loadTexture("/gui/items.png");
            Tessellator tessellator = Tessellator.instance;

            if (icon == ItemPotion.func_94589_d("potion_splash"))
            {
                int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false);
                float f2 = (float)(i >> 16 & 255) / 255.0F;
                float f3 = (float)(i >> 8 & 255) / 255.0F;
                float f4 = (float)(i & 255) / 255.0F;
                GL11.glColor3f(f2, f3, f4);
                GL11.glPushMatrix();
                this.func_77026_a(tessellator, ItemPotion.func_94589_d("potion_contents"));
                GL11.glPopMatrix();
                GL11.glColor3f(1.0F, 1.0F, 1.0F);
            }

            this.func_77026_a(tessellator, icon);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
        }
    }

    private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon)
    {
        float f = par2Icon.getMinU();
        float f1 = par2Icon.getMaxU();
        float f2 = par2Icon.getMinV();
        float f3 = par2Icon.getMaxV();
        float f4 = 1.0F;
        float f5 = 0.5F;
        float f6 = 0.25F;
        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        par1Tessellator.startDrawingQuads();
        par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
        par1Tessellator.draw();
    }
}

 

ClientProxy class

package fxxcmd.minecraftmods.hardcraft;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraft.client.renderer.entity.RenderArrow;
import net.minecraft.item.Item;
import net.minecraft.src.ModLoader;
import net.minecraftforge.client.MinecraftForgeClient;
import fxxcmd.minecraftmods.hardcraft.CommonProxy;
import fxxcmd.minecraftmods.hardcraft.entity.EntityPoisonDart;
import fxxcmd.minecraftmods.hardcraft.renderers.RenderPoisonDart;

public class ClientProxy extends CommonProxy
{
       
        @Override
        public void registerRenderers()
        {
                MinecraftForgeClient.preloadTexture(ITEMS_PNG);
                MinecraftForgeClient.preloadTexture(BLOCK_PNG);
                
                EntityRegistry.registerGlobalEntityID(EntityPoisonDart.class, "PoisonDart", ModLoader.getUniqueEntityId());
                //EntityRegistry.registerModEntity(EntityPoisonDart.class, "PoisonDart", 0, this, 128, 1, true);
                RenderingRegistry.registerEntityRenderingHandler(EntityPoisonDart.class, new RenderPoisonDart(Item.snowball, 1));
        }
}
  

Posted

How are you spawning these darts? Usually there's a sided issue here, And is your code left in single line comments '//' at runtime?

 

 

 

 

 

a few OCD comments

 

Okay first of all your ModID must be the same as your InstanceID, you can and likely will run into problems later because of that

 

GL11.glTranslatef

you could just use glTranslated instead of casting to floats...

 

Also, why are you using ModLoader functions? those are condemned in forge...

I think its my java of the variables.

Posted

From an item whenever you right-click

 

public ItemStack onItemRightClick(ItemStack par1ItemStack, World world, EntityPlayer player)
{

		if (!player.capabilities.isCreativeMode)
	       {
	           --par1ItemStack.stackSize;
	       }
	       world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
	       if (!world.isRemote)
	       {
	           world.spawnEntityInWorld(new EntityPoisonDart(world, player));
	       }

	return par1ItemStack;
}

 

The stuff that's been commented out is stuff that I've tried and didn't work or just gave me errors, I do it so I remember I've already tried it and whatever

 

I think I'm setting the same Id, not sure...

 

I'm using ModLoader functions because that's what all the tutorials told me to do, not sure how to do it otherwise, but I'm pretty sure that it's an issue with registering the render but I'm not sure

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.