Skip to content

Commit

Permalink
camp raider walk setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Raycoms committed Dec 16, 2024
1 parent a8774b2 commit f96480e
Show file tree
Hide file tree
Showing 67 changed files with 437 additions and 381 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.minecolonies.api.client.render.modeltype;

import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob;
import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMonster;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import org.jetbrains.annotations.NotNull;

/**
* Amazon model.
*/
public class AmazonModel<T extends AbstractEntityMinecoloniesMob> extends HumanoidModel<AbstractEntityMinecoloniesMob>
public class AmazonModel<T extends AbstractEntityMinecoloniesMonster> extends HumanoidModel<AbstractEntityMinecoloniesMonster>
{
public AmazonModel(final ModelPart part)
{
super(part);
}

@Override
public void setupAnim(@NotNull final AbstractEntityMinecoloniesMob entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch)
public void setupAnim(@NotNull final AbstractEntityMinecoloniesMonster entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch)
{
super.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
head.y -= 3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.minecolonies.api.client.render.modeltype;

import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob;
import com.minecolonies.api.entity.mobs.egyptians.AbstractEntityEgyptianRaider;
import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMonster;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;

/**
* Egyptian model.
*/
public class EgyptianModel<T extends AbstractEntityMinecoloniesMob> extends HumanoidModel<AbstractEntityMinecoloniesMob>
public class EgyptianModel<T extends AbstractEntityMinecoloniesMonster> extends HumanoidModel<AbstractEntityMinecoloniesMonster>
{
/**
* Create a model of a specific size.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.minecolonies.api.client.render.modeltype;

import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob;
import com.minecolonies.api.entity.mobs.vikings.AbstractEntityNorsemenRaider;
import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMonster;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;

/**
* Norsemen model.
*/
public class NorsemenModel extends HumanoidModel<AbstractEntityMinecoloniesMob>
public class NorsemenModel extends HumanoidModel<AbstractEntityMinecoloniesMonster>
{
/**
* Create a model of a specific size.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.minecolonies.api.colony.ICitizenData;
import com.minecolonies.api.colony.colonyEvents.IColonyRaidEvent;
import com.minecolonies.api.entity.mobs.AbstractEntityRaiderMob;
import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesRaider;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;

Expand Down Expand Up @@ -216,7 +216,7 @@ default RaidSpawnResult raiderEvent(String raidType, final boolean overrideConfi
*
* @param entity
*/
void onRaiderDeath(AbstractEntityRaiderMob entity);
void onRaiderDeath(AbstractEntityMinecoloniesRaider entity);

void onRaidEventFinished(IColonyRaidEvent event);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/minecolonies/api/entity/ModEntities.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.minecolonies.api.entity;

import com.minecolonies.api.entity.citizen.AbstractEntityCitizen;
import com.minecolonies.api.entity.mobs.AbstractEntityRaiderMob;
import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesRaider;
import com.minecolonies.api.entity.mobs.amazons.AbstractEntityAmazon;
import com.minecolonies.api.entity.mobs.amazons.AbstractEntityAmazonRaider;
import com.minecolonies.api.entity.mobs.barbarians.AbstractEntityBarbarian;
Expand Down Expand Up @@ -118,7 +118,7 @@ public class ModEntities

public static EntityType<? extends AbstractDrownedEntityPirate> CAMP_DROWNED_ARCHERPIRATE;

public static List<EntityType<? extends AbstractEntityRaiderMob>> getRaiders()
public static List<EntityType<? extends AbstractEntityMinecoloniesRaider>> getRaiders()
{
return List.of(
BARBARIAN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public int getThreatFor(final LivingEntity attacker)
}
}

return 0;
return -1;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,51 @@
import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry;
import com.minecolonies.api.sounds.RaiderSounds;
import com.minecolonies.api.util.Log;
import com.minecolonies.api.util.MathUtils;
import com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate;
import com.minecolonies.core.entity.pathfinding.navigation.PathingStuckHandler;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.Tuple;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.monster.Enemy;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.common.util.ITeleporter;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;

import static com.minecolonies.api.entity.citizen.AbstractEntityCitizen.ENTITY_AI_TICKRATE;
import static com.minecolonies.api.entity.mobs.RaiderMobUtils.MOB_ATTACK_DAMAGE;
import static com.minecolonies.api.util.constant.NbtTagConstants.*;
import static com.minecolonies.api.util.constant.RaiderConstants.*;

/**
* Abstract for all raider entities.
*/
public abstract class AbstractEntityMinecoloniesMob extends AbstractFastMinecoloniesEntity implements IThreatTableEntity, Enemy
public abstract class AbstractEntityMinecoloniesMonster extends AbstractFastMinecoloniesEntity implements IThreatTableEntity, Enemy
{
/**
* The New PathNavigate navigator.
*/
protected AbstractAdvancedPathNavigate newNavigator;

/**
* The current tick since creation.
* The invulnerability timer for spawning, to prevent suffocate/grouping damage.
*/
private int currentTick = 0;
private int invulTime = 2 * 20;

/**
* The invulnerability timer for spawning, to prevent suffocate/grouping damage.
* Texture id of the pirates.
*/
private int invulTime = 2 * 20;
private int textureId;

/**
* Counts entity collisions
Expand All @@ -62,12 +68,6 @@ public abstract class AbstractEntityMinecoloniesMob extends AbstractFastMinecolo
* The collision threshold
*/
private final static int COLL_THRESHOLD = 50;
private final static String RAID_TEAM = "RAIDERS_TEAM";

/**
* Mob difficulty
*/
private double difficulty = 1.0d;

/**
* The threattable of the mob
Expand All @@ -80,12 +80,17 @@ public abstract class AbstractEntityMinecoloniesMob extends AbstractFastMinecolo
private ITickRateStateMachine<IState> ai = new TickRateStateMachine<>(CombatAIStates.NO_TARGET, e -> Log.getLogger().warn(e), ENTITY_AI_TICKRATE);

/**
* Constructor method for Abstract Barbarians.
* Initial spawn pos of the entity.
*/
private BlockPos spawnPos = null;

/**
* Constructor method for Abstract minecolonies mobs.
*
* @param world the world.
* @param type the entity type.
*/
public AbstractEntityMinecoloniesMob(final EntityType<? extends AbstractEntityMinecoloniesMob> type, final Level world)
public AbstractEntityMinecoloniesMonster(final EntityType<? extends AbstractEntityMinecoloniesMonster> type, final Level world)
{
super(type, world);
this.setPersistenceRequired();
Expand All @@ -96,6 +101,19 @@ public AbstractEntityMinecoloniesMob(final EntityType<? extends AbstractEntityMi
RaiderMobUtils.setEquipment(this);
}

/**
* Constructor method for Abstract minecolonies mobs.
*
* @param world the world.
* @param type the entity type.
* @param textureCount the texture count.
*/
public AbstractEntityMinecoloniesMonster(final EntityType<? extends AbstractEntityMinecoloniesMonster> type, final Level world, final int textureCount)
{
this(type, world);
this.textureId = MathUtils.RANDOM.nextInt(textureCount);
}

/**
* Ignores cramming
*/
Expand Down Expand Up @@ -228,7 +246,6 @@ public void initStatsFor(final double baseHealth, final double difficulty, final
{
this.getAttribute(MOB_ATTACK_DAMAGE.get()).setBaseValue(baseDamage);

this.difficulty = difficulty;
final double armor = difficulty * ARMOR;
this.getAttribute(Attributes.ARMOR).setBaseValue(armor);

Expand All @@ -244,6 +261,11 @@ public void aiStep()
return;
}

if (this.spawnPos == null && this.blockPosition() != BlockPos.ZERO)
{
this.spawnPos = this.blockPosition();
}

updateSwingTime();
if (collisionCounter > 0)
{
Expand All @@ -267,14 +289,21 @@ public void aiStep()
@Override
public boolean hurt(@NotNull final DamageSource damageSource, final float damage)
{
if (damageSource.getEntity() instanceof AbstractEntityMinecoloniesMob)
if (damageSource.getEntity() instanceof AbstractEntityMinecoloniesMonster)
{
return false;
}

if (damageSource.getEntity() instanceof LivingEntity)
if (damageSource.getEntity() instanceof LivingEntity attacker)
{
threatTable.addThreat((LivingEntity) damageSource.getEntity(), (int) damage);
if (threatTable.getThreatFor(attacker) == -1)
{
for (final AbstractEntityMinecoloniesMonster monster : level.getEntitiesOfClass(AbstractEntityMinecoloniesMonster.class, AABB.ofSize(position(), 10,10,10)))
{
monster.threatTable.addThreat(attacker, 0);
}
}
threatTable.addThreat(attacker, (int) damage);
}

if (damageSource.typeHolder().is(DamageTypes.FELL_OUT_OF_WORLD))
Expand All @@ -300,6 +329,26 @@ public static AttributeSupplier.Builder getDefaultAttributes()
.add(Attributes.ATTACK_DAMAGE, Attributes.ATTACK_DAMAGE.getDefaultValue());
}

@Override
public void addAdditionalSaveData(final CompoundTag compound)
{
if (spawnPos != null)
{
compound.putLong(TAG_SPAWN_POS, spawnPos.asLong());
}
super.addAdditionalSaveData(compound);
}

@Override
public void readAdditionalSaveData(final CompoundTag compound)
{
if (compound.contains(TAG_SPAWN_POS))
{
this.spawnPos = BlockPos.of(compound.getLong(TAG_SPAWN_POS));
}
super.readAdditionalSaveData(compound);
}

/**
* Disallow pushing from fluids to prevent stuck
*
Expand Down Expand Up @@ -335,11 +384,20 @@ public int getTeamId()
}

/**
* Texture id of the mob. Default 0. Override for use.
* Texture id of the mob.
* @return the texture id.
*/
public int getTextureId()
{
return 0;
return textureId;
}

/**
* Getter for the initial spawn pos of the entity.
* @return the pos.
*/
public BlockPos getSpawnPos()
{
return this.spawnPos;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/**
* Abstract for all raider entities.
*/
public abstract class AbstractEntityRaiderMob extends AbstractEntityMinecoloniesMob implements IThreatTableEntity, Enemy
public abstract class AbstractEntityMinecoloniesRaider extends AbstractEntityMinecoloniesMonster implements IThreatTableEntity, Enemy
{
/**
* The percent of life taken per damage modifier
Expand Down Expand Up @@ -158,9 +158,21 @@ public abstract class AbstractEntityRaiderMob extends AbstractEntityMinecolonies
* @param world the world.
* @param type the entity type.
*/
public AbstractEntityRaiderMob(final EntityType<? extends AbstractEntityRaiderMob> type, final Level world)
public AbstractEntityMinecoloniesRaider(final EntityType<? extends AbstractEntityMinecoloniesRaider> type, final Level world)
{
super(type, world);
this(type, world, 0);
}

/**
* Constructor method for Abstract Barbarians.
*
* @param world the world.
* @param type the entity type.
* @param textureCount texture count.
*/
public AbstractEntityMinecoloniesRaider(final EntityType<? extends AbstractEntityMinecoloniesRaider> type, final Level world, final int textureCount)
{
super(type, world, textureCount);
this.setPersistenceRequired();
this.goalSelector = new CustomGoalSelector(this.goalSelector);
this.targetSelector = new CustomGoalSelector(this.targetSelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private RaiderMobUtils()
* @param mob The mob to set the attributes on.
* @param colony The colony that the mob is attacking.
*/
public static void setMobAttributes(final AbstractEntityRaiderMob mob, final IColony colony)
public static void setMobAttributes(final AbstractEntityMinecoloniesRaider mob, final IColony colony)
{
final double difficultyModifier = colony.getRaiderManager().getRaidDifficultyModifier();
mob.getAttribute(Attributes.FOLLOW_RANGE).setBaseValue(FOLLOW_RANGE * 2);
Expand Down Expand Up @@ -120,7 +120,7 @@ public static void spawn(

for (int i = 0; i < numberOfSpawns; i++)
{
final AbstractEntityRaiderMob entity = (AbstractEntityRaiderMob) entityToSpawn.create(world);
final AbstractEntityMinecoloniesRaider entity = (AbstractEntityMinecoloniesRaider) entityToSpawn.create(world);

if (entity != null)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ public static void spawn(
*
* @param mob the equipment to set up.
*/
public static void setEquipment(final AbstractEntityMinecoloniesMob mob)
public static void setEquipment(final AbstractEntityMinecoloniesMonster mob)
{
if (mob instanceof IMeleeBarbarianEntity || mob instanceof IMeleeNorsemenEntity || mob instanceof INorsemenChiefEntity)
{
Expand Down Expand Up @@ -208,10 +208,10 @@ else if (mob instanceof IPirateEntity)
* @param distanceFromEntity The distance to check for
* @return the barbarians (if any) that is nearest
*/
public static List<AbstractEntityRaiderMob> getBarbariansCloseToEntity(final Entity entity, final double distanceFromEntity)
public static List<AbstractEntityMinecoloniesRaider> getBarbariansCloseToEntity(final Entity entity, final double distanceFromEntity)
{
return CompatibilityUtils.getWorldFromEntity(entity).getEntitiesOfClass(
AbstractEntityRaiderMob.class,
AbstractEntityMinecoloniesRaider.class,
entity.getBoundingBox().expandTowards(
distanceFromEntity,
3.0D,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.minecolonies.api.entity.mobs.amazons;

import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob;
import com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMonster;
import com.minecolonies.api.entity.mobs.RaiderType;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.EntityType;
Expand All @@ -14,7 +14,7 @@
/**
* Abstract for all egyptian entities.
*/
public abstract class AbstractEntityAmazon extends AbstractEntityMinecoloniesMob
public abstract class AbstractEntityAmazon extends AbstractEntityMinecoloniesMonster
{
/**
* Swim speed for amazons
Expand Down
Loading

0 comments on commit f96480e

Please sign in to comment.