Skip to content

Commit

Permalink
ItemInHand info now shows NBT values, and fluid container information…
Browse files Browse the repository at this point in the history
… with the containing fluid (If any)

If any errors occour while loading, any op/admin will be notified if he/she logs in via an ingame message
CustomDrops can now have NBT Tags
All items/blocks and fluids will report the failed item in addition to the generic "xx failed to register" message
Fixed MysteriousCrystalDensePlate to use the correct Item-Name (Was set to CallistoIceDensePlate)
  • Loading branch information
Namikon committed Sep 29, 2015
1 parent 82d61ac commit cbdb163
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.7.10-0.9.25"
version = "1.7.10-0.9.26"
group= "com.dreammaster" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "GTNewHorizonsCoreMod"

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/dreammaster/block/BlockList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dreammaster.creativetab.ModTabList;
import com.dreammaster.lib.Refstrings;
import com.dreammaster.main.MainRegistry;

import eu.usrv.yamcore.blocks.ModBlockManager;
import eu.usrv.yamcore.blocks.ModSimpleBaseBlock;
Expand Down Expand Up @@ -66,7 +67,10 @@ public static boolean AddToItemManager(ModBlockManager pBlockManager)
{
if (bl.Block != null)
if (!pBlockManager.AddItemToManagedRegistry(bl.Block))
{
MainRegistry.Logger.error(String.format("Block [%s] failed to register", bl.toString()));
tResult = false;
}
}

return tResult;
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/dreammaster/command/ItemInHandInfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;

import com.dreammaster.main.MainRegistry;
import com.dreammaster.modhazardousitems.HazardousItems.HazardousItem;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
Expand Down Expand Up @@ -79,13 +83,33 @@ public void processCommand(ICommandSender pCmdSender, String[] pArgs)
PlayerChatHelper.SendPlain(pCmdSender, String.format("Unloc.Name: [%s]", inHand.getUnlocalizedName()));
PlayerChatHelper.SendPlain(pCmdSender, String.format("ItemName: [%s]", UID.toString()));
PlayerChatHelper.SendPlain(pCmdSender, String.format("ItemMeta: [%s]", inHand.getItemDamage()));
PlayerChatHelper.SendPlain(pCmdSender, String.format("ItemNBT: [%s]", inHand.stackTagCompound));
PlayerChatHelper.SendPlain(pCmdSender, String.format("FluidContainer: [%s]", getFluidContainerContents(inHand)));

} catch (Exception e)
{
e.printStackTrace();
PlayerChatHelper.SendError(pCmdSender, "Unknown error occoured");
}
}

private String getFluidContainerContents(ItemStack pItemInQuestion)
{
String tResult = "No fluid container";

if (pItemInQuestion.getItem() instanceof IFluidContainerItem)
{
IFluidContainerItem tFluidContainer = IFluidContainerItem.class.cast(pItemInQuestion.getItem());
FluidStack tContents = tFluidContainer.getFluid(pItemInQuestion);
if (tContents != null)
{
tResult = String.format("FluidID: [%d], UnlocName: [%s], Name: [%s]", tContents.getFluid().getID(), tContents.getFluid().getUnlocalizedName(), tContents.getFluid().getName());
}
}

return tResult;
}

private boolean InGame(ICommandSender pCmdSender)
{
if (!(pCmdSender instanceof EntityPlayer))
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/dreammaster/config/CoreModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public CoreModConfig(File pConfigBaseDirectory,
public boolean ModItemInHandInfo_Enabled;
public boolean ModCustomFuels_Enabled;
public boolean ModCustomDrops_Enabled;
public boolean ModAdminErrorLogs_Enabled;
public int PotionTimer;

@Override
Expand All @@ -26,6 +27,7 @@ protected void PreInit() {
ModItemInHandInfo_Enabled = false;
ModCustomFuels_Enabled = false;
ModCustomDrops_Enabled = false;
ModAdminErrorLogs_Enabled = true;
PotionTimer = 100;
}

Expand All @@ -36,7 +38,7 @@ protected void Init() {
ModItemInHandInfo_Enabled = _mainConfig.getBoolean("ItemInHandInfo", "Modules", ModItemInHandInfo_Enabled, "Set to true to enable ItemInHandInfo module. If enabled, type /iih to display the item's name-info");
ModCustomDrops_Enabled = _mainConfig.getBoolean("CustomDrops", "Modules", ModCustomDrops_Enabled, "Set to true to enable CustomDrops module. This needs a separate config file which is created once you start with this setting enabled");
ModCustomFuels_Enabled = _mainConfig.getBoolean("CustomFuels", "Modules", ModCustomFuels_Enabled, "Set to true to enable CustomFuels module. Allows you to set burn-time values to almost any item");

ModAdminErrorLogs_Enabled = _mainConfig.getBoolean("AdminErrorLog", "Modules", ModAdminErrorLogs_Enabled, "If set to true, every op/admin will receive all errors occoured during the startup phase as ingame message on join");
PotionTimer = _mainConfig.getInt("PotionTimer", "Limits", PotionTimer, 100, 2048, "The time (in ticks) the potion effect will remain on the player when he drops the bucket. 20 = 1 second");
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/dreammaster/fluids/FluidList.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.dreammaster.creativetab.ModTabList;
import com.dreammaster.lib.Refstrings;
import com.dreammaster.main.MainRegistry;

import eu.usrv.yamcore.fluids.ModFluidManager;
import eu.usrv.yamcore.fluids.ModSimpleBaseFluid;
Expand Down Expand Up @@ -40,7 +41,10 @@ public static boolean AddToItemManager(ModFluidManager pFluidManager)
{
if (il.Fluid != null)
if (!pFluidManager.AddItemToManagedRegistry(il.Fluid))
{
MainRegistry.Logger.error(String.format("Fluid [%s] failed to register", il.toString()));
tResult = false;
}
}

return tResult;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/dreammaster/item/ItemList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dreammaster.creativetab.ModTabList;
import com.dreammaster.lib.Refstrings;
import com.dreammaster.main.MainRegistry;

import eu.usrv.yamcore.items.ModItemManager;
import eu.usrv.yamcore.items.ModSimpleBaseItem;
Expand Down Expand Up @@ -139,7 +140,7 @@ public enum ItemList {
MysteriousCrystalIngot(new ModSimpleBaseItem("MysteriousCrystalIngot", ModTabList.ModGenericTab)),
MysteriousCrystalColdIngot(new ModSimpleBaseItem("MysteriousCrystalColdIngot", ModTabList.ModGenericTab)),
MysteriousCrystalPlate(new ModSimpleBaseItem("MysteriousCrystalPlate", ModTabList.ModGenericTab)),
MysteriousCrystalDensePlate(new ModSimpleBaseItem("CallistoIceDensePlate", ModTabList.ModGenericTab)),
MysteriousCrystalDensePlate(new ModSimpleBaseItem("MysteriousCrystalDensePlate", ModTabList.ModGenericTab)),
MysteriousCrystalCompressedPlate(new ModSimpleBaseItem("MysteriousCrystalCompressedPlate", ModTabList.ModGenericTab)),
MytrylCrystal(new ModSimpleBaseItem("MytrylCrystal", ModTabList.ModGenericTab)),
MytrylDust(new ModSimpleBaseItem("MytrylDust", ModTabList.ModGenericTab)),
Expand Down Expand Up @@ -263,7 +264,10 @@ public static boolean AddToItemManager(ModItemManager pItemManager)
{
if (il.Item != null)
if (!pItemManager.AddItemToManagedRegistry(il.Item))
{
MainRegistry.Logger.error(String.format("Item [%s] failed to register", il.toString()));
tResult = false;
}
}

return tResult;
Expand Down
37 changes: 33 additions & 4 deletions src/main/java/com/dreammaster/main/MainRegistry.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dreammaster.main;
package com.dreammaster.main;

import java.util.Random;

Expand All @@ -22,6 +22,7 @@
import com.dreammaster.modcustomdrops.CustomDropsHandler;
import com.dreammaster.modcustomfuels.CustomFuelsHandler;
import com.dreammaster.modhazardousitems.HazardousItemsHandler;
import com.dreammaster.modingameerrorlog.IngameErrorLog;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
Expand Down Expand Up @@ -57,22 +58,36 @@ public class MainRegistry {
public static CustomToolTipsHandler Module_CustomToolTips = null;
public static CustomFuelsHandler Module_CustomFuels = null;
public static CustomDropsHandler Module_CustomDrops = null;
public static IngameErrorLog Module_AdminErrorLogs = null;
public static CoreModConfig CoreConfig;
public static Random Rnd = null;
public static LogHelper Logger = new LogHelper(Refstrings.MODID);

public static void AddLoginError(String pMessage)
{
if (Module_AdminErrorLogs != null)
Module_AdminErrorLogs.AddErrorLogOnAdminJoin(pMessage);
}

@EventHandler
public static void PreLoad(FMLPreInitializationEvent PreEvent) {
Logger.setDebugOutput(true);

Rnd = new Random(System.currentTimeMillis());

// ------------------------------------------------------------
// Init coremod config file. Create it if it's not there
CoreConfig = new CoreModConfig(PreEvent.getModConfigurationDirectory(), Refstrings.COLLECTIONID, Refstrings.MODID);
if (!CoreConfig.LoadConfig())
Logger.error(String.format("%s could not load its config file. Things are going to be weird!", Refstrings.MODID));
// ------------------------------------------------------------

if (CoreConfig.ModAdminErrorLogs_Enabled)
{
Logger.debug("Module_AdminErrorLogs is enabled");
Module_AdminErrorLogs = new IngameErrorLog();
}

// ------------------------------------------------------------
Logger.debug("PRELOAD Init itemmanager");
ItemManager = new ModItemManager(Refstrings.MODID);
Expand All @@ -88,26 +103,31 @@ public static void PreLoad(FMLPreInitializationEvent PreEvent) {
// ------------------------------------------------------------



// ------------------------------------------------------------
Logger.debug("PRELOAD Create Items");
if (!ItemList.AddToItemManager(ItemManager))
{
Logger.warn("Some items failed to register. Check the logfile for details");
AddLoginError("[CoreMod-Items] Some items failed to register. Check the logfile for details");
}
// ------------------------------------------------------------




// ------------------------------------------------------------
Logger.info("PRELOAD Create Blocks");
if (!BlockList.AddToItemManager(BlockManager))
{
Logger.warn("Some blocks failed to register. Check the logfile for details");
AddLoginError("[CoreMod-Blocks] Some blocks failed to register. Check the logfile for details");
}
// ------------------------------------------------------------



// ------------------------------------------------------------
// Init Modules
Logger.debug("PRELOAD Init Modules");

if (CoreConfig.ModHazardousItems_Enabled)
{
Logger.debug("Module_HazardousItems is enabled");
Expand Down Expand Up @@ -142,7 +162,10 @@ public static void PreLoad(FMLPreInitializationEvent PreEvent) {
Logger.debug("PRELOAD Create Fluids");
FluidManager = new ModFluidManager(Refstrings.MODID);
if(!FluidList.AddToItemManager(FluidManager))
{
Logger.warn("Some fluids failed to register. Check the logfile for details");
AddLoginError("[CoreMod-Fluids] Some fluids failed to register. Check the logfile for details");
}
// ------------------------------------------------------------

proxy.registerRenderInfo();
Expand Down Expand Up @@ -177,7 +200,10 @@ public static void load(FMLInitializationEvent event) {
// register all non-enum items
Logger.debug("LOAD Register non enum Items");
if (!RegisterNonEnumItems())
{
Logger.error("Some extended items could not be registered to the game registry");
AddLoginError("[CoreMod-Items] Some extended items could not be registered to the game registry");
}

// register events in modules
RegisterModuleEvents();
Expand All @@ -186,6 +212,9 @@ public static void load(FMLInitializationEvent event) {

private static void RegisterModuleEvents()
{
if (CoreConfig.ModAdminErrorLogs_Enabled)
FMLCommonHandler.instance().bus().register(Module_AdminErrorLogs);

if (CoreConfig.ModHazardousItems_Enabled)
FMLCommonHandler.instance().bus().register(Module_HazardousItems);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void LoadConfig()
if (!ReloadCustomToolTips())
{
_mLogger.warn("Configuration File seems to be damaged, loading does-nothing-evil default config. You should fix your file and reload it");
MainRegistry.AddLoginError("[CustomToolTips] Config file not loaded due errors");
InitSampleConfig();
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/dreammaster/modcustomdrops/CustomDrops.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static class Drop

@XmlAttribute(name = "Amount")
protected int mAmount;

@XmlAttribute(name = "NBTTag")
protected String mTag;

@XmlAttribute(name = "Chance")
protected int mChance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public CustomDrop createCustomDropEntry(String pMobClassName)
}

public Drop createDrop(String pItemName, String pIdentifier, int pAmount, boolean pDropRnd, int pChance, int pLimitedDropCount)
{
return createDrop(pItemName, pIdentifier, "", pAmount, pDropRnd, pChance, pLimitedDropCount);
}

public Drop createDrop(String pItemName, String pIdentifier, String pNBTTag, int pAmount, boolean pDropRnd, int pChance, int pLimitedDropCount)
{
Drop drop = new Drop();
drop.mAmount = pAmount;
Expand All @@ -21,6 +26,7 @@ public Drop createDrop(String pItemName, String pIdentifier, int pAmount, boolea
drop.mIsRandomAmount = pDropRnd;
drop.mItemName = pItemName;
drop.mLimitedDropCount = pLimitedDropCount;
drop.mTag = pNBTTag;

return drop;
}
Expand Down
Loading

1 comment on commit cbdb163

@Namikon
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.