Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[1.0.6]

**Changed**
* Decreased FlintAmmunition damage from "5" to "4"
* Increased Diamond Ammunition damage from "9" to "12"
* Flint Ammunition now acts as shotgun ammo, firing 4–8 pellets in a wider spread with limited range and distance-based damage falloff

**Fixed**
* Crash when Boar entity executed attack-related goals due to missing `ATTACK_DAMAGE` attribute
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BoarEntity(EntityType<? extends Animal> entityType, Level world) {
}

public static AttributeSupplier.@NotNull Builder createMobAttributes() {
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 12.0).add(Attributes.MOVEMENT_SPEED, 0.2F);
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 12.0).add(Attributes.MOVEMENT_SPEED, 0.2F).add(Attributes.ATTACK_DAMAGE, 2.0D);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class BulletEntity extends Fireball {
private double knockbackStrength = 0;
private int ticksSinceFired;
private Vec3 initialPosition;
private int lifeTicks = 40;

public BulletEntity(EntityType<? extends Fireball> entityType, Level level) {
super(entityType, level);
Expand All @@ -44,6 +45,11 @@ public BulletEntity(Level worldIn, LivingEntity shooter, double accelX, double a

@Override
public void tick() {
if (--lifeTicks <= 0) {
discard();
return;
}

if (initialPosition == null) {
initialPosition = this.position();
}
Expand Down Expand Up @@ -72,7 +78,8 @@ protected void onHitEntity(EntityHitResult raytrace) {

int lastHurtResistant = target.invulnerableTime;
if (ignoreInvulnerability) target.invulnerableTime = 0;
boolean damaged = target.hurt(level().damageSources().indirectMagic(this, shooter), (float) bullet.modifyDamage(damage, this, target, shooter, level()));
boolean damaged = target.hurt(level().damageSources().indirectMagic(this, shooter),
(float) bullet.modifyDamage(damage, this, target, shooter, level()));

if (damaged && target instanceof LivingEntity livingTarget) {
if (knockbackStrength > 0) {
Expand All @@ -97,6 +104,7 @@ public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("tickssincefired", ticksSinceFired);
compound.putDouble("damage", damage);
compound.putInt("lifeTicks", lifeTicks);
if (ignoreInvulnerability) compound.putBoolean("ignoreinvulnerability", true);
if (knockbackStrength != 0) compound.putDouble("knockback", knockbackStrength);
}
Expand All @@ -106,6 +114,7 @@ public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
ticksSinceFired = compound.getInt("tickssincefired");
damage = compound.getDouble("damage");
lifeTicks = compound.getInt("lifeTicks");
ignoreInvulnerability = compound.getBoolean("ignoreinvulnerability");
knockbackStrength = compound.getDouble("knockback");
}
Expand All @@ -122,6 +131,10 @@ public void setIgnoreInvulnerability(boolean ignoreInvulnerability) {
this.ignoreInvulnerability = ignoreInvulnerability;
}

public void setLifeTicks(int ticks) {
this.lifeTicks = ticks;
}

@Override
public void shootFromRotation(Entity shooter, float xRot, float yRot, float p_37255_, float speed, float spread) {
float f = -Mth.sin(yRot * ((float) Math.PI / 180F)) * Mth.cos(xRot * ((float) Math.PI / 180F));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ public boolean hasAmmo(ItemStack stack) {
public double modifyDamage(double damage, BulletEntity projectile, Entity target, @Nullable Entity shooter, Level world) {
return damage;
}

public int getDamage() {
return damage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class BlunderBussItem extends ProjectileWeaponItem {
private static final int DEFAULT_DURABILITY = 128;
private static final Ingredient DEFAULT_REPAIR_MATERIAL = Ingredient.of(Items.IRON_INGOT);
private static final Predicate<ItemStack> BULLETS = (stack) -> stack.getItem() instanceof AmmunitionItem && ((AmmunitionItem) stack.getItem()).hasAmmo(stack);

private final int bonusDamage;
private final double damageMultiplier;
private final int fireDelay;
Expand All @@ -55,7 +56,7 @@ public BlunderBussItem() {

if (!ammo.isEmpty() || player.getAbilities().instabuild) {
if (ammo.isEmpty()) {
ammo = new ItemStack(net.minecraft.world.item.Items.IRON_INGOT);
ammo = new ItemStack(Items.IRON_INGOT);
}

if (ammo.getItem() instanceof AmmunitionItem bulletItem) {
Expand All @@ -68,9 +69,11 @@ public BlunderBussItem() {
if (!bulletFree) bulletItem.consume(ammo, player);
}

world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundRegistry.BLUNDERBUSS_SHOOT.get(), SoundSource.PLAYERS, 1.0F, world.getRandom().nextFloat() * 5F + 1.0F);
player.awardStat(Stats.ITEM_USED.get(this));
world.playSound(null, player.getX(), player.getY(), player.getZ(),
SoundRegistry.BLUNDERBUSS_SHOOT.get(), SoundSource.PLAYERS, 1.0F,
world.getRandom().nextFloat() * 5F + 1.0F);

player.awardStat(Stats.ITEM_USED.get(this));
player.getCooldowns().addCooldown(this, getFireDelay());

if (world instanceof ServerLevel serverWorld) {
Expand All @@ -80,7 +83,9 @@ public BlunderBussItem() {

serverWorld.sendParticles(ParticleTypes.SMALL_FLAME, particleX, particleY, particleZ, 5, 0.1, 0.1, 0.1, 0.01);
serverWorld.sendParticles(ParticleTypes.SMOKE, particleX, particleY, particleZ, 10, 0.1, 0.1, 0.1, 0.01);
serverWorld.getServer().tell(new TickTask(serverWorld.getServer().getTickCount() + 40, () -> world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundRegistry.BLUNDERBUSS_LOAD.get(), SoundSource.PLAYERS, 0.5F, 1.0F)));
serverWorld.getServer().tell(new TickTask(serverWorld.getServer().getTickCount() + 40,
() -> world.playSound(null, player.getX(), player.getY(), player.getZ(),
SoundRegistry.BLUNDERBUSS_LOAD.get(), SoundSource.PLAYERS, 0.5F, 1.0F)));
}

return InteractionResultHolder.consume(gun);
Expand All @@ -92,18 +97,34 @@ public BlunderBussItem() {
}

protected void shoot(Level world, Player player, ItemStack ammo, AmmunitionItem bulletItem) {
BulletEntity shot = bulletItem.createProjectile(world, ammo, player);
shot.shootFromRotation(player, player.getXRot(), player.getYRot(), 0, (float) getProjectileSpeed(), (float) getInaccuracy());
shot.setDamage((shot.getDamage() + getBonusDamage()) * getDamageMultiplier());
shot.setIgnoreInvulnerability(ignoreInvulnerability);
if (bulletItem instanceof FlintAmmunitionItem) {
int pelletCount = 4 + world.getRandom().nextInt(5);
for (int i = 0; i < pelletCount; i++) {
BulletEntity pellet = bulletItem.createProjectile(world, ammo.copy(), player);

world.addFreshEntity(shot);
float spread = (float) (getInaccuracy() * 3.5);
pellet.shootFromRotation(player, player.getXRot(), player.getYRot(),
0, (float) getProjectileSpeed() * 0.6f, spread);

double distScale = Math.max(0.2, 1.0 - (player.distanceTo(pellet) / 12.0));
pellet.setDamage(((bulletItem.getDamage() + 3) * getDamageMultiplier()) * distScale);

pellet.setIgnoreInvulnerability(ignoreInvulnerability);
pellet.setLifeTicks(12 + world.getRandom().nextInt(4));
world.addFreshEntity(pellet);
}
} else {
BulletEntity shot = bulletItem.createProjectile(world, ammo, player);
shot.shootFromRotation(player, player.getXRot(), player.getYRot(), 0, (float) getProjectileSpeed(), (float) getInaccuracy());
shot.setDamage((shot.getDamage() + getBonusDamage()) * getDamageMultiplier());
shot.setIgnoreInvulnerability(ignoreInvulnerability);
world.addFreshEntity(shot);
}

if (world instanceof ServerLevel serverWorld) {
double particleX = player.getX() + player.getLookAngle().x * 0.5;
double particleY = player.getY() + player.getEyeHeight() - 0.1;
double particleZ = player.getZ() + player.getLookAngle().z * 0.5;

serverWorld.sendParticles(ParticleTypes.SMALL_FLAME, particleX, particleY, particleZ, 5, 0.1, 0.1, 0.1, 0.01);
serverWorld.sendParticles(ParticleTypes.SMOKE, particleX, particleY, particleZ, 10, 0.1, 0.1, 0.1, 0.01);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.satisfy.wildernature.item;

public class FlintAmmunitionItem extends AmmunitionItem {
public FlintAmmunitionItem(Properties properties, int damage) {
super(properties, damage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class ObjectRegistry {
public static final RegistrySupplier<Item> CASSOWARY_MEAT = registerItem("cassowary_meat", () -> new Item(getSettings().food(Foods.RABBIT)));
public static final RegistrySupplier<Item> COOKED_CASSOWARY_MEAT = registerItem("cooked_cassowary_meat", () -> new Item(getSettings().food(Foods.COOKED_RABBIT)));
public static final RegistrySupplier<Item> BLUNDERBUSS = registerItem("blunderbuss", BlunderBussItem::new);
public static final RegistrySupplier<Item> FLINT_AMMUNITION = registerItem("flint_ammunition", () -> new AmmunitionItem(getSettings().rarity(Rarity.UNCOMMON), 5));
public static final RegistrySupplier<Item> DIAMOND_AMMUNITION = registerItem("diamond_ammunition", () -> new AmmunitionItem(getSettings().rarity(Rarity.COMMON), 9));
public static final RegistrySupplier<Item> FLINT_AMMUNITION = registerItem("flint_ammunition", () -> new FlintAmmunitionItem(getSettings().rarity(Rarity.UNCOMMON), 4));
public static final RegistrySupplier<Item> DIAMOND_AMMUNITION = registerItem("diamond_ammunition", () -> new AmmunitionItem(getSettings().rarity(Rarity.COMMON), 12));
public static final RegistrySupplier<Item> FUR_CLOAK = registerItem("fur_cloak", () -> new FurCloakItem(ArmorMaterials.LEATHER, ArmorItem.Type.CHESTPLATE, new Item.Properties()));
public static final RegistrySupplier<Item> FISH_OIL = registerItem("fish_oil", () -> new Item(getSettings().stacksTo(16)));
public static final RegistrySupplier<Item> LOOT_BAG = registerItem("loot_bag", () -> new LootBagItem(getSettings().rarity(Rarity.COMMON)));
Expand Down
Loading