mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-17 03:05:10 +00:00
Repackage to team.chisel (excepting API)
This commit is contained in:
1 parent
7555e21144
commit
9574e05c29
132 files changed
+526
-596
No files matched your search
@@ -0,0 +1,55 @@
|
||||
package team.chisel.compat;
|
||||
|
||||
import com.cricketcraft.chisel.api.IMC;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.carving.Carving;
|
||||
import net.minecraft.block.Block;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCHandler {
|
||||
|
||||
public static final IMCHandler INSTANCE = new IMCHandler();
|
||||
|
||||
private int order = 1000;
|
||||
|
||||
private IMCHandler() {
|
||||
}
|
||||
|
||||
public void handleMessage(IMCMessage message) {
|
||||
for (IMC imc : IMC.values()) {
|
||||
if (imc.key.equals(message.key)) {
|
||||
handle(message, imc, message.getStringValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(IMCMessage message, IMC type, String value) {
|
||||
ICarvingRegistry reg = Carving.chisel;
|
||||
String[] data = value.split("\\|");
|
||||
try {
|
||||
switch (type) {
|
||||
case ADD_VARIATION:
|
||||
case REMOVE_VARIATION:
|
||||
Block block = (Block) Block.blockRegistry.getObject(data[1]);
|
||||
int meta = Short.parseShort(data[2]);
|
||||
if (type == IMC.ADD_VARIATION) {
|
||||
reg.addVariation(data[0], block, meta, order++);
|
||||
} else {
|
||||
reg.removeVariation(block, meta, data[0]);
|
||||
}
|
||||
break;
|
||||
case REGISTER_GROUP_ORE:
|
||||
reg.registerOre(data[0], data[1]);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid IMC constant! How...what...?");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Chisel.logger.error("Could not handle data {} for IMC type {}. This was sent from mod {}.\n" + "!! This is a bug in that mod !!\nSwallowing error and continuing...", value, type.name(),
|
||||
message.getSender());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user