See description (Read as: Too much for this title)

-Add ConfigGUI
-Fix chat messages sending twice
-Fix bound flint'n'steel swinging when inactive
-Create and use actual logger
-Make .gitignore not suck
-Update mcmod.info to actually be useful
-Update build scripts
-Upgradle
This commit is contained in:
TehNut committed 2014-11-03 20:11:31 -08:00
1 parent aa13190829
commit d3719c85b2
14 files changed
+269 -138

No files matched your search

@@ -19,12 +19,14 @@ import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@Mod(modid="BloodArsenal", version="0.8.0", name="Blood Arsenal", dependencies="required-after:AWWayofTime")
@Mod(modid="BloodArsenal", version="0.8.0", name="Blood Arsenal", dependencies="required-after:AWWayofTime", guiFactory = "com.arc.bloodarsenal.gui.ConfigGuiFactory")
public class BloodArsenal
{
public static String MODID = "BloodArsenal";
@@ -49,6 +51,7 @@ public class BloodArsenal
public static boolean isBaublesLoaded;
public static Logger logger = LogManager.getLogger(MODID);
public static CreativeTabs BA_TAB = new CreativeTabs("BA_TAB")
{
@Override
@@ -63,39 +66,40 @@ public class BloodArsenal
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
ModBlocks.init();
ModBlocks.registerBlocksInPre();
BloodArsenalConfig.init(new File(event.getModConfigurationDirectory(), "BloodArsenal.cfg"));
ModItems.init();
ModItems.registerItems();
ModBlocks.init();
ModBlocks.registerBlocksInPre();
Potion[] potionTypes = null;
ModItems.init();
ModItems.registerItems();
for (Field f : Potion.class.getDeclaredFields())
Potion[] potionTypes = null;
for (Field f : Potion.class.getDeclaredFields())
{
f.setAccessible(true);
f.setAccessible(true);
try
try
{
if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a"))
if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a"))
{
Field modfield = Field.class.getDeclaredField("modifiers");
modfield.setAccessible(true);
modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL);
potionTypes = (Potion[]) f.get(null);
final Potion[] newPotionTypes = new Potion[256];
System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length);
f.set(null, newPotionTypes);
Field modfield = Field.class.getDeclaredField("modifiers");
modfield.setAccessible(true);
modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL);
potionTypes = (Potion[]) f.get(null);
final Potion[] newPotionTypes = new Potion[256];
System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length);
f.set(null, newPotionTypes);
}
}
catch (Exception e)
{
System.err.println("Severe error, please report this to the mod author:");
System.err.println(e);
logger.error("Severe error, please report this to the mod author:");
logger.error(e);
}
}
BloodArsenalConfig.init(new File(event.getModConfigurationDirectory(), "BloodArsenal.cfg"));
Object dropsEvent = new ModLivingDropsEvent();
MinecraftForge.EVENT_BUS.register(dropsEvent);
@@ -125,12 +129,12 @@ public class BloodArsenal
{
if (Loader.isModLoaded("Baubles"))
{
this.isBaublesLoaded = true;
System.out.println("Loaded Baubles integration");
isBaublesLoaded = true;
logger.info("Loaded Baubles integration");
}
else
{
this.isBaublesLoaded = false;
isBaublesLoaded = false;
}
}
}
@@ -8,6 +8,8 @@ public class BloodArsenalConfig
{
public static Configuration config;
public static boolean exampleBoolean;
public static void init(File configFile)
{
config = new Configuration(configFile);
@@ -15,14 +17,27 @@ public class BloodArsenalConfig
try
{
config.load();
syncConfig();
config.addCustomCategoryComment("Example Section", "This is an example section. Isn't it wonderful?");
}
catch (Exception e)
{
BloodArsenal.logger.error("Configuration loading has failed. Please report this.");
BloodArsenal.logger.error(e);
}
finally
{
config.save();
}
}
public static void syncConfig()
{
// Options go here
exampleBoolean = config.get("Example Section", "exampleBoolean", true, "This is an example.").getBoolean(exampleBoolean);
config.save();
}
}
@@ -1,5 +1,6 @@
package com.arc.bloodarsenal;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -24,4 +25,14 @@ public class BloodArsenalEventHooks
}
}
}
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
{
if (event.modID.equals(BloodArsenal.MODID))
{
BloodArsenalConfig.syncConfig();
BloodArsenal.logger.info("Refreshing configuration file.");
}
}
}
@@ -7,12 +7,14 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.*;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -134,17 +136,20 @@ public class BlockBloodCake extends Block
{
player.getFoodStats().addStats(2, 1.5F);
SoulNetworkHandler.syphonFromNetwork(owner, 200);
player.addChatMessage(new ChatComponentText("Omm nom nom"));
if (!world.isRemote)
player.addChatMessage(new ChatComponentText("Omm nom nom"));
}
else if (player.canEat(true))
{
player.addChatMessage(new ChatComponentText("You are too full to eat any cake"));
if (!world.isRemote)
player.addChatMessage(new ChatComponentText("You are too full to eat any cake"));
}
}
else
{
player.setHealth(player.getHealth() - 2);
player.addChatMessage(new ChatComponentText("The cake is a lie!"));
if (!world.isRemote)
player.addChatMessage(new ChatComponentText("The cake is a lie!"));
}
}
@@ -1,7 +1,5 @@
package com.arc.bloodarsenal.blocks;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import com.arc.bloodarsenal.BloodArsenal;
import com.arc.bloodarsenal.items.ModItems;
import com.arc.bloodarsenal.tileentity.TileOwned;
@@ -14,7 +12,6 @@ import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.world.IBlockAccess;
@@ -287,16 +284,19 @@ public class BlockInfusedIronDoor extends BlockContainer
if (tileEntity.owner.equals(null))
{
tileEntity.setOwner(playerName);
player.addChatMessage(new ChatComponentTranslation("Door successfully bounded to you!"));
if (!world.isRemote)
player.addChatMessage(new ChatComponentTranslation("Door successfully bounded to you!"));
}
else if (tileEntity.owner.equals(playerName))
{
player.addChatMessage(new ChatComponentTranslation("Door is already bound to you!"));
if (!world.isRemote)
player.addChatMessage(new ChatComponentTranslation("Door is already bound to you!"));
}
else if (!tileEntity.owner.equals(playerName))
{
player.addChatMessage(new ChatComponentTranslation("You feel an odd draining sensation as the door actively resists you."));
if (!world.isRemote)
player.addChatMessage(new ChatComponentTranslation("You feel an odd draining sensation as the door actively resists you."));
player.setHealth(player.getHealth() - 1);
if (player.getHealth() <= 0.0005f)
@@ -2,7 +2,6 @@ package com.arc.bloodarsenal.blocks;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
import com.arc.bloodarsenal.items.ModItems;
import com.arc.bloodarsenal.tileentity.TileOwned;
import cpw.mods.fml.relauncher.Side;
@@ -12,11 +11,8 @@ import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
@@ -290,16 +286,19 @@ public class BlockInfusedWoodenDoor extends BlockContainer
if (tileEntity.owner.equals(null))
{
tileEntity.setOwner(playerName);
player.addChatMessage(new ChatComponentTranslation("Door successfully bounded to you!"));
if (!world.isRemote)
player.addChatMessage(new ChatComponentText("Door successfully bounded to you!"));
}
else if (tileEntity.owner.equals(playerName))
{
player.addChatMessage(new ChatComponentTranslation("Door is already bound to you!"));
if (!world.isRemote)
player.addChatMessage(new ChatComponentText("Door is already bound to you!"));
}
else if (!tileEntity.owner.equals(playerName))
{
player.hurtTime = 2;
player.addChatMessage(new ChatComponentTranslation("You feel an odd draining sensation as the door actively resists you."));
if (!world.isRemote)
player.addChatMessage(new ChatComponentText("You feel an odd draining sensation as the door actively resists you."));
}
}
@@ -328,7 +327,8 @@ public class BlockInfusedWoodenDoor extends BlockContainer
if (currentEssence < 10)
{
player.addChatMessage(new ChatComponentText("You are too weak to open the door."));
if (!world.isRemote)
player.addChatMessage(new ChatComponentText("You are too weak to open the door."));
}
else
{
@@ -349,7 +349,8 @@ public class BlockInfusedWoodenDoor extends BlockContainer
}
else
{
player.addChatComponentMessage(new ChatComponentTranslation("The door is locked."));
if (!world.isRemote)
player.addChatComponentMessage(new ChatComponentTranslation("The door is locked."));
}
return true;
}
@@ -0,0 +1,30 @@
package com.arc.bloodarsenal.gui;
import com.arc.bloodarsenal.BloodArsenal;
import cpw.mods.fml.client.config.GuiConfig;
import cpw.mods.fml.client.config.IConfigElement;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigElement;
import java.util.ArrayList;
import java.util.List;
import static com.arc.bloodarsenal.BloodArsenalConfig.config;
public class ConfigGui extends GuiConfig {
public ConfigGui(GuiScreen parentScreen) {
super(parentScreen, getConfigElements(parentScreen), BloodArsenal.MODID, false, false, "BloodArsenal Configuration");
}
@SuppressWarnings("rawtypes")
private static List<IConfigElement> getConfigElements(GuiScreen parent) {
List<IConfigElement> list = new ArrayList<IConfigElement>();
// Adds sections declared in BloodArsenalConfig. toLowerCase() is used because the configuration class automatically does this, so must we.
list.add(new ConfigElement<ConfigCategory>(config.getCategory("Example Section".toLowerCase())));
return list;
}
}
@@ -0,0 +1,30 @@
package com.arc.bloodarsenal.gui;
import cpw.mods.fml.client.IModGuiFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import java.util.Set;
public class ConfigGuiFactory implements IModGuiFactory {
@Override
public void initialize(Minecraft minecraftInstance) {
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return ConfigGui.class;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null;
}
}
@@ -137,9 +137,11 @@ public class BoundFlintAndSteel extends Item implements IBindable
world.setBlock(x, y, z, Blocks.fire);
}
}
return true;
}
return true;
return false;
}
@Override