Skip to content

Commit 9ad59a7

Browse files
committed
myctm
1 parent 87e45bf commit 9ad59a7

24 files changed

+1080
-1886
lines changed

dependencies.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@
3434
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
3535
*/
3636
dependencies {
37-
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
37+
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.6.35-GTNH:dev")
38+
39+
// implementation("com.github.GTNewHorizons:Angelica:1.0.0-beta6:dev")
40+
implementation("com.github.GTNewHorizons:GT5-Unofficial:5.09.49.83:dev")
3841
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ apiPackage =
7474
accessTransformersFile =
7575

7676
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
77-
usesMixins = false
77+
usesMixins = true
7878

7979
# Adds some debug arguments like verbose output and class export.
80-
usesMixinDebug = false
80+
usesMixinDebug = true
8181

8282
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
8383
mixinPlugin =
8484

8585
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
86-
mixinsPackage =
86+
mixinsPackage = mixins
8787

8888
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
8989
# This parameter is for legacy compatibility only
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package com.github.wohaopa.MyCTMLib;
2+
3+
import net.minecraft.util.IIcon;
4+
5+
import cpw.mods.fml.relauncher.Side;
6+
import cpw.mods.fml.relauncher.SideOnly;
7+
8+
public class CTMIconManager {
9+
10+
private final IIcon[] icons = new CTMIcon[21];
11+
private final IIcon icon, iconSmall;
12+
13+
public CTMIconManager(IIcon iconSmall, IIcon icon) {
14+
this.icon = icon;
15+
this.iconSmall = iconSmall;
16+
}
17+
18+
private boolean inited = false;
19+
20+
public void init() {
21+
for (int i = 1; i <= 4; i++) for (int j = 0; j < 4; j++) icons[i + j * 4] = new CTMIcon(icon, 4, 4, i - 1, j);
22+
23+
for (int i = 1; i <= 2; i++)
24+
for (int j = 0; j < 2; j++) icons[i + j * 2 + 16] = new CTMIcon(iconSmall, 2, 2, i - 1, j);
25+
inited = true;
26+
}
27+
28+
public IIcon getIcon(int index) {
29+
if (index > 0 && index < 21) return icons[index];
30+
throw new RuntimeException("Invalid index: " + index);
31+
}
32+
33+
public boolean hasInited() {
34+
return inited;
35+
}
36+
37+
private static class CTMIcon implements IIcon {
38+
39+
private final int width;
40+
private final int height;
41+
private final float umin;
42+
private final float umax;
43+
private final float vmin;
44+
private final float vmax;
45+
private final IIcon parentIcon;
46+
47+
private CTMIcon(IIcon parent, int w, int h, int x, int y) {
48+
parentIcon = parent;
49+
50+
umin = parentIcon.getInterpolatedU(16.0 * (x) / w);
51+
umax = parentIcon.getInterpolatedU(16.0 * (x + 1) / w);
52+
vmin = parentIcon.getInterpolatedV(16.0 * (y) / h);
53+
vmax = parentIcon.getInterpolatedV(16.0 * (y + 1) / h);
54+
55+
width = parentIcon.getIconWidth();
56+
height = parentIcon.getIconHeight();
57+
}
58+
59+
@Override
60+
@SideOnly(Side.CLIENT)
61+
public float getMinU() {
62+
return umin;
63+
}
64+
65+
@Override
66+
@SideOnly(Side.CLIENT)
67+
public float getMaxU() {
68+
return umax;
69+
}
70+
71+
@Override
72+
@SideOnly(Side.CLIENT)
73+
public float getInterpolatedU(double d0) {
74+
return (float) (umin + (umax - umin) * d0 / 16.0);
75+
}
76+
77+
@Override
78+
@SideOnly(Side.CLIENT)
79+
public float getMinV() {
80+
return vmin;
81+
}
82+
83+
@Override
84+
@SideOnly(Side.CLIENT)
85+
public float getMaxV() {
86+
return vmax;
87+
}
88+
89+
@Override
90+
@SideOnly(Side.CLIENT)
91+
public float getInterpolatedV(double d0) {
92+
return (float) (vmin + (vmax - vmin) * d0 / 16.0);
93+
}
94+
95+
@Override
96+
@SideOnly(Side.CLIENT)
97+
public String getIconName() {
98+
return parentIcon.getIconName();
99+
}
100+
101+
@Override
102+
@SideOnly(Side.CLIENT)
103+
public int getIconWidth() {
104+
return width;
105+
}
106+
107+
@Override
108+
@SideOnly(Side.CLIENT)
109+
public int getIconHeight() {
110+
return height;
111+
}
112+
}
113+
}

src/main/java/com/github/wohaopa/MyCTMLib/ClientProxy.java

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

src/main/java/com/github/wohaopa/MyCTMLib/CommonProxy.java

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

src/main/java/com/github/wohaopa/MyCTMLib/Config.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,64 @@
11
package com.github.wohaopa.MyCTMLib;
22

3+
import net.minecraftforge.common.config.Configuration;
4+
35
import org.apache.logging.log4j.LogManager;
46
import org.apache.logging.log4j.Logger;
57

8+
import cpw.mods.fml.client.event.ConfigChangedEvent;
9+
import cpw.mods.fml.common.FMLCommonHandler;
610
import cpw.mods.fml.common.Mod;
7-
import cpw.mods.fml.common.SidedProxy;
811
import cpw.mods.fml.common.event.FMLInitializationEvent;
9-
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
1012
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
11-
import cpw.mods.fml.common.event.FMLServerStartingEvent;
13+
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
1214

1315
@Mod(modid = MyCTMLib.MODID, version = Tags.VERSION, name = "MyCTMLib", acceptedMinecraftVersions = "[1.7.10]")
1416
public class MyCTMLib {
1517

1618
public static final String MODID = "MyCTMLib";
1719
public static final Logger LOG = LogManager.getLogger(MODID);
18-
19-
@SidedProxy(clientSide = "com.github.wohaopa.MyCTMLib.ClientProxy", serverSide = "com.github.wohaopa.MyCTMLib.CommonProxy")
20-
public static CommonProxy proxy;
20+
public String[] textures;
21+
public Configuration configuration;
2122

2223
@Mod.EventHandler
23-
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the
24-
// GameRegistry." (Remove if not needed)
2524
public void preInit(FMLPreInitializationEvent event) {
26-
proxy.preInit(event);
25+
FMLCommonHandler.instance()
26+
.bus()
27+
.register(this);
28+
configuration = new Configuration(event.getSuggestedConfigurationFile());
29+
// GameRegistry.registerBlock(new Block(Material.wood) {
30+
//
31+
// @Override
32+
// public void registerBlockIcons(IIconRegister reg) {
33+
// blockIcon = reg.registerIcon("myctmlib:iceiceice");
34+
// IIcon icon = reg.registerIcon("myctmlib:iceiceice-ctm");
35+
// Textures.ctmIconMap.put("myctmlib:iceiceice", new CTMIconManager(blockIcon, icon));
36+
// }
37+
//
38+
// @Override
39+
// public IIcon getIcon(int side, int meta) {
40+
// return super.getIcon(side, meta);
41+
// }
42+
// }, "iceiceice");
43+
loadConfig();
2744
}
2845

2946
@Mod.EventHandler
30-
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed)
3147
public void init(FMLInitializationEvent event) {
32-
proxy.init(event);
48+
Textures.register(textures);
3349
}
3450

35-
@Mod.EventHandler
36-
// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed)
37-
public void postInit(FMLPostInitializationEvent event) {
38-
proxy.postInit(event);
51+
@SubscribeEvent
52+
public void onConfigChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
53+
if (event.modID.equalsIgnoreCase(MyCTMLib.MODID)) {
54+
loadConfig();
55+
}
3956
}
4057

41-
@Mod.EventHandler
42-
// register server commands in this event handler (Remove if not needed)
43-
public void serverStarting(FMLServerStartingEvent event) {
44-
proxy.serverStarting(event);
58+
private void loadConfig() {
59+
textures = configuration.getStringList("textures", Configuration.CATEGORY_GENERAL, new String[] {}, "ctm list");
60+
if (configuration.hasChanged()) {
61+
configuration.save();
62+
}
4563
}
4664
}

0 commit comments

Comments
 (0)