Skip to content

Commit f102c53

Browse files
committed
Improve Carmot Staff projectile checking
Possibly helps with #264
1 parent 78d96bd commit f102c53

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/java/nourl/mythicmetals/item/tools/CarmotStaff.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,19 @@ public void usageTick(World world, LivingEntity user, ItemStack stack, int remai
497497
}
498498

499499
for (Entity entity : entities) {
500+
if (entity.getCommandTags().contains(PROJECTILE_MODIFIED.toString())) {
501+
return;
502+
}
503+
500504
// Setting the owner of the trident to someone else would lead to shenanigans, don't do that
501-
if (entity instanceof TridentEntity trident && !trident.getCommandTags().contains(PROJECTILE_MODIFIED.toString())) {
505+
if (entity instanceof TridentEntity trident) {
502506
var bounceVec = trident.getVelocity().multiply(-0.25, -0.25, -0.25);
503507
trident.setVelocity(bounceVec.x, bounceVec.y, bounceVec.z);
504508
trident.returnTimer = 0;
505509
trident.addCommandTag(PROJECTILE_MODIFIED.toString());
506510
}
507511
// Special handling for ExplosiveProjectileEntities, like fireballs
508-
if (entity instanceof ExplosiveProjectileEntity projectile && !projectile.getCommandTags().contains(PROJECTILE_MODIFIED.toString())) {
512+
if (entity instanceof ExplosiveProjectileEntity projectile) {
509513
var bounceVec = projectile.getVelocity().multiply(-0.25, -0.25, -0.25);
510514
projectile.setVelocity(bounceVec.x, bounceVec.y, bounceVec.z, 1.05F, 0.5F);
511515
// projectile.powerX = -projectile.powerX;
@@ -516,15 +520,15 @@ public void usageTick(World world, LivingEntity user, ItemStack stack, int remai
516520
stack.damage(2, user, EquipmentSlot.MAINHAND);
517521
}
518522
// Shulker bullet handling
519-
if (entity instanceof ShulkerBulletEntity projectile && !projectile.getCommandTags().contains(PROJECTILE_MODIFIED.toString())) {
523+
if (entity instanceof ShulkerBulletEntity projectile) {
520524
projectile.damage(world.getDamageSources().generic(), 1.0F);
521525
}
522526
// Default/Arrow handling
523-
else if (entity instanceof ProjectileEntity projectile && !projectile.getCommandTags().contains(PROJECTILE_MODIFIED.toString())) {
527+
else if (entity instanceof ProjectileEntity projectile) {
524528
// Bounce the projectiles in the direction the player is looking
525529
var bounceVec = projectile.getVelocity().multiply(-0.25, -0.25, -0.25);
526530
projectile.setVelocity(bounceVec.x, bounceVec.y, bounceVec.z, 1.05F, 0.5F);
527-
projectile.getCommandTags().add(PROJECTILE_MODIFIED.toString());
531+
projectile.addCommandTag(PROJECTILE_MODIFIED.toString());
528532
stack.damage(1, user, EquipmentSlot.MAINHAND);
529533
}
530534
}

0 commit comments

Comments
 (0)