Skip to content

Commit 93dcef6

Browse files
committed
prevent babies from wearing armor
1 parent ab92025 commit 93dcef6

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package mekanism.additions.common.entity.baby;
22

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.util.RandomSource;
5+
import net.minecraft.world.DifficultyInstance;
46
import net.minecraft.world.entity.EntityDimensions;
57
import net.minecraft.world.entity.EntityType;
8+
import net.minecraft.world.entity.EquipmentSlot;
69
import net.minecraft.world.entity.Pose;
710
import net.minecraft.world.entity.monster.Bogged;
811
import net.minecraft.world.entity.projectile.AbstractArrow;
@@ -30,11 +33,21 @@ public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
3033
//Note: We already have the age scale factored into the dimensions
3134
return getType().getDimensions();
3235
}
33-
36+
3437
@Override
3538
protected AbstractArrow getArrow(ItemStack arrow, float velocity, @Nullable ItemStack weapon) {
3639
AbstractArrow projectile = super.getArrow(arrow, velocity, weapon);
3740
projectile.setBaseDamage(projectile.getBaseDamage() * 0.25);
3841
return projectile;
3942
}
43+
44+
@Override
45+
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
46+
super.populateDefaultEquipmentSlots(random, difficulty);
47+
for (EquipmentSlot slot : EquipmentSlot.values()) {
48+
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
49+
this.setItemSlot(slot, ItemStack.EMPTY);
50+
}
51+
}
52+
}
4053
}

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

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

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.util.RandomSource;
5+
import net.minecraft.world.DifficultyInstance;
46
import net.minecraft.world.entity.EntityDimensions;
57
import net.minecraft.world.entity.EntityType;
8+
import net.minecraft.world.entity.EquipmentSlot;
69
import net.minecraft.world.entity.Pose;
710
import net.minecraft.world.entity.monster.Skeleton;
811
import net.minecraft.world.entity.projectile.AbstractArrow;
@@ -46,4 +49,14 @@ protected AbstractArrow getArrow(ItemStack arrow, float velocity, @Nullable Item
4649
projectile.setBaseDamage(projectile.getBaseDamage() * 0.25);
4750
return projectile;
4851
}
52+
53+
@Override
54+
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
55+
super.populateDefaultEquipmentSlots(random, difficulty);
56+
for (EquipmentSlot slot : EquipmentSlot.values()) {
57+
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
58+
this.setItemSlot(slot, ItemStack.EMPTY);
59+
}
60+
}
61+
}
4962
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import net.minecraft.core.BlockPos;
55
import net.minecraft.core.Direction;
66
import net.minecraft.util.RandomSource;
7+
import net.minecraft.world.DifficultyInstance;
78
import net.minecraft.world.entity.EntityDimensions;
89
import net.minecraft.world.entity.EntityType;
10+
import net.minecraft.world.entity.EquipmentSlot;
911
import net.minecraft.world.entity.MobSpawnType;
1012
import net.minecraft.world.entity.Pose;
1113
import net.minecraft.world.entity.monster.Stray;
14+
import net.minecraft.world.item.ItemStack;
1215
import net.minecraft.world.level.Level;
1316
import net.minecraft.world.level.ServerLevelAccessor;
1417
import net.minecraft.world.level.block.Blocks;
@@ -49,4 +52,14 @@ public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
4952
//Note: We already have the age scale factored into the dimensions
5053
return getType().getDimensions();
5154
}
55+
56+
@Override
57+
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
58+
super.populateDefaultEquipmentSlots(random, difficulty);
59+
for (EquipmentSlot slot : EquipmentSlot.values()) {
60+
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
61+
this.setItemSlot(slot, ItemStack.EMPTY);
62+
}
63+
}
64+
}
5265
}

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

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

33
import mekanism.additions.common.registries.AdditionsEntityTypes;
4+
import net.minecraft.util.RandomSource;
5+
import net.minecraft.world.DifficultyInstance;
46
import net.minecraft.world.entity.EntityDimensions;
57
import net.minecraft.world.entity.EntityType;
8+
import net.minecraft.world.entity.EquipmentSlot;
69
import net.minecraft.world.entity.Pose;
710
import net.minecraft.world.entity.monster.WitherSkeleton;
11+
import net.minecraft.world.item.ItemStack;
812
import net.minecraft.world.level.Level;
913
import org.jetbrains.annotations.NotNull;
1014

@@ -27,4 +31,14 @@ public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
2731
//Note: We already have the age scale factored into the dimensions
2832
return getType().getDimensions();
2933
}
34+
35+
@Override
36+
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
37+
super.populateDefaultEquipmentSlots(random, difficulty);
38+
for (EquipmentSlot slot : EquipmentSlot.values()) {
39+
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
40+
this.setItemSlot(slot, ItemStack.EMPTY);
41+
}
42+
}
43+
}
3044
}

0 commit comments

Comments
 (0)