mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Tracker 'thrower' of mana bursts and use that for terra sword
This commit is contained in:
1 parent
d54ebc610d
commit
f433ee8858
2 files changed
+18
-21
No files matched your search
@@ -149,16 +149,15 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
|
||||
}
|
||||
|
||||
public EntityManaBurst(PlayerEntity player, Hand hand) {
|
||||
this(player.world);
|
||||
super(TYPE, player, player.world);
|
||||
|
||||
setBurstSourceCoords(new BlockPos(0, -1, 0));
|
||||
setLocationAndAngles(player.posX, player.posY + player.getEyeHeight(), player.posZ, player.rotationYaw + 180, -player.rotationPitch);
|
||||
setRotation(player.rotationYaw + 180, -player.rotationPitch);
|
||||
|
||||
posX -= (hand == Hand.OFF_HAND ? -1 : 1) * MathHelper.cos((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F;
|
||||
posY -= 0.10000000149011612D;
|
||||
posZ -= (hand == Hand.OFF_HAND ? -1 : 1) * MathHelper.sin((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F;
|
||||
double dX = (hand == Hand.OFF_HAND ? -1 : 1) * MathHelper.cos((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F;
|
||||
double dZ = (hand == Hand.OFF_HAND ? -1 : 1) * MathHelper.sin((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F;
|
||||
|
||||
setPosition(posX, posY, posZ);
|
||||
setPosition(posX - dX, posY, posZ - dZ);
|
||||
float f = 0.4F;
|
||||
double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D;
|
||||
double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D;
|
||||
|
||||
+13
-15
@@ -40,9 +40,6 @@ import java.util.UUID;
|
||||
|
||||
public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
|
||||
// todo 1.14 use throwableentity's owner system instead of tracking it ourselves
|
||||
private static final String TAG_ATTACKER_UUID = "attackerUuid";
|
||||
|
||||
private static final int MANA_PER_DAMAGE = 100;
|
||||
|
||||
public ItemTerraSword(Properties props) {
|
||||
@@ -59,8 +56,8 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
}
|
||||
|
||||
private void attackEntity(AttackEntityEvent evt) {
|
||||
if (!evt.getEntityPlayer().world.isRemote) {
|
||||
trySpawnBurst(evt.getEntityPlayer());
|
||||
if (!evt.getPlayer().world.isRemote) {
|
||||
trySpawnBurst(evt.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +91,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
burst.setBurstMotion(burst.getMotion().getX() * motionModifier,
|
||||
burst.getMotion().getY() * motionModifier, burst.getMotion().getZ() * motionModifier);
|
||||
|
||||
ItemStack lens = stack.copy();
|
||||
ItemNBTHelper.setUuid(lens, TAG_ATTACKER_UUID, player.getUniqueID());
|
||||
burst.setSourceLens(lens);
|
||||
burst.setSourceLens(stack.copy());
|
||||
return burst;
|
||||
}
|
||||
|
||||
@@ -113,11 +108,11 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
ThrowableEntity entity = (ThrowableEntity) burst;
|
||||
AxisAlignedBB axis = new AxisAlignedBB(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).grow(1);
|
||||
List<LivingEntity> entities = entity.world.getEntitiesWithinAABB(LivingEntity.class, axis);
|
||||
UUID attacker = ItemNBTHelper.getUuid(burst.getSourceLens(), TAG_ATTACKER_UUID);
|
||||
LivingEntity thrower = entity.getThrower();
|
||||
|
||||
for(LivingEntity living : entities) {
|
||||
if(living instanceof PlayerEntity && (living.getUniqueID().equals(attacker)
|
||||
|| ServerLifecycleHooks.getCurrentServer() != null && !ServerLifecycleHooks.getCurrentServer().isPVPEnabled()))
|
||||
if(living == thrower
|
||||
|| ServerLifecycleHooks.getCurrentServer() != null && !ServerLifecycleHooks.getCurrentServer().isPVPEnabled())
|
||||
continue;
|
||||
|
||||
if(living.hurtTime == 0) {
|
||||
@@ -127,10 +122,13 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
burst.setMana(mana - cost);
|
||||
float damage = 4F + BotaniaAPI.TERRASTEEL_ITEM_TIER.getAttackDamage();
|
||||
if(!burst.isFake() && !entity.world.isRemote) {
|
||||
PlayerEntity player = attacker != null ? living.world.getPlayerByUuid(attacker) : null;
|
||||
living.attackEntityFrom(player == null
|
||||
? DamageSource.MAGIC
|
||||
: DamageSource.causePlayerDamage(player), damage);
|
||||
DamageSource source = DamageSource.MAGIC;
|
||||
if(thrower instanceof PlayerEntity) {
|
||||
source = DamageSource.causePlayerDamage((PlayerEntity) thrower);
|
||||
} else if(thrower != null) {
|
||||
source = DamageSource.causeMobDamage(thrower);
|
||||
}
|
||||
living.attackEntityFrom(source, damage);
|
||||
entity.remove();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user