use of de.sanandrew.mods.claysoldiers.entity.soldier.EntityClaySoldier in project ClaySoldiersMod by SanAndreasP.
the class ClientProxy method init.
@Override
public void init(FMLInitializationEvent event) {
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new ItemColorSoldier(), ItemRegistry.DOLL_SOLDIER);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new ItemColorHorse(), ItemRegistry.DOLL_HORSE);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new ItemColorPegasus(), ItemRegistry.DOLL_PEGASUS);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new ItemColorTurtle(), ItemRegistry.DOLL_TURTLE);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new ItemColorBunny(), ItemRegistry.DOLL_BUNNY);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new ItemColorGecko(), ItemRegistry.DOLL_GECKO);
this.soldierRenderer = (ISoldierRender) Minecraft.getMinecraft().getRenderManager().<EntityClaySoldier>getEntityClassRenderObject(EntityClaySoldier.class);
ClaySoldiersMod.PLUGINS.forEach(plugin -> {
plugin.registerSoldierRenderHook(this);
});
Shaders.initShaders();
}
use of de.sanandrew.mods.claysoldiers.entity.soldier.EntityClaySoldier in project ClaySoldiersMod by SanAndreasP.
the class EntityClayProjectile method doCollisionCheck.
private void doCollisionCheck() {
Vec3d posVec = new Vec3d(this.posX, this.posY, this.posZ);
Vec3d futurePosVec = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
RayTraceResult hitObj = this.world.rayTraceBlocks(posVec, futurePosVec, false, true, false);
posVec = new Vec3d(this.posX, this.posY, this.posZ);
futurePosVec = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (hitObj != null) {
futurePosVec = new Vec3d(hitObj.hitVec.x, hitObj.hitVec.y, hitObj.hitVec.z);
}
Entity entity = null;
AxisAlignedBB checkBB = this.getEntityBoundingBox().offset(this.motionX, this.motionY, this.motionZ).grow(1.0D, 1.0D, 1.0D);
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, checkBB);
double minDist = 0.0D;
float collisionRange;
for (Entity collidedEntity : list) {
if (collidedEntity.canBeCollidedWith() && collidedEntity != this.shooterCache) {
collisionRange = 0.1F;
AxisAlignedBB collisionAABB = collidedEntity.getEntityBoundingBox().grow(collisionRange, collisionRange, collisionRange);
RayTraceResult interceptObj = collisionAABB.calculateIntercept(posVec, futurePosVec);
if (interceptObj != null) {
double vecDistance = posVec.distanceTo(interceptObj.hitVec);
if (collidedEntity == this.targetCache && (vecDistance < minDist || minDist == 0.0D)) {
entity = collidedEntity;
minDist = vecDistance;
}
}
}
}
if (entity != null) {
hitObj = new RayTraceResult(entity);
}
if (hitObj != null && hitObj.entityHit != null && hitObj.entityHit instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) hitObj.entityHit;
if (player.capabilities.disableDamage) {
hitObj = null;
}
}
if (hitObj != null) {
if (hitObj.entityHit != null) {
MutableFloat dmg = new MutableFloat(this.getDamage(hitObj.entityHit));
DamageSource damagesource = this.getProjDamageSource(hitObj.entityHit);
if (this.isBurning() && !(hitObj.entityHit instanceof EntityEnderman)) {
hitObj.entityHit.setFire(5);
}
if (this.shooterCache instanceof EntityClaySoldier) {
EntityClaySoldier soldier = (EntityClaySoldier) this.shooterCache;
final Entity target = hitObj.entityHit;
soldier.callUpgradeFunc(EnumUpgFunctions.ON_ATTACK, upg -> upg.getUpgrade().onAttack(soldier, upg, target, damagesource, dmg));
}
boolean preHitVelocityChanged = hitObj.entityHit.velocityChanged;
boolean preHitAirBorne = hitObj.entityHit.isAirBorne;
double preHitMotionX = hitObj.entityHit.motionX;
double preHitMotionY = hitObj.entityHit.motionY;
double preHitMotionZ = hitObj.entityHit.motionZ;
if (this.onPreHit(hitObj.entityHit, damagesource, dmg) && hitObj.entityHit.attackEntityFrom(damagesource, dmg.floatValue())) {
if (this.shooterCache instanceof EntityClaySoldier) {
EntityClaySoldier soldier = (EntityClaySoldier) this.shooterCache;
final Entity target = hitObj.entityHit;
soldier.callUpgradeFunc(EnumUpgFunctions.ON_ATTACK_SUCCESS, upg -> upg.getUpgrade().onAttackSuccess(soldier, upg, target));
}
hitObj.entityHit.velocityChanged = preHitVelocityChanged;
hitObj.entityHit.isAirBorne = preHitAirBorne;
hitObj.entityHit.motionX = preHitMotionX;
hitObj.entityHit.motionY = preHitMotionY;
hitObj.entityHit.motionZ = preHitMotionZ;
this.onPostHit(hitObj.entityHit, damagesource);
if (hitObj.entityHit instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) hitObj.entityHit;
if (!this.world.isRemote) {
living.setArrowCountInEntity(living.getArrowCountInEntity() + 1);
}
double deltaX = this.posX - living.posX;
double deltaZ = this.posZ - living.posZ;
while (deltaX * deltaX + deltaZ * deltaZ < 0.0001D) {
deltaZ = (Math.random() - Math.random()) * 0.01D;
deltaX = (Math.random() - Math.random()) * 0.01D;
}
this.knockBackEntity(living, deltaX, deltaZ);
if (this.shooterCache instanceof EntityLivingBase) {
EnchantmentHelper.applyThornEnchantments(living, this.shooterCache);
EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase) this.shooterCache, living);
}
}
}
} else {
this.onBlockHit(hitObj.getBlockPos());
}
this.processHit(hitObj);
}
}
use of de.sanandrew.mods.claysoldiers.entity.soldier.EntityClaySoldier in project ClaySoldiersMod by SanAndreasP.
the class ClayModelRotationEventHandler method onModelRotation.
@SubscribeEvent
public void onModelRotation(ClayModelRotationEvent event) {
if (event.model instanceof ModelClaySoldier && event.entity instanceof EntityClaySoldier) {
ModelClaySoldier model = (ModelClaySoldier) event.model;
EntityClaySoldier soldier = (EntityClaySoldier) event.entity;
if (soldier.hasUpgrade(Upgrades.MC_FEATHER, EnumUpgradeType.MISC) && !soldier.onGround) {
model.bipedLeftArm.rotateAngleX += Math.PI;
model.bipedRightArm.rotateAngleX += Math.PI;
}
}
}
Aggregations