Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rad & acid resistance tags #1470

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public void entityInside(BlockState blockState, Level level, BlockPos pos, Entit
for (EquipmentSlot slot : EquipmentSlot.values()) {
if (slot.isArmor()) {
ItemStack item = living.getItemBySlot(slot);
if (item != null && item.isDamageableItem() && !(item.getItem() instanceof HazmatArmorItem)) {
if (item != null && item.isDamageableItem() && !(living.getItemBySlot(slot).is(ACTagRegistry.ACID_PROT))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use item instead of calling living.getItemBySlot again

armor = true;
if (living.getRandom().nextFloat() < 0.05F && !(entity instanceof Player player && player.isCreative())) {
item.hurtAndBreak(1, living, e -> e.broadcastBreakEvent(slot));
}
}
}
}
dmgMultiplier = 1.0F - (HazmatArmorItem.getWornAmount(living) / 4F);
dmgMultiplier = 1.0F - (HazmatArmorItem.getAcidAmount(living) / 4F);
}
if (armor) {
ACAdvancementTriggerRegistry.ENTER_ACID_WITH_ARMOR.triggerForEntity(entity);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.alexmodguy.alexscaves.server.item;

import com.github.alexmodguy.alexscaves.AlexsCaves;
import com.github.alexmodguy.alexscaves.server.misc.ACTagRegistry;
import com.github.alexmodguy.alexscaves.client.particle.ACParticleRegistry;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
Expand Down Expand Up @@ -52,16 +53,33 @@ public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot

public static int getWornAmount(LivingEntity entity) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed to be specific to radiation.

int i = 0;
if (entity.getItemBySlot(EquipmentSlot.HEAD).is(ACItemRegistry.HAZMAT_MASK.get())) {
if (entity.getItemBySlot(EquipmentSlot.HEAD).is(ACTagRegistry.HAZMAT_PROT)) {
i++;
}
if (entity.getItemBySlot(EquipmentSlot.CHEST).is(ACItemRegistry.HAZMAT_CHESTPLATE.get())) {
if (entity.getItemBySlot(EquipmentSlot.CHEST).is(ACTagRegistry.HAZMAT_PROT)) {
i++;
}
if (entity.getItemBySlot(EquipmentSlot.LEGS).is(ACItemRegistry.HAZMAT_LEGGINGS.get())) {
if (entity.getItemBySlot(EquipmentSlot.LEGS).is(ACTagRegistry.HAZMAT_PROT)) {
i++;
}
if (entity.getItemBySlot(EquipmentSlot.FEET).is(ACItemRegistry.HAZMAT_BOOTS.get())) {
if (entity.getItemBySlot(EquipmentSlot.FEET).is(ACTagRegistry.HAZMAT_PROT)) {
i++;
}
return i;
}

public static int getAcidAmount(LivingEntity entity) {
int i = 0;
if (entity.getItemBySlot(EquipmentSlot.HEAD).is(ACTagRegistry.ACID_PROT)) {
i++;
}
if (entity.getItemBySlot(EquipmentSlot.CHEST).is(ACTagRegistry.ACID_PROT)) {
i++;
}
if (entity.getItemBySlot(EquipmentSlot.LEGS).is(ACTagRegistry.ACID_PROT)) {
i++;
}
if (entity.getItemBySlot(EquipmentSlot.FEET).is(ACTagRegistry.ACID_PROT)) {
i++;
}
return i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public class ACTagRegistry {
public static final TagKey<Structure> GINGERBREAD_MEN_WANDER_THROUGH = registerStructureTag("gingerbread_men_wander_through");
public static final TagKey<DamageType> DEEP_ONE_IGNORES = registerDamageTypeTag("deep_one_ignores");
public static final TagKey<Fluid> DOES_NOT_FLOW_INTO_WATERLOGGABLE_BLOCKS = registerFluidTag("does_not_flow_into_waterloggable_blocks");
public static final TagKey<Item> HAZMAT_PROT = registerItemTag("hazmat_prot");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering hazmat is just any hazardous material and you're only using it for radiation, this should have a more specific name than hazmat.
Also I think these tags should have full names such as acid_protective_armor.

public static final TagKey<Item> ACID_PROT = registerItemTag("acid_prot");

private static TagKey<EntityType<?>> registerEntityTag(String name) {
return TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation(AlexsCaves.MODID, name));
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/data/alexscaves/tags/items/acid_prot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"values": [
"alexscaves:hazmat_mask",
"alexscaves:hazmat_chestplate",
"alexscaves:hazmat_leggings",
"alexscaves:hazmat_boots"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"values": [
"alexscaves:hazmat_mask",
"alexscaves:hazmat_chestplate",
"alexscaves:hazmat_leggings",
"alexscaves:hazmat_boots"
]
}