Skip to content

Commit

Permalink
Merge pull request #41 from Fi0x/featureEntity
Browse files Browse the repository at this point in the history
Feature entity
  • Loading branch information
Fi0x authored Jun 18, 2020
2 parents a6d429b + 26d00b1 commit b30478c
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 147 deletions.
32 changes: 0 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,43 +99,11 @@ Deep Crystal Powder

## Blocks / Fluids
### Insanity Blocks / Fluids
Insanity Planks (Block, Stairs, Slabs)
- Like Oak-Planks
- Texture is more red

Insanity Wood
- part of the insanity tree

Insanity Leaves
- part of the insanity tree

Insanity Sapling
- grows into an insanity tree

Insanity Water
- Like regular Water
- Texture is more purple

### Other
Clean Stone Slabs and Stairs

Deep Crystal Block
- Block-version of the Deep Crystal

Deep Crystal Ore
- Ore that drops Deep Crystals
- Overworld, Nether and End-versions

Effect-Stones
- Stones with several Potion or other effects
- Defence: Pushes mobs away
- Attack: Damages mobs
- Speed: Speed Buff to players
- Heal: Regeneration effect to players
- Vision: Night vision to players
- Saturation: Saturation effect to players
- Levitation: Propells players up

##Commands
/tpdim
- Alias: /tpdimension
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/POLISHING
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ change shape of insanity trees
change item model of insanity sapling and flower to normal item
add custom music to insanity dimension
fix structures get destroyed by lake spawn
fix todos in EntityAISpellAttack
fix todos in EntityAISpellAttack and EntityDepthMage
7 changes: 3 additions & 4 deletions src/main/java/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ Mobs {
Cyclopse
Giant
create loottable
shrink hitbox
adjust eye height
Hovering Orb
improve pathfinding (can't find path to target (due to hovering?))
EntityAIRandomFly
make it work
Passives
Rock Troll
add animation to defence mechanism
fix standing still animation
Mage of the Depths
create custom loottable
optimize ai
add different spells as attack
add custom sounds
Insanity Cow
create loottable
Expand Down
52 changes: 41 additions & 11 deletions src/main/java/com/fi0x/deepmagic/entities/EntityDepthMage.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.fi0x.deepmagic.entities;

import com.fi0x.deepmagic.entities.projectiles.EntitySpellFireball;
import com.fi0x.deepmagic.util.CustomNameGenerator;
import com.fi0x.deepmagic.util.handlers.LootTableHandler;
import com.fi0x.deepmagic.util.handlers.SoundsHandler;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -22,22 +21,22 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class EntityDepthMage extends EntityCreature
public class EntityDepthMage extends EntityCreature implements IRangedAttackMob
{
public EntityDepthMage(World worldIn)
{
super(worldIn);
this.setSize(1F, 2F);
this.setCustomNameTag(CustomNameGenerator.getRandomMageName());
}

@Override
protected void initEntityAI()
{
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAttackMelee(this, 1, false));
this.tasks.addTask(2, new EntityAIMoveTowardsRestriction(this, 1.0D));
this.tasks.addTask(2, new EntityAIAttackRanged(this, 1.0D, 40, 20.0F));
this.tasks.addTask(3, new EntityAIWanderAvoidWater(this, 1.0D));
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityCreature.class, 8.0F));
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
this.tasks.addTask(5, new EntityAILookIdle(this));

this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, false));
Expand All @@ -50,8 +49,8 @@ protected void applyEntityAttributes()
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);

this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(100.0D);
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(100.0D);
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(32.0D);
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D);
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6);
}
Expand Down Expand Up @@ -87,7 +86,7 @@ protected ResourceLocation getLootTable()
@Override
public float getEyeHeight()
{
return 1.8F;
return 1.75F;
}

@Override
Expand Down Expand Up @@ -143,4 +142,35 @@ public boolean attackEntityAsMob(@Nonnull Entity entityIn)

return flag;
}

@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
launchProjectileToCoords(target.posX, target.posY + target.getEyeHeight()*0.5, target.posZ);
}

//TODO: Fill with Wither data
@Override
public void setSwingingArms(boolean swingingArms) {

}

private void launchProjectileToCoords(double x, double y, double z)
{
this.world.playEvent(null, 1024, new BlockPos(this), 0);
double d0 = getPosition().getX();
double d1 = getPosition().getY() + getEyeHeight();
double d2 = getPosition().getZ();
double d3 = x - d0;
double d4 = y - d1;
double d5 = z - d2;
EntitySpellFireball fireball = new EntitySpellFireball(world, this, d3, d4, d5);

fireball.setEntityInvulnerable(true);

fireball.posY = d1;
fireball.posX = d0;
fireball.posZ = d2;
this.world.spawnEntity(fireball);
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/fi0x/deepmagic/entities/EntityGiant.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ protected void initEntityAI()
this.tasks.addTask(5, new EntityAILookIdle(this));

this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityInsanityCow.class, true));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityDepthMage.class, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
}

@Override
Expand Down
62 changes: 9 additions & 53 deletions src/main/java/com/fi0x/deepmagic/entities/EntityHoveringOrb.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.fi0x.deepmagic.entities;

import com.fi0x.deepmagic.entities.ai.EntityAIRandomFly;
import com.fi0x.deepmagic.util.handlers.LootTableHandler;
import com.fi0x.deepmagic.util.handlers.SoundsHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.World;

import javax.annotation.Nonnull;
Expand All @@ -34,12 +33,9 @@ public EntityHoveringOrb(World worldIn)
@Override
protected void initEntityAI()
{
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAttackMelee(this, 1, false));
this.tasks.addTask(1, new EntityAILeapAtTarget(this, 0.5F));
this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D));
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.tasks.addTask(2, new EntityAIRandomFly(this, 1));

this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, EntityPigZombie.class));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
Expand All @@ -50,16 +46,12 @@ protected void applyEntityAttributes()
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16);
getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.27);
getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(25.0D);
getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(32.0D);
getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(10.0D);
getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.1);
getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(1);
}
@Override
public void onLivingUpdate()
{
super.onLivingUpdate();
}
@Override
public float getEyeHeight()
{
return 0.5F;
Expand All @@ -84,7 +76,6 @@ protected void playStepSound(@Nonnull BlockPos pos, @Nonnull Block blockIn)
{
this.playSound(SoundsHandler.ENTITY_HOVERING_ORB_STEP, 1F, 1F);
}

@Override
protected float getSoundVolume()
{
Expand All @@ -96,39 +87,4 @@ protected ResourceLocation getLootTable()
{
return LootTableHandler.HOVERING_ORB;
}

@Override
public void onUpdate()
{
super.onUpdate();
if(world.getBlockState(this.getPosition().down()) == Blocks.AIR.getDefaultState())
{
IBlockState ground = world.getBlockState(this.getPosition().down().down());
if(ground != Blocks.AIR.getDefaultState() && !(ground instanceof BlockBush))
{
this.addVelocity(0,-this.motionY, 0);
} else
{
this.addVelocity(0, -0.05, 0);
}
} else
{
this.addVelocity(0,0.1,0);
}
this.onGround = true;
}

@Nullable
@Override
public IEntityLivingData onInitialSpawn(@Nonnull DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
{
this.posY += 1;
return super.onInitialSpawn(difficulty, livingdata);
}

@Override
public void spawnRunningParticles()
{
this.createRunningParticles();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
public class EntityRockTroll extends EntityCreature
{
public boolean defenceState;
public int defenceTime;

public EntityRockTroll(World worldIn)
{
super(worldIn);
setSize(2F, 2.5F);
this.isImmuneToFire = true;
defenceState = false;
defenceTime = 0;
this.setCustomNameTag(CustomNameGenerator.getRandomTrollName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ public boolean shouldExecute()
public void startExecuting()
{
this.creature.defenceState = true;
this.creature.defenceTime = 5*20;
}

public boolean shouldContinueExecuting()
{
if(creature.ticksExisted - startTick > 5*20)
if(creature.defenceTime <= 0)
{
creature.defenceState = false;
return false;
}
creature.defenceTime--;
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.fi0x.deepmagic.entities.ai;

import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityAIWanderAvoidWater;
import net.minecraft.util.math.Vec3d;

public class EntityAIRandomFly extends EntityAIWanderAvoidWater
{
private final EntityLiving entity;

public EntityAIRandomFly(EntityLiving entity, double speed)
{
super((EntityCreature) entity, speed);
this.entity = entity;
this.executionChance = 50;
this.setMutexBits(1);
}

@Override
public boolean shouldExecute()
{
if (!this.mustUpdate)
{
if (this.entity.getIdleTime() >= 100)
{
return false;
}

if (this.entity.getRNG().nextInt(this.executionChance) != 0)
{
return false;
}
}

Vec3d vec3d = this.getPosition();

if (vec3d == null)
{
return false;
}
else
{
this.x = vec3d.x;
this.y = vec3d.y;
this.z = vec3d.z;
this.mustUpdate = false;
return true;
}
}

@Override
public boolean shouldContinueExecuting()
{
return super.shouldContinueExecuting();
}

public void startExecuting()
{
this.entity.getNavigator().tryMoveToXYZ(this.x, this.y, this.z, this.speed);
}
}
Loading

0 comments on commit b30478c

Please sign in to comment.