mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +01:00
added a config to change the configuration items
This commit is contained in:
parent
d0f93a4288
commit
97766f8ac5
5 changed files with 37 additions and 7 deletions
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
|
@ -141,7 +142,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
if(tile instanceof TileEntityLaserRelay){
|
if(tile instanceof TileEntityLaserRelay){
|
||||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||||
|
|
||||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){
|
if(StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemCompassConfigurator){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
relay.onCompassAction(player);
|
relay.onCompassAction(player);
|
||||||
|
|
||||||
|
@ -188,7 +189,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
||||||
if(posHit != null && posHit.getBlockPos() != null && minecraft.theWorld != null && StackUtil.isValid(stack)){
|
if(posHit != null && posHit.getBlockPos() != null && minecraft.theWorld != null && StackUtil.isValid(stack)){
|
||||||
boolean compass = stack.getItem() instanceof ItemCompass;
|
boolean compass = stack.getItem() == ConfigValues.itemCompassConfigurator;
|
||||||
if(compass || stack.getItem() instanceof ItemLaserWrench){
|
if(compass || stack.getItem() instanceof ItemLaserWrench){
|
||||||
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
||||||
if(tile instanceof TileEntityLaserRelay){
|
if(tile instanceof TileEntityLaserRelay){
|
||||||
|
@ -202,7 +203,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
expl = relay.getCompassDisplayString();
|
expl = relay.getCompassDisplayString();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Compass to modify!";
|
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a "+StringUtil.localize(ConfigValues.itemCompassConfigurator.getUnlocalizedName()+".name")+" to modify!";
|
||||||
}
|
}
|
||||||
|
|
||||||
StringUtil.drawSplitString(minecraft.fontRendererObj, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true);
|
StringUtil.drawSplitString(minecraft.fontRendererObj, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
|
@ -111,7 +112,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
|
||||||
|
|
||||||
public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player){
|
public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player){
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
if(StackUtil.isValid(stack) && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
|
if(StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator){
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityBase){
|
if(tile instanceof TileEntityBase){
|
||||||
TileEntityBase base = (TileEntityBase)tile;
|
TileEntityBase base = (TileEntityBase)tile;
|
||||||
|
|
|
@ -11,10 +11,18 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.config;
|
package de.ellpeck.actuallyadditions.mod.config;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.*;
|
import de.ellpeck.actuallyadditions.mod.config.values.*;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
|
||||||
public final class ConfigValues{
|
public final class ConfigValues{
|
||||||
|
|
||||||
|
public static Item itemRedstoneTorchConfigurator;
|
||||||
|
public static Item itemCompassConfigurator;
|
||||||
|
|
||||||
public static void defineConfigValues(Configuration config){
|
public static void defineConfigValues(Configuration config){
|
||||||
|
|
||||||
for(ConfigCrafting currConf : ConfigCrafting.values()){
|
for(ConfigCrafting currConf : ConfigCrafting.values()){
|
||||||
|
@ -37,5 +45,24 @@ public final class ConfigValues{
|
||||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
|
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseConfiguratorConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void parseConfiguratorConfig(){
|
||||||
|
itemRedstoneTorchConfigurator = null;
|
||||||
|
itemCompassConfigurator = null;
|
||||||
|
|
||||||
|
String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue();
|
||||||
|
if(conf.length == 2){
|
||||||
|
itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0]));
|
||||||
|
itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null){
|
||||||
|
ModUtil.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!");
|
||||||
|
|
||||||
|
itemRedstoneTorchConfigurator = Item.getItemFromBlock(Blocks.REDSTONE_TORCH);
|
||||||
|
itemCompassConfigurator = Items.COMPASS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||||
|
|
||||||
public enum ConfigStringListValues{
|
public enum ConfigStringListValues{
|
||||||
|
|
||||||
|
CONFIGURE_ITEMS("Configuration Items", ConfigCategories.OTHER, new String[]{"minecraft:redstone_torch", "minecraft:compass"}, "The non-Actually Additions items that are used to configure blocks from the mod. The first one is the Redstone Torch used to configure the Redstone Mode, and the second one is the Compass used to configure Laser Relays. If another mod overrides usage of either one of these items, you can change the registry name of the used items (using blocks is not possible) here."),
|
||||||
CRUSHER_RECIPE_EXCEPTIONS("Crusher Recipe Exceptions", ConfigCategories.OTHER, new String[]{"ingotBrick", "ingotBrickNether"}, "Ingots, Dusts and Ores that will be blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only."),
|
CRUSHER_RECIPE_EXCEPTIONS("Crusher Recipe Exceptions", ConfigCategories.OTHER, new String[]{"ingotBrick", "ingotBrickNether"}, "Ingots, Dusts and Ores that will be blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only."),
|
||||||
CRUSHER_OUTPUT_BLACKLIST("Crusher Output Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed as outputs from OreDict Crusher recipes. Use this in case a mod, for example, adds a dust variant that can't be smelted into an ingot. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_item@3"),
|
CRUSHER_OUTPUT_BLACKLIST("Crusher Output Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed as outputs from OreDict Crusher recipes. Use this in case a mod, for example, adds a dust variant that can't be smelted into an ingot. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_item@3"),
|
||||||
MASHED_FOOD_CRAFTING_EXCEPTIONS("Mashed Food Crafting Exceptions", ConfigCategories.ITEMS_CRAFTING, new String[]{"ActuallyAdditions:itemCoffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."),
|
MASHED_FOOD_CRAFTING_EXCEPTIONS("Mashed Food Crafting Exceptions", ConfigCategories.ITEMS_CRAFTING, new String[]{"ActuallyAdditions:itemCoffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."),
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.event;
|
package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
|
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.EnergyDisplay;
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.EnergyDisplay;
|
||||||
|
@ -20,7 +21,6 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockRedstoneTorch;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
@ -162,11 +162,11 @@ public class ClientEvents{
|
||||||
font.drawStringWithShadow(strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
|
font.drawStringWithShadow(strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
|
||||||
|
|
||||||
String expl;
|
String expl;
|
||||||
if(StackUtil.isValid(stack) && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
|
if(StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator){
|
||||||
expl = TextFormatting.GREEN+"Right-Click to toggle!";
|
expl = TextFormatting.GREEN+"Right-Click to toggle!";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Redstone Torch to toggle!";
|
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a "+StringUtil.localize(ConfigValues.itemRedstoneTorchConfigurator.getUnlocalizedName()+".name")+" to toggle!";
|
||||||
}
|
}
|
||||||
font.drawStringWithShadow(expl, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE);
|
font.drawStringWithShadow(expl, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue