Skip to content

Commit

Permalink
Check curios slots for radiation shielding (#8216)
Browse files Browse the repository at this point in the history
  • Loading branch information
blockgoblin31 authored Aug 25, 2024
1 parent b73f09d commit 2a36017
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/mekanism/common/lib/radiation/RadiationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import mekanism.common.Mekanism;
import mekanism.common.capabilities.Capabilities;
import mekanism.common.config.MekanismConfig;
import mekanism.common.integration.curios.CuriosIntegration;
import mekanism.common.lib.MekanismSavedData;
import mekanism.common.lib.collection.HashList;
import mekanism.common.network.to_client.PacketRadiationData;
Expand Down Expand Up @@ -66,6 +67,7 @@
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.entity.living.LivingEvent.LivingTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.server.ServerLifecycleHooks;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -309,6 +311,21 @@ private double getRadiationResistance(LivingEntity entity) {
resistance += shielding.get().getRadiationShielding();
}
}
if (resistance < 1 && Mekanism.hooks.CuriosLoaded) {
Optional<? extends IItemHandler> handlerOptional = CuriosIntegration.getCuriosInventory(entity);
if (handlerOptional.isPresent()) {
IItemHandler handler = handlerOptional.get();
int slots = handler.getSlots();
for (int i = 0; i < slots; i++) {
ItemStack item = handler.getStackInSlot(i);
Optional<IRadiationShielding> shielding = CapabilityUtils.getCapability(item, Capabilities.RADIATION_SHIELDING, null).resolve();
if (shielding.isPresent()) {
resistance += shielding.get().getRadiationShielding();
if (resistance >= 1) return 1;
}
}
}
}
return resistance;
}

Expand Down

0 comments on commit 2a36017

Please sign in to comment.