Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Bloopers

Forge Modder
  • Posts

    77
  • Joined

  • Last visited

Posts posted by Bloopers

  1. Note:

     

    For isLadder to work, two things must be true about your block:

    1) Your block must be less than a full cube in the X-Z directions (player must be able to be inside the the standard block volume)

    2) Your block must be solid

    Don't know if this is related or not, but is it possible to make it so that you can walk through the block only while doing something(like crouching) - The block I'm trying to make is somewhat like a rope/rope ladder

  2. The ItemBow class' #onPlayerStoppedUsing method implementation shows you how to do all of those things - it's worth a read through and is pretty much copy-paste ready once you figure out what's going on.

    I've managed to make the item work only if an ender pearl is in the inventory now. I can't figure out how to consume an ender pearl from the inventory and I also cannot figure out how to do the velocity(it seems like ender pearls have a lot less parameters than arrows)

     

  3. Hello, I've created this item that will charge up like a bow and shoot an ender pearl(thanks to the help of Choonster)

     

    I'd like to expand on it a bit more, however. This is my class file for the item right now:

    package bloopers.trinkets.items;
    
    import javax.annotation.Nullable;
    
    import net.minecraft.command.ICommandSender;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.enchantment.EnchantmentHelper;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.item.EntityEnderPearl;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.projectile.EntityArrow;
    import net.minecraft.entity.projectile.EntityTippedArrow;
    import net.minecraft.init.Enchantments;
    import net.minecraft.init.Items;
    import net.minecraft.init.SoundEvents;
    import net.minecraft.item.EnumAction;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemArrow;
    import net.minecraft.item.ItemEnderPearl;
    import net.minecraft.item.ItemStack;
    import net.minecraft.stats.StatList;
    import net.minecraft.util.ActionResult;
    import net.minecraft.util.EnumActionResult;
    import net.minecraft.util.EnumHand;
    import net.minecraft.util.SoundCategory;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.World;
    
    public class ItemEnderRifle extends Item
    {
        public ItemEnderRifle()
        {
            this.maxStackSize = 1;
            this.setMaxDamage(32);
            this.setCreativeTab(CreativeTabs.MISC);
        }
    
        
        @Override
        public EnumAction getItemUseAction(ItemStack stack)
        {
            return EnumAction.BOW;
        }
        
        
        /**
         * How long it takes to use or consume an item
         */
        @Override
        public int getMaxItemUseDuration(ItemStack stack)
        {
            return 5000;
        }
        
        @Override
        public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
        {
    
                playerIn.setActiveHand(hand);
                return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    
        
        @Override
        public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
        {
        	    	
        	
        	if (!worldIn.isRemote)
            {
                EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, entityLiving);
                entityenderpearl.setHeadingFromThrower(entityLiving, entityLiving.rotationPitch, entityLiving.rotationYaw, 0.0F, 1.5F, 1.0F);
                worldIn.spawnEntityInWorld(entityenderpearl);
                stack.damageItem(1, entityLiving);
            }   
        }
        
    
    }
    

     

    So, I want to be able to make it require ammo(an ender pearl) AND I want it to have different velocities depending on how much you charge up the item(it's meant to throw ender pearls extra far)

    Any help is appreciated.

  4. I'm not sure what I am supposed to do from here still, sorry to bother you again.

     

    Override the method by creating a method with the same name, return type and parameter types and annotating it with

    @Override

    . Your IDE should be able to do this for you.

     

    It's not strictly necessary, but you should also annotate your override method with the same annotations as the super method.

     

    If you've managed to override the method, post your latest code and describe what the current problem is.

    It's no longer giving me an error when overriding, but when I finish charging up the game crashes. I think I know the problem too. Here's the code first:

        @Override
        public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
        {
        	
        	EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, player);
            entityenderpearl.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
            worldIn.spawnEntityInWorld(entityenderpearl);
            stack.damageItem(1, player);
        	
        }
    

     

    So, I noticed this now, is the onPlayerStoppedUsing method supposed to return something?

        @Override
        public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
        {
        	
        	EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, player);
            entityenderpearl.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
            worldIn.spawnEntityInWorld(entityenderpearl);
            stack.damageItem(1, player);
        	
        }
    

     

    Because onItemRightClick returns EnumActionResult.SUCCESS - I wonder if onPlayerStoppedUsing is supposed to return something.

  5. Didn't know what method signature was before, did a search and it told me that it's the parameters before the method like public, static and void. (is that correct?)

    I tried multiple combinations of them and I'm still getting the error.

     

    That's not correct. This tutorial explains method overriding and method signatures.

    I'm not sure what I am supposed to do from here still, sorry to bother you again.

  6. You didn't override

    Item#getMaxItemUseDuration

    .

     

    Side note: Always annotate override methods with

    @Override

    so you get a compilation error if they don't override a super method.

    The item will charge up now like a bow, but it doesn't do anything on release, even though I have written down to throw an enderpearl in the onPlayerStoppedUsing. This is what I have now:

     

     

    package bloopers.trinkets.items;

     

    import net.minecraft.creativetab.CreativeTabs;

    import net.minecraft.entity.EntityLivingBase;

    import net.minecraft.entity.item.EntityEnderPearl;

    import net.minecraft.entity.player.EntityPlayer;

    import net.minecraft.init.SoundEvents;

    import net.minecraft.item.EnumAction;

    import net.minecraft.item.Item;

    import net.minecraft.item.ItemStack;

    import net.minecraft.stats.StatList;

    import net.minecraft.util.ActionResult;

    import net.minecraft.util.EnumActionResult;

    import net.minecraft.util.EnumHand;

    import net.minecraft.util.SoundCategory;

    import net.minecraft.world.World;

     

    public class ItemEnderRifle extends Item

    {

        public ItemEnderRifle()

        {

            this.maxStackSize = 1;

            this.setMaxDamage(32);

            this.setCreativeTab(CreativeTabs.MISC);

        }

     

        @Override

        public EnumAction getItemUseAction(ItemStack stack)

        {

            return EnumAction.BOW;

        }

       

        /**

        * How long it takes to use or consume an item

        */

        @Override

        public int getMaxItemUseDuration(ItemStack stack)

        {

            return 5000;

        }

       

        @Override

        public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)

        {

     

                playerIn.setActiveHand(hand);

                return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);

        }

       

        public void onPlayerStoppedUsing(ItemStack itemStackIn, World worldIn, EntityLivingBase entityLiving, int timeLeft, EntityPlayer playerIn)

        {

       

                EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);

                entityenderpearl.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);

                worldIn.spawnEntityInWorld(entityenderpearl);

                itemStackIn.damageItem(1, playerIn);

               

        }

       

    }

     

     

     

    I couldn't put @Override ontop of onPlayerStoppedUsing(it gave me an error and told me to remove the @Override annotation)

  7. Override the following methods:

    • Item#onItemRightClick

      to set the item in use by calling

      EntityLivingBase#setActiveHand


    • Item#getMaxItemUseDuration

      to return the maximum use duration of your item

    • Item#getItemUseAction

      to return

      EnumAction.BOW

      so the entity draws the item back like a bow

    • Item#onPlayerStoppedUsing

      or

      Item#onItemUseFinish

      to do something (e.g. spawn a projectile entity) when the entity stops or finishes using item

     

    Thank you for the quick response, I have this now:

     

     

    package bloopers.trinkets.items;

     

    import net.minecraft.creativetab.CreativeTabs;

    import net.minecraft.entity.EntityLivingBase;

    import net.minecraft.entity.item.EntityEnderPearl;

    import net.minecraft.entity.player.EntityPlayer;

    import net.minecraft.init.SoundEvents;

    import net.minecraft.item.EnumAction;

    import net.minecraft.item.Item;

    import net.minecraft.item.ItemStack;

    import net.minecraft.stats.StatList;

    import net.minecraft.util.ActionResult;

    import net.minecraft.util.EnumActionResult;

    import net.minecraft.util.EnumHand;

    import net.minecraft.util.SoundCategory;

    import net.minecraft.world.World;

     

    public class ItemEnderRifle extends Item

    {

        public ItemEnderRifle()

        {

            this.maxStackSize = 1;

            this.setMaxDamage(32);

            this.setCreativeTab(CreativeTabs.MISC);

        }

     

       

        public EnumAction getItemUseAction(ItemStack stack)

        {

            return EnumAction.BOW;

        }

       

       

       

        public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)

        {

     

                playerIn.setActiveHand(hand);

                return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);

        }

       

        public void onPlayerStoppedUsing(ItemStack itemStackIn, World worldIn, EntityLivingBase entityLiving, int timeLeft, EntityPlayer playerIn)

        {

       

            if (!worldIn.isRemote)

            {

                EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);

                entityenderpearl.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);

                worldIn.spawnEntityInWorld(entityenderpearl);

                itemStackIn.damageItem(1, playerIn);

            }

       

        }

       

    }

     

     

     

    But it doesn't do anything ingame(like a blank item)

    Any idea what I've done wrong?

  8. I'd like to create an item that is meant to charge up like a bow, and then shoot an enderpearl(meant to be able to shoot enderpearls really far). I've taken a look at the bow class file and I don't understand any of it...

     

    Any help is appreciated.

  9. PlayerEvent.ItemCraftedEvent

    should work.

    I created this class, but am I supposed to register it in my main file? If so, how?

     

    package bloopers.novelties.handlers;
    
    import net.minecraft.item.ItemBed;
    import net.minecraft.item.ItemStack;
    import net.minecraft.item.ItemSword;
    import net.minecraft.launchwrapper.Launch;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
    import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
    
    public class EventItemCrafted 
    {
    @SubscribeEvent
    public void onItemCrafted(ItemCraftedEvent event)
    {
    	ItemStack stack = event.crafting;
    	NBTTagCompound nbt = stack.getTagCompound();
    
    	if (stack.getItem() instanceof ItemBed)
    	{
    		stack.setTagInfo("Test", null);
    	}
    }
    }
    

  10. I want to make it so that when you craft a bed, it will be given a special lore(AddInformation method I think.) but I'm not sure how. I researched crafting handlers and achievements but they are for old versions and none seem to work.

  11. When removing the two lines saying "registerGlobalEntityID" and "findGlobalUniqueEntityIdD" how am I supposed to set the Entity ID now?
    IDs for
    registerModEntity

    are local to your mod. Start at 0 and increment for every new entity.

    When loading up the game the entity simply doesn't exist anymore
    What exactly do you mean by "it doesn't exist anymore"?

     

    The mob doesn't show up in /summon (i never created a spawn egg for it in the first place) and all of them that existed in the world before are now gone.

  12. What should I use instead?

    Nothing. Just
    registerModEntity

    .

    Update as in update my MDK?

    No, update as in change your code to use the new version.

     

    When removing the two lines saying "registerGlobalEntityID" and "findGlobalUniqueEntityIdD" how am I supposed to set the Entity ID now? When loading up the game the entity simply doesn't exist anymore - This is my EntityCreate class now:

     

     

     

     

    package bloopers.novelties.entity;

     

    import bloopers.novelties.NoveltiesMod;

    import net.minecraft.entity.EntityList;

    import net.minecraft.entity.EnumCreatureType;

    import net.minecraft.init.Biomes;

    import net.minecraftforge.fml.common.registry.EntityRegistry;

     

    public class EntityCreate {

     

    public static void mainRegistry() {

    registerEntity();

    }

     

    public static void registerEntity() {

     

    createEntity(EntityWraithMob.class, "Wraith");

    }

     

    public static void createEntity(Class entityClass, String entityName) {

    EntityRegistry.registerModEntity(entityClass, entityName, 1, NoveltiesMod.modInstance, 64, 1, true);

    EntityRegistry.addSpawn(entityClass, 2, 0, 1, EnumCreatureType.MONSTER, Biomes.roofedForest);

     

    }

     

     

    }

     

     

     

     

  13. I created a custom model and texture for a mob, and everything works fine, except for ingame, the mob is just purple and black checkerboard patterns. Here are the classes I used:

     

    ClientProxy.java (proxy class is registered in main class already)

     

     

    package bloopers.novelties.proxy;

     

    import bloopers.novelties.entity.EntityWraithMob;

    import bloopers.novelties.entity.RenderWraithMob;

    import bloopers.novelties.entity.Wraith;

    import bloopers.novelties.init.NoveltiesBlocks;

    import bloopers.novelties.init.NoveltiesItems;

    import net.minecraft.client.Minecraft;

    import net.minecraftforge.fml.client.registry.RenderingRegistry;

     

    public class ClientProxy extends CommonProxy {

     

    public void registerRenders() {

     

    RenderingRegistry.registerEntityRenderingHandler(EntityWraithMob.class, new RenderWraithMob(Minecraft.getMinecraft().getRenderManager(), new Wraith(), 0));

     

     

    NoveltiesBlocks.registerRenders();

    NoveltiesItems.registerRenders();

    }

    }

     

     

     

    EntityWraithMob.java (ai class)

     

     

    package bloopers.novelties.entity;

     

    import net.minecraft.entity.EntityAgeable;

    import net.minecraft.entity.EntityCreature;

    import net.minecraft.entity.EntityFlying;

    import net.minecraft.entity.SharedMonsterAttributes;

    import net.minecraft.entity.ai.EntityAIAttackMelee;

    import net.minecraft.entity.ai.EntityAINearestAttackableTarget;

    import net.minecraft.entity.ai.EntityAIPanic;

    import net.minecraft.entity.ai.EntityAIWander;

    import net.minecraft.entity.passive.EntityAnimal;

    import net.minecraft.entity.player.EntityPlayer;

    import net.minecraft.world.World;

     

    public class EntityWraithMob extends EntityCreature {

     

    public EntityWraithMob(World worldIn) {

    super(worldIn);

    this.setSize(0.7F, 0.4F);

    this.tasks.addTask(0, new EntityAIWander(this, 0.5D));

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

    }

     

    public boolean isAIEnabled() {

    return true;

    }

     

    protected void applyEntityAttributes() {

    super.applyEntityAttributes();

    this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);

    this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.6D);

    }

     

    }

     

     

     

     

    Wraith.java(model class)

     

     

    // Date: 5/17/2016 1:24:45 PM

    // Template version 1.1

    // Java generated by Techne

    // Keep in mind that you still need to fill in some blanks

    // - ZeuX

     

     

     

     

     

     

    package bloopers.novelties.entity;

     

    import net.minecraft.client.model.ModelBase;

    import net.minecraft.client.model.ModelRenderer;

    import net.minecraft.entity.Entity;

     

    public class Wraith extends ModelBase

    {

      //fields

        ModelRenderer head;

        ModelRenderer body;

        ModelRenderer rightarm;

        ModelRenderer leftarm;

        ModelRenderer dot;

     

      public Wraith()

      {

        textureWidth = 64;

        textureHeight = 64;

       

          head = new ModelRenderer(this, 0, 0);

          head.addBox(-4F, -8F, -4F, 11, 11, 11);

          head.setRotationPoint(-1F, 0F, 0F);

          head.setTextureSize(64, 64);

          head.mirror = true;

          setRotation(head, 0F, 0F, 0F);

          body = new ModelRenderer(this, 1, 27);

          body.addBox(-4F, 0F, -2F, 9, 13, 6);

          body.setRotationPoint(0F, 2F, 0F);

          body.setTextureSize(64, 64);

          body.mirror = true;

          setRotation(body, 0.5948578F, 0F, 0F);

          rightarm = new ModelRenderer(this, 40, 46);

          rightarm.addBox(-3F, -2F, -2F, 5, 12, 5);

          rightarm.setRotationPoint(-6F, 3F, 0F);

          rightarm.setTextureSize(64, 64);

          rightarm.mirror = true;

          setRotation(rightarm, -1.301248F, 0F, 0F);

          leftarm = new ModelRenderer(this, 40, 46);

          leftarm.addBox(-1F, -2F, -2F, 5, 12, 5);

          leftarm.setRotationPoint(6F, 3F, 0F);

          leftarm.setTextureSize(64, 64);

          leftarm.mirror = true;

          setRotation(leftarm, -1.301248F, 0F, 0F);

          dot = new ModelRenderer(this, 1, 52);

          dot.addBox(0F, 0F, 0F, 8, 10, 1);

          dot.setRotationPoint(-3.5F, -7F, 0F);

          dot.setTextureSize(64, 64);

          dot.mirror = true;

          setRotation(dot, 0F, 0F, 0F);

      }

     

      public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)

      {

        super.render(entity, f, f1, f2, f3, f4, f5);

        setRotationAngles(f, f1, f2, f3, f4, f5, entity);

        head.render(f5);

        body.render(f5);

        rightarm.render(f5);

        leftarm.render(f5);

        dot.render(f5);

      }

     

      private void setRotation(ModelRenderer model, float x, float y, float z)

      {

        model.rotateAngleX = x;

        model.rotateAngleY = y;

        model.rotateAngleZ = z;

      }

     

      public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)

      {

        super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

      }

     

    }

     

     

     

     

    RenderWraithMob.java(render class - yes, the directory for the texture is correct.)

     

     

    package bloopers.novelties.entity;

     

    import bloopers.novelties.Reference;

    import net.minecraft.client.model.ModelBase;

    import net.minecraft.client.renderer.entity.RenderLiving;

    import net.minecraft.client.renderer.entity.RenderManager;

    import net.minecraft.entity.Entity;

    import net.minecraft.util.ResourceLocation;

     

    public class RenderWraithMob extends RenderLiving {

     

    private static final ResourceLocation WraithTextures = new ResourceLocation("novelties:textures/entity/wraith/Wraith.png");

     

    public RenderWraithMob(RenderManager rendermanagerIn, ModelBase modelbaseIn, float shadowsizeIn) {

    super(rendermanagerIn, modelbaseIn, shadowsizeIn);

    }

     

    protected ResourceLocation getEntityTexture(EntityWraithMob entity) {

    return WraithTextures;

    }

     

    protected ResourceLocation getEntityTexture(Entity entity) {

    return this.getEntityTexture((EntityWraithMob)entity);

    }

     

    }

     

     

     

     

     

    EntityCreate.java (my initialization thing for entity)

     

     

    package bloopers.novelties.entity;

     

    import bloopers.novelties.NoveltiesMod;

    import net.minecraft.entity.EntityList;

    import net.minecraft.entity.EnumCreatureType;

    import net.minecraft.init.Biomes;

    import net.minecraftforge.fml.common.registry.EntityRegistry;

     

    public class EntityCreate {

     

    public static void mainRegistry() {

    registerEntity();

    }

     

    public static void registerEntity() {

     

    createEntity(EntityWraithMob.class, "Wraith");

    }

     

    public static void createEntity(Class entityClass, String entityName) {

    int randomId = EntityRegistry.findGlobalUniqueEntityId();

    EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId);

    EntityRegistry.registerModEntity(entityClass, entityName, randomId, NoveltiesMod.modInstance, 64, 1, true);

    EntityRegistry.addSpawn(entityClass, 2, 0, 1, EnumCreatureType.MONSTER, Biomes.roofedForest);

     

    }

     

     

    }

     

     

     

     

     

     

     

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.