Skip to content

Commit

Permalink
Fixed an issue where Minecraft crashes, decreased deviation of skelet…
Browse files Browse the repository at this point in the history
…ons' ranged attacks, increased the target sense range of mobs, added features I forgot to mention to README.
  • Loading branch information
Pot-Tx committed Oct 22, 2023
1 parent 0850f83 commit 5e595e9
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This is a Minecraft Better Than Wolves addon that aims to slightly strengthen mo
- Skeletons predict their target's position before ranged attacks.
- Skeletons try not to get too close to dangerous targets when holding a bow.
- Skeletons flee from dangerous targets when their health is low.
- Skeletons' max health is decreased from 20 to 16.

### Creepers

Expand All @@ -34,6 +35,10 @@ This is a Minecraft Better Than Wolves addon that aims to slightly strengthen mo
- Witches predict their target's position before throwing potions.
- Witches try not to get too close to dangerous targets.

### Spiders

- Cobwebs don't only slow down entities' move speed, but also make players hardly rotate their look direction.

### Silverfish

- Infested stones generate in all biomes; the deeper, the more.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class MobsEnhancementAddon extends BTWAddon {
private static MobsEnhancementAddon instance;

private MobsEnhancementAddon() {
super("Mobs Enhancement", "0.1.0", "Mo");
super("Mobs Enhancement", "0.1.1", "Mo");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean realisticCanEntityBeSeen(Entity entity, double absDist) {
float yaw = entity.rotationYaw >= 0 ? entity.rotationYaw % 360 : entity.rotationYaw % 360 + 360;
double angel = Math.atan2(entity.posX - this.posX, entity.posZ - this.posZ) * 180 / Math.PI;

boolean isInSight = this.getDistanceSqToEntity(entity) < absDist * absDist || Math.abs(yaw - angel) < 60;
boolean isInSight = this.getDistanceSqToEntity(entity) < absDist * absDist || Math.abs(yaw - angel) < 75;

return isInSight && (canTopBeSeen || canCenterBeSeen || canBottomBeSeen || canEyeBeSeen);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public EntitySkeletonMixin(World par1World) {

@Inject(
method = "<init>",
at = @At(value = "INVOKE", target = "Lnet/minecraft/src/EntityAITasks;addTask(ILnet/minecraft/src/EntityAIBase;)V", ordinal = 0)
at = @At(value = "TAIL")
)
private void resetMoveSpeed(CallbackInfo ci) {
this.moveSpeed = 0.375F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public EntityWitchMixin(World par1World) {

@Inject(
method = "<init>",
at = @At(value = "INVOKE", target = "Lnet/minecraft/src/EntityAITasks;addTask(ILnet/minecraft/src/EntityAIBase;)V", ordinal = 0)
at = @At(value = "TAIL")
)
private void resetMoveSpeed(CallbackInfo ci) {
this.moveSpeed = 0.375F;
Expand All @@ -29,7 +29,7 @@ private void resetMoveSpeed(CallbackInfo ci) {
at = @At(value = "INVOKE", target = "Lnet/minecraft/src/EntityAITasks;addTask(ILnet/minecraft/src/EntityAIBase;)V", ordinal = 1)
)
private void modifyArrowAttackTask(Args args) {
args.set(1, new EntityAISmartArrowAttack(this, this.moveSpeed, 60, 9, 15.0F, 8F));
args.set(1, new EntityAISmartArrowAttack(this, 0.375F, 60, 9, 15.0F, 8F));
}

@ModifyArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public SkeletonEntityMixin(World world) {

@Inject(
method = "<init>",
at = @At(value = "INVOKE", target = "Lnet/minecraft/src/EntityAITasks;addTask(ILnet/minecraft/src/EntityAIBase;)V")
at = @At(value = "TAIL")
)
private void addFleeFromEnemyTask(CallbackInfo ci) {
tasks.addTask(3, new EntityAIFleeFromEnemy(this, EntityPlayer.class, 0.375F, 24.0F, 5));
Expand All @@ -39,18 +39,18 @@ private void addFleeFromEnemyTask(CallbackInfo ci) {
method = "entityInit()V",
at = @At(value = "TAIL")
)
private void setSmartRangedAttackAI(CallbackInfo ci) {
private void setSmartAttackAI(CallbackInfo ci) {
this.aiSmartRangedAttack = new EntityAISmartArrowAttack(this, 0.375F, 60, 6, 20F , 6F);
this.aiSmartMeleeAttack = new EntityAISmartAttackOnCollide(this, EntityPlayer.class, 0.375F, false, 6);
}

@Inject(
method = "attackEntityWithRangedAttack(Lnet/minecraft/src/EntityLiving;F)V",
method = {"attackEntityWithRangedAttack", "method_4552"},
at = @At(value = "INVOKE", target = "Lnet/minecraft/src/EnchantmentHelper;getEnchantmentLevel(ILnet/minecraft/src/ItemStack;)I"),
locals = LocalCapture.CAPTURE_FAILHARD
)
private void resetArrowForPrediction(EntityLiving target, float fDamageModifier, CallbackInfo ci, EntityArrow arrow) {
((EntityArrowAccess)arrow).resetForPrediction(this, target, 1.6F, 8F);
((EntityArrowAccess)arrow).resetForPrediction(this, target, 1.6F, 6F);
}

@ModifyArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ZombieEntityMixin(World par1World) {

@Inject(
method = "<init>",
at = @At(value = "INVOKE", target = "Lnet/minecraft/src/EntityAITasks;addTask(ILnet/minecraft/src/EntityAIBase;)V", ordinal = 0)
at = @At(value = "TAIL")
)
private void addBreakBlockTask(CallbackInfo ci) {
this.tasks.addTask(1, new EntityAIBreakBlock(this));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "mobsenhancement",
"version": "0.1.0",
"version": "0.1.1",

"name": "Mobs Enhancement Addon",
"description": "Slightly strengthens monsters.",
Expand Down

0 comments on commit 5e595e9

Please sign in to comment.