aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/entities
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2023-04-01 20:06:12 +0100
committerGitHub <noreply@github.com>2023-04-01 19:06:12 +0000
commitb088958c9f6935d356b6c087c8e8106b400aa24f (patch)
treebe608fac08ba158f1226a4fb9f5b1ed459bac2a9 /src/main/java/gregtech/common/entities
parente52cd9c3458584e58073df5cd9cde1302994f266 (diff)
downloadGT5-Unofficial-b088958c9f6935d356b6c087c8e8106b400aa24f.tar.gz
GT5-Unofficial-b088958c9f6935d356b6c087c8e8106b400aa24f.tar.bz2
GT5-Unofficial-b088958c9f6935d356b6c087c8e8106b400aa24f.zip
Jabel, Generic injection and mostly automatic code cleanup (#1829)
* Enable Jabel&Generic injection, fix type error caused by this * add missing <> * Infer generic types automatically * Parametrize cast types * Use enhanced for loops * Unnecessary boxing * Unnecessary unboxing * Use Objects.equals * Explicit type can be replaced with `<>` * Collapse identical catch blocks * Add SafeVarargs where applicable * Anonymous type can be replaced with lambda * Use List.sort directly * Lambda can be a method reference * Statement lambda can be an expression lambda * Use string switches * Instanceof pattern matching * Text block can be used * Migrate to enhanced switch * Java style array declarations * Unnecessary toString() * More unnecessary String conversions * Unnecessary modifiers * Unnecessary semicolons * Fix duplicate conditions * Extract common code from if branches * Replace switches with ifs for 1-2 cases * Inner class may be static * Minor performance issues * Replace string appending in loops with string builders * Fix IntelliJ using the wrong empty list method * Use Long.compare * Generic arguments: getSubItems * Generic arguments: getSubBlocks * Raw types warnings * Fix remaining missing generics * Too weak variable type leads to unnecessary cast * Redundant type casts * Redundant array length check * Redundant vararg arrays * Manual min/max implementations * A couple missed inspections * Goodbye explosion power ternary ladder * Apply spotless * Get rid of the other two big ternary ladders * Binary search explosion power * Don't overcomplicate things
Diffstat (limited to 'src/main/java/gregtech/common/entities')
-rw-r--r--src/main/java/gregtech/common/entities/GT_Entity_Arrow.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java
index 540a8e23a5..c07e316684 100644
--- a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java
+++ b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java
@@ -126,13 +126,13 @@ public class GT_Entity_Arrow extends EntityArrow {
vec3 = Vec3.createVectorHelper(tVector.hitVec.xCoord, tVector.hitVec.yCoord, tVector.hitVec.zCoord);
}
Entity tHitEntity = null;
- List tAllPotentiallyHitEntities = this.worldObj.getEntitiesWithinAABBExcludingEntity(
+ List<Entity> tAllPotentiallyHitEntities = this.worldObj.getEntitiesWithinAABBExcludingEntity(
this,
this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ)
.expand(1.0D, 1.0D, 1.0D));
double tLargestDistance = Double.MAX_VALUE;
- for (int i = 0; i < tAllPotentiallyHitEntities.size(); i++) {
- Entity entity1 = (Entity) tAllPotentiallyHitEntities.get(i);
+ for (Entity tAllPotentiallyHitEntity : tAllPotentiallyHitEntities) {
+ Entity entity1 = tAllPotentiallyHitEntity;
if ((entity1.canBeCollidedWith()) && ((entity1 != tShootingEntity) || (this.ticksInAir >= 5))) {
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(0.3D, 0.3D, 0.3D);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
@@ -148,8 +148,7 @@ public class GT_Entity_Arrow extends EntityArrow {
if (tHitEntity != null) {
tVector = new MovingObjectPosition(tHitEntity);
}
- if ((tVector != null) && ((tVector.entityHit instanceof EntityPlayer))) {
- EntityPlayer entityplayer = (EntityPlayer) tVector.entityHit;
+ if ((tVector != null) && ((tVector.entityHit instanceof EntityPlayer entityplayer))) {
if ((entityplayer.capabilities.disableDamage) || (((tShootingEntity instanceof EntityPlayer))
&& (!((EntityPlayer) tShootingEntity).canAttackPlayer(entityplayer)))) {
tVector = null;
@@ -209,7 +208,7 @@ public class GT_Entity_Arrow extends EntityArrow {
new GameProfile(
new UUID(0L, 0L),
(tShootingEntity instanceof EntityLivingBase)
- ? ((EntityLivingBase) tShootingEntity).getCommandSenderName()
+ ? tShootingEntity.getCommandSenderName()
: "Arrow"));
}
if (tPlayer != null) {
@@ -224,7 +223,7 @@ public class GT_Entity_Arrow extends EntityArrow {
tShootingEntity == null ? this : tShootingEntity);
if ((tDamage + tMagicDamage > 0.0F)
&& (tVector.entityHit.attackEntityFrom(tDamageSource, tDamage + tMagicDamage))) {
- if ((tVector.entityHit instanceof EntityLivingBase)) {
+ if ((tVector.entityHit instanceof EntityLivingBase tHitLivingEntity)) {
if (tHitTimer >= 0) {
tVector.entityHit.hurtResistantTime = tHitTimer;
}
@@ -234,7 +233,6 @@ public class GT_Entity_Arrow extends EntityArrow {
this.mArrow) > 0)) {
((EntityCreeper) tVector.entityHit).func_146079_cb();
}
- EntityLivingBase tHitLivingEntity = (EntityLivingBase) tVector.entityHit;
if (!this.worldObj.isRemote) {
tHitLivingEntity.setArrowCountInEntity(
tHitLivingEntity.getArrowCountInEntity() + 1);