Skip to content

Commit c5fe4d5

Browse files
Version 1.1.3-forge-119
- Made Homing arrows target all players
1 parent ecd5fa8 commit c5fe4d5

File tree

5 files changed

+31
-42
lines changed

5 files changed

+31
-42
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919
apply plugin: 'org.spongepowered.mixin'
2020
apply plugin: 'org.parchmentmc.librarian.forgegradle'
2121

22-
version = '1.1.2'
22+
version = '1.1.3'
2323
group = 'com.thaddev.iw2thshortbows' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
2424
archivesBaseName = 'iw2thshortbows'
2525

src/main/java/com/thaddev/iw2thshortbows/IWant2TryHardsShortbows.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class IWant2TryHardsShortbows {
2525
public static final String MODID = "iw2thshortbows";
2626
public static final Logger LOGGER = LogUtils.getLogger();
2727
public static IWant2TryHardsShortbows instance;
28-
public static String VERSION = "1.1.2";
28+
public static String VERSION = "1.1.3";
2929

3030
public static final String MESSAGE_WELCOME = "message.iw2thshortbows.welcome";
3131
public static final String SCREEN_VERSION_MISMATCH = "menu.iw2thshortbows.modmismatch";

src/main/java/com/thaddev/iw2thshortbows/content/entities/projectiles/DiamondHeadedArrow.java

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.util.List;
3838
import java.util.Objects;
3939
import java.util.Set;
40+
import java.util.UUID;
4041

4142
public class DiamondHeadedArrow extends AbstractArrow {
4243
private static final int EXPOSED_POTION_DECAY_TIME = 600;
@@ -315,47 +316,38 @@ protected void onHitEntity(@NotNull EntityHitResult result) {
315316
//HOMING BEHAVIOR
316317
private void setTarget() {
317318
if (target == null || target.isDeadOrDying() || (target instanceof EnderDragon dragon && dragon.getPhaseManager().getCurrentPhase().getPhase() == EnderDragonPhase.DYING)) {
318-
AABB aabb = (new AABB(new BlockPos(this.position()))).inflate(20).expandTowards(0.0D, level.getHeight(), 0.0D);
319-
List<LivingEntity> potentialTargets = this.level.getEntitiesOfClass(LivingEntity.class, aabb);
320-
321-
if (potentialTargets.size() == 0) {
322-
target = null;
323-
return;
324-
}
325-
326-
potentialTargets.removeIf(LivingEntity::isDeadOrDying);
327-
potentialTargets.removeIf(entity -> !(entity instanceof Enemy));
328-
potentialTargets.removeIf(entity -> !entity.hasLineOfSight(this));
329-
potentialTargets.removeIf(entity -> entity instanceof EnderMan);
330-
potentialTargets.removeIf(entity -> (entity instanceof WitherBoss boss && boss.isPowered()));
331-
potentialTargets.removeIf(entity -> {
332-
if (entity instanceof EnderDragon){
333-
EnderDragonPhase<? extends DragonPhaseInstance> phase = ((EnderDragon) entity).getPhaseManager().getCurrentPhase().getPhase();
334-
return phase == EnderDragonPhase.SITTING_ATTACKING ||
335-
phase == EnderDragonPhase.SITTING_SCANNING ||
336-
phase == EnderDragonPhase.SITTING_FLAMING ||
337-
phase == EnderDragonPhase.DYING;
338-
}
339-
return false;
340-
});
341-
potentialTargets.removeIf(entity ->
342-
entity instanceof Player player &&
343-
player.getUUID().equals(Objects.requireNonNull(this.getOwner()).getUUID())
344-
);
345-
potentialTargets.removeIf(entity ->
346-
entity instanceof Player player && (player.isCreative() || player.isSpectator())
347-
);
348-
potentialTargets.removeIf(entity ->
349-
entity instanceof Player player && this.getOwner() instanceof Player owner && !owner.canHarmPlayer(player)
350-
);
351-
352-
353-
if (potentialTargets.size() == 0) {
319+
AABB aabb = new AABB(new BlockPos(this.position())).inflate(20).expandTowards(0.0D, level.getHeight(), 0.0D);
320+
List<LivingEntity> potentialTargets = level.getEntitiesOfClass(LivingEntity.class, aabb)
321+
.stream()
322+
.filter(entity -> !entity.isDeadOrDying() &&
323+
entity instanceof Enemy &&
324+
entity.hasLineOfSight(this) &&
325+
!(entity instanceof EnderMan) &&
326+
(!(entity instanceof WitherBoss) || !((WitherBoss) entity).isPowered()) &&
327+
!(entity instanceof EnderDragon) ||
328+
!isDragonSittingOrDying((EnderDragon) entity) &&
329+
!(entity instanceof Player) ||
330+
!playerMatchesOwner((Player) entity))
331+
.toList();
332+
333+
if (potentialTargets.isEmpty()) {
354334
target = null;
355335
return;
356336
}
357337

358338
target = potentialTargets.get(random.nextInt(potentialTargets.size()));
359339
}
360340
}
341+
private boolean isDragonSittingOrDying(EnderDragon dragon) {
342+
EnderDragonPhase<? extends DragonPhaseInstance> phase = dragon.getPhaseManager().getCurrentPhase().getPhase();
343+
return phase == EnderDragonPhase.SITTING_ATTACKING ||
344+
phase == EnderDragonPhase.SITTING_SCANNING ||
345+
phase == EnderDragonPhase.SITTING_FLAMING ||
346+
phase == EnderDragonPhase.DYING;
347+
}
348+
349+
private boolean playerMatchesOwner(Player player) {
350+
UUID ownerUUID = Objects.requireNonNull(this.getOwner()).getUUID();
351+
return player.getUUID().equals(ownerUUID) || player.isCreative() || player.isSpectator();
352+
}
361353
}

src/main/java/com/thaddev/iw2thshortbows/content/items/weapons/ShortBowBase.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ public int getUseDuration(@NotNull ItemStack p_40680_) {
9696
if (strengthBoost > 0){
9797
PotionUtils.getPotion(itemstack).getEffects().forEach(effect -> {
9898
if (effect.getEffect().isInstantenous()){
99-
// player.addEffect(new MobEffectInstance(effect.getEffect(), 1, (effect.getAmplifier() + 1) > 1 ?
100-
// (int) Math.round(Math.floor(effect.getAmplifier() / 2f)) :
101-
// effect.getAmplifier()));
10299
effect.getEffect().applyInstantenousEffect(null, player, player, (effect.getAmplifier() + 1) > 1 ?
103100
(int) Math.round(Math.floor(effect.getAmplifier() / 2f)) :
104101
effect.getAmplifier(), 1);

src/main/resources/META-INF/mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ license="MIT"
44

55
[[mods]]
66
modId = "iw2thshortbows"
7-
version = "1.1.2" #mandatory
7+
version = "1.1.3" #mandatory
88
displayName = "IWant2TryHard's Shortbows" #mandatory
99
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
1010
displayURL = "https://github.com/MyNameTsThad/IW2THs-Shortbows" #optional

0 commit comments

Comments
 (0)