Spring Cleaning (#127)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
koolkrafter5andgithub-actions[bot] authored and GitHub committed 2026-05-12 20:52:29 +02:00
1 parent 1544c1bf0d
commit 3b2b31f733
413 files changed
+9272 -17658

No files matched your search

@@ -1,7 +1,6 @@
package WayofTime.alchemicalWizardry.api.spell;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -43,35 +42,27 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
// Custom variables
private int maxRicochet = 0;
private float damage = 1;
public List<IProjectileImpactEffect> impactList = new ArrayList();
public List<IProjectileImpactEffect> impactList = new ArrayList<>();
private boolean penetration = false;
public List<IProjectileUpdateEffect> updateEffectList = new ArrayList();
public List<SpellEffect> spellEffectList = new LinkedList();
public List<IProjectileUpdateEffect> updateEffectList = new ArrayList<>();
public List<SpellEffect> spellEffectList = new LinkedList<>();
private int blocksBroken = 0;
public EntitySpellProjectile(World par1World) {
super(par1World);
public EntitySpellProjectile(World world) {
super(world);
this.setSize(0.5F, 0.5F);
}
public EntitySpellProjectile(World par1World, double par2, double par4, double par6) {
super(par1World);
this.setSize(0.5F, 0.5F);
this.setPosition(par2, par4, par6);
yOffset = 0.0F;
}
public EntitySpellProjectile(World par1World, EntityPlayer par2EntityPlayer) {
super(par1World);
shootingEntity = par2EntityPlayer;
float par3 = 0.8F;
public EntitySpellProjectile(World world, EntityPlayer player) {
super(world);
shootingEntity = player;
this.setSize(0.1F, 0.1F);
this.setLocationAndAngles(
par2EntityPlayer.posX,
par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(),
par2EntityPlayer.posZ,
par2EntityPlayer.rotationYaw,
par2EntityPlayer.rotationPitch);
player.posX,
player.posY + player.getEyeHeight(),
player.posZ,
player.rotationYaw,
player.rotationPitch);
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
posY -= 0.2D;
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
@@ -82,7 +73,7 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI)
* MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
this.setThrowableHeading(motionX, motionY, motionZ, 1.2f, 1.0F);
}
@Override
@@ -90,62 +81,48 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
dataWatcher.addObject(16, 0);
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
@Override
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) {
float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
var1 /= var9;
var3 /= var9;
var5 /= var9;
var1 += rand.nextGaussian() * 0.007499999832361937D * var8;
var3 += rand.nextGaussian() * 0.007499999832361937D * var8;
var5 += rand.nextGaussian() * 0.007499999832361937D * var8;
var1 *= var7;
var3 *= var7;
var5 *= var7;
motionX = var1;
motionY = var3;
motionZ = var5;
float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI);
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) {
float distance = MathHelper.sqrt_double(x * x + y * y + z * z);
x /= distance;
y /= distance;
z /= distance;
x += rand.nextGaussian() * 0.0075D * inaccuracy;
y += rand.nextGaussian() * 0.0075D * inaccuracy;
z += rand.nextGaussian() * 0.0075D * inaccuracy;
x *= velocity;
y *= velocity;
z *= velocity;
motionX = x;
motionY = y;
motionZ = z;
float horizontalDistance = MathHelper.sqrt_double(x * x + z * z);
prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalDistance) * 180.0D / Math.PI);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) {
this.setPosition(par1, par3, par5);
this.setRotation(par7, par8);
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int rotationIncrements) {
this.setPosition(x, y, z);
this.setRotation(yaw, pitch);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity(double par1, double par3, double par5) {
motionX = par1;
motionY = par3;
motionZ = par5;
public void setVelocity(double x, double y, double z) {
motionX = x;
motionY = y;
motionZ = z;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch;
float horizontalDistance = MathHelper.sqrt_double(x * x + z * z);
prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalDistance) * 180.0D / Math.PI);
prevRotationYaw = rotationYaw;
this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
super.onUpdate();
@@ -154,17 +131,16 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
this.setDead();
}
if (shootingEntity == null) {
List players = worldObj.getEntitiesWithinAABB(
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(
EntityPlayer.class,
AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
Iterator i = players.iterator();
double closestDistance = Double.MAX_VALUE;
EntityPlayer closestPlayer = null;
while (i.hasNext()) {
EntityPlayer e = (EntityPlayer) i.next();
double distance = e.getDistanceToEntity(this);
for (EntityPlayer player : players) {
double distance = player.getDistanceToEntity(this);
if (distance < closestDistance) {
closestPlayer = e;
closestPlayer = player;
}
}
if (closestPlayer != null) {
@@ -172,84 +148,69 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
}
}
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
float horizontalDistance = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, horizontalDistance) * 180.0D / Math.PI);
}
Block var16 = worldObj.getBlock(xTile, yTile, zTile);
Block block = worldObj.getBlock(xTile, yTile, zTile);
if (var16 != null) {
var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (block != null) {
block.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB collision = block.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (var2 != null && var2.isVecInside(APISpellHelper.createVec3(posX, posY, posZ))) {
if (collision != null && collision.isVecInside(APISpellHelper.createVec3(posX, posY, posZ))) {
inGround = true;
}
}
if (inGround) {
Block var18 = worldObj.getBlock(xTile, yTile, zTile);
int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile);
// if (var18.equals(Block.getBlockById(inTile)) && var19 == inData)
{
// this.groundImpact();
// this.setDead();
}
} else {
if (!inGround) {
++ticksInAir;
if (ticksInAir > 1 && ticksInAir < 3) {
// worldObj.spawnParticle("flame", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ +
// smallGauss(0.1D), 0D, 0D, 0D);
if (ticksInAir == 2) {
for (int particles = 0; particles < 3; particles++) {
this.doFiringParticles();
}
}
Vec3 var17 = APISpellHelper.createVec3(posX, posY, posZ);
Vec3 var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false);
var17 = APISpellHelper.createVec3(posX, posY, posZ);
var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ);
Vec3 start = APISpellHelper.createVec3(posX, posY, posZ);
Vec3 end = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movement = worldObj.func_147447_a(start, end, true, false, false);
start = APISpellHelper.createVec3(posX, posY, posZ);
end = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ);
if (var4 != null) {
var3 = APISpellHelper.createVec3(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
if (movement != null) {
end = APISpellHelper.createVec3(movement.hitVec.xCoord, movement.hitVec.yCoord, movement.hitVec.zCoord);
}
Entity var5 = null;
List var6 = worldObj.getEntitiesWithinAABBExcludingEntity(
Entity closestEntity = null;
List<Entity> entitiesInRange = worldObj.getEntitiesWithinAABBExcludingEntity(
this,
boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double var7 = 0.0D;
Iterator var9 = var6.iterator();
float var11;
double closestDistance = 0.0D;
while (var9.hasNext()) {
Entity var10 = (Entity) var9.next();
for (Entity entity : entitiesInRange) {
if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5)) {
var11 = 0.3F;
AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11);
MovingObjectPosition var13 = var12.calculateIntercept(var17, var3);
if (entity.canBeCollidedWith() && (entity != shootingEntity || ticksInAir >= 5)) {
AxisAlignedBB box = entity.boundingBox.expand(0.3F, 0.3F, 0.3F);
MovingObjectPosition intercept = box.calculateIntercept(start, end);
if (var13 != null) {
double var14 = var17.distanceTo(var13.hitVec);
if (intercept != null) {
double distance = start.distanceTo(intercept.hitVec);
if (var14 < var7 || var7 == 0.0D) {
var5 = var10;
var7 = var14;
if (distance < closestDistance || closestDistance == 0.0D) {
closestEntity = entity;
closestDistance = distance;
}
}
}
}
if (var5 != null) {
var4 = new MovingObjectPosition(var5);
if (closestEntity != null) {
movement = new MovingObjectPosition(closestEntity);
}
if (var4 != null) {
this.onImpact(var4);
if (movement != null) {
this.onImpact(movement);
if (scheduledForDeath) {
this.setDead();
@@ -259,16 +220,7 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
posX += motionX;
posY += motionY;
posZ += motionZ;
MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
this.setPosition(posX, posY, posZ);
// this.doBlockCollisions();
}
}
private void doFlightParticles() {
if (ticksInAir % 3 == 0) {
double gauss = gaussian(1.0F);
worldObj.spawnParticle("mobSpell", posX, posY, posZ, gauss, gauss, 0.0F);
}
}
@@ -284,17 +236,14 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
par1NBTTagCompound.setShort("xTile", (short) xTile);
par1NBTTagCompound.setShort("yTile", (short) yTile);
par1NBTTagCompound.setShort("zTile", (short) zTile);
par1NBTTagCompound.setByte("inTile", (byte) inTile);
par1NBTTagCompound.setByte("inData", (byte) inData);
par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0));
public void writeEntityToNBT(NBTTagCompound tag) {
tag.setShort("xTile", (short) xTile);
tag.setShort("yTile", (short) yTile);
tag.setShort("zTile", (short) zTile);
tag.setByte("inTile", (byte) inTile);
tag.setByte("inData", (byte) inData);
tag.setByte("inGround", (byte) (inGround ? 1 : 0));
NBTTagList effectList = new NBTTagList();
@@ -302,50 +251,34 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
effectList.appendTag(eff.getTag());
}
// for (String str : this.effectList)
// {
// if (str != null)
// {
// NBTTagCompound tag = new NBTTagCompound();
//
// tag.setString("Class", str);
// effectList.appendTag(tag);
// }
// }
par1NBTTagCompound.setTag("Effects", effectList);
par1NBTTagCompound.setInteger("blocksBroken", blocksBroken);
par1NBTTagCompound.setBoolean("isSilkTouch", isSilkTouch);
tag.setTag("Effects", effectList);
tag.setInteger("blocksBroken", blocksBroken);
tag.setBoolean("isSilkTouch", isSilkTouch);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
xTile = par1NBTTagCompound.getShort("xTile");
yTile = par1NBTTagCompound.getShort("yTile");
zTile = par1NBTTagCompound.getShort("zTile");
inTile = par1NBTTagCompound.getByte("inTile") & 255;
inData = par1NBTTagCompound.getByte("inData") & 255;
inGround = par1NBTTagCompound.getByte("inGround") == 1;
blocksBroken = par1NBTTagCompound.getInteger("blocksBroken");
isSilkTouch = par1NBTTagCompound.getBoolean("isSilkTouch");
public void readEntityFromNBT(NBTTagCompound tag) {
xTile = tag.getShort("xTile");
yTile = tag.getShort("yTile");
zTile = tag.getShort("zTile");
inTile = tag.getByte("inTile") & 255;
inData = tag.getByte("inData") & 255;
inGround = tag.getByte("inGround") == 1;
blocksBroken = tag.getInteger("blocksBroken");
isSilkTouch = tag.getBoolean("isSilkTouch");
NBTTagList tagList = par1NBTTagCompound.getTagList("Effects", Constants.NBT.TAG_COMPOUND);
NBTTagList tagList = tag.getTagList("Effects", Constants.NBT.TAG_COMPOUND);
List<SpellEffect> spellEffectList = new LinkedList();
List<SpellEffect> spellEffectList = new LinkedList<>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound tag = tagList.getCompoundTagAt(i);
SpellEffect eff = SpellEffect.getEffectFromTag(tag);
SpellEffect eff = SpellEffect.getEffectFromTag(tagList.getCompoundTagAt(i));
if (eff != null) {
spellEffectList.add(eff);
}
}
this.spellEffectList = spellEffectList;
// this.effectList = new LinkedList();
// this.effectList = new LinkedList<>();
// for (int i = 0; i < tagList.tagCount(); i++)
// {
// NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
@@ -374,39 +307,11 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
return 0.0F;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int par1) {}
/**
* If returns false, the item will not inflict any damage against entities.
*/
@Override
public boolean canAttackWithItem() {
return false;
}
/**
* Whether the arrow has a stream of critical hit particles flying behind it.
*/
public void setIsCritical(boolean par1) {
byte var2 = dataWatcher.getWatchableObjectByte(16);
if (par1) {
dataWatcher.updateObject(16, var2 | 1);
} else {
dataWatcher.updateObject(16, var2 & -2);
}
}
/**
* Whether the arrow has a stream of critical hit particles flying behind it.
*/
public boolean getIsCritical() {
byte var1 = dataWatcher.getWatchableObjectByte(16);
return (var1 & 1) != 0;
}
private void onImpact(MovingObjectPosition mop) {
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) {
if (mop.entityHit == shootingEntity) return;
@@ -471,87 +376,23 @@ public class EntitySpellProjectile extends Entity implements IProjectile {
private void ricochet(int sideHit) {
switch (sideHit) {
case 0:
case 1:
// topHit, bottomHit, reflect Y
motionY = motionY * -1;
break;
case 2:
case 3:
// westHit, eastHit, reflect Z
motionZ = motionZ * -1;
break;
case 4:
case 5:
// southHit, northHit, reflect X
motionX = motionX * -1;
break;
case 0, 1 -> motionY = motionY * -1; // topHit, bottomHit, reflect Y
case 2, 3 -> motionZ = motionZ * -1; // westHit, eastHit, reflect Z
case 4, 5 -> motionX = motionX * -1; // southHit, northHit, reflect X
}
ricochetCounter++;
if (ricochetCounter > this.getRicochetMax()) {
scheduledForDeath = true;
for (int particles = 0; particles < 4; particles++) {
switch (sideHit) {
case 0:
worldObj.spawnParticle(
"smoke",
posX,
posY,
posZ,
gaussian(0.1D),
-gaussian(0.1D),
gaussian(0.1D));
break;
case 1:
worldObj.spawnParticle(
"smoke",
posX,
posY,
posZ,
gaussian(0.1D),
gaussian(0.1D),
gaussian(0.1D));
break;
case 2:
worldObj.spawnParticle(
"smoke",
posX,
posY,
posZ,
gaussian(0.1D),
gaussian(0.1D),
-gaussian(0.1D));
break;
case 3:
worldObj.spawnParticle(
"smoke",
posX,
posY,
posZ,
gaussian(0.1D),
gaussian(0.1D),
gaussian(0.1D));
break;
case 4:
worldObj.spawnParticle(
"smoke",
posX,
posY,
posZ,
-gaussian(0.1D),
gaussian(0.1D),
gaussian(0.1D));
break;
case 5:
worldObj.spawnParticle(
"smoke",
posX,
posY,
posZ,
gaussian(0.1D),
gaussian(0.1D),
gaussian(0.1D));
break;
case 0 -> worldObj
.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), -gaussian(0.1D), gaussian(0.1D));
case 1, 3, 5 -> worldObj
.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
case 2 -> worldObj
.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), -gaussian(0.1D));
case 4 -> worldObj
.spawnParticle("smoke", posX, posY, posZ, -gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
}
}
}