Skip to content

Commit 12fb7a3

Browse files
committed
-fix NPE
1 parent b92b60d commit 12fb7a3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

common/src/main/java/smartin/miapi/modules/abilities/util/ItemProjectile/ItemProjectile.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public ItemStack getBowItem() {
7171
return this.dataTracker.get(BOW_ITEM_STACK);
7272
}
7373

74+
@Override
7475
protected void initDataTracker() {
7576
super.initDataTracker();
7677
this.dataTracker.startTracking(THROWING_STACK, ItemStack.EMPTY);
@@ -90,6 +91,7 @@ public void setSpeedDamage(boolean speedDamage) {
9091
this.dataTracker.set(SPEED_DAMAGE, speedDamage);
9192
}
9293

94+
@Override
9395
public void tick() {
9496
if (this.inGroundTime > 4) {
9597
this.dealtDamage = true;
@@ -142,11 +144,13 @@ public boolean isEnchanted() {
142144
return this.dataTracker.get(ENCHANTED);
143145
}
144146

147+
@Override
145148
@Nullable
146149
protected EntityHitResult getEntityCollision(Vec3d currentPosition, Vec3d nextPosition) {
147150
return this.dealtDamage ? null : super.getEntityCollision(currentPosition, nextPosition);
148151
}
149152

153+
@Override
150154
protected void onEntityHit(EntityHitResult entityHitResult) {
151155
Entity entity = entityHitResult.getEntity();
152156
float damage = getProjectileDamage();
@@ -204,6 +208,7 @@ public boolean hasChanneling() {
204208
return EnchantmentHelper.hasChanneling(this.thrownStack);
205209
}
206210

211+
@Override
207212
protected boolean tryPickup(PlayerEntity player) {
208213
int slotId = this.dataTracker.get(PREFERRED_SLOT);
209214
boolean earlyPickup = switch (this.pickupType) {
@@ -237,17 +242,20 @@ public void setDamageToDeal(boolean hasDamage) {
237242
this.dealtDamage = !hasDamage;
238243
}
239244

245+
@Override
240246
protected SoundEvent getHitSound() {
241247
return SoundEvents.ITEM_TRIDENT_HIT_GROUND;
242248
}
243249

250+
@Override
244251
public void onPlayerCollision(PlayerEntity player) {
245252
if (this.isOwner(player) || this.getOwner() == null) {
246253
super.onPlayerCollision(player);
247254
}
248255

249256
}
250257

258+
@Override
251259
public void readCustomDataFromNbt(NbtCompound nbt) {
252260
super.readCustomDataFromNbt(nbt);
253261
if (nbt.contains("ThrownItem", 10)) {
@@ -263,13 +271,15 @@ public void readCustomDataFromNbt(NbtCompound nbt) {
263271
this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(this.thrownStack));
264272
}
265273

274+
@Override
266275
public void writeCustomDataToNbt(NbtCompound nbt) {
267276
super.writeCustomDataToNbt(nbt);
268277
nbt.put("ThrownItem", this.thrownStack.writeNbt(new NbtCompound()));
269278
nbt.put("BowItem", this.getBowItem().writeNbt(new NbtCompound()));
270279
nbt.putBoolean("DealtDamage", this.dealtDamage);
271280
}
272281

282+
@Override
273283
public void age() {
274284
int i = this.dataTracker.get(LOYALTY);
275285
if (this.pickupType != PickupPermission.ALLOWED || i <= 0) {
@@ -278,10 +288,12 @@ public void age() {
278288

279289
}
280290

291+
@Override
281292
protected float getDragInWater() {
282293
return waterDrag;
283294
}
284295

296+
@Override
285297
public boolean shouldRender(double cameraX, double cameraY, double cameraZ) {
286298
return true;
287299
}

0 commit comments

Comments
 (0)