Skip to content

Commit

Permalink
prevent babies from wearing armor
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Jul 21, 2024
1 parent ab92025 commit 93dcef6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package mekanism.additions.common.entity.baby;

import mekanism.additions.common.registries.AdditionsEntityTypes;
import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.monster.Bogged;
import net.minecraft.world.entity.projectile.AbstractArrow;
Expand Down Expand Up @@ -30,11 +33,21 @@ public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
//Note: We already have the age scale factored into the dimensions
return getType().getDimensions();
}

@Override
protected AbstractArrow getArrow(ItemStack arrow, float velocity, @Nullable ItemStack weapon) {
AbstractArrow projectile = super.getArrow(arrow, velocity, weapon);
projectile.setBaseDamage(projectile.getBaseDamage() * 0.25);
return projectile;
}

@Override
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
super.populateDefaultEquipmentSlots(random, difficulty);
for (EquipmentSlot slot : EquipmentSlot.values()) {
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
this.setItemSlot(slot, ItemStack.EMPTY);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package mekanism.additions.common.entity.baby;

import mekanism.additions.common.registries.AdditionsEntityTypes;
import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.monster.Skeleton;
import net.minecraft.world.entity.projectile.AbstractArrow;
Expand Down Expand Up @@ -46,4 +49,14 @@ protected AbstractArrow getArrow(ItemStack arrow, float velocity, @Nullable Item
projectile.setBaseDamage(projectile.getBaseDamage() * 0.25);
return projectile;
}

@Override
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
super.populateDefaultEquipmentSlots(random, difficulty);
for (EquipmentSlot slot : EquipmentSlot.values()) {
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
this.setItemSlot(slot, ItemStack.EMPTY);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.monster.Stray;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.Blocks;
Expand Down Expand Up @@ -49,4 +52,14 @@ public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
//Note: We already have the age scale factored into the dimensions
return getType().getDimensions();
}

@Override
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
super.populateDefaultEquipmentSlots(random, difficulty);
for (EquipmentSlot slot : EquipmentSlot.values()) {
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
this.setItemSlot(slot, ItemStack.EMPTY);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package mekanism.additions.common.entity.baby;

import mekanism.additions.common.registries.AdditionsEntityTypes;
import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.monster.WitherSkeleton;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;

Expand All @@ -27,4 +31,14 @@ public EntityDimensions getDefaultDimensions(@NotNull Pose pose) {
//Note: We already have the age scale factored into the dimensions
return getType().getDimensions();
}

@Override
protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
super.populateDefaultEquipmentSlots(random, difficulty);
for (EquipmentSlot slot : EquipmentSlot.values()) {
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
this.setItemSlot(slot, ItemStack.EMPTY);
}
}
}
}

0 comments on commit 93dcef6

Please sign in to comment.