2019-09-12 10:00:15 +02:00
|
|
|
package com.simibubi.create.modules;
|
|
|
|
|
2019-09-14 18:21:30 +02:00
|
|
|
import com.simibubi.create.AllBlocks;
|
|
|
|
import com.simibubi.create.AllItems;
|
2019-09-12 10:00:15 +02:00
|
|
|
import com.simibubi.create.CreateConfig;
|
2019-12-09 14:58:12 +01:00
|
|
|
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
2019-09-14 18:21:30 +02:00
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.item.BlockItem;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2019-09-12 10:00:15 +02:00
|
|
|
|
|
|
|
public interface IModule {
|
|
|
|
|
|
|
|
public static boolean isActive(String module) {
|
|
|
|
if (module.equals("materials"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
CreateConfig conf = CreateConfig.parameters;
|
|
|
|
switch (module) {
|
|
|
|
case "contraptions":
|
|
|
|
return conf.enableContraptions.get();
|
|
|
|
case "palettes":
|
|
|
|
return conf.enablePalettes.get();
|
|
|
|
case "curiosities":
|
|
|
|
return conf.enableCuriosities.get();
|
|
|
|
case "logistics":
|
|
|
|
return conf.enableLogistics.get();
|
|
|
|
case "schematics":
|
|
|
|
return conf.enableSchematics.get();
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2019-09-14 18:21:30 +02:00
|
|
|
|
|
|
|
public default Palette getToolTipColor() {
|
|
|
|
String module = getModuleName();
|
|
|
|
|
|
|
|
if (module.equals("materials"))
|
|
|
|
return Palette.Purple;
|
|
|
|
|
|
|
|
switch (module) {
|
|
|
|
case "contraptions":
|
|
|
|
return Palette.Red;
|
|
|
|
case "palettes":
|
2020-02-03 16:47:58 +01:00
|
|
|
return Palette.Green;
|
2019-09-14 18:21:30 +02:00
|
|
|
case "curiosities":
|
|
|
|
return Palette.Purple;
|
|
|
|
case "logistics":
|
|
|
|
return Palette.Yellow;
|
|
|
|
case "schematics":
|
|
|
|
return Palette.Blue;
|
|
|
|
default:
|
|
|
|
return Palette.Purple;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IModule of(ItemStack stack) {
|
|
|
|
Item item = stack.getItem();
|
|
|
|
if (item instanceof BlockItem)
|
|
|
|
return ofBlock(((BlockItem) item).getBlock());
|
|
|
|
return ofItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
static IModule ofItem(Item item) {
|
|
|
|
for (AllItems allItems : AllItems.values()) {
|
|
|
|
if (allItems.get() == item)
|
|
|
|
return allItems.module;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IModule ofBlock(Block block) {
|
|
|
|
for (AllBlocks allBlocks : AllBlocks.values()) {
|
|
|
|
if (allBlocks.get() == block)
|
|
|
|
return allBlocks.module;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2019-09-12 10:00:15 +02:00
|
|
|
|
|
|
|
public default boolean isEnabled() {
|
|
|
|
return isActive(getModuleName());
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getModuleName();
|
|
|
|
|
|
|
|
}
|