Skip to content

Commit

Permalink
Added Pharaoh / Pharaoh Orb abilities
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Jan 13, 2021
1 parent 0b97dc3 commit 962ac80
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void resetTask() {
this.seeTime = 0;
this.attackTime = -1;
this.entity.resetActiveHand();
System.out.println("Reset task");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,41 @@
import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.api.God;
import com.teammetallurgy.atum.entity.projectile.arrow.CustomArrow;
import com.teammetallurgy.atum.entity.undead.PharaohEntity;
import com.teammetallurgy.atum.init.AtumEntities;
import com.teammetallurgy.atum.items.artifacts.horus.HorusAscensionItem;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.SChangeGameStatePacket;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.*;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.network.FMLPlayMessages;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@Mod.EventBusSubscriber(modid = Atum.MOD_ID)
public class PharaohOrbEntity extends CustomArrow implements IEntityAdditionalSpawnData {
private final God god;
//Montu Berserk
private static int berserkTimer;
private static float berserkDamage;

public PharaohOrbEntity(FMLPlayMessages.SpawnEntity spawnEntity, World world) {
super(AtumEntities.PHARAOH_ORB, world);
Expand All @@ -42,7 +54,8 @@ public PharaohOrbEntity(EntityType<? extends PharaohOrbEntity> entityType, World
}

public PharaohOrbEntity(World world, LivingEntity shooter, God god) {
super(AtumEntities.PHARAOH_ORB, world, shooter);
super(AtumEntities.PHARAOH_ORB, world, shooter.getPosX(), shooter.getPosYEye() - (double) 0.3F, shooter.getPosZ());
this.setShooter(shooter);
this.pickupStatus = PickupStatus.DISALLOWED;
this.setDamage(this.getOrbDamage());
this.god = god;
Expand All @@ -65,16 +78,33 @@ protected ItemStack getArrowStack() {
@Override
@Nonnull
protected SoundEvent getHitEntitySound() {
return SoundEvents.BLOCK_ANCIENT_DEBRIS_HIT;
return SoundEvents.ENTITY_GENERIC_EXTINGUISH_FIRE;
}

@Override
protected void func_225516_i_() {
this.remove();
}

@Override
public void tick() {
super.tick();
this.setMotion(this.getMotion().add(0.0D, 0.01D, 0.0D)); //Decrease arc

//Montu Berserk
if (this.getGod() == God.MONTU) {
if (berserkTimer > 1) {
berserkTimer--;
}
if (berserkTimer == 1) {
berserkDamage = 0;
berserkTimer = 0;
}
}
}

public static DamageSource causeOrbDamage(PharaohOrbEntity pharaohOrbEntity, @Nullable Entity indirectEntity) {
return (new IndirectEntityDamageSource("atum:pharaoh_orb", pharaohOrbEntity, indirectEntity)).setDifficultyScaled().setProjectile();
return (new IndirectEntityDamageSource("atum_pharaoh_orb", pharaohOrbEntity, indirectEntity)).setDifficultyScaled().setProjectile();
}

@Override
Expand All @@ -83,11 +113,6 @@ protected void onEntityHit(EntityRayTraceResult rayTrace) {
float f = (float) this.getMotion().length();
int i = MathHelper.ceil(MathHelper.clamp((double) f * this.getDamage(), 0.0D, 2.147483647E9D));

if (this.getIsCritical()) {
long j = this.rand.nextInt(i / 2 + 2);
i = (int) Math.min(j + (long) i, 2147483647L);
}

Entity entity1 = this.func_234616_v_();
DamageSource damagesource = causeOrbDamage(this, entity1);
if (entity1 instanceof LivingEntity) {
Expand All @@ -96,7 +121,7 @@ protected void onEntityHit(EntityRayTraceResult rayTrace) {

int fireTimer = entity.getFireTimer();

if (entity.attackEntityFrom(damagesource, (float) i)) {
if (!(entity instanceof PharaohEntity) && entity.attackEntityFrom(damagesource, (float) i)) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;

Expand All @@ -113,6 +138,10 @@ protected void onEntityHit(EntityRayTraceResult rayTrace) {
}

this.arrowHit(livingEntity);
Entity shooter = this.func_234616_v_();
if (!this.world.isRemote && shooter instanceof LivingEntity) {
this.doGodSpecificEffect(this.getGod(), (LivingEntity) shooter, livingEntity);
}
if (entity1 != null && livingEntity != entity1 && livingEntity instanceof PlayerEntity && entity1 instanceof ServerPlayerEntity && !this.isSilent()) {
((ServerPlayerEntity) entity1).connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241770_g_, 0.0F));
}
Expand All @@ -131,6 +160,77 @@ protected void onEntityHit(EntityRayTraceResult rayTrace) {
this.remove();
}
}
this.remove();
}

public void doGodSpecificEffect(God god, LivingEntity shooter, LivingEntity target) {
switch (god) {
case ANPUT:
target.addPotionEffect(new EffectInstance(Effects.HUNGER, 80, 1));
break;
case ANUBIS:
target.addPotionEffect(new EffectInstance(Effects.WITHER, 60, 1));
break;
case ATEM:
target.addPotionEffect(new EffectInstance(Effects.INSTANT_DAMAGE, 1, 0));
break;
case GEB:
target.addPotionEffect(new EffectInstance(Effects.BLINDNESS, 60, 0));
break;
case HORUS:
target.addPotionEffect(new EffectInstance(Effects.MINING_FATIGUE, 60, 1));
break;
case ISIS:
shooter.heal(10);
break;
case NUIT:
target.addPotionEffect(new EffectInstance(Effects.WEAKNESS, 120));
break;
case PTAH:
this.applyReverseKnockback(target, 2.0F, MathHelper.sin(this.rotationYaw * ((float) Math.PI / 180F)), -MathHelper.cos(this.rotationYaw * ((float) Math.PI / 180F)));
break;
case RA:
target.setFire(3);
break;
case SETH:
target.addPotionEffect(new EffectInstance(Effects.POISON, 100, 0));
break;
case SHU:
HorusAscensionItem.knockUp(target, shooter, this.rand);
break;
case TEFNUT:
target.addPotionEffect(new EffectInstance(Effects.NAUSEA, 100));
break;
default:
break;
}
}

public void applyReverseKnockback(LivingEntity target, float reverseStrength, double ratioX, double ratioZ) {
reverseStrength = (float) ((double) reverseStrength * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)));
if (!(reverseStrength <= 0.0F)) {
target.isAirBorne = true;
Vector3d vector3d = target.getMotion();
Vector3d vector3d1 = (new Vector3d(ratioX, 0.0D, ratioZ)).normalize().scale(reverseStrength);
target.setMotion(vector3d.x / 2.0D - vector3d1.x, target.isOnGround() ? -Math.min(0.4D, vector3d.y / 2.0D + (double) reverseStrength) : vector3d.y, -(vector3d.z / 2.0D - vector3d1.z));
}
}

@SubscribeEvent
public static void onBerserk(LivingHurtEvent event) {
Entity immediateSource = event.getSource().getImmediateSource();
if (immediateSource instanceof PharaohOrbEntity) {
if (((PharaohOrbEntity) immediateSource).getGod() == God.MONTU) {
if (berserkTimer == 0) {
event.setAmount(event.getAmount());
berserkDamage = (event.getAmount() / 10) + event.getAmount();
} else {
berserkDamage = berserkDamage + (event.getAmount() / 10);
event.setAmount(berserkDamage);
}
berserkTimer = 80;
}
}
}

@Override
Expand All @@ -145,6 +245,5 @@ public void writeSpawnData(PacketBuffer buffer) {

@Override
public void readSpawnData(PacketBuffer additionalData) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.entity.projectile.ArrowEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.IPacket;
Expand All @@ -12,21 +14,25 @@

import javax.annotation.Nonnull;

public abstract class CustomArrow extends AbstractArrowEntity {
public abstract class CustomArrow extends ArrowEntity {

public CustomArrow(EntityType<? extends CustomArrow> entityType, World world) {
super(entityType, world);
}

public CustomArrow(EntityType<? extends CustomArrow> entityType, World world, double x, double y, double z) {
super(entityType, x, y, z, world);
this(entityType, world);
this.setPosition(x, y, z);
}

public CustomArrow(EntityType<? extends CustomArrow> entityType, World world, LivingEntity shooter) {
super(entityType, shooter, world);
this(entityType, world, shooter.getPosX(), shooter.getPosYEye() - (double) 0.1F, shooter.getPosZ());
this.setShooter(shooter);
if (shooter instanceof PlayerEntity) {
this.pickupStatus = AbstractArrowEntity.PickupStatus.ALLOWED;
}
}


@Override
@Nonnull
public IPacket<?> createSpawnPacket() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.server.ServerLifecycleHooks;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -77,8 +75,6 @@ public void startExecuting() {
private int prefixID = 0;
private int numID = 0;
private int regenTime = 0;
private int berserkTimer;
private float berserkDamage;
private String texturePath;
private boolean dropsGodSpecificLoot;

Expand Down Expand Up @@ -240,7 +236,7 @@ public void attackEntityWithRangedAttack(@Nonnull LivingEntity target, float dis
double y = target.getPosYHeight(0.3333333333333333D) - orb.getPosY();
double z = target.getPosZ() - this.getPosZ();
double height = MathHelper.sqrt(x * x + z * z);
orb.shoot(x, y + height * 0.2D, z, 1.6F, (8 - this.world.getDifficulty().getId() * 4));
orb.shoot(x, y + height * 0.2D, z, 1.6F, 1);
this.playSound(SoundEvents.ENTITY_GHAST_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.world.addEntity(orb);
}
Expand Down Expand Up @@ -355,21 +351,6 @@ public boolean attackEntityFrom(@Nonnull DamageSource source, float amount) {
return false;
}

@SubscribeEvent
public void onBerserk(LivingHurtEvent event) {
if (event.getSource().getTrueSource() == this && God.getGod(this.getVariant()) == God.MONTU) {
if (this.berserkTimer == 0) {
event.setAmount(event.getAmount());
this.berserkDamage = (event.getAmount() / 10) + event.getAmount();
this.berserkTimer = 80;
} else {
this.berserkDamage = this.berserkDamage + (event.getAmount() / 10);
event.setAmount(this.berserkDamage);
this.berserkTimer = 80;
}
}
}

@Override
public void tick() {
super.tick();
Expand Down Expand Up @@ -399,14 +380,7 @@ protected void updateAITasks() {
public void livingTick() {
if (regenTime++ > 60) {
regenTime = 0;
this.heal(God.getGod(this.getVariant()) == God.ISIS ? 2 : 1);
}
if (God.getGod(this.getVariant()) == God.MONTU && this.berserkTimer > 1) {
this.berserkTimer--;
}
if (this.berserkTimer == 1) {
this.berserkDamage = 0;
this.berserkTimer = 0;
this.heal(God.getGod(this.getVariant()) == God.OSIRIS ? 6 : 1);
}
super.livingTick();
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/teammetallurgy/atum/items/CoinItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
import com.teammetallurgy.atum.init.AtumItems;
import net.minecraft.block.BlockState;
import net.minecraft.block.CauldronBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import org.lwjgl.glfw.GLFW;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;

public class CoinItem extends Item {

Expand Down Expand Up @@ -41,4 +50,18 @@ public boolean onEntityItemUpdate(@Nonnull ItemStack stack, ItemEntity entityIte
}
return super.onEntityItemUpdate(stack, entityItem);
}

@Override
public void addInformation(@Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> tooltip, @Nonnull ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);
if (stack.getItem() == AtumItems.DIRTY_COIN) {
if (InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT)) {
tooltip.add(new TranslationTextComponent(Atum.MOD_ID + ".tooltip.dirty").appendString(": ").mergeStyle(TextFormatting.GRAY)
.append(new TranslationTextComponent(Atum.MOD_ID + ".tooltip.dirty.description").mergeStyle(TextFormatting.DARK_GRAY)));
} else {
tooltip.add(new TranslationTextComponent(Atum.MOD_ID + ".tooltip.dirty").mergeStyle(TextFormatting.GRAY)
.appendString(" ").append(new TranslationTextComponent(Atum.MOD_ID + ".tooltip.shift").mergeStyle(TextFormatting.DARK_GRAY)));
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/atum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@
"entity.atum.mummy": "Mummy",
"entity.atum.nomad": "Nomad",
"entity.atum.pharaoh": "Pharaoh",
"entity.atum.pharaoh_orb": "Pharaoh Orb",
"entity.atum.quail": "Quail",
"entity.atum.scarab": "Scarab",
"entity.atum.sergeant": "Sergeant",
Expand Down Expand Up @@ -910,6 +911,7 @@

"_comment": "Death Messages",
"death.attack.assassinated": "%1$s was assassinated",
"death.attack.atum_pharaoh_orb": "%1$s has felt the wrath of %2$s",

"_comment": "Pharaoh Names",
"entity.atum.pharaoh.Ama": "Ama'",
Expand Down

0 comments on commit 962ac80

Please sign in to comment.