diff --git a/gradle.properties b/gradle.properties index 0e591d8..5ae9de5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ minecraft_version=1.20.1 # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. -minecraft_version_range=[1.20.1,1.21) +minecraft_version_range=[1.20.1] # The Forge version must agree with the Minecraft version to get a valid artifact forge_version=47.3.0 # The Forge version range can use any version of Forge as bounds or match the loader version range @@ -38,7 +38,7 @@ mod_name=Advanced Arrows # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=All Rights Reserved # The mod version. See https://semver.org/ -mod_version=0.0.1 +mod_version=0.0.2 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/jenny/advancedarrows/entities/enderArrow.java b/src/main/java/com/jenny/advancedarrows/entities/enderArrow.java new file mode 100644 index 0000000..288be72 --- /dev/null +++ b/src/main/java/com/jenny/advancedarrows/entities/enderArrow.java @@ -0,0 +1,53 @@ +package com.jenny.advancedarrows.entities; + +import com.jenny.advancedarrows.config.ConfigClient; +import com.jenny.advancedarrows.items.items; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; + +public class enderArrow extends baseArrow { + public enderArrow(EntityType pEntityType, Level pLevel) { + super(pEntityType, pLevel); + } + + public enderArrow(Level pLevel, LivingEntity pShooter) { + super(pLevel, pShooter, entities.ARROW_ENDER.get()); + } + + @Override + protected void onHitEntity(@NotNull EntityHitResult pTarget) { + super.onHitEntity(pTarget); + Entity target = pTarget.getEntity(); + target.addDeltaMovement(getDeltaMovement().multiply(1.5, 0.2, 1.5)); + } + + @NotNull + protected ItemStack getPickupItem() { + return new ItemStack(items.ARROW_ENDER.get()); + } + + @Override + protected void onHit(@NotNull HitResult pResult) { + super.onHit(pResult); + if (getOwner() != null) { + Vec3 pos = pResult.getLocation(); + level().getPlayerByUUID(getOwner().getUUID()).teleportTo(pos.x, pos.y, pos.z); + } + } + + @Override + public void spawnParticles() { + for (int i = 1; i <= ConfigClient.calcPCount(5); i++) { + Vec3 pos = createParticlePos(1f); + level().addParticle(ParticleTypes.ELECTRIC_SPARK, pos.x, pos.y, pos.z, 0, 0, 0); + } + } +} diff --git a/src/main/java/com/jenny/advancedarrows/entities/entities.java b/src/main/java/com/jenny/advancedarrows/entities/entities.java index 27063e1..1dcba68 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/entities.java +++ b/src/main/java/com/jenny/advancedarrows/entities/entities.java @@ -1,7 +1,6 @@ package com.jenny.advancedarrows.entities; -import com.jenny.advancedarrows.entities.client.*; - +import com.jenny.advancedarrows.entities.client.baseArrowRenderer; import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; @@ -13,9 +12,9 @@ import net.minecraftforge.registries.RegistryObject; import static com.jenny.advancedarrows.advancedArrows.MODID; public class entities { - private static int tr = 16; - private static float w = 0.5f; - private static float h = 0.5f; + private static final int tr = 16; + private static final float w = 0.5f; + private static final float h = 0.5f; public static final DeferredRegister> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, MODID); @@ -44,6 +43,14 @@ public class entities { ENTITY_TYPES.register("arrow_breaching", () -> EntityType.Builder.of(breachingArrow::new, MobCategory.MISC) .sized(w, h).fireImmune().clientTrackingRange(tr).build("arrow_breaching")); + public static final RegistryObject> ARROW_HOMING = + ENTITY_TYPES.register("arrow_homing", () -> EntityType.Builder.of(homingArrow::new, MobCategory.MISC) + .sized(w, h).fireImmune().clientTrackingRange(tr).build("arrow_homing")); + + public static final RegistryObject> ARROW_ENDER = + ENTITY_TYPES.register("arrow_ender", () -> EntityType.Builder.of(enderArrow::new, MobCategory.MISC) + .sized(w, h).fireImmune().clientTrackingRange(tr).build("arrow_ender")); + public static void register(IEventBus eventBus) { ENTITY_TYPES.register(eventBus); } @@ -55,5 +62,7 @@ public class entities { EntityRenderers.register(ARROW_SHARPENED.get(), baseArrowRenderer::new); EntityRenderers.register(ARROW_SWITCH.get(), baseArrowRenderer::new); EntityRenderers.register(ARROW_BREACHING.get(), baseArrowRenderer::new); + EntityRenderers.register(ARROW_HOMING.get(), baseArrowRenderer::new); + EntityRenderers.register(ARROW_ENDER.get(), baseArrowRenderer::new); } } diff --git a/src/main/java/com/jenny/advancedarrows/entities/homingArrow.java b/src/main/java/com/jenny/advancedarrows/entities/homingArrow.java new file mode 100644 index 0000000..57a267e --- /dev/null +++ b/src/main/java/com/jenny/advancedarrows/entities/homingArrow.java @@ -0,0 +1,95 @@ +package com.jenny.advancedarrows.entities; + +import com.jenny.advancedarrows.config.ConfigClient; +import com.jenny.advancedarrows.items.items; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class homingArrow extends baseArrow { + LivingEntity target; + + public homingArrow(EntityType pEntityType, Level pLevel) { + super(pEntityType, pLevel); + } + + public homingArrow(Level pLevel, LivingEntity pShooter) { + super(pLevel, pShooter, entities.ARROW_HOMING.get()); + setBaseDamage(1); + } + + @NotNull + protected ItemStack getPickupItem() { + return new ItemStack(items.ARROW_HOMING.get()); + } + + @Override + public void tick() { + if (!level().isClientSide) { + if (target == null || getTargetDist() > 64) { + findTarget(); + } else { + if (!inGround) { + Vec3 targetvec = targetVector().normalize().scale(getDeltaMovement().length()); + setDeltaMovement(getDeltaMovement().multiply(0.7, 0.7, 0.7).add(targetvec.multiply(0.3, 0.3, 0.3))); + } + } + } + super.tick(); + } + + public double getTargetDist() { + return targetVector().length(); + } + + private Vec3 targetVector() { + double y = target.getBoundingBox().getYsize() / 2; + return position().vectorTo(target.position().add(0, y, 0)); + } + + public void findTarget() { + double minAngle = Double.MAX_VALUE; + for (LivingEntity entity : getEntities()) { + Vec3 vecTarget = position().vectorTo(entity.position()); + double newAngle = Math.acos(vecTarget.dot(getDeltaMovement()) / (getDeltaMovement().length() * vecTarget.length())); + if (newAngle < minAngle) { + target = entity; + minAngle = newAngle; + } + } + } + + protected List getEntities() { + if (getOwner() == null) { + setOwner(this); + } + + List ret_list = new ArrayList<>(); + Vec3 corner1 = this.position().subtract(32, 32, 32); + Vec3 corner2 = this.position().add(32, 32, 32); + AABB boundingBox = new AABB(corner1, corner2); + + for (LivingEntity entity : level().getEntitiesOfClass(LivingEntity.class, boundingBox)) { + if (entity.getUUID() != getOwner().getUUID()) { + ret_list.add(entity); + } + } + return ret_list; + } + + @Override + public void spawnParticles() { + for (int i = 1; i <= ConfigClient.calcPCount(5); i++) { + Vec3 pos = createParticlePos(0.5f); + level().addParticle(ParticleTypes.GLOW_SQUID_INK, pos.x, pos.y, pos.z, 0, 0, 0); + } + } +} diff --git a/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java b/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java index 9dba837..e8085e4 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java @@ -2,17 +2,12 @@ package com.jenny.advancedarrows.entities; import com.jenny.advancedarrows.config.ConfigClient; import com.jenny.advancedarrows.items.items; - import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; - import org.jetbrains.annotations.NotNull; public class sharpenedArrow extends baseArrow{ @@ -22,24 +17,7 @@ public class sharpenedArrow extends baseArrow{ public sharpenedArrow(Level pLevel, LivingEntity pShooter) { super(pLevel, pShooter, entities.ARROW_SHARPENED.get()); - } - - @Override - protected void onHitEntity(@NotNull EntityHitResult pTarget) { - super.onHitEntity(pTarget); - System.out.println("a"); - Entity entity1 = this.getOwner(); - Entity target = pTarget.getEntity(); - DamageSource damagesource; - if (entity1 == null) { - damagesource = this.damageSources().arrow(this, this); - } else { - damagesource = this.damageSources().arrow(this, entity1); - if (entity1 instanceof LivingEntity) { - ((LivingEntity)entity1).setLastHurtMob(target); - } - } - target.hurt(damagesource, 5); + setBaseDamage(3); } @NotNull diff --git a/src/main/java/com/jenny/advancedarrows/items/ArrowEnder.java b/src/main/java/com/jenny/advancedarrows/items/ArrowEnder.java new file mode 100644 index 0000000..f9526fe --- /dev/null +++ b/src/main/java/com/jenny/advancedarrows/items/ArrowEnder.java @@ -0,0 +1,20 @@ +package com.jenny.advancedarrows.items; + +import com.jenny.advancedarrows.entities.enderArrow; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +public class ArrowEnder extends ArrowAbstract { + public ArrowEnder(Properties properties) { + super(properties); + } + + @Override + @NotNull + public AbstractArrow createArrow(@NotNull Level pLevel, @NotNull ItemStack pStack, @NotNull LivingEntity pShooter) { + return new enderArrow(pLevel, pShooter); + } +} diff --git a/src/main/java/com/jenny/advancedarrows/items/ArrowHoming.java b/src/main/java/com/jenny/advancedarrows/items/ArrowHoming.java new file mode 100644 index 0000000..4cab07e --- /dev/null +++ b/src/main/java/com/jenny/advancedarrows/items/ArrowHoming.java @@ -0,0 +1,20 @@ +package com.jenny.advancedarrows.items; + +import com.jenny.advancedarrows.entities.homingArrow; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +public class ArrowHoming extends ArrowAbstract { + public ArrowHoming(Properties properties) { + super(properties); + } + + @Override + @NotNull + public AbstractArrow createArrow(@NotNull Level pLevel, @NotNull ItemStack pStack, @NotNull LivingEntity pShooter) { + return new homingArrow(pLevel, pShooter); + } +} diff --git a/src/main/java/com/jenny/advancedarrows/items/items.java b/src/main/java/com/jenny/advancedarrows/items/items.java index 33462da..7b52d80 100644 --- a/src/main/java/com/jenny/advancedarrows/items/items.java +++ b/src/main/java/com/jenny/advancedarrows/items/items.java @@ -11,13 +11,15 @@ import static com.jenny.advancedarrows.advancedArrows.MODID; public class items { public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - public static final RegistryObject ARROW_INCENDIARY = ITEMS.register("arrow_incendiary", () -> new ArrowIncendiary(new Item.Properties())); public static final RegistryObject ARROW_RICOCHET = ITEMS.register("arrow_ricochet", () -> new ArrowRicochet(new Item.Properties())); public static final RegistryObject ARROW_KINETIC = ITEMS.register("arrow_kinetic", () -> new ArrowKinetic(new Item.Properties())); public static final RegistryObject ARROW_SHARPENED = ITEMS.register("arrow_sharpened", () -> new ArrowSharpened(new Item.Properties())); public static final RegistryObject ARROW_SWITCH = ITEMS.register("arrow_switch", () -> new ArrowSwitch(new Item.Properties())); public static final RegistryObject ARROW_BREACHING = ITEMS.register("arrow_breaching", () -> new ArrowBreaching(new Item.Properties())); + public static final RegistryObject ARROW_HOMING = ITEMS.register("arrow_homing", () -> new ArrowHoming(new Item.Properties())); + public static final RegistryObject ARROW_ENDER = ITEMS.register("arrow_ender", () -> new ArrowEnder(new Item.Properties())); + public static void register(IEventBus bus) { ITEMS.register(bus); diff --git a/src/main/resources/assets/advancedarrows/lang/en_us.json b/src/main/resources/assets/advancedarrows/lang/en_us.json index e69de29..9c8602a 100644 --- a/src/main/resources/assets/advancedarrows/lang/en_us.json +++ b/src/main/resources/assets/advancedarrows/lang/en_us.json @@ -0,0 +1,18 @@ +{ + "item.advancedarrows.arrow_breaching": "Breaching Arrow", + "tooltip.advancedarrows.arrow_breaching": "hurts entities hiding behind a hit block", + "item.advancedarrows.arrow_ender": "Ender Arrow", + "tooltip.advancedarrows.arrow_ender": "teleports the shooter to it's positon upon hit", + "item.advancedarrows.arrow_homing": "Homing Arrow", + "tooltip.advancedarrows.arrow_homing": "flies towards the closest entity", + "item.advancedarrows.arrow_incendiary": "Incendiary Arrow", + "tooltip.advancedarrows.arrow_incendiary": "sets hit entity on fire", + "item.advancedarrows.arrow_kinetic": "Kinetic Arrow", + "tooltip.advancedarrows.arrow_kinetic": "pushes hit entity away", + "item.advancedarrows.arrow_ricochet": "Ricocheting Arrow", + "tooltip.advancedarrows.arrow_ricochet": "ricochets off blocks", + "item.advancedarrows.arrow_sharpened": "Sharpened Arrow", + "tooltip.advancedarrows.arrow_sharpened": "does more damage", + "item.advancedarrows.arrow_switch": "Switching Arrow", + "tooltip.advancedarrows.arrow_switch": "switches shooter's & target's position on hit" +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedarrows/textures/item/arrow_breaching.png b/src/main/resources/assets/advancedarrows/textures/item/arrow_breaching.png index c03fcbb..bd310f6 100644 Binary files a/src/main/resources/assets/advancedarrows/textures/item/arrow_breaching.png and b/src/main/resources/assets/advancedarrows/textures/item/arrow_breaching.png differ diff --git a/src/main/resources/assets/advancedarrows/textures/item/arrow_breaching.png.mcmeta b/src/main/resources/assets/advancedarrows/textures/item/arrow_breaching.png.mcmeta new file mode 100644 index 0000000..f64f9eb --- /dev/null +++ b/src/main/resources/assets/advancedarrows/textures/item/arrow_breaching.png.mcmeta @@ -0,0 +1,34 @@ +{ + "animation": { + "frametime": 3, + "interpolate": false, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 4, + 3, + 2, + 1, + 0, + 0, + 0, + 0 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/advancedarrows/textures/item/arrow_ender.png b/src/main/resources/assets/advancedarrows/textures/item/arrow_ender.png new file mode 100644 index 0000000..ddebf53 Binary files /dev/null and b/src/main/resources/assets/advancedarrows/textures/item/arrow_ender.png differ diff --git a/src/main/resources/assets/advancedarrows/textures/item/arrow_ricochet.png b/src/main/resources/assets/advancedarrows/textures/item/arrow_ricochet.png index 168550f..67f05d0 100644 Binary files a/src/main/resources/assets/advancedarrows/textures/item/arrow_ricochet.png and b/src/main/resources/assets/advancedarrows/textures/item/arrow_ricochet.png differ diff --git a/src/main/resources/assets/advancedarrows/textures/item/arrow_ricochet.png.mcmeta b/src/main/resources/assets/advancedarrows/textures/item/arrow_ricochet.png.mcmeta new file mode 100644 index 0000000..6c5be66 --- /dev/null +++ b/src/main/resources/assets/advancedarrows/textures/item/arrow_ricochet.png.mcmeta @@ -0,0 +1,10 @@ +{ + "animation": { + "frametime": 15, + "interpolate": false, + "frames": [ + 0, + 1 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/items/arrows.json b/src/main/resources/data/minecraft/tags/items/arrows.json index 5b8195e..0ef5d26 100644 --- a/src/main/resources/data/minecraft/tags/items/arrows.json +++ b/src/main/resources/data/minecraft/tags/items/arrows.json @@ -5,6 +5,8 @@ "advancedarrows:arrow_kinetic", "advancedarrows:arrow_sharpened", "advancedarrows:arrow_switch", - "advancedarrows:arrow_breaching" + "advancedarrows:arrow_breaching", + "advancedarrows:arrow_homing", + "advancedarrows:arrow_ender" ] } \ No newline at end of file