Skip to content

Commit 39baa7d

Browse files
committed
Fix baby mobs not interacting properly with the new scale attribute (#8108)
1 parent 07ba83b commit 39baa7d

File tree

7 files changed

+62
-1
lines changed

7 files changed

+62
-1
lines changed

src/additions/java/mekanism/additions/client/render/entity/RenderBabyEnderman.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public void render(EntityBabyEnderman enderman, float entityYaw, float partialTi
4141
@Override
4242
public Vec3 getRenderOffset(EntityBabyEnderman enderman, float partialTicks) {
4343
if (enderman.isCreepy()) {
44-
return new Vec3(this.random.nextGaussian() * 0.02, 0, this.random.nextGaussian() * 0.02);
44+
double offset = 0.02 * enderman.getScale();
45+
return new Vec3(this.random.nextGaussian() * offset, 0, this.random.nextGaussian() * offset);
4546
}
4647
return super.getRenderOffset(enderman, partialTicks);
4748
}

src/additions/java/mekanism/additions/common/entity/baby/EntityBabyBogged.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package mekanism.additions.common.entity.baby;
22

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.world.entity.EntityDimensions;
45
import net.minecraft.world.entity.EntityType;
6+
import net.minecraft.world.entity.Pose;
57
import net.minecraft.world.entity.monster.Bogged;
68
import net.minecraft.world.level.Level;
9+
import org.jetbrains.annotations.NotNull;
710

811
public class EntityBabyBogged extends Bogged {
912

@@ -17,4 +20,11 @@ public EntityBabyBogged(EntityType<EntityBabyBogged> type, Level world) {
1720
public boolean isBaby() {
1821
return true;
1922
}
23+
24+
@NotNull
25+
@Override
26+
public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
27+
//Note: We already have the age scale factored into the dimensions
28+
return getType().getDimensions();
29+
}
2030
}

src/additions/java/mekanism/additions/common/entity/baby/EntityBabyCreeper.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package mekanism.additions.common.entity.baby;
22

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.world.entity.EntityDimensions;
45
import net.minecraft.world.entity.EntityType;
6+
import net.minecraft.world.entity.Pose;
57
import net.minecraft.world.entity.monster.Creeper;
68
import net.minecraft.world.level.Level;
9+
import org.jetbrains.annotations.NotNull;
710

811
public class EntityBabyCreeper extends Creeper {
912

@@ -18,6 +21,13 @@ public boolean isBaby() {
1821
return true;
1922
}
2023

24+
@NotNull
25+
@Override
26+
public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
27+
//Note: We already have the age scale factored into the dimensions
28+
return getType().getDimensions();
29+
}
30+
2131
/**
2232
* Modify vanilla's explode method to half the explosion strength of baby creepers, and charged baby creepers
2333
*/

src/additions/java/mekanism/additions/common/entity/baby/EntityBabyEnderman.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package mekanism.additions.common.entity.baby;
22

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.world.entity.EntityDimensions;
45
import net.minecraft.world.entity.EntityType;
6+
import net.minecraft.world.entity.Pose;
57
import net.minecraft.world.entity.monster.EnderMan;
68
import net.minecraft.world.level.Level;
9+
import org.jetbrains.annotations.NotNull;
710

811
public class EntityBabyEnderman extends EnderMan {
912

@@ -17,4 +20,11 @@ public EntityBabyEnderman(EntityType<EntityBabyEnderman> type, Level world) {
1720
public boolean isBaby() {
1821
return true;
1922
}
23+
24+
@NotNull
25+
@Override
26+
public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
27+
//Note: We already have the age scale factored into the dimensions
28+
return getType().getDimensions();
29+
}
2030
}

src/additions/java/mekanism/additions/common/entity/baby/EntityBabySkeleton.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package mekanism.additions.common.entity.baby;
22

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.world.entity.EntityDimensions;
45
import net.minecraft.world.entity.EntityType;
6+
import net.minecraft.world.entity.Pose;
57
import net.minecraft.world.entity.monster.Skeleton;
68
import net.minecraft.world.level.Level;
79
import net.minecraft.world.level.block.LevelEvent;
10+
import org.jetbrains.annotations.NotNull;
811

912
public class EntityBabySkeleton extends Skeleton {
1013

@@ -19,6 +22,13 @@ public boolean isBaby() {
1922
return true;
2023
}
2124

25+
@NotNull
26+
@Override
27+
public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
28+
//Note: We already have the age scale factored into the dimensions
29+
return getType().getDimensions();
30+
}
31+
2232
@Override
2333
protected void doFreezeConversion() {
2434
convertTo(AdditionsEntityTypes.BABY_STRAY.value(), true);

src/additions/java/mekanism/additions/common/entity/baby/EntityBabyStray.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
import net.minecraft.core.BlockPos;
55
import net.minecraft.core.Direction;
66
import net.minecraft.util.RandomSource;
7+
import net.minecraft.world.entity.EntityDimensions;
78
import net.minecraft.world.entity.EntityType;
89
import net.minecraft.world.entity.MobSpawnType;
10+
import net.minecraft.world.entity.Pose;
911
import net.minecraft.world.entity.monster.Stray;
1012
import net.minecraft.world.level.Level;
1113
import net.minecraft.world.level.ServerLevelAccessor;
1214
import net.minecraft.world.level.block.Blocks;
15+
import org.jetbrains.annotations.NotNull;
1316

1417
public class EntityBabyStray extends Stray {
1518

@@ -39,4 +42,11 @@ public EntityBabyStray(EntityType<EntityBabyStray> type, Level world) {
3942
public boolean isBaby() {
4043
return true;
4144
}
45+
46+
@NotNull
47+
@Override
48+
public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
49+
//Note: We already have the age scale factored into the dimensions
50+
return getType().getDimensions();
51+
}
4252
}

src/additions/java/mekanism/additions/common/entity/baby/EntityBabyWitherSkeleton.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package mekanism.additions.common.entity.baby;
22

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.world.entity.EntityDimensions;
45
import net.minecraft.world.entity.EntityType;
6+
import net.minecraft.world.entity.Pose;
57
import net.minecraft.world.entity.monster.WitherSkeleton;
68
import net.minecraft.world.level.Level;
9+
import org.jetbrains.annotations.NotNull;
710

811
public class EntityBabyWitherSkeleton extends WitherSkeleton {
912

@@ -17,4 +20,11 @@ public EntityBabyWitherSkeleton(EntityType<EntityBabyWitherSkeleton> type, Level
1720
public boolean isBaby() {
1821
return true;
1922
}
23+
24+
@NotNull
25+
@Override
26+
public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
27+
//Note: We already have the age scale factored into the dimensions
28+
return getType().getDimensions();
29+
}
2030
}

0 commit comments

Comments
 (0)