Added item dictionary
Fixed breathing with IC2 compressed air
This commit is contained in:
parent
5502cd5fa6
commit
91bbc80480
3 changed files with 89 additions and 57 deletions
|
@ -4,6 +4,7 @@ import cr0s.warpdrive.config.WarpDriveConfig;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
|
||||||
public class GravityManager {
|
public class GravityManager {
|
||||||
|
@ -41,11 +42,15 @@ public class GravityManager {
|
||||||
EntityPlayer player = (EntityPlayer) entity;
|
EntityPlayer player = (EntityPlayer) entity;
|
||||||
|
|
||||||
if (player.isSneaking()) {
|
if (player.isSneaking()) {
|
||||||
if (player.getCurrentArmor(2) != null && WarpDriveConfig.jetpacks.contains(player.getCurrentArmor(2))) {
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ItemStack armor = player.getCurrentArmor(i);
|
||||||
|
if (armor != null) {
|
||||||
|
if (WarpDriveConfig.ITEMS_FLYINSPACE.contains(armor.getItem())) {
|
||||||
return SPACE_VOID_GRAVITY_JETPACKSNEAK;
|
return SPACE_VOID_GRAVITY_JETPACKSNEAK;
|
||||||
} else {
|
|
||||||
return SPACE_VOID_GRAVITY_RAWSNEAK;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SPACE_VOID_GRAVITY_RAWSNEAK;
|
||||||
} else {
|
} else {
|
||||||
// FIXME: compensate jetpack
|
// FIXME: compensate jetpack
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import cpw.mods.fml.common.Loader;
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.registry.GameData;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import cr0s.warpdrive.WarpDrive;
|
import cr0s.warpdrive.WarpDrive;
|
||||||
import cr0s.warpdrive.config.filler.FillerManager;
|
import cr0s.warpdrive.config.filler.FillerManager;
|
||||||
|
@ -48,7 +49,6 @@ public class WarpDriveConfig {
|
||||||
public static boolean isAdvancedSolarPanelLoaded = false;
|
public static boolean isAdvancedSolarPanelLoaded = false;
|
||||||
public static boolean isAppliedEnergistics2Loaded = false;
|
public static boolean isAppliedEnergistics2Loaded = false;
|
||||||
public static boolean isICBMLoaded = false;
|
public static boolean isICBMLoaded = false;
|
||||||
public static boolean isGraviSuiteLoaded = false;
|
|
||||||
public static boolean isIndustrialCraft2loaded = false;
|
public static boolean isIndustrialCraft2loaded = false;
|
||||||
public static boolean isComputerCraftLoaded = false;
|
public static boolean isComputerCraftLoaded = false;
|
||||||
public static boolean isOpenComputersLoaded = false;
|
public static boolean isOpenComputersLoaded = false;
|
||||||
|
@ -69,8 +69,6 @@ public class WarpDriveConfig {
|
||||||
public static int AS_Turbine, AS_deuteriumCell;
|
public static int AS_Turbine, AS_deuteriumCell;
|
||||||
public static int ICBM_Machine, ICBM_Missile, ICBM_Explosive;
|
public static int ICBM_Machine, ICBM_Missile, ICBM_Explosive;
|
||||||
|
|
||||||
public static ArrayList<Item> spaceHelmets, jetpacks;
|
|
||||||
|
|
||||||
// Mod configuration (see loadWarpDriveConfig() for comments/definitions)
|
// Mod configuration (see loadWarpDriveConfig() for comments/definitions)
|
||||||
// General
|
// General
|
||||||
public static int G_SPACE_BIOME_ID = 95;
|
public static int G_SPACE_BIOME_ID = 95;
|
||||||
|
@ -144,6 +142,7 @@ public class WarpDriveConfig {
|
||||||
// Tagged blocks and entities (loaded from configuration file at PreInit, parsed at PostInit)
|
// Tagged blocks and entities (loaded from configuration file at PreInit, parsed at PostInit)
|
||||||
private static HashMap<String, String> taggedBlocks = null;
|
private static HashMap<String, String> taggedBlocks = null;
|
||||||
private static HashMap<String, String> taggedEntities = null;
|
private static HashMap<String, String> taggedEntities = null;
|
||||||
|
private static HashMap<String, String> taggedItems = null;
|
||||||
|
|
||||||
// Blocks dictionary
|
// Blocks dictionary
|
||||||
public static HashSet<Block> BLOCKS_ORES;
|
public static HashSet<Block> BLOCKS_ORES;
|
||||||
|
@ -162,6 +161,11 @@ public class WarpDriveConfig {
|
||||||
public static HashSet<String> ENTITIES_NOMASS = null;
|
public static HashSet<String> ENTITIES_NOMASS = null;
|
||||||
public static HashSet<String> ENTITIES_LEFTBEHIND = null;
|
public static HashSet<String> ENTITIES_LEFTBEHIND = null;
|
||||||
|
|
||||||
|
// Items dictionary
|
||||||
|
public static HashSet<Item> ITEMS_FLYINSPACE = null;
|
||||||
|
public static HashSet<Item> ITEMS_NOFALLDAMAGE = null;
|
||||||
|
public static HashSet<Item> ITEMS_BREATHINGIC2 = null;
|
||||||
|
|
||||||
// Radar
|
// Radar
|
||||||
public static int RADAR_MAX_ENERGY_STORED = 100000000; // 100kk eU
|
public static int RADAR_MAX_ENERGY_STORED = 100000000; // 100kk eU
|
||||||
public static int RADAR_MAX_ISOLATION_RANGE = 2;
|
public static int RADAR_MAX_ISOLATION_RANGE = 2;
|
||||||
|
@ -556,6 +560,46 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Item dictionary
|
||||||
|
{
|
||||||
|
config.addCustomCategoryComment("item_tags",
|
||||||
|
"Use this section to enable special behavior on items using tags.\n"
|
||||||
|
+ "Most items are already supported automatically. Only modify this section when something doesn't work!\n"
|
||||||
|
+ "\n"
|
||||||
|
+ "Tags shall be separated by at least one space, comma or tabulation.\n"
|
||||||
|
+ "Invalid tags will be ignored silently. Tags and block names are case sensitive.\n"
|
||||||
|
+ "In case of conflicts, the latest tag overwrite the previous ones.\n"
|
||||||
|
+ "- FlyInSpace: player can move without gravity effect while wearing this item (default: jetpacks).\n"
|
||||||
|
+ "- NoFallDamage: player doesn't take fall damage while wearing this armor item (default: IC2 rubber boots).\n"
|
||||||
|
+ "- BreathingIC2: player can breath IC2 compressed air while wearing this armor item (default: IC2 nano helmet and Cie).\n");
|
||||||
|
|
||||||
|
ConfigCategory categoryItemTags = config.getCategory("item_tags");
|
||||||
|
String[] taggedItemsName = categoryItemTags.getValues().keySet().toArray(new String[0]);
|
||||||
|
if (taggedItemsName.length == 0) {
|
||||||
|
config.get("item_tags", "IC2:itemArmorHazmatHelmet" , "BreathingIC2" ).getString();
|
||||||
|
config.get("item_tags", "IC2:itemSolarHelmet" , "BreathingIC2" ).getString();
|
||||||
|
config.get("item_tags", "IC2:itemArmorNanoHelmet" , "BreathingIC2" ).getString();
|
||||||
|
config.get("item_tags", "IC2:itemArmorQuantumHelmet" , "BreathingIC2" ).getString();
|
||||||
|
config.get("item_tags", "AdvancedSolarPanel:advanced_solar_helmet" , "BreathingIC2" ).getString();
|
||||||
|
config.get("item_tags", "AdvancedSolarPanel:hybrid_solar_helmet" , "BreathingIC2" ).getString();
|
||||||
|
config.get("item_tags", "AdvancedSolarPanel:ultimate_solar_helmet" , "BreathingIC2" ).getString();
|
||||||
|
|
||||||
|
config.get("item_tags", "IC2:itemArmorJetpack" , "FlyInSpace NoFallDamage" ).getString();
|
||||||
|
config.get("item_tags", "IC2:itemArmorJetpackElectric" , "FlyInSpace NoFallDamage" ).getString();
|
||||||
|
config.get("item_tags", "GraviSuite:advJetpack" , "FlyInSpace NoFallDamage" ).getString();
|
||||||
|
config.get("item_tags", "GraviSuite:advNanoChestPlate" , "FlyInSpace NoFallDamage" ).getString();
|
||||||
|
config.get("item_tags", "GraviSuite:graviChestPlate" , "FlyInSpace NoFallDamage" ).getString();
|
||||||
|
|
||||||
|
config.get("item_tags", "IC2:itemArmorQuantumBoots" , "NoFallDamage" ).getString();
|
||||||
|
taggedItemsName = categoryItemTags.getValues().keySet().toArray(new String[0]);
|
||||||
|
}
|
||||||
|
taggedItems = new HashMap(taggedItemsName.length);
|
||||||
|
for (String name : taggedItemsName) {
|
||||||
|
String tags = config.get("item_tags", name, "").getString();
|
||||||
|
taggedItems.put(name, tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Radar
|
// Radar
|
||||||
RADAR_MAX_ENERGY_STORED = clamp(0, Integer.MAX_VALUE,
|
RADAR_MAX_ENERGY_STORED = clamp(0, Integer.MAX_VALUE,
|
||||||
config.get("radar", "max_energy_stored", RADAR_MAX_ENERGY_STORED).getInt());
|
config.get("radar", "max_energy_stored", RADAR_MAX_ENERGY_STORED).getInt());
|
||||||
|
@ -753,9 +797,6 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onFMLInitialization() {
|
public static void onFMLInitialization() {
|
||||||
spaceHelmets = new ArrayList<Item>();
|
|
||||||
jetpacks = new ArrayList<Item>();
|
|
||||||
|
|
||||||
isForgeMultipartLoaded = Loader.isModLoaded("ForgeMultipart");
|
isForgeMultipartLoaded = Loader.isModLoaded("ForgeMultipart");
|
||||||
if (isForgeMultipartLoaded) {
|
if (isForgeMultipartLoaded) {
|
||||||
loadForgeMultipart();
|
loadForgeMultipart();
|
||||||
|
@ -772,15 +813,6 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
isAdvancedSolarPanelLoaded = Loader.isModLoaded("AdvancedSolarPanel");
|
isAdvancedSolarPanelLoaded = Loader.isModLoaded("AdvancedSolarPanel");
|
||||||
if (isAdvancedSolarPanelLoaded) {
|
|
||||||
loadASP();
|
|
||||||
}
|
|
||||||
|
|
||||||
isGraviSuiteLoaded = Loader.isModLoaded("GraviSuite");
|
|
||||||
if (isGraviSuiteLoaded) {
|
|
||||||
loadGraviSuite();
|
|
||||||
}
|
|
||||||
|
|
||||||
isThermalExpansionLoaded = Loader.isModLoaded("ThermalExpansion");
|
isThermalExpansionLoaded = Loader.isModLoaded("ThermalExpansion");
|
||||||
isAppliedEnergistics2Loaded = Loader.isModLoaded("appliedenergistics2");
|
isAppliedEnergistics2Loaded = Loader.isModLoaded("appliedenergistics2");
|
||||||
isOpenComputersLoaded = Loader.isModLoaded("OpenComputers");
|
isOpenComputersLoaded = Loader.isModLoaded("OpenComputers");
|
||||||
|
@ -907,6 +939,30 @@ public class WarpDriveConfig {
|
||||||
WarpDrive.logger.info("- " + ENTITIES_ANCHOR.size() + " anchors: " + getHashMessage(ENTITIES_ANCHOR));
|
WarpDrive.logger.info("- " + ENTITIES_ANCHOR.size() + " anchors: " + getHashMessage(ENTITIES_ANCHOR));
|
||||||
WarpDrive.logger.info("- " + ENTITIES_NOMASS.size() + " with NoMass tag: " + getHashMessage(ENTITIES_NOMASS));
|
WarpDrive.logger.info("- " + ENTITIES_NOMASS.size() + " with NoMass tag: " + getHashMessage(ENTITIES_NOMASS));
|
||||||
WarpDrive.logger.info("- " + ENTITIES_LEFTBEHIND.size() + " with LeftBehind tag: " + getHashMessage(ENTITIES_LEFTBEHIND));
|
WarpDrive.logger.info("- " + ENTITIES_LEFTBEHIND.size() + " with LeftBehind tag: " + getHashMessage(ENTITIES_LEFTBEHIND));
|
||||||
|
|
||||||
|
// translate tagged items
|
||||||
|
ITEMS_FLYINSPACE = new HashSet(taggedItems.size());
|
||||||
|
ITEMS_NOFALLDAMAGE = new HashSet(taggedItems.size());
|
||||||
|
ITEMS_BREATHINGIC2 = new HashSet(taggedItems.size());
|
||||||
|
for (Entry<String, String> taggedItem : taggedItems.entrySet()) {
|
||||||
|
String itemId = taggedItem.getKey();
|
||||||
|
Item item = GameData.getItemRegistry().getObject(itemId);
|
||||||
|
if (item != null) {
|
||||||
|
WarpDrive.logger.info("Ignoring missing item " + itemId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (String tag : taggedItem.getValue().replace("\t", " ").replace(",", " ").replace(" ", " ").split(" ")) {
|
||||||
|
switch (tag) {
|
||||||
|
case "FlyInSpace" : ITEMS_FLYINSPACE.add(item); break;
|
||||||
|
case "NoFallDamage" : ITEMS_NOFALLDAMAGE.add(item); break;
|
||||||
|
case "BreathingIC2" : ITEMS_BREATHINGIC2.add(item); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WarpDrive.logger.info("Active items dictionnary:");
|
||||||
|
WarpDrive.logger.info("- " + ITEMS_FLYINSPACE.size() + " allowing fly in space: " + getHashMessage(ITEMS_FLYINSPACE));
|
||||||
|
WarpDrive.logger.info("- " + ITEMS_NOFALLDAMAGE.size() + " absorbing fall damages: " + getHashMessage(ITEMS_NOFALLDAMAGE));
|
||||||
|
WarpDrive.logger.info("- " + ITEMS_BREATHINGIC2.size() + " allowing breathing compressed air: " + getHashMessage(ITEMS_BREATHINGIC2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getHashMessage(HashSet hashSet) {
|
private static String getHashMessage(HashSet hashSet) {
|
||||||
|
@ -954,14 +1010,6 @@ public class WarpDriveConfig {
|
||||||
|
|
||||||
private static void loadIC2() {
|
private static void loadIC2() {
|
||||||
try {
|
try {
|
||||||
spaceHelmets.add(getModItemStack("IC2", "itemArmorHazmatHelmet", -1).getItem());
|
|
||||||
spaceHelmets.add(getModItemStack("IC2", "itemSolarHelmet", -1).getItem());
|
|
||||||
spaceHelmets.add(getModItemStack("IC2", "itemArmorNanoHelmet", -1).getItem());
|
|
||||||
spaceHelmets.add(getModItemStack("IC2", "itemArmorQuantumHelmet", -1).getItem());
|
|
||||||
|
|
||||||
jetpacks.add(getModItemStack("IC2", "itemArmorJetpack", -1).getItem());
|
|
||||||
jetpacks.add(getModItemStack("IC2", "itemArmorJetpackElectric", -1).getItem());
|
|
||||||
|
|
||||||
IC2_empty = getModItemStack("IC2", "itemCellEmpty", -1);
|
IC2_empty = getModItemStack("IC2", "itemCellEmpty", -1);
|
||||||
IC2_air = getModItemStack("IC2", "itemCellEmpty", 5);
|
IC2_air = getModItemStack("IC2", "itemCellEmpty", 5);
|
||||||
|
|
||||||
|
@ -986,30 +1034,6 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadASP() {
|
|
||||||
try {
|
|
||||||
spaceHelmets.add((Item) Item.itemRegistry.getObject("AdvancedSolarPanel:advanced_solar_helmet"));
|
|
||||||
spaceHelmets.add((Item) Item.itemRegistry.getObject("AdvancedSolarPanel:hybrid_solar_helmet"));
|
|
||||||
spaceHelmets.add((Item) Item.itemRegistry.getObject("AdvancedSolarPanel:ultimate_solar_helmet"));
|
|
||||||
} catch (Exception exception) {
|
|
||||||
WarpDrive.logger.error("Error loading ASP classes");
|
|
||||||
exception.printStackTrace();
|
|
||||||
isAdvancedSolarPanelLoaded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadGraviSuite() {
|
|
||||||
try {
|
|
||||||
jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite:advJetpack"));
|
|
||||||
jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite:advNanoChestPlate"));
|
|
||||||
jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite:graviChestPlate"));
|
|
||||||
} catch (Exception exception) {
|
|
||||||
WarpDrive.logger.error("Error loading GS classes");
|
|
||||||
exception.printStackTrace();
|
|
||||||
isGraviSuiteLoaded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DocumentBuilder getXmlDocumentBuilder() {
|
public static DocumentBuilder getXmlDocumentBuilder() {
|
||||||
if (xmlDocumentBuilder == null) {
|
if (xmlDocumentBuilder == null) {
|
||||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
|
|
|
@ -138,10 +138,9 @@ public class LivingHandler {
|
||||||
player_airTank.put(playerName, air - 1);
|
player_airTank.put(playerName, air - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (WarpDriveConfig.spaceHelmets.contains(helmetStack)) {
|
} else if (WarpDriveConfig.ITEMS_BREATHINGIC2.contains(helmet)) {
|
||||||
hasHelmet = true;
|
hasHelmet = true;
|
||||||
if (air == null) {// new player in space => grace
|
if (air == null) {// new player in space => grace period
|
||||||
// period
|
|
||||||
player_airTank.put(playerName, AIR_TANK_TICKS);
|
player_airTank.put(playerName, AIR_TANK_TICKS);
|
||||||
} else if (air <= 1) {
|
} else if (air <= 1) {
|
||||||
if (consumeO2(player.inventory.mainInventory, player)) {
|
if (consumeO2(player.inventory.mainInventory, player)) {
|
||||||
|
@ -238,11 +237,15 @@ public class LivingHandler {
|
||||||
int check = MathHelper.ceiling_float_int(distance - 3.0F);
|
int check = MathHelper.ceiling_float_int(distance - 3.0F);
|
||||||
|
|
||||||
if (check > 0) {
|
if (check > 0) {
|
||||||
if ( (player.getCurrentArmor(0) != null && player.getCurrentArmor(0) == WarpDriveConfig.getModItemStack("IC2", "itemArmorQuantumBoots", -1)) // FIXME cache the value
|
for (int i = 0; i < 4; i++) {
|
||||||
|| (player.getCurrentArmor(2) != null && WarpDriveConfig.jetpacks.contains(player.getCurrentArmor(2)))) {
|
ItemStack armor = player.getCurrentArmor(i);
|
||||||
|
if (armor != null) {
|
||||||
|
if (WarpDriveConfig.ITEMS_NOFALLDAMAGE.contains(armor.getItem())) {
|
||||||
event.setCanceled(true); // Don't damage player
|
event.setCanceled(true); // Don't damage player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue