Jump to content

clearcut

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by clearcut

  1. 			while(startingHealth - victim.getHealth() < flatDamageCap && (victim.getHealth() / maxHealth) > damagePercentageCap)
    			{
    				if((victim.ticksExisted - startingTime) % 10 == 0 ) 
    				{
    					//do damage
    				}
    			}

    This is more or less how I wanted it to work. It would keep checking it the total damage dealth by the method reaches the flat damage cap or percentage damage cap and would only deal damage on the 10th tick

  2. Ah, I didn't know about the overwriting.

    			stand.writeAdditional(compound);
    			compound.putBoolean("ShowArms", true);

    Adding the lines above before the readAdditional method seems to work but does it fix the overwriting issue?

    I wanted to find a work around using setShowArms since I did not know how to use it.

  3. Thanks, it now works

    For anyone else trying to do this, the final code is:

    package com.chaoticsoul.evolate.events;
    import com.chaoticsoul.evolate.Evolate;
    
    import net.minecraft.entity.item.ArmorStandEntity;
    import net.minecraft.nbt.CompoundNBT;
    import net.minecraft.network.datasync.DataParameter;
    import net.minecraft.network.datasync.DataSerializers;
    import net.minecraft.network.datasync.EntityDataManager;
    import net.minecraftforge.event.entity.EntityJoinWorldEvent;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
    
    @Mod.EventBusSubscriber(modid = Evolate.MOD_ID, bus = Bus.FORGE)
    public class SpawnArmorStandEvent {
    	@SubscribeEvent
    	public static void spawnArmorStandEvent(EntityJoinWorldEvent event)
    	{
    		if (event.getEntity() instanceof ArmorStandEntity)
    		{
    			ArmorStandEntity stand = (ArmorStandEntity) event.getEntity();
    			CompoundNBT compound = new CompoundNBT();
    			compound.putBoolean("ShowArms", true);
    			stand.readAdditional(compound);
    		}
    	}
    	
    
    }

     

  4. I am trying to make an event that will spawn armor stands with arms whenever an armor stand is spawned but I cannot get it to work.

    I included a logger to see if it gets past the if statement that checks if the entity spawned was an armor stand and it does not log anything so I am assuming that is the problem(I put one outside of the if statement and it does log when things spawn).

    Any ideas?

     

    package com.chaoticsoul.evolate.events;
    import com.chaoticsoul.evolate.Evolate;
    
    import net.minecraft.entity.item.ArmorStandEntity;
    import net.minecraft.nbt.CompoundNBT;
    import net.minecraftforge.event.entity.living.LivingSpawnEvent;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
    
    @Mod.EventBusSubscriber(modid = Evolate.MOD_ID, bus = Bus.FORGE)
    public class SpawnArmorStandEvent {
    
    	@SubscribeEvent
    	public static void spawnArmorStandEvent(LivingSpawnEvent event)
    	{
    		if (event.getEntityLiving() instanceof ArmorStandEntity)
    		{
    			Evolate.LOGGER.info("test");
    			ArmorStandEntity stand = (ArmorStandEntity) event.getEntityLiving();
    			CompoundNBT compound = new CompoundNBT();
    			compound.putBoolean("ShowArms", true);
    			stand.writeAdditional(compound);
    		}
    	}
    	
    
    }

    Also, I am new to nbt data so that part may be wrong as well.

  5. It is finally fixed! Thanks for the help

     

     

     

    For the people having the same issue as me.

    super(modelSize, 0, 128, 128);

     

    ^I implemented this change and followed this tutorial below to update all my classes.

    2 hours ago, ChampionAsh5357 said:

    That made the model look a bit better as it fixed the double rendering issue. However, I still had the same issue.

     

     

    I then found out that the problem was as below.

           ModelRenderer LeftBoot = new ModelRenderer(this, 0, 13);
    	LeftBoot.setTextureOffset(22, 53).addBox(-3.0F, 8.0F, -3.0F, 1.0F, 4.0F, 6.0F, 0.0F, 0.0F, 0.0F);

    This makes the group "LeftBoot" as well as all my other groups that were declared have a texture offset(that is the "0,13").

     

    In tabula, to find the texture offset for a box, it adds the texture offset from the group to the texture offset from the individual boxes and so your model will look normal.

    However, in game it does not work the same way.

     

     

    	LeftBoot = new ModelRenderer(this);
            LeftBoot.setTextureOffset(22, 66).addBox(-3.0F, 8.0F, -3.0F, 1.0F, 4.0F, 6.0F, 0.0F, 0.0F, 0.0F);

     

    To fix this, I changed the declaration of all my groups to be declared as above. This makes the group texture offset (0,0) then you can add the numbers that were in the group's texture offset to each of the boxes in that group.

  6. My textures have been changed to make sure that nothing is in the 64 x 32 area so I believe that shouldnt get in the way of the default model rendering.

     

    But I still do not understand why the textures on the model are so off.

    17 hours ago, ChampionAsh5357 said:

    When declaring the width, height, or depth of your model, it adjusts the scale of the texture needed to be wrapped. In the example I took from you, a width and height of 5.0 and 4.0 are fine. However, .26 is not so much. Even though in the tabula it will look normal, Minecraft will actually take your image, scale it up, and reference it as if it was literally 0.26 instead of what tabula outputs. So in your case, to have a correctly mapped texture, it would need to be scaled up to 6400x3200 to correctly map those decimal values.

    I thought this might be the same problem for me but I do not have any decimals and I tried playing around with scaling the texture up aswell as increasing textureHeight and textureWidth in the model but It does not make it any better.

     

    Thanks for your help so far btw,

    onyx_armor2.png

  7. On 7/7/2020 at 4:55 PM, ChampionAsh5357 said:

    Do you have a picture of what it is supposed to look like because from what I can gather, the model seems to be rendering the way you wrote it.

     

    Fun fact about global and local ModelRenderers: If you make a global ModelRenderer a child of some other model, it will render twice! So, for every ModelRenderer you add, you need to make them local variables within your constructor to prevent that. Also, you shouldn't need to copyModelAngles if they are a child of the parent ModelRenderer.

     

    Also, make sure you are using the newest version of tabula released for 1.15 if you are creating models.

    http://prntscr.com/teaidw 

    ^how to textures look in tabula(im using the latest version btw 8.0.1 for 1.15)

     

            ModelRenderer helmetLocal = this.Helmet;
            ModelRenderer chestplateLocal = this.Chestplate;
            ModelRenderer leftSleeveLocal = this.LeftSleeve;
            ModelRenderer rightSleeveLocal = this.RightSleeve;
            ModelRenderer rightLeggingLocal = this.RightLegging;
            ModelRenderer leftLeggingLocal = this.LeftLegging;
            ModelRenderer rightBootLocal = this.RightBoot;
            ModelRenderer leftBootLocal = this.LeftBoot;

    ^ also i'm not sure if this is what you meant with the local variables and would the double rendering cause the incorrect textures

     

     

  8. Just to make sure, does it animate correctly?

    If it does, then the way I fixed the problem you are having was by going in to tabula(what I used instead of blockbench) and opening up the player model. Then, make all of your parts childs of the player model. e.g. make helmet a child of the head. Once it is like that you should re align all of your parts so they are in the right place before removing them as children (even if it looks wrong) and deleting the player model from it and then exporting the model and doing the rest again.

  9. On 3/22/2020 at 2:08 PM, ChampionAsh5357 said:

    That's probably because you didn't align anything relative to the head. When you add something as a child model, everything becomes relative to the that specific renderer and not the entire model. So you have reorient everything in terms of the specific renderer.

    I think I am having the same problem with textures but I do not understand how to do this, could you elaborate please?

  10. I am now having other problems regarding this item.

    the item shows up in game like in the screenshots.

     

    I don't know where the item model (for when it is in hand) is stored so that I can change it and use it for my item. I assumed it would be in the json files but I have tried to copy and change it to my item with no difference.

     

    Also, after I hold right click to throw the "trident" the entity model does not render but it still collides with entities/ blocks and makes noise.

     

    These are all the files related to the item. (I know I shouldn't be copying big blocks of code but I am trying to understand how things work before I make my own things from scratch.):

     

    https://github.com/clearcut01/evolate

    2019-08-13_17.12.06.png

    2019-08-13_17.12.09.png

  11. package com.chaoticsoul.evolate.items;
    
    import net.minecraft.item.TridentItem;
    
    
    public class Gungnir extends TridentItem {
    
    	public Gungnir(Properties builder) {
    		super(builder);
    		
    	}
    	@Override
    	public int getItemEnchantability() {
    		return 0;
    	}
    	
    }

    This is the code. I want to make a custom trident and so am trying to see if the trident works before adding extra functionality but this does not work.

    In game it works like a standard item that does nothing when you right click or hold right click and is able to have a stack of up to 64. 

    The only thing that works is that it has the correct attack damage and attack speed

  12. I made a left click event so that left clicking will fire out a fireball (I will make it specific to some items after I get it to work)

    I have got this to work on a right click event in the tool class and it works fine.

    package com.ChaoticSoul.MoreArmor.items.tools;
    
    import com.ChaoticSoul.MoreArmor.Main;
    import com.ChaoticSoul.MoreArmor.init.ModItems;
    import com.ChaoticSoul.MoreArmor.util.IHasModel;
    
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.projectile.EntityLargeFireball;
    import net.minecraft.item.ItemStack;
    import net.minecraft.item.ItemSword;
    import net.minecraft.util.ActionResult;
    import net.minecraft.util.EnumActionResult;
    import net.minecraft.util.EnumHand;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.util.math.Vec3d;
    import net.minecraft.world.World;
    
    public class ToolSword extends ItemSword implements IHasModel
    {
    	
    	public ToolSword(String name, ToolMaterial material)
    	{
    		super(material);
    		setUnlocalizedName(name);
    		setRegistryName(name);
    		setCreativeTab(CreativeTabs.COMBAT);
    		
    		
    		ModItems.ITEMS.add(this);
    	}
    	
    	@Override
    	public void registerModels() 
    	{
    		Main.proxy.registerItemRenderer(this, 0, "inventory");
    		
    	}
    	
    	public ActionResult<ItemStack> onEntitySwing(EntityLivingBase entityLiving, ItemStack stack, EnumHand handIn, World worldIn) {
    		ItemStack item = entityLiving.getHeldItem(handIn);
    		Vec3d aim = entityLiving.getLookVec();
    		EntityLargeFireball fireball = new EntityLargeFireball(worldIn, entityLiving, 1, 1, 1);
    		
    		fireball.setPosition(entityLiving.posX, entityLiving.posY, entityLiving.posZ);
    		fireball.accelerationX = aim.x * 0.1; fireball.accelerationY = aim.y * 0.1; fireball.accelerationZ = aim.z * 0.1;
    		worldIn.spawnEntity(fireball);
    		
    		item.damageItem(1, entityLiving);
    		return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item);
    	}
    	@Override
    	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    		ItemStack item = playerIn.getHeldItem(handIn);
    		Vec3d aim = playerIn.getLookVec();
    		EntityLargeFireball fireball = new EntityLargeFireball(worldIn, playerIn, 1, 1, 1);
    		
    		fireball.setPosition(playerIn.posX, playerIn.posY, playerIn.posZ);
    		fireball.accelerationX = aim.x * 0.1; fireball.accelerationY = aim.y * 0.1; fireball.accelerationZ = aim.z * 0.1;
    		worldIn.spawnEntity(fireball);
    		
    		item.damageItem(1, playerIn);
    		return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item);
    	}
    
    }
    	
    

    I then made a left click event which spawns and fires the fireball correctly but the fireball just travels through all entities and blocks without interacting in any way.

    package com.ChaoticSoul.MoreArmor.events;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.projectile.EntityLargeFireball;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.ActionResult;
    import net.minecraft.util.EnumActionResult;
    import net.minecraft.util.EnumHand;
    import net.minecraft.util.math.Vec3d;
    import net.minecraft.world.World;
    import net.minecraftforge.event.entity.player.PlayerInteractEvent;
    import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickEmpty;
    import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
    
    public class MAEventHandler {
    	@SubscribeEvent
    	public ActionResult<ItemStack> leftClick(LeftClickEmpty event) {
    		ItemStack item = event.getEntityPlayer().getHeldItemMainhand();
    		Vec3d aim = event.getEntityPlayer().getLookVec();
    		World worldIn = event.getEntityPlayer().getEntityWorld();
    		EntityPlayer playerIn = event.getEntityPlayer(); 
    		EntityLargeFireball fireball = new EntityLargeFireball(worldIn, playerIn, 1, 1, 1);
    		
    		fireball.setPosition(playerIn.posX, playerIn.posY, playerIn.posZ);
    		fireball.accelerationX = aim.x * 0.1; fireball.accelerationY = aim.y * 0.1; fireball.accelerationZ = aim.z * 0.1;
    		worldIn.spawnEntity(fireball);
    		
    		item.damageItem(1, playerIn);
    		return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item);
    	}
    
    }

     

  13. package com.ChaoticSoul.MoreArmor.entity;
    
    import java.util.Set;
    
    import com.ChaoticSoul.MoreArmor.init.ModItems;
    import com.google.common.collect.Sets;
    
    import net.minecraft.entity.EntityLiving;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.IRangedAttackMob;
    import net.minecraft.entity.SharedMonsterAttributes;
    import net.minecraft.entity.ai.EntityAIAttackRanged;
    import net.minecraft.entity.ai.EntityAIFollow;
    import net.minecraft.entity.ai.EntityAILookIdle;
    import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
    import net.minecraft.entity.ai.EntityAIWatchClosest;
    import net.minecraft.entity.monster.IMob;
    import net.minecraft.entity.passive.EntityHorse;
    import net.minecraft.entity.passive.HorseArmorType;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.PlayerCapabilities;
    import net.minecraft.init.Items;
    import net.minecraft.init.MobEffects;
    import net.minecraft.init.SoundEvents;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.network.datasync.DataParameter;
    import net.minecraft.network.datasync.DataSerializers;
    import net.minecraft.network.datasync.EntityDataManager;
    import net.minecraft.util.DamageSource;
    import net.minecraft.util.EnumHand;
    import net.minecraft.util.SoundEvent;
    import net.minecraft.util.math.MathHelper;
    import net.minecraft.world.World;
    
    public class EntityPegasus2 extends EntityHorse implements IRangedAttackMob
    {
        private boolean allowStandSliding;
        public EntityPegasus2(World worldIn)
        {
            super(worldIn);
    		setSize(1.2F, 2.0F);
        }
        
        @Override
    	public SoundEvent getAmbientSound() {
       	return SoundEvents.ENTITY_HORSE_AMBIENT;
       }
       
        @Override
       protected SoundEvent getDeathSound() {
        	return SoundEvents.ENTITY_HORSE_DEATH;
       }
       @Override
       protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
       	return SoundEvents.ENTITY_HORSE_HURT;
       }
       
       protected void applyEntityAttributes()
       {
           super.applyEntityAttributes();
    
           
           this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
           this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(6);
           this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D);
           
           
       }
    	protected void initEntityAI() 
    	{
    	    this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 40, 10.0F));
    	    this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    	    this.tasks.addTask(4, new EntityAILookIdle(this));
    	    this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 10, true, false, IMob.MOB_SELECTOR));
            this.tasks.addTask(1, new EntityAIFollow(this, 2.0D, 3.0F, 7.0F));
    	}
    
    	@Override
    	public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
    		this.spit(target);
    		
    	}
        private void spit(EntityLivingBase target)
        {
        	
    		EntityPegasusProjectile entitypegasusprojectile = new EntityPegasusProjectile(this.world, this);
            double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
            double d1 = target.posX - this.posX;
            double d2 = d0 - entitypegasusprojectile.posY;
            double d3 = target.posZ - this.posZ;
            float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
            entitypegasusprojectile.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F);
            this.playSound(SoundEvents.ENTITY_LLAMA_SPIT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
            this.world.spawnEntity(entitypegasusprojectile);
    
        }
    
    	@Override
    	public void setSwingingArms(boolean swingingArms) {
    		// TODO Auto-generated method stub
    		
    	}
        protected void mountTo(EntityPlayer player)
        {
            player.rotationYaw = this.rotationYaw;
            player.rotationPitch = this.rotationPitch;
    
    
            if (!this.world.isRemote)
            {
                player.startRiding(this);
            }
        }
        private static final Set<Item> TAME_ITEMS = Sets.newHashSet(ModItems.SAPPHIRE);
        private static final Item DEADLY_ITEM = ModItems.ANTI_PET_CHARM;
        private static final DataParameter<Float> DATA_HEALTH_ID = EntityDataManager.<Float>createKey(EntityPegasus2.class, DataSerializers.FLOAT);
    	
        @Override
        public boolean isHorseSaddled()
          {
              return true;
          }
        @Override
        public boolean isTame() {
        	return true;
        }
    
        @Override
        public void travel(float strafe, float vertical, float forward)
        {
            if (this.isBeingRidden() && this.canBeSteered() && this.isHorseSaddled())
            {
            	
                EntityLivingBase entitylivingbase = (EntityLivingBase)this.getControllingPassenger();
                this.rotationYaw = entitylivingbase.rotationYaw;
                this.prevRotationYaw = this.rotationYaw;
                this.rotationPitch = entitylivingbase.rotationPitch * 0.5F;
                this.setRotation(this.rotationYaw, this.rotationPitch);
                this.renderYawOffset = this.rotationYaw;
                this.rotationYawHead = this.renderYawOffset;
                strafe = entitylivingbase.moveStrafing * 0.5F;
                forward = entitylivingbase.moveForward;
    
                if (forward <= 0.0F)
                {
                    forward *= 0.25F;
                    this.gallopTime = 0;
                }
    
                if (this.onGround && this.jumpPower == 0.0F && this.isRearing() && !this.allowStandSliding)
                {
                    strafe = 0.0F;
                    forward = 0.0F;
                }
                if (this.jumpPower > 0.0F && !this.isHorseJumping() && this.onGround)
                {
                    this.motionY = this.getHorseJumpStrength() * (double)this.jumpPower;
    
                    if (this.isPotionActive(MobEffects.JUMP_BOOST))
                    {
                        this.motionY += (double)((float)(this.getActivePotionEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1) * 0.1F);
                    }
    
                    this.setHorseJumping(true);
                    this.isAirBorne = true;
    
                    if (forward > 0.0F)
                    {
                        float f = MathHelper.sin(this.rotationYaw * 0.017453292F);
                        float f1 = MathHelper.cos(this.rotationYaw * 0.017453292F);
                        this.motionX += (double)(-0.4F * f * this.jumpPower);
                        this.motionZ += (double)(0.4F * f1 * this.jumpPower);
                        this.playSound(SoundEvents.ENTITY_HORSE_JUMP, 0.4F, 1.0F);
                    }
    
                    this.jumpPower = 0.0F;
                }
    
                this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;
    
                if (this.canPassengerSteer())
                {
                    this.setAIMoveSpeed((float)this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue());
                    super.travel(strafe, vertical, forward);
                }
                else if (entitylivingbase instanceof EntityPlayer)
                {
                    this.motionX = 0.0D;
                    this.motionY = 0.0D;
                    this.motionZ = 0.0D;
                }
    
                if (this.onGround)
                {
                    this.jumpPower = 0.0F;
                    this.setHorseJumping(false);
                }
    
                this.prevLimbSwingAmount = this.limbSwingAmount;
                double d1 = this.posX - this.prevPosX;
                double d0 = this.posZ - this.prevPosZ;
                float f2 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F;
    
                if (f2 > 1.0F)
                {
                    f2 = 1.0F;
                }
    
                this.limbSwingAmount += (f2 - this.limbSwingAmount) * 0.4F;
                this.limbSwing += this.limbSwingAmount;
            }
            else
            {
                this.jumpMovementFactor = 0.02F;
                super.travel(strafe, vertical, forward);
            }
        }
    }

    I have made a mob that extends EntityHorse so that I am able to ride and control it. But I do not know how I can change the travel method to allow me to double tap space bar to fly and have another keybind in order to descend (as if I was using creative flight but it is not shift to descend as that would dismount).

    PS: I am still new to Minecraft modding so go easy.

     

×
×
  • Create New...

Important Information

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