Skip to content

Commit

Permalink
Check curios slots for radiation shielding(hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
blockgoblin31 committed Aug 22, 2024
1 parent b73f09d commit 6c733e3
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 (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) resistance = 1;
return resistance;
}

Expand Down

0 comments on commit 6c733e3

Please sign in to comment.