Skip to content

Commit 6d26d97

Browse files
committed
Fix Codacy Error Issues (could lead to stupid bugs otherwise)
1 parent 264dcde commit 6d26d97

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

java/com/httymd/entity/EntityDragon.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import net.minecraft.enchantment.EnchantmentHelper;
99
import net.minecraft.entity.Entity;
1010
import net.minecraft.entity.EntityLivingBase;
11-
import net.minecraft.entity.SharedMonsterAttributes;
1211
import net.minecraft.entity.player.EntityPlayer;
1312
import net.minecraft.item.ItemStack;
1413
import net.minecraft.nbt.NBTTagCompound;
@@ -21,7 +20,7 @@ public class EntityDragon extends EntityTameableFlying {
2120

2221
private static final String NBT_IS_STARTLED = "IsStartled";
2322

24-
protected boolean isStartled = false;
23+
protected boolean startled = false;
2524

2625
public EntityDragon(World world) {
2726
super(world);
@@ -32,7 +31,7 @@ public EntityDragon(World world) {
3231
@Override
3332
protected void applyEntityAttributes() {
3433
super.applyEntityAttributes();
35-
this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
34+
this.getAttributeMap().registerAttribute(damageAtt);
3635
}
3736

3837
public boolean isRideableBy(Entity rider) {
@@ -90,16 +89,13 @@ public boolean onFeed(EntityLivingBase feeder, ItemStack feed) {
9089

9190
public boolean interact(EntityPlayer ply) {
9291
ItemStack hand = ply.getCurrentEquippedItem();
93-
if (hand == null)
94-
;
95-
else if (HTTYMDMod.getConfig().isDebugMode() && hand.getItem() == ItemRegistry.wing) {
96-
this.onTakeoff();
97-
return true;
98-
} else if (ItemUtils.isFood(hand)) {
99-
boolean feed = this.onFeed(ply, hand); // Running twice might cause problems
100-
if(this.canTame(ply, hand) && feed); // Prevents double taking of tame items
101-
else if(feed && !ply.capabilities.isCreativeMode && --hand.stackSize <= 0)
102-
ply.inventory.setInventorySlotContents(ply.inventory.currentItem, (ItemStack) null);
92+
if (hand != null) {
93+
if (HTTYMDMod.getConfig().isDebugMode() && hand.getItem() == ItemRegistry.wing) {
94+
this.onTakeoff();
95+
return true;
96+
} else if (ItemUtils.isFood(hand) && !this.canTame(ply, hand) &&
97+
this.onFeed(ply, hand) && !ply.capabilities.isCreativeMode && --hand.stackSize <= 0)
98+
ply.inventory.setInventorySlotContents(ply.inventory.currentItem, (ItemStack) null);
10399
}
104100

105101
if (this.isOwner(ply) && this.isRideableBy(ply)) {
@@ -112,7 +108,6 @@ else if(feed && !ply.capabilities.isCreativeMode && --hand.stackSize <= 0)
112108
@Override
113109
public boolean attackEntityAsMob(Entity target) {
114110
double damage = 2.0D;
115-
116111
int knockback = 0;
117112

118113
if (target instanceof EntityLivingBase) {
@@ -153,7 +148,7 @@ public boolean isAngry() {
153148
}
154149

155150
public boolean isStartled() {
156-
return this.isStartled;
151+
return this.startled;
157152
}
158153

159154
public boolean isTameable(EntityLivingBase tamer) {
@@ -170,12 +165,12 @@ public void readEntityFromNBT(NBTTagCompound tag) {
170165
* Sets whether this dragon is angry or not.
171166
*/
172167
public void setAngry(boolean p_70916_1_) {
173-
byte b0 = this.dataWatcher.getWatchableObjectByte(BOOL_WATCHER);
168+
byte boolByte = this.dataWatcher.getWatchableObjectByte(BOOL_WATCHER);
174169

175170
if (p_70916_1_)
176-
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | BOOL_IS_ANGRY)));
171+
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (boolByte | BOOL_IS_ANGRY)));
177172
else
178-
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -(BOOL_IS_ANGRY + 1))));
173+
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (boolByte & -(BOOL_IS_ANGRY + 1))));
179174
}
180175

181176
public void setAttackTarget(EntityLivingBase p_70624_1_) {
@@ -188,7 +183,7 @@ else if (!this.isTamed())
188183
}
189184

190185
public void setStartled(boolean startled) {
191-
this.isStartled = startled;
186+
this.startled = startled;
192187
}
193188

194189
@Override

java/com/httymd/item/ItemWeapon.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public boolean func_150897_b(Block block) {
109109
*/
110110
@SuppressWarnings({ "unchecked", "rawtypes" })
111111
public float getModifiedAmount(ItemStack stack, String modifierName) {
112-
if(modifierName.equals("")) return 0;
112+
if(modifierName.isEmpty()) return 0;
113113
Iterator itr = stack.getAttributeModifiers().get(modifierName).iterator();
114114
float f = 0;
115115
while (itr.hasNext()) {

java/com/httymd/util/NameManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public String get(EntityLivingBase entity, String currentName) {
5151

5252
String id = ((EntityPlayer) entity).getGameProfile().getId().toString();
5353

54-
if (id.equals("b2848781-aafe-454b-a87d-89ceffad585f"))
54+
if ("b2848781-aafe-454b-a87d-89ceffad585f".equals(id))
5555
return "s322";
5656

57-
if (id.equals("5c884585-0245-4452-bcac-5005c73d3196"))
57+
if ("5c884585-0245-4452-bcac-5005c73d3196".equals(id))
5858
return "cmmr";
5959

6060
return null;

0 commit comments

Comments
 (0)