Jump to content

Problem Overwriting Vanilla Cow Class Forge 1.7.10


kitsushadow

Recommended Posts

I'm trying to Overwrite the vanilla cow class with my own cow class. Im attempting to make the cow drop an item similar to how a chicken does. I believe my custom cow class is fine but that Im registering my cowclass incorrectly or that im not disabling the spawn correctly. Please look at my Main and Cow classes and let me know if something is amiss.

 

Thanks in Advance (Also Spoilers dont seem to be working at the time i was writing this post)

 

MedievalCow.class

 

package com.kitsu.medievalcraft.entity;

 

import com.kitsu.medievalcraft.item.ModItems;

 

import net.minecraft.block.Block;

import net.minecraft.entity.EntityAgeable;

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.entity.ai.EntityAIFollowParent;

import net.minecraft.entity.ai.EntityAILookIdle;

import net.minecraft.entity.ai.EntityAIMate;

import net.minecraft.entity.ai.EntityAIPanic;

import net.minecraft.entity.ai.EntityAISwimming;

import net.minecraft.entity.ai.EntityAITempt;

import net.minecraft.entity.ai.EntityAIWander;

import net.minecraft.entity.ai.EntityAIWatchClosest;

import net.minecraft.entity.passive.EntityCow;

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;

 

public class MedievalCow extends EntityCow {

 

public float field_70886_e;

    public float destPos;

    public float field_70884_g;

    public float field_70888_h;

    public float field_70889_i = 1.0F;

    /** The time until the next egg is spawned. */

    public int timeUntilNextEgg;

    public boolean field_152118_bv;

    private static final String __OBFID = "CL_00001639";

 

public MedievalCow(World p_i1683_1_) {

super(p_i1683_1_);

        this.setSize(0.9F, 1.3F);

        this.getNavigator().setAvoidsWater(true);

        this.tasks.addTask(0, new EntityAISwimming(this));

        this.tasks.addTask(1, new EntityAIPanic(this, 2.0D));

        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));

        this.tasks.addTask(3, new EntityAITempt(this, 1.25D, Items.wheat, false));

        this.tasks.addTask(4, new EntityAIFollowParent(this, 1.25D));

        this.tasks.addTask(5, new EntityAIWander(this, 1.0D));

        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));

        this.tasks.addTask(7, new EntityAILookIdle(this));

        this.timeUntilNextEgg = this.rand.nextInt(10) + 10;

}

 

    /**

    * Returns true if the newer Entity AI code should be run

    */

    public boolean isAIEnabled()

    {

        return true;

    }

 

    protected void applyEntityAttributes()

    {

        super.applyEntityAttributes();

        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);

        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D);

    }

 

    /**

    * Returns the sound this mob makes while it's alive.

    */

    protected String getLivingSound()

    {

        return "mob.cow.say";

    }

 

    /**

    * Returns the sound this mob makes when it is hurt.

    */

    protected String getHurtSound()

    {

    return "mob.cow.hurt";

    }

 

    /**

    * Returns the sound this mob makes on death.

    */

    protected String getDeathSound()

    {

        return "mob.cow.hurt";

    }

 

    protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_)

    {

        this.playSound("mob.cow.step", 0.15F, 1.0F);

    }

 

    /**

    * Returns the volume for the sounds this mob makes.

    */

    protected float getSoundVolume()

    {

        return 0.4F;

    }

 

    protected Item getDropItem()

    {

        return Items.leather;

    }

 

    /**

    * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param

    * par2 - Level of Looting used to kill this mob.

    */

   

    public void onLivingUpdate()

    {

        super.onLivingUpdate();

        this.field_70888_h = this.field_70886_e;

        this.field_70884_g = this.destPos;

        this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D);

 

        if (this.destPos < 0.0F)

        {

            this.destPos = 0.0F;

        }

 

        if (this.destPos > 1.0F)

        {

            this.destPos = 1.0F;

        }

 

        if (!this.onGround && this.field_70889_i < 1.0F)

        {

            this.field_70889_i = 1.0F;

        }

 

        this.field_70889_i = (float)((double)this.field_70889_i * 0.9D);

 

        if (!this.onGround && this.motionY < 0.0D)

        {

            this.motionY *= 0.6D;

        }

 

        this.field_70886_e += this.field_70889_i * 2.0F;

 

        if (!this.worldObj.isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0)

        {

            this.playSound("mob.chicken.plop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);

            this.dropItem(Items.egg, 1);

            this.timeUntilNextEgg = this.rand.nextInt(10) + 10;

        }

    }

   

   

    protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)

    {

        int j = this.rand.nextInt(4) + this.rand.nextInt(1 + p_70628_2_);

        int k;

 

        for (k = 0; k < j; ++k)

        {

            this.dropItem(Items.leather, 1);

        }

 

        j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_);

 

        for (k = 0; k < j; ++k)

        {

            if (this.isBurning())

            {

                this.dropItem(Items.cooked_beef, 1);

            }

            else

            {

                this.dropItem(Items.beef, 1);

            }

        }

    }

 

    /**

    * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.

    */

    public boolean interact(EntityPlayer p_70085_1_)

    {

        ItemStack itemstack = p_70085_1_.inventory.getCurrentItem();

 

        if (itemstack != null && itemstack.getItem() == Items.bucket && !p_70085_1_.capabilities.isCreativeMode)

        {

            if (itemstack.stackSize-- == 1)

            {

                p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, new ItemStack(Items.milk_bucket));

            }

            else if (!p_70085_1_.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))

            {

                p_70085_1_.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false);

            }

 

            return true;

        }

        else

        {

            return super.interact(p_70085_1_);

        }

    }

 

    public EntityCow createChild(EntityAgeable p_90011_1_)

    {

        return new EntityCow(this.worldObj);

    }

}

 

________________________________________________________________________________

Main

 

package com.kitsu.medievalcraft;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.entity.passive.EntityCow;

import net.minecraft.world.biome.BiomeGenBase;

 

import com.kitsu.medievalcraft.block.ModBlocks;

import com.kitsu.medievalcraft.crafting.ModCrafting;

import com.kitsu.medievalcraft.entity.EntityShit;

import com.kitsu.medievalcraft.entity.MedievalCow;

import com.kitsu.medievalcraft.item.ModItems;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.Mod.Instance;

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.registry.EntityRegistry;

 

@Mod(modid = Main.MODID, name = Main.MODNAME, version = Main.VERSION)

public class Main {

 

        public static final String MODID = "kitsumedievalcraft";

        public static final String MODNAME = "Medieval Craft";

        public static final String VERSION = "1.0.0";

       

        @Instance

        public static Main instance = new Main();

       

        @SidedProxy(clientSide="com.kitsu.medievalcraft.ClientProxy", serverSide="com.kitsu.medievalcraft.CommonProxy")

        public static CommonProxy proxy;

       

        /**

        * Run before anything else. Read your config, create blocks, items, etc, and

        * register them with the GameRegistry.

        */

        @EventHandler

        public void preInit(FMLPreInitializationEvent e) {

                this.proxy.preInit(e);

                CustomTab.MedievalTab();

 

        ModItems.init();

        ModBlocks.init();

        ModCrafting.init();

               

        }

       

        /**

        * Do your mod setup. Build whatever data structures you care about. Register recipes.

        */

        @EventHandler

        public void init(FMLInitializationEvent e) {

                this.proxy.init(e);

 

                EntityRegistry.registerModEntity(EntityShit.class, "itemShit", 1, this, 64, 10, true);

                EntityRegistry.registerModEntity(MedievalCow.class, "Medieval Cow", 1, this, 80, 3, true);

                for (int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++)

                        {

                            if (BiomeGenBase.getBiomeGenArray() != null)

                            {

                                EntityRegistry.removeSpawn(EntityCow.class, EnumCreatureType.monster, BiomeGenBase.getBiomeGenArray());

                            }

                        }

                EntityRegistry.addSpawn(MedievalCow.class, 10, 1, 3, EnumCreatureType.monster, BiomeGenBase.birchForest, BiomeGenBase.forest, BiomeGenBase.jungle, BiomeGenBase.plains, BiomeGenBase.savanna, BiomeGenBase.taiga);

           

               

        }

       

        /**

        * Handle interaction with other mods, complete your setup based on this.

        */

        @EventHandler

        public void postInit(FMLPostInitializationEvent e) {

              this.proxy.postInit(e);

              this.proxy.registerRenderer();

             

              //RenderingRegistry.registerEntityRenderingHandler(EntityShit.class, new RenderSnowball(ModItems.itemShit));

             

               

        }

}

 

 

Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am not using hardcoded recipes, I'm using Vanilla's already existing code for leather armor dying. (via extending and implementing DyeableArmorItem / DyeableLeatherItem respectively) I have actually figured out that it's something to do with registering item colors to the ItemColors instance, but I'm trying to figure out where exactly in my mod's code I would be placing a call to the required event handler. Unfortunately the tutorial is criminally undescriptive. The most I've found is that it has to be done during client initialization. I'm currently trying to do the necessary setup via hijacking the item registry since trying to modify the item classes directly (via using SubscribeEvent in the item's constructor didn't work. Class so far: // mrrp mrow - mcmod item painter v1.0 - catzrule ch package catzadvitems.init; import net.minecraft.client.color.item.ItemColors; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.client.event.ColorHandlerEvent; import catzadvitems.item.DyeableWoolArmorItem; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Painter { @ObjectHolder("cai:dyeable_wool_chestplate") public static final Item W_CHEST = null; @ObjectHolder("cai:dyeable_wool_leggings") public static final Item W_LEGS = null; @ObjectHolder("cai:dyeable_wool_boots") public static final Item W_SOCKS = null; public Painter() { // left blank, idk if forge throws a fit if constructors are missing, not taking the chance of it happening. } @SubscribeEvent public static void init(FMLClientSetupEvent event) { new Painter(); } @Mod.EventBusSubscriber private static class ForgeBusEvents { @SubscribeEvent public static void registerItemColors(ColorHandlerEvent.Item event) { ItemColors col = event.getItemColors(); col.register(DyeableUnderArmorItem::getItemDyedColor, W_CHEST, W_LEGS, W_SOCKS); //placeholder for other dye-able items here later.. } } } (for those wondering, i couldn't think of a creative wool helmet name)
    • nvm found out it was because i had create h and not f
    • Maybe there's something happening in the 'leather armor + dye' recipe itself that would be updating the held item texture?
    • @SubscribeEvent public static void onRenderPlayer(RenderPlayerEvent.Pre e) { e.setCanceled(true); model.renderToBuffer(e.getPoseStack(), pBuffer, e.getPackedLight(), 0f, 0f, 0f, 0f, 0f); //ToaPlayerRenderer.render(); } Since getting the render method from a separate class is proving to be bit of a brick wall for me (but seems to be the solution in older versions of minecraft/forge) I've decided to try and pursue using the renderToBuffer method directly from the model itself. I've tried this route before but can't figure out what variables to feed it for the vertexConsumer and still can't seem to figure it out; if this is even a path to pursue.  The vanilla model files do not include any form of render methods, and seem to be fully constructed from their layer definitions? Their renderer files seem to take their layers which are used by the render method in the vanilla MobRenderer class. But for modded entities we @Override this function and don't have to feed the method variables because of that? I assume that the render method in the extended renderer takes the layer definitions from the renderer classes which take those from the model files. Or maybe instead of trying to use a render method I should be calling the super from the renderer like   new ToaPlayerRenderer(context, false); Except I'm not sure what I would provide for context? There's a context method in the vanilla EntityRendererProvider class which doesn't look especially helpful. I've been trying something like <e.getEntity(), model<e.getEntity()>> since that generally seems to be what is provided to the renderers for context, but I don't know if it's THE context I'm looking for? Especially since the method being called doesn't want to take this or variations of this.   In short; I feel like I'm super super close but I have to be missing something obvious? Maybe this insane inane ramble post will provide some insight into this puzzle?
  • Topics

×
×
  • Create New...

Important Information

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