Jump to content

Recommended Posts

Posted

Look at ModelBiped.class. The way it's done there is by checking an "aimedBow" boolean and rotating / translating the biped arms based on that. It will be complicated, using Trig functions, so I recommend copying vanilla's code and changing the biped arms to your own limbs or whatever you need to do.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Posted

it no work why?

package com.OlympiansMod.entity;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;

public class ModelWarrior extends ModelBiped{
 public ModelWarrior()
    {
        this(0.0F);
    }
	    public ModelWarrior(float p_i1156_1_)
	    {
	    	
	        super(p_i1156_1_, 0.0F, 64, 32);
	       
	    }
	    
	    public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
	    {
	    	this.bipedHead.rotateAngleY = f3 / (180F / (float)Math.PI);
	        this.bipedHead.rotateAngleX = f4 / (180F / (float)Math.PI);
	        this.bipedHeadwear.rotateAngleY = this.bipedHead.rotateAngleY;
	        this.bipedHeadwear.rotateAngleX = this.bipedHead.rotateAngleX;
	        this.bipedRightArm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 2.0F * f1 * 0.5F;
	        this.bipedLeftArm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;
	        this.bipedRightArm.rotateAngleZ = 0.0F;
	        this.bipedLeftArm.rotateAngleZ = 0.0F;
	        this.bipedRightLeg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
	        this.bipedLeftLeg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
	        this.bipedRightLeg.rotateAngleY = 0.0F;
	        this.bipedLeftLeg.rotateAngleY = 0.0F;

	        if (this.isRiding)
	        {
	            this.bipedRightArm.rotateAngleX += -((float)Math.PI / 5F);
	            this.bipedLeftArm.rotateAngleX += -((float)Math.PI / 5F);
	            this.bipedRightLeg.rotateAngleX = -((float)Math.PI * 2F / 5F);
	            this.bipedLeftLeg.rotateAngleX = -((float)Math.PI * 2F / 5F);
	            this.bipedRightLeg.rotateAngleY = ((float)Math.PI / 10F);
	            this.bipedLeftLeg.rotateAngleY = -((float)Math.PI / 10F);
	        }

	        if (this.heldItemLeft != 0)
	        {
	            this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemLeft;
	        }

	        if (this.heldItemRight != 0)
	        {
	            this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight;
	        }

	        this.bipedRightArm.rotateAngleY = 0.0F;
	        this.bipedLeftArm.rotateAngleY = 0.0F;
	        float f6;
	        float f7;

	        if (this.onGround > -9990.0F)
	        {
	            f6 = this.onGround;
	            this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI * 2.0F) * 0.2F;
	            this.bipedRightArm.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F;
	            this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
	            this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F;
	            this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
	            this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY;
	            this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY;
	            this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY;
	            f6 = 1.0F - this.onGround;
	            f6 *= f6;
	            f6 *= f6;
	            f6 = 1.0F - f6;
	            f7 = MathHelper.sin(f6 * (float)Math.PI);
	            float f8 = MathHelper.sin(this.onGround * (float)Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F;
	            this.bipedRightArm.rotateAngleX = (float)((double)this.bipedRightArm.rotateAngleX - ((double)f7 * 1.2D + (double)f8));
	            this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F;
	            this.bipedRightArm.rotateAngleZ = MathHelper.sin(this.onGround * (float)Math.PI) * -0.4F;
	        }

	        if (this.isSneak)
	        {
	            this.bipedBody.rotateAngleX = 0.5F;
	            this.bipedRightArm.rotateAngleX += 0.4F;
	            this.bipedLeftArm.rotateAngleX += 0.4F;
	            this.bipedRightLeg.rotationPointZ = 4.0F;
	            this.bipedLeftLeg.rotationPointZ = 4.0F;
	            this.bipedRightLeg.rotationPointY = 9.0F;
	            this.bipedLeftLeg.rotationPointY = 9.0F;
	            this.bipedHead.rotationPointY = 1.0F;
	            this.bipedHeadwear.rotationPointY = 1.0F;
	        }
	        else
	        {
	            this.bipedBody.rotateAngleX = 0.0F;
	            this.bipedRightLeg.rotationPointZ = 0.1F;
	            this.bipedLeftLeg.rotationPointZ = 0.1F;
	            this.bipedRightLeg.rotationPointY = 12.0F;
	            this.bipedLeftLeg.rotationPointY = 12.0F;
	            this.bipedHead.rotationPointY = 0.0F;
	            this.bipedHeadwear.rotationPointY = 0.0F;
	        }

	        this.bipedRightArm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
	        this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
	        this.bipedRightArm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F;
	        this.bipedLeftArm.rotateAngleX -= MathHelper.sin(f2 * 0.067F) * 0.05F;

	        if (this.aimedBow)
	        {
	            f6 = 0.0F;
	            f7 = 0.0F;
	            this.bipedRightArm.rotateAngleZ = 0.0F;
	            this.bipedLeftArm.rotateAngleZ = 0.0F;
	            this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F) + this.bipedHead.rotateAngleY;
	            this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F + this.bipedHead.rotateAngleY + 0.4F;
	            this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX;
	            this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX;
	            this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;
	            this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;
	            this.bipedRightArm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
	            this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
	            this.bipedRightArm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F;
	            this.bipedLeftArm.rotateAngleX -= MathHelper.sin(f2 * 0.067F) * 0.05F;
	        }
	    
	    float f61 = 0.0F;
            float f71 = 0.0F;
            EntityWarrior warrior = (EntityWarrior)entity;
            int i = warrior.getattackTimer();
            if(i > 0){
            this.bipedRightArm.rotateAngleZ = 0.0F;
            this.bipedLeftArm.rotateAngleZ = 0.0F;
            this.bipedRightArm.rotateAngleY = -(0.1F - f61 * 0.6F) + this.bipedHead.rotateAngleY;
            this.bipedLeftArm.rotateAngleY = 0.1F - f61 * 0.6F + this.bipedHead.rotateAngleY + 0.4F;
            this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX;
            this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX;
            this.bipedRightArm.rotateAngleX -= f61 * 1.2F - f71 * 0.4F;
            this.bipedLeftArm.rotateAngleX -= f61 * 1.2F - f71 * 0.4F;
            this.bipedRightArm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
            this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
            this.bipedRightArm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F;
            this.bipedLeftArm.rotateAngleX -= MathHelper.sin(f2 * 0.067F) * 0.05F;
	    }
	    }
	    
}

 

package com.OlympiansMod.entity;

import com.OlympiansMod.Item.ModItems;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAIMoveTowardsTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityGolem;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntityWarrior extends EntityMob implements IRangedAttackMob{
 private EntityAISmart aiSmart = new EntityAISmart(this);
 private EntityAIAvoidEntity aiPanic = new EntityAIAvoidEntity(this, EntityLiving.class, 0.8F, 0.8D, 0.8D);
 private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 17, 15.0F);
 private EntityAIAttackOnCollide aiAttackOnCollide2 = new EntityAIAttackOnCollide(this,  EntityLiving.class, 0.9D, false);
 private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this,  EntityPlayer.class, 0.9D, false);
private int attackTimer;
public EntityWarrior(World world) {
	super(world);
	this.tasks.addTask(1, new EntityAIWander(this, 0.4D));
	this.setSize(0.6F, 2F);
        this.tasks.addTask(1, new EntityAISwimming(this));
        this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 2.0D, 32.0F));
        this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D));
        this.tasks.addTask(4, new EntityAIWander(this, 0.6D));
        this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(6, new EntityAILookIdle(this));
        this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
        if (world != null && !world.isRemote)
        {
            this.setCombatTask();
        }
    
}
 protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.50000001192092896D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(120.0D);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(120.0D);
	       
	       
      
    }
   public void onLivingUpdate()
    {
	   

	   if(this.getAttackTarget() != null){
	   if(this.getAttackTarget().getDistanceSqToEntity(this) > 60.0D){
	   this.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
	   this.tasks.addTask(0, aiArrowAttack);
	   }
	   if(this.getAttackTarget().getDistanceSqToEntity(this) < 3.0D){
	   this.setCurrentItemOrArmor(0, new ItemStack(ModItems.CBronzeSword));
	   this.tasks.addTask(1, aiAttackOnCollide);
	   this.tasks.addTask(1, aiAttackOnCollide2);
	   this.tasks.removeTask(aiArrowAttack);
	   }
	   }
	   if(this.getHealth() <= 50){
		   this.tasks.addTask(0, aiPanic);
		   this.tasks.removeTask(aiArrowAttack);
		   
		   if(this.getAttackTarget() != null){
		   if(this.getAttackTarget().getDistanceSqToEntity(this) > 58.0D){
			   this.setCurrentItemOrArmor(0, new ItemStack(Items.potionitem)); 
		   }
		   }
	   }
	   if(this.getHealth() >= 55){
		   this.tasks.removeTask(aiPanic);
		   
	   
	   }
	   ItemStack itemstack = this.getHeldItem();

        
	   if(this.getAttackTarget() != null){
		   if(this.getAttackTarget().getDistanceSqToEntity(this) > 60.0D &&  itemstack.getItem() == Items.potionitem){
	   this.addPotionEffect(new PotionEffect(Potion.regeneration.id, 300, 4));
	   
		   }
		   
		   }
	   if (this.attackTimer > 0) {

			--this.attackTimer;
	   }
	super.onLivingUpdate();


}

    public boolean isAIEnabled(){
	return true;
    	
    }
    protected String getHurtSound()
    {
        return "random.classic_hurt";
    }

    protected String getDeathSound()
    {
        return "random.classic_hurt";
    }

public void setCombatTask() {

}
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) {
	int j = this.rand.nextInt(3);
	int k;

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

	k = 3 + this.rand.nextInt(3);

	for (int l = 0; l < k; ++l) {
		this.dropItem(Items.arrow, 1);
		this.dropItem(Items.bread, 2);

	}

}
    public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
    {
    	this.attackTimer = 10;
	this.worldObj.setEntityState(this, (byte) 4);
    	
        EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.difficultySetting.getDifficultyId() * 4));
        int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
        int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
        entityarrow.setDamage((double)(p_82196_2_ * 5.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.difficultySetting.getDifficultyId() * 0.11F));

        this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
        this.worldObj.spawnEntityInWorld(entityarrow);
    }
    @SideOnly(Side.CLIENT)
public int getattackTimer() {
	return this.attackTimer;

}
}


Im serious don't look at it!!

Posted

sorry I didn't really have time to explain. from looking at iron golem vanilla code I found a way to create an attack animation but for some reason it isn't working. and I do know that this is a way to do it, since ive done it with other mobs in my mod. so I should I fix this please

 

Im serious don't look at it!!

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

    • logs too big for one pastebin https://pastebin.com/ZjUGHu3u  https://pastebin.com/RqCUZf3X  https://pastebin.com/6ZPS99nD
    • You probably used jd-gui to open it, didn't you? Nothing wrong with that, I also made that mistake, except that Notch was a smart guy and he obfuscated the code. That's why you only see files called "a", "b", "c" and then a file that combines them all. As I said, use RetroMCP to deobfuscate the code so that you will 100% understand it and be able to navigate it.
    • Decompiling minecraft indev, infdev, alpha, beta or whichever legacy version is really easy. I'm not a plug, I just also got interested in modding legacy versions (Infdev to be specific). Use https://github.com/MCPHackers/RetroMCP-Java Once you install their client and the Zulu Architecture that they say they recommend (or use your own Java). I encountered some problems, so I run it with: "java -jar RetroMCP-Java-CLI.jar". You should run it in a seperate folder (not in downloads), otherwise the files and folders will go all over the place. How to use RetroMCP: Type setup (every time you want change version), copy-paste the version number from their list (they support indev), write "decompile" and done! The code will now be deobfuscated and filenames will be normal, instead of "a", "b" and "c"! Hope I helped you, but I don't expect you to reply, as this discussion is 9 years old! What a piece of history!  
    • I know that this may be a basic question, but I am very new to modding. I am trying to have it so that I can create modified Vanilla loot tables that use a custom enchantment as a condition (i.e. enchantment present = item). However, I am having trouble trying to implement this; the LootItemRandomChanceWithEnchantedBonusCondition constructor needs a Holder<Enchantment> and I am unable to use the getOrThrow() method on the custom enchantment declared in my mod's enchantments class. Here is what I have so far in the GLM:   protected void start(HolderLookup.Provider registries) { HolderLookup.RegistryLookup<Enchantment> registrylookup = registries.lookupOrThrow(Registries.ENCHANTMENT); LootItemRandomChanceWithEnchantedBonusCondition lootItemRandomChanceWithEnchantedBonusCondition = new LootItemRandomChanceWithEnchantedBonusCondition(0.0f, LevelBasedValue.perLevel(0.07f), registrylookup.getOrThrow(*enchantment here*)); this.add("nebu_from_deepslate", new AddItemModifier(new LootItemCondition[]{ LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.DEEPSLATE).build(), LootItemRandomChanceCondition.randomChance(0.25f).build(), lootItemRandomChanceWithEnchantedBonusCondition }, OrichalcumItems.NEBU.get())); }   Inserting Enchantments.[vanilla enchantment here] actually works but trying to declare an enchantment from my custom enchantments class as [mod enchantment class].[custom enchantment] does not work even though they are both a ResourceKey and are registered in Registries.ENCHANTMENT. Basically, how would I go about making it so that a custom enchantment declared as a ResourceKey<Enchantment> of value ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath([modid], [name])), declared in a seperate enchantments class, can be used in the LootItemRandomChanceWithEnchantedBonusCondition constructor as a Holder? I can't use getOrThrow() because there is no level or block entity/entity in the start() method and it is running as datagen. It's driving me nuts.
  • Topics

×
×
  • Create New...

Important Information

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