mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
spicy ME drives
This commit is contained in:
parent
7d3a4d197b
commit
c40ba15023
@ -6,7 +6,7 @@ import static com.hbm.inventory.OreDictManager.*;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.hazard.modifier.*;
|
||||
import com.hbm.hazard.transformer.HazardTransformerRadiationNBT;
|
||||
import com.hbm.hazard.transformer.*;
|
||||
import com.hbm.hazard.type.*;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemBreedingRod.BreedingRodType;
|
||||
@ -469,6 +469,7 @@ public class HazardRegistry {
|
||||
|
||||
public static void registerTrafos() {
|
||||
HazardSystem.trafos.add(new HazardTransformerRadiationNBT());
|
||||
HazardSystem.trafos.add(new HazardTransformerRadiationME());
|
||||
}
|
||||
|
||||
private static HazardData makeData() { return new HazardData(); }
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package com.hbm.hazard.transformer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.hazard.HazardEntry;
|
||||
import com.hbm.hazard.HazardRegistry;
|
||||
import com.hbm.hazard.HazardSystem;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HazardTransformerRadiationME extends HazardTransformerBase {
|
||||
|
||||
@Override
|
||||
public void transformPre(ItemStack stack, List<HazardEntry> entries) { }
|
||||
|
||||
@Override
|
||||
public void transformPost(ItemStack stack, List<HazardEntry> entries) {
|
||||
|
||||
if(stack.getItem().getClass().getName().equals("appeng.items.storage.ItemBasicStorageCell")) {
|
||||
List<ItemStack> stacks = Compat.scrapeItemFromME(stack);
|
||||
float radiation = 0;
|
||||
|
||||
for(ItemStack held : stacks) {
|
||||
radiation += HazardSystem.getHazardLevelFromStack(held, HazardRegistry.RADIATION);
|
||||
}
|
||||
|
||||
if(radiation > 0) {
|
||||
entries.add(new HazardEntry(HazardRegistry.RADIATION, radiation));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,14 @@
|
||||
package com.hbm.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.hazard.HazardRegistry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class Compat {
|
||||
|
||||
@ -62,4 +68,29 @@ public class Compat {
|
||||
return this.rads;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ItemStack> scrapeItemFromME(ItemStack meDrive) {
|
||||
List<ItemStack> stacks = new ArrayList();
|
||||
|
||||
if(meDrive != null && meDrive.hasTagCompound()) {
|
||||
NBTTagCompound nbt = meDrive.getTagCompound();
|
||||
int types = nbt.getShort("it"); //ITEM_TYPE_TAG
|
||||
|
||||
for(int i = 0; i < types; i++) {
|
||||
NBTBase stackTag = nbt.getTag("#" + i);
|
||||
|
||||
if(stackTag instanceof NBTTagCompound) {
|
||||
NBTTagCompound compound = (NBTTagCompound) stackTag;
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(compound);
|
||||
|
||||
int count = nbt.getInteger("@" + i);
|
||||
stack.stackSize = count;
|
||||
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stacks;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user