mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Implemented Configs (Sectioned them out in advance...)
This commit is contained in:
parent
9ca86b2937
commit
500117bb7a
6 changed files with 73 additions and 5 deletions
|
@ -1,12 +1,15 @@
|
||||||
package de.ellpeck.actuallyadditions.common;
|
package de.ellpeck.actuallyadditions.common;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
||||||
|
import de.ellpeck.actuallyadditions.common.config.Config;
|
||||||
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
@ -27,6 +30,10 @@ public class ActuallyAdditions {
|
||||||
};
|
};
|
||||||
|
|
||||||
public ActuallyAdditions() {
|
public ActuallyAdditions() {
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Config.SERVER_CONFIG);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_CONFIG);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);
|
||||||
|
|
||||||
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
ActuallyBlocks.BLOCKS.register(eventBus);
|
ActuallyBlocks.BLOCKS.register(eventBus);
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.config;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
|
import static net.minecraftforge.common.ForgeConfigSpec.Builder;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
protected static final Builder SERVER_BUILDER = new Builder();
|
||||||
|
protected static final Builder CLIENT_BUILDER = new Builder();
|
||||||
|
protected static final Builder COMMON_BUILDER = new Builder();
|
||||||
|
|
||||||
|
public static final GeneralConfig GENERAL = new GeneralConfig();
|
||||||
|
public static final ItemConfig ITEM_CONFIG = new ItemConfig();
|
||||||
|
|
||||||
|
public static final ForgeConfigSpec SERVER_CONFIG = SERVER_BUILDER.build();
|
||||||
|
public static final ForgeConfigSpec CLIENT_CONFIG = CLIENT_BUILDER.build();
|
||||||
|
public static final ForgeConfigSpec COMMON_CONFIG = COMMON_BUILDER.build();
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.config;
|
||||||
|
|
||||||
|
import static de.ellpeck.actuallyadditions.common.config.Config.*;
|
||||||
|
import static net.minecraftforge.common.ForgeConfigSpec.*;
|
||||||
|
|
||||||
|
public class GeneralConfig {
|
||||||
|
public final BooleanValue advancedInfo;
|
||||||
|
|
||||||
|
public GeneralConfig() {
|
||||||
|
CLIENT_BUILDER.comment("Actually Additions General Config").push("general");
|
||||||
|
|
||||||
|
advancedInfo = CLIENT_BUILDER
|
||||||
|
.comment("Shows advanced item info when holding control on every item")
|
||||||
|
.define("Advanced Info", true);
|
||||||
|
|
||||||
|
CLIENT_BUILDER.pop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.config;
|
||||||
|
|
||||||
|
import static de.ellpeck.actuallyadditions.common.config.Config.COMMON_BUILDER;
|
||||||
|
import static net.minecraftforge.common.ForgeConfigSpec.IntValue;
|
||||||
|
|
||||||
|
public class ItemConfig {
|
||||||
|
public final IntValue teleportStaffCost;
|
||||||
|
public final IntValue teleportStaffMaxEnergy;
|
||||||
|
|
||||||
|
public ItemConfig() {
|
||||||
|
COMMON_BUILDER.comment("Item Config Options").push("items");
|
||||||
|
|
||||||
|
teleportStaffCost = COMMON_BUILDER
|
||||||
|
.comment(
|
||||||
|
"The base cost of the Teleport Staff (this is used to calculate the cost per distances as well)",
|
||||||
|
"Don't assign this value higher than the Teleport Staffs max energy!"
|
||||||
|
)
|
||||||
|
.defineInRange("Teleport Staff Base Cost", 200, 0, 100000);
|
||||||
|
|
||||||
|
teleportStaffMaxEnergy = COMMON_BUILDER
|
||||||
|
.comment("The max amount of Crystal Flux stored in the Teleport Staff")
|
||||||
|
.defineInRange("Teleport Staff Max Energy", 250000, 0, 1000000);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package de.ellpeck.actuallyadditions.common.items.useables;
|
package de.ellpeck.actuallyadditions.common.items.useables;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.common.config.Config;
|
||||||
import de.ellpeck.actuallyadditions.common.items.CrystalFluxItem;
|
import de.ellpeck.actuallyadditions.common.items.CrystalFluxItem;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
@ -13,12 +14,11 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
|
|
||||||
public class TeleportStaffItem extends CrystalFluxItem {
|
public class TeleportStaffItem extends CrystalFluxItem {
|
||||||
private static final int BASE_COST_PER_USE = 200;
|
|
||||||
|
|
||||||
public TeleportStaffItem() {
|
public TeleportStaffItem() {
|
||||||
super(baseProps(), () -> 250000);
|
super(baseProps(), Config.ITEM_CONFIG.teleportStaffMaxEnergy::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: come back and clean this up
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
@ -37,7 +37,8 @@ public class TeleportStaffItem extends CrystalFluxItem {
|
||||||
Vector3f centerOfHit = new Vector3f(toPos.getX(), toPos.getY(), toPos.getZ());
|
Vector3f centerOfHit = new Vector3f(toPos.getX(), toPos.getY(), toPos.getZ());
|
||||||
centerOfHit.add(.5f, (blockTrace.getFace().getAxis() == Direction.Axis.Y ? .5f : 0), .5f);
|
centerOfHit.add(.5f, (blockTrace.getFace().getAxis() == Direction.Axis.Y ? .5f : 0), .5f);
|
||||||
|
|
||||||
int energyCost = BASE_COST_PER_USE + (int) (BASE_COST_PER_USE * (player.getDistanceSq(toPos.getX(), toPos.getY(), toPos.getZ()) / 100));
|
int baseCost = Config.ITEM_CONFIG.teleportStaffCost.get();
|
||||||
|
int energyCost = baseCost + (int) (baseCost * (player.getDistanceSq(toPos.getX(), toPos.getY(), toPos.getZ()) / 100));
|
||||||
boolean canUse = stack.getCapability(CapabilityEnergy.ENERGY).map(e -> e.getEnergyStored() >= energyCost).orElse(false);
|
boolean canUse = stack.getCapability(CapabilityEnergy.ENERGY).map(e -> e.getEnergyStored() >= energyCost).orElse(false);
|
||||||
|
|
||||||
if (!canUse) {
|
if (!canUse) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package de.ellpeck.actuallyadditions.common.utilities;
|
||||||
|
|
||||||
public class VisualHelper {
|
public class VisualHelper {
|
||||||
/**
|
/**
|
||||||
* Stolen from Ell's original code, because lazy. What does it do? Something with wheels? (It's an hsb selector)
|
* Stolen from Ell's original code, because lazy. What does it do? Something with wheels? (It's an RGB selector)
|
||||||
*/
|
*/
|
||||||
public static float[] getWheelColor(float pos) {
|
public static float[] getWheelColor(float pos) {
|
||||||
if (pos < 85.0f) { return new float[] { pos * 3.0F, 255.0f - pos * 3.0f, 0.0f }; }
|
if (pos < 85.0f) { return new float[] { pos * 3.0F, 255.0f - pos * 3.0f, 0.0f }; }
|
||||||
|
|
Loading…
Reference in a new issue