mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
new hazard system fully functional, hazard transformer classes
This commit is contained in:
parent
383473ea86
commit
9d83a333fd
@ -1,5 +1,6 @@
|
||||
package com.hbm.hazard;
|
||||
|
||||
import com.hbm.hazard.transformer.HazardTransformerRadiationNBT;
|
||||
import com.hbm.hazard.type.HazardTypeBase;
|
||||
import com.hbm.hazard.type.HazardTypeRadiation;
|
||||
import com.hbm.items.special.ItemHazard;
|
||||
@ -11,6 +12,9 @@ public class HazardRegistry {
|
||||
public static void registerItems() {
|
||||
HazardSystem.register("ingotPlutonium", makeData(RADIATION, ItemHazard.pu * ItemHazard.ingot));
|
||||
//TODO: move all the itemhazard stuff here
|
||||
|
||||
//TODO: move this into its own method
|
||||
HazardSystem.trafos.add(new HazardTransformerRadiationNBT());
|
||||
}
|
||||
|
||||
private static HazardData makeData() { return new HazardData(); }
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.hazard.transformer.HazardTransformerBase;
|
||||
import com.hbm.interfaces.Untested;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
|
||||
@ -35,6 +36,10 @@ public class HazardSystem {
|
||||
* For items that should, for whichever reason, be completely exempt from the hazard system.
|
||||
*/
|
||||
public static final HashSet<ComparableStack> blacklist = new HashSet();
|
||||
/*
|
||||
* List of hazard transformers, called in order before and after unrolling all the HazardEntries.
|
||||
*/
|
||||
public static final List<HazardTransformerBase> trafos = new ArrayList();
|
||||
|
||||
/**
|
||||
* Automatically casts the first parameter and registers it to the HazSys
|
||||
@ -109,6 +114,10 @@ public class HazardSystem {
|
||||
|
||||
List<HazardEntry> entries = new ArrayList();
|
||||
|
||||
for(HazardTransformerBase trafo : trafos) {
|
||||
trafo.transformPre(stack, entries);
|
||||
}
|
||||
|
||||
int mutex = 0;
|
||||
|
||||
for(HazardData data : chronological) {
|
||||
@ -122,6 +131,10 @@ public class HazardSystem {
|
||||
}
|
||||
}
|
||||
|
||||
for(HazardTransformerBase trafo : trafos) {
|
||||
trafo.transformPost(stack, entries);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
@ -156,6 +169,17 @@ public class HazardSystem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateLivingInventory(EntityLivingBase entity) {
|
||||
|
||||
for(int i = 0; i < 5; i++) {
|
||||
ItemStack stack = entity.getEquipmentInSlot(i);
|
||||
|
||||
if(stack != null) {
|
||||
applyHazards(stack, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void addFullTooltip(ItemStack stack, EntityPlayer player, List list) {
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package com.hbm.hazard.transformer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.hazard.HazardEntry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class HazardTransformerBase {
|
||||
|
||||
public abstract void transformPre(ItemStack stack, List<HazardEntry> entries);
|
||||
public abstract void transformPost(ItemStack stack, List<HazardEntry> entries);
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.hbm.hazard.transformer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.hazard.HazardEntry;
|
||||
import com.hbm.hazard.HazardRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HazardTransformerRadiationNBT extends HazardTransformerBase {
|
||||
|
||||
public static final String RAD_KEY = "hfrHazRadiation";
|
||||
|
||||
@Override
|
||||
public void transformPre(ItemStack stack, List<HazardEntry> entries) { }
|
||||
|
||||
@Override
|
||||
public void transformPost(ItemStack stack, List<HazardEntry> entries) {
|
||||
|
||||
if(stack.hasTagCompound() && stack.stackTagCompound.hasKey(RAD_KEY)) {
|
||||
entries.add(new HazardEntry(HazardRegistry.RADIATION, stack.stackTagCompound.getFloat(RAD_KEY)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -33,6 +33,7 @@ import com.hbm.handler.ArmorModHandler;
|
||||
import com.hbm.handler.BossSpawnHandler;
|
||||
import com.hbm.handler.EntityEffectHandler;
|
||||
import com.hbm.handler.RadiationWorldHandler;
|
||||
import com.hbm.hazard.HazardSystem;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.handler.HTTPHandler;
|
||||
import com.hbm.items.IEquipReceiver;
|
||||
@ -486,6 +487,10 @@ public class ModEventHandler {
|
||||
}
|
||||
|
||||
EntityEffectHandler.onUpdate(event.entityLiving);
|
||||
|
||||
if(!event.entity.worldObj.isRemote && !(event.entityLiving instanceof EntityPlayer)) {
|
||||
HazardSystem.updateLivingInventory(event.entityLiving);
|
||||
}
|
||||
}
|
||||
|
||||
public static int currentBrightness = 0;
|
||||
@ -943,6 +948,10 @@ public class ModEventHandler {
|
||||
}
|
||||
|
||||
/// PU RADIATION END ///
|
||||
|
||||
/// NEW ITEM SYS START ///
|
||||
HazardSystem.updatePlayerInventory(player);
|
||||
/// NEW ITEM SYS END ///
|
||||
}
|
||||
|
||||
//TODO: rewrite this so it doesn't look like shit
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user