Skip to content

Commit

Permalink
Bug fix, scaling difficulty update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pot-Tx committed Feb 1, 2024
1 parent 08cd773 commit 29fd7f2
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 24 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,40 @@ This is a Minecraft Better Than Wolves addon that aims to slightly strengthen mo
- Mobs' senses are strengthened, with further target distance and more points to check, instead of only doing an eye-to-eye check.
- Mobs cannot see entities behind them unless they are very close.
- Mobs can see through transparent blocks such as glass, leaves.
- Mobs no longer try to watch the closest player.
- Mobs no longer try to stare at the closest player.
- Hostile mobs' max health increase when the first nether portal is constructed.
- Nether and undead mobs' max health increase when the first wither is summoned.

### Zombies

- Zombies are able to break certain types of blocks blocking the way to their attack target, determined by their held item.
- Zombies' base max health is decreased from 20 to 16.
- Zombies have a chance to be able to sense targets through opaque blocks.
- Zombies transform into a skeleton of half its max health when die of sunlight,

### Skeletons

- Skeletons move faster.
- Skeletons no longer burn under sunlight.
- Skeletons have a chance to spawn with a melee weapon instead of a bow.
- Skeletons have a chance to spawn as a wither skeleton in the overworld at a low Y level after the first nether portal is constructed.
- Skeletons predict their target's position before ranged attacks.
- Skeletons' accuracy increases when the first nether portal is constructed, and when the first wither is summoned.
- 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.
- Skeletons' base max health is decreased from 20 to 12.
- Skeletons target villagers.
- Skeletons try to break nearby burning torches.
- Skeletons have a chance to be able to sense targets through opaque blocks.
- Skeletons try to flee from explosions.

### Creepers

- Creepers' fuse time is decreased from 1.5 seconds to 1 second.
- Creepers have a chance to spawn charged after the first nether portal is constructed.
- Creepers' base fuse time is decreased from 1.5 seconds to 1.25 second.
- Creepers' fuse time decrease when the first nether portal is constructed.
- Creepers' explosions spawn at the center of them, instead of the bottom.
- Creepers have a chance to instantly explode when interacted with shears.
- Creepers have a chance to instantly explode when interacted with shears, the chance is higher when charged.
- Creepers explode when damaged by explosions.
- Creepers don't immediately stop fusing on sight being blocked.
- Creepers have a chance to be able to sense targets through opaque blocks.
Expand All @@ -52,6 +61,7 @@ This is a Minecraft Better Than Wolves addon that aims to slightly strengthen mo

### Spiders

- Spiders have a high chance to spawn with a random positive potion effect after the first nether portal is constructed.
- Cobwebs don't only slow down entities' move speed, but also make players hardly rotate their look direction.

### Slimes
Expand All @@ -74,11 +84,16 @@ This is a Minecraft Better Than Wolves addon that aims to slightly strengthen mo
- Small magma cubes melt into a puddle of lava on death.
- Magma cubes regenerate their health when touching lava.

### Blazes

- Blazes' fireballs cause explosions after the first wither is summoned.

### Ghasts

- Ghasts have a translucent look.
- Arrows and throwable items cannot collide with ghasts, instead fly through them.
- Ghasts only take damage from fireballs and magic.
- Ghasts' fireballs cause larger explosions after the first wither is summoned.

### Withers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class MobsEnhancementAddon extends BTWAddon {
private static MobsEnhancementAddon instance;

private MobsEnhancementAddon() {
super("Mobs Enhancement", "0.1.4", "MEA");
super("Mobs Enhancement", "0.2.0", "MEA");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public void updateTask() {
double angel = Math.atan2(targetPosX + 0.5F - this.theEntity.posX, targetPosZ + 0.5F - this.theEntity.posZ) * 180 / Math.PI;
angel = angel >= 0 ? 360 - angel : 0 - angel;
if (this.theEntity.getDistanceSq((double)this.targetPosX + 0.5F, this.theEntity.posY, (double)this.targetPosZ + 0.5F) > 2.25D
|| (Math.abs(yaw - (float)angel) > 45 && Math.abs(yaw - (float)angel) < 315) || Math.abs(this.theEntity.motionX) >= 0.25D || Math.abs(this.theEntity.motionY + 0.0784000015258789D) >= 0.01D || Math.abs(this.theEntity.motionZ) >= 0.25D || this.theEntity.isLivingDead) {
|| (Math.abs(yaw - (float)angel) > 45 && Math.abs(yaw - (float)angel) < 315) || Math.abs(this.theEntity.motionX) >= 0.25D || Math.abs(this.theEntity.motionY + 0.0784000015258789D) >= 0.01D || Math.abs(this.theEntity.motionZ) >= 0.25D || this.theEntity.isLivingDead
|| this.theEntity.worldObj.getBlockId(this.targetPosX, this.targetPosY, this.targetPosZ) != this.targetBlock.blockID) {
this.hasStoppedBlockBreaking = true;
}

Expand Down
25 changes: 19 additions & 6 deletions src/main/java/net/pottx/mobsenhancement/MEAUtils.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package net.pottx.mobsenhancement;

import btw.block.BTWBlocks;
import net.pottx.mobsenhancement.access.EntityMobAccess;
import net.pottx.mobsenhancement.access.EntityPlayerAccess;
import btw.world.util.WorldUtils;
import net.minecraft.src.*;
import net.pottx.mobsenhancement.mixin.EntityAccess;
import net.pottx.mobsenhancement.mixin.EntityLivingAccess;

import java.util.Random;
import net.pottx.mobsenhancement.access.EntityPlayerAccess;

public class MEAUtils {
public static double[] predictRelativeXZOnRangedHit(EntityLiving target, double initRelativeX, double initRelativeY, double initRelativeZ, float projectileVelocity) {
Expand Down Expand Up @@ -279,4 +275,21 @@ else if (dProportionOfLengthToNextBlockBoundaryY < dProportionOfLengthToNextBloc

return null;
}

public static int getGameProgressMobsLevel(World world) {
if (!world.worldInfo.getDifficulty().shouldHCSRangeIncrease()) {
return 0;
}
else if (WorldUtils.gameProgressHasEndDimensionBeenAccessedServerOnly()) {
return 3;
}
else if (WorldUtils.gameProgressHasWitherBeenSummonedServerOnly()) {
return 2;
}
else if (WorldUtils.gameProgressHasNetherBeenAccessedServerOnly()) {
return 1;
}

return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import btw.entity.mob.CreeperEntity;
import net.minecraft.src.*;
import net.pottx.mobsenhancement.MEAUtils;
import net.pottx.mobsenhancement.access.EntityMobAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -34,10 +35,17 @@ public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) {
at = @At(value = "TAIL")
)
private void resetFuseTimeAndXray(CallbackInfo ci) {
((EntityCreeperAccess)this).setFuseTime(20);
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);

((EntityCreeperAccess)this).setFuseTime(i > 0 ? 20 : 25);

if (((EntityMobAccess)this).getCanXray() == (byte)1 && this.rand.nextInt(2) == 0) ((EntityMobAccess)this).setCanXray((byte)0);

if (i > 0 && this.rand.nextInt(8) == 0)
{
this.dataWatcher.updateObject(17, Byte.valueOf((byte)1));
}

this.tasks.removeAllTasksOfClass(EntityAIWatchClosest.class);
}

Expand All @@ -47,7 +55,8 @@ private void resetFuseTimeAndXray(CallbackInfo ci) {
cancellable = true
)
private void explodeWithChance(EntityPlayer player, CallbackInfoReturnable<Boolean> cir) {
if (this.rand.nextInt(8) == 0) {
int i = this.getPowered() ? 2 : 8;
if (this.rand.nextInt(i) == 0) {
boolean mobGriefing = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");

if (this.getPowered()) {
Expand All @@ -60,4 +69,10 @@ private void explodeWithChance(EntityPlayer player, CallbackInfoReturnable<Boole
cir.setReturnValue(super.interact(player));
}
}

@Override
public int getMaxHealth() {
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);
return i > 0 ? 20 : 16;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.pottx.mobsenhancement.mixin;

import net.minecraft.src.*;
import net.pottx.mobsenhancement.MEAUtils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -23,6 +24,15 @@ private void splitWhenAttacked(DamageSource par1DamageSource, int par2, Callback
}
}

@Inject(
method = "getMaxHealth()I",
at = @At(value = "HEAD"),
cancellable = true
)
private void returnScaledHealth(CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(MEAUtils.getGameProgressMobsLevel(this.worldObj) > 0 ? 12 : 8);
}

@Unique
public void split() {
double vx = this.motionZ * (0.25 + this.rand.nextDouble() * 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import btw.item.BTWItems;
import net.minecraft.src.*;
import net.pottx.mobsenhancement.MEAUtils;
import net.pottx.mobsenhancement.access.EntityMobAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -31,7 +32,10 @@ private void resetMoveSpeed(CallbackInfo ci) {
cancellable = true
)
private void returnSmallerMaxHealth(CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(16);
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);
i = i > 1 ? 20 : (i > 0 ? 16 : 12);

cir.setReturnValue(i);
}

@Inject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import net.minecraft.src.DamageSource;
import net.minecraft.src.EntityGhast;
import net.minecraft.src.World;
import net.pottx.mobsenhancement.MEAUtils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GhastEntity.class)
public abstract class GhastEntityMixin extends EntityGhast {
public abstract class GhastEntityMixin extends EntityGhast implements EntityGhastAccess {
public GhastEntityMixin(World par1World) {
super(par1World);
}
Expand All @@ -21,6 +22,10 @@ public GhastEntityMixin(World par1World) {
)
private void replaceTexture(CallbackInfo ci) {
this.texture = "/meatextures/ghast.png";

if (MEAUtils.getGameProgressMobsLevel(this.worldObj) > 1) {
this.setExplosionStrength(2);
}
}

@Override
Expand All @@ -39,4 +44,11 @@ public void onUpdate() {
byte var1 = this.dataWatcher.getWatchableObjectByte(16);
this.texture = var1 == 1 ? "/meatextures/ghast_fire.png" : "/meatextures/ghast.png";
}

@Override
public int getMaxHealth() {
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);

return i > 1 ? 16 : 10;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,14 @@ public void setDead() {
}
super.setDead();
}

@Override
public int getMaxHealth()
{
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);
i = i > 1 ? 1 : 0;
int var1 = this.getSlimeSize() + i;

return var1 * var1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
Expand All @@ -37,6 +38,7 @@ public SkeletonEntityMixin(World world) {
)
private void addExtraTasks(CallbackInfo ci) {
this.tasks.removeAllTasksOfClass(EntityAIWatchClosest.class);
this.tasks.removeAllTasksOfClass(EntityAIFleeSun.class);

tasks.addTask(2, new EntityAIFleeFromExplosion(this, 0.375F, 4.0F));
tasks.addTask(3, new EntityAIFleeFromEnemy(this, EntityPlayer.class, 0.375F, 24.0F, 5));
Expand All @@ -59,7 +61,20 @@ private void setSmartAttackAI(CallbackInfo ci) {
locals = LocalCapture.CAPTURE_FAILHARD
)
private void resetArrowForPrediction(EntityLiving target, float fDamageModifier, CallbackInfo ci, EntityArrow arrow) {
((EntityArrowAccess)arrow).resetForPrediction(this, target, 1.6F, 6F);
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);
float f = i > 2 ? 2F : (i > 1 ? 4F : (i > 0 ? 6F : 8F));
((EntityArrowAccess)arrow).resetForPrediction(this, target, 1.6F, f);
}

@Inject(
method = "initCreature()V",
at = @At(value = "TAIL")
)
private void witherChanceAfterNether(CallbackInfo ci) {
if (this.worldObj.provider.dimensionId == 0 && this.posY < 32 && getRNG().nextInt( 4 ) == 0)
{
setSkeletonType( 1 );
}
}

@ModifyArgs(
Expand Down Expand Up @@ -112,4 +127,12 @@ public void addRandomArmor() {
equipmentDropChances[0] = 0.99F;
}
}

@Redirect(
method = "onLivingUpdate()V",
at = @At(value = "INVOKE", target = "Lbtw/entity/mob/SkeletonEntity;checkForCatchFireInSun()V")
)
private void skipSunCheck(SkeletonEntity skeletonEntity)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
import net.pottx.mobsenhancement.MEAEffectManager;
import net.pottx.mobsenhancement.MEAUtils;
import net.pottx.mobsenhancement.access.SlimeEntityAccess;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand Down Expand Up @@ -228,4 +228,14 @@ public void setDead() {

this.isDead = true;
}

@Override
public int getMaxHealth()
{
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);
i = i > 0 ? 1 : 0;
int var1 = this.getSlimeSize() + i;

return var1 * var1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.src.EntityWitch;
import net.minecraft.src.World;
import net.pottx.mobsenhancement.EntityAIFleeFromExplosion;
import net.pottx.mobsenhancement.MEAUtils;
import net.pottx.mobsenhancement.access.EntityMobAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -29,4 +30,10 @@ private void addFleeFromExplosionTask(CallbackInfo ci) {
tasks.addTask(1, new EntityAIFleeFromExplosion(this, 0.375F, 4.0F));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, VillagerEntity.class, 24.0F, 0, ((EntityMobAccess)this).getCanXray() == (byte)0));
}

@Override
public int getMaxHealth() {
int i = MEAUtils.getGameProgressMobsLevel(this.worldObj);
return i > 0 ? 28 : 24;
}
}
Loading

0 comments on commit 29fd7f2

Please sign in to comment.