Skip to content

Commit 80b7507

Browse files
committed
Polish for first release
1 parent 2d5bcc1 commit 80b7507

18 files changed

Lines changed: 228 additions & 82 deletions

src/main/java/org/cyclops/structurecrafting/GeneralConfig.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/main/java/org/cyclops/structurecrafting/Configs.java renamed to src/main/java/org/cyclops/structuredcrafting/Configs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package org.cyclops.structurecrafting;
1+
package org.cyclops.structuredcrafting;
22

33
import org.cyclops.cyclopscore.config.ConfigHandler;
4-
import org.cyclops.structurecrafting.block.BlockStructuredCrafterConfig;
4+
import org.cyclops.structuredcrafting.block.BlockStructuredCrafterConfig;
55

66
/**
77
* This class holds a set of all the configs that need to be registered.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.cyclops.structuredcrafting;
2+
3+
import org.cyclops.cyclopscore.config.ConfigurableProperty;
4+
import org.cyclops.cyclopscore.config.ConfigurableTypeCategory;
5+
import org.cyclops.cyclopscore.config.extendedconfig.DummyConfig;
6+
import org.cyclops.cyclopscore.init.ModBase;
7+
import org.cyclops.cyclopscore.tracking.Analytics;
8+
import org.cyclops.cyclopscore.tracking.Versions;
9+
10+
/**
11+
* A config with general options for this mod.
12+
* @author rubensworks
13+
*
14+
*/
15+
public class GeneralConfig extends DummyConfig {
16+
17+
/**
18+
* The current mod version, will be used to check if the player's config isn't out of date and
19+
* warn the player accordingly.
20+
*/
21+
@ConfigurableProperty(category = ConfigurableTypeCategory.CORE, comment = "Config version for " + Reference.MOD_NAME +".\nDO NOT EDIT MANUALLY!")
22+
public static String version = Reference.MOD_VERSION;
23+
24+
/**
25+
* If the debug mode should be enabled. @see Debug
26+
*/
27+
@ConfigurableProperty(category = ConfigurableTypeCategory.CORE, comment = "Set 'true' to enable development debug mode. This will result in a lower performance!", requiresMcRestart = true)
28+
public static boolean debug = false;
29+
30+
/**
31+
* If the recipe loader should crash when finding invalid recipes.
32+
*/
33+
@ConfigurableProperty(category = ConfigurableTypeCategory.CORE, comment = "If the recipe loader should crash when finding invalid recipes.", requiresMcRestart = true)
34+
public static boolean crashOnInvalidRecipe = false;
35+
36+
/**
37+
* If an anonymous mod startup analytics request may be sent to our analytics service.
38+
*/
39+
@ConfigurableProperty(category = ConfigurableTypeCategory.CORE, comment = "If an anonymous mod startup analytics request may be sent to our analytics service.")
40+
public static boolean analytics = true;
41+
42+
/**
43+
* If the version checker should be enabled.
44+
*/
45+
@ConfigurableProperty(category = ConfigurableTypeCategory.CORE, comment = "If the version checker should be enabled.")
46+
public static boolean versionChecker = true;
47+
48+
/**
49+
* Create a new instance.
50+
*/
51+
public GeneralConfig() {
52+
super(StructuredCrafting._instance, true, "general", null, GeneralConfig.class);
53+
}
54+
55+
@Override
56+
public void onRegistered() {
57+
// Check version of config file
58+
if(!version.equals(Reference.MOD_VERSION))
59+
System.err.println("The config file of " + Reference.MOD_NAME + " is out of date and might cause problems, please remove it so it can be regenerated.");
60+
61+
getMod().putGenericReference(ModBase.REFKEY_CRASH_ON_INVALID_RECIPE, GeneralConfig.crashOnInvalidRecipe);
62+
getMod().putGenericReference(ModBase.REFKEY_DEBUGCONFIG, GeneralConfig.debug);
63+
64+
if(analytics) {
65+
Analytics.registerMod(getMod(), Reference.GA_TRACKING_ID);
66+
}
67+
if(versionChecker) {
68+
Versions.registerMod(getMod(), StructuredCrafting._instance, Reference.VERSION_URL);
69+
}
70+
}
71+
72+
@Override
73+
public boolean isEnabled() {
74+
return true;
75+
}
76+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.cyclops.structuredcrafting;
2+
3+
import net.minecraft.client.gui.GuiScreen;
4+
import org.cyclops.cyclopscore.client.gui.config.ExtendedConfigGuiFactoryBase;
5+
import org.cyclops.cyclopscore.client.gui.config.GuiConfigOverviewBase;
6+
import org.cyclops.cyclopscore.init.ModBase;
7+
8+
/**
9+
* @author rubensworks
10+
*/
11+
public class GuiConfigOverview extends GuiConfigOverviewBase {
12+
/**
13+
* Make a new instance.
14+
* @param parentScreen the parent GuiScreen object
15+
*/
16+
public GuiConfigOverview(GuiScreen parentScreen) {
17+
super(StructuredCrafting._instance, parentScreen);
18+
}
19+
20+
@Override
21+
public ModBase getMod() {
22+
return StructuredCrafting._instance;
23+
}
24+
25+
public static class ExtendedConfigGuiFactory extends ExtendedConfigGuiFactoryBase {
26+
27+
@Override
28+
public Class<? extends GuiConfigOverviewBase> mainConfigGuiClass() {
29+
return GuiConfigOverview.class;
30+
}
31+
}
32+
}

src/main/java/org/cyclops/structurecrafting/Reference.java renamed to src/main/java/org/cyclops/structuredcrafting/Reference.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.cyclops.structurecrafting;
1+
package org.cyclops.structuredcrafting;
22

33
/**
44
* Class that can hold basic static things that are better not hard-coded
@@ -13,13 +13,20 @@ public final class Reference {
1313
public static final String MOD_VERSION = "@VERSION@";
1414
public static final String MOD_BUILD_NUMBER = "@BUILD_NUMBER@";
1515
public static final String MOD_MC_VERSION = "@MC_VERSION@";
16+
public static final String GA_TRACKING_ID = "UA-65307010-3";
17+
public static final String VERSION_URL = "https://raw.githubusercontent.com/CyclopsMC/Versions/master/1.8/StructuredCrafting.txt";
1618

1719
// MOD ID's
20+
public static final String MOD_FORGE = "Forge";
21+
public static final String MOD_FORGE_VERSION = "@FORGE_VERSION@";
22+
public static final String MOD_FORGE_VERSION_MIN = "11.14.3.1487";
1823
public static final String MOD_CYCLOPSCORE = "cyclopscore";
1924
public static final String MOD_CYCLOPSCORE_MINVERSION = "@CYCLOPSCORE_VERSION@";
25+
public static final String MOD_CYCLOPSCORE_VERSION_MIN = "0.1.0";
2026

27+
// Dependencies
2128
public static final String MOD_DEPENDENCIES =
22-
"required-after:Forge@[11.14.1.1329,);"
23-
+ "required-after:" + Reference.MOD_CYCLOPSCORE + ""; // TODO: add min version requirements
29+
"required-after:" + MOD_FORGE + "@[" + MOD_FORGE_VERSION_MIN + ",);" +
30+
"required-after:" + MOD_CYCLOPSCORE + "@[" + MOD_CYCLOPSCORE_VERSION_MIN + ",);";
2431

2532
}

src/main/java/org/cyclops/structurecrafting/StructuredCrafting.java renamed to src/main/java/org/cyclops/structuredcrafting/StructuredCrafting.java

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
package org.cyclops.structurecrafting;
1+
package org.cyclops.structuredcrafting;
22

33
import net.minecraft.creativetab.CreativeTabs;
4-
import net.minecraft.init.Items;
54
import net.minecraftforge.fml.common.Mod;
65
import net.minecraftforge.fml.common.event.*;
76
import org.apache.logging.log4j.Level;
87
import org.cyclops.cyclopscore.config.ConfigHandler;
98
import org.cyclops.cyclopscore.config.extendedconfig.BlockItemConfigReference;
10-
import org.cyclops.cyclopscore.config.extendedconfig.ItemConfigReference;
119
import org.cyclops.cyclopscore.init.ItemCreativeTab;
1210
import org.cyclops.cyclopscore.init.ModBase;
1311
import org.cyclops.cyclopscore.init.RecipeHandler;
1412
import org.cyclops.cyclopscore.proxy.ICommonProxy;
15-
import org.cyclops.structurecrafting.block.BlockStructuredCrafter;
16-
import org.cyclops.structurecrafting.block.BlockStructuredCrafterConfig;
17-
import org.cyclops.structurecrafting.craft.provider.IItemStackProviderRegistry;
18-
import org.cyclops.structurecrafting.craft.provider.InventoryItemStackProvider;
19-
import org.cyclops.structurecrafting.craft.provider.ItemStackProviderRegistry;
20-
import org.cyclops.structurecrafting.craft.provider.WorldItemStackProvider;
13+
import org.cyclops.cyclopscore.tracking.IModVersion;
14+
import org.cyclops.structuredcrafting.block.BlockStructuredCrafterConfig;
15+
import org.cyclops.structuredcrafting.craft.provider.IItemStackProviderRegistry;
16+
import org.cyclops.structuredcrafting.craft.provider.InventoryItemStackProvider;
17+
import org.cyclops.structuredcrafting.craft.provider.ItemStackProviderRegistry;
18+
import org.cyclops.structuredcrafting.craft.provider.WorldItemStackProvider;
2119

2220
/**
2321
* The main mod class of StructuredCrafting.
@@ -28,23 +26,30 @@
2826
name = Reference.MOD_NAME,
2927
useMetadata = true,
3028
version = Reference.MOD_VERSION,
31-
dependencies = Reference.MOD_DEPENDENCIES
29+
dependencies = Reference.MOD_DEPENDENCIES,
30+
guiFactory = "org.cyclops.structuredcrafting.GuiConfigOverview$ExtendedConfigGuiFactory"
3231
)
33-
public class StructuredCrafting extends ModBase {
32+
public class StructuredCrafting extends ModBase implements IModVersion {
3433

3534
/**
3635
* The unique instance of this mod.
3736
*/
3837
@Mod.Instance(value = Reference.MOD_ID)
3938
public static StructuredCrafting _instance;
4039

40+
private boolean versionInfo = false;
41+
private String version;
42+
private String info;
43+
private String updateUrl;
44+
4145
public StructuredCrafting() {
4246
super(Reference.MOD_ID, Reference.MOD_NAME);
47+
putGenericReference(REFKEY_MOD_VERSION, Reference.MOD_VERSION);
4348
}
4449

4550
@Override
4651
protected RecipeHandler constructRecipeHandler() {
47-
return null; // TODO
52+
return new RecipeHandler(this, "recipes.xml");
4853
}
4954

5055
@Mod.EventHandler
@@ -103,6 +108,39 @@ public ICommonProxy getProxy() {
103108
return null;
104109
}
105110

111+
@Override
112+
public void setVersionInfo(String version, String info, String updateUrl) {
113+
versionInfo = true;
114+
this.version = version;
115+
this.info = info;
116+
this.updateUrl = updateUrl;
117+
}
118+
119+
@Override
120+
public boolean isVersionInfo() {
121+
return versionInfo;
122+
}
123+
124+
@Override
125+
public String getVersion() {
126+
return version;
127+
}
128+
129+
@Override
130+
public String getInfo() {
131+
return info;
132+
}
133+
134+
@Override
135+
public String getUpdateUrl() {
136+
return updateUrl;
137+
}
138+
139+
@Override
140+
public boolean needsUpdate() {
141+
return getVersion() != null && !Reference.MOD_VERSION.equals(getVersion());
142+
}
143+
106144
/**
107145
* Log a new info message for this mod.
108146
* @param message The message to show.

src/main/java/org/cyclops/structurecrafting/block/BlockStructuredCrafter.java renamed to src/main/java/org/cyclops/structuredcrafting/block/BlockStructuredCrafter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
package org.cyclops.structurecrafting.block;
1+
package org.cyclops.structuredcrafting.block;
22

33
import com.google.common.collect.Lists;
4-
import com.google.common.collect.Sets;
54
import net.minecraft.block.material.Material;
65
import net.minecraft.block.properties.PropertyDirection;
76
import net.minecraft.block.state.IBlockState;
87
import net.minecraft.entity.EntityLivingBase;
98
import net.minecraft.util.BlockPos;
109
import net.minecraft.util.EnumFacing;
11-
import net.minecraft.util.MathHelper;
1210
import net.minecraft.world.World;
1311
import org.cyclops.cyclopscore.block.property.BlockProperty;
1412
import org.cyclops.cyclopscore.config.configurable.ConfigurableBlockContainer;
1513
import org.cyclops.cyclopscore.config.extendedconfig.ExtendedConfig;
16-
import org.cyclops.structurecrafting.tileentity.TileStructuredCrafter;
14+
import org.cyclops.structuredcrafting.tileentity.TileStructuredCrafter;
1715

1816
/**
1917
* This block will detect neighbour block updates and will try to craft a new block/item from them.

src/main/java/org/cyclops/structurecrafting/block/BlockStructuredCrafterConfig.java renamed to src/main/java/org/cyclops/structuredcrafting/block/BlockStructuredCrafterConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package org.cyclops.structurecrafting.block;
1+
package org.cyclops.structuredcrafting.block;
22

33
import org.cyclops.cyclopscore.config.extendedconfig.BlockContainerConfig;
4-
import org.cyclops.structurecrafting.StructuredCrafting;
4+
import org.cyclops.structuredcrafting.StructuredCrafting;
55

66
/**
77
* Config for {@link BlockStructuredCrafter}.

src/main/java/org/cyclops/structurecrafting/craft/WorldCraftingMatrix.java renamed to src/main/java/org/cyclops/structuredcrafting/craft/WorldCraftingMatrix.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
package org.cyclops.structurecrafting.craft;
1+
package org.cyclops.structuredcrafting.craft;
22

33
import com.google.common.collect.Lists;
4-
import net.minecraft.item.ItemBlock;
54
import net.minecraft.item.ItemStack;
65
import net.minecraft.item.crafting.CraftingManager;
76
import net.minecraft.util.BlockPos;
87
import net.minecraft.util.EnumFacing;
98
import net.minecraft.world.World;
109
import org.apache.commons.lang3.tuple.Pair;
11-
import org.cyclops.structurecrafting.StructuredCrafting;
12-
import org.cyclops.structurecrafting.block.BlockStructuredCrafter;
13-
import org.cyclops.structurecrafting.craft.provider.IItemStackProvider;
14-
import org.cyclops.structurecrafting.craft.provider.IItemStackProviderRegistry;
10+
import org.cyclops.structuredcrafting.StructuredCrafting;
11+
import org.cyclops.structuredcrafting.block.BlockStructuredCrafter;
12+
import org.cyclops.structuredcrafting.craft.provider.IItemStackProvider;
13+
import org.cyclops.structuredcrafting.craft.provider.IItemStackProviderRegistry;
1514

1615
import java.util.List;
1716

src/main/java/org/cyclops/structurecrafting/craft/WorldInventoryCrafting.java renamed to src/main/java/org/cyclops/structuredcrafting/craft/WorldInventoryCrafting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.cyclops.structurecrafting.craft;
1+
package org.cyclops.structuredcrafting.craft;
22

33
import net.minecraft.entity.player.EntityPlayer;
44
import net.minecraft.inventory.Container;

0 commit comments

Comments
 (0)