Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ if (enableSpotless.toBoolean()) {
target 'src/*/kotlin/**/*.kt'

toggleOffOn()
ktfmt('0.39')
ktfmt("0.50").kotlinlangStyle()

trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
}
scala {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ mavenArtifactGroup =
# By default this will use the files found here: https://github.com/GregTechCEu/Buildscripts/tree/master/spotless
# to format your code. However, you can create your own version of these files and place them in your project's
# root directory to apply your own formatting options instead.
enableSpotless = false
enableSpotless = true

# Enable JUnit testing platform used for testing your code.
# Uses JUnit 5. See guide and documentation here: https://junit.org/junit5/docs/current/user-guide/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* so we have to use Java.
*/
public class ClayLaserByteBufAdapter implements IByteBufAdapter<@Nullable ClayLaser> {

public static final ClayLaserByteBufAdapter INSTANCE = new ClayLaserByteBufAdapter();

private ClayLaserByteBufAdapter() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ConfigCore {
public static FeGen feGen = new FeGen();

public static class SubCategoryRendering {

private SubCategoryRendering() {}

@Config.Comment({
Expand All @@ -33,6 +34,7 @@ private SubCategoryRendering() {}
}

public static class SubCategoryWorldGen {

private SubCategoryWorldGen() {}

@Config.Comment("Default: 88")
Expand Down Expand Up @@ -60,6 +62,7 @@ private SubCategoryWorldGen() {}
}

public static class SubCategoryMisc {

private SubCategoryMisc() {}

@Config.Comment({
Expand All @@ -80,8 +83,8 @@ private SubCategoryMisc() {}

@Config.RangeInt(min = 1, max = 30)
@Config.Comment({
"The maximum tier that the waterwheel can provide energy to.",
"It cannot provide energy to machines of a higher tier.",
"The maximum tier that the waterwheel can provide energy to.",
"It cannot provide energy to machines of a higher tier.",
"Default: 3"
})
public int waterwheelMaxTier = 3;
Expand Down Expand Up @@ -120,6 +123,7 @@ private SubCategoryMisc() {}
}

public static class FeGen {

private FeGen() {}

@Config.Comment("Default: false")
Expand All @@ -145,6 +149,7 @@ private FeGen() {}
"Default: FE/t * 1000"
})
@Config.Name("FE Storage Size")
public int[] feStorageSize = new int[] { 10_000, 30_000, 90_000, 270_000, 810_000, 2430_000, 7290_000, 21870_000, 65610_000, 196830_000 };
public int[] feStorageSize = new int[] { 10_000, 30_000, 90_000, 270_000, 810_000, 2430_000, 7290_000,
21870_000, 65610_000, 196830_000 };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,43 @@
@LangKey("clayium.config.tier")
@Config(modid = MOD_ID, name = MOD_ID + "/tier_balance")
public class ConfigTierBalance {

private ConfigTierBalance() {}

@RangeInt(min = 1)
@Comment({
"Auto IO interval for machines other than buffers.",
"These values correspond to the tiers 0 to 13 respectively, from top to bottom."
})
public static int[] machineInterval = new int[] {20, 20, 20, 20, 20, 2, 1, 1, 1, 1, 1, 1, 1, 1};
public static int[] machineInterval = new int[] { 20, 20, 20, 20, 20, 2, 1, 1, 1, 1, 1, 1, 1, 1 };

@RangeInt(min = 0)
@Comment({
"The machine will transfer X items per transfer.",
"These values correspond to the tiers 0 to 13 respectively, from top to bottom."
})
public static int[] machineAmount = new int[] {8, 8, 8, 8, 8, 16, 64, 64, 64, 64, 64, 64, 64, 64};
public static int[] machineAmount = new int[] { 8, 8, 8, 8, 8, 16, 64, 64, 64, 64, 64, 64, 64, 64 };

@RangeInt(min = 1)
@Comment({
"Auto IO interval for buffers.",
"These values correspond to the tiers 0 to 13 respectively, from top to bottom."
})
public static int[] bufferInterval = new int[] {8, 8, 8, 8, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1};
public static int[] bufferInterval = new int[] { 8, 8, 8, 8, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1 };

@RangeInt(min = 0)
@Comment({
"The buffer will transfer X items per transfer.",
"These values correspond to the tiers 0 to 13 respectively, from top to bottom."
})
public static int[] bufferAmount = new int[] {1, 1, 1, 1, 1, 4, 16, 64, 128, 192, 256, 512, 1024, 6400};
public static int[] bufferAmount = new int[] { 1, 1, 1, 1, 1, 4, 16, 64, 128, 192, 256, 512, 1024, 6400 };

public static SubCategoryMachines crafting = new SubCategoryMachines();

public static class SubCategoryMachines {

private SubCategoryMachines() {}

@Comment({
"craft time multiplier for clay smelters.",
"These values correspond to the tiers 4 to 9 respectively, from top to bottom."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraftforge.oredict.OreDictionary;

public class DebugUtils {

@SuppressWarnings("unused")
@SubscribeEvent
@SideOnly(Side.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;

public class ClayiumLateMixinLoadingPlugin implements ILateMixinLoader {

@Override
public List<String> getMixinConfigs() {
return Collections.singletonList("mixins.clayium.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@

import java.util.List;

//todo: delete this once it's fixed in ModularUI.
// todo: delete this once it's fixed in ModularUI.
// open a PR to ModularUI to fix this.
@Mixin(ModularContainer.class)
public abstract class FixDupeWithPhantomSlotMixin {

@Final @Shadow private List<ModularSlot> slots;
@Final
@Shadow
private List<ModularSlot> slots;

@Inject(method = "slotClick", at = @At("HEAD"), cancellable = true)
public void clayium$slotClick(int slotId, int mouseButton, ClickType clickTypeIn, EntityPlayer player, CallbackInfoReturnable<ItemStack> cir) {
public void clayium$slotClick(int slotId, int mouseButton, ClickType clickTypeIn, EntityPlayer player,
CallbackInfoReturnable<ItemStack> cir) {
if (!(clickTypeIn == ClickType.SWAP && mouseButton >= 0 && mouseButton < 9)) return;
ModularSlot hotbar = this.slots.get(mouseButton);
ModularSlot phantom = this.slots.get(slotId);
Expand Down
16 changes: 8 additions & 8 deletions src/main/kotlin/com/github/trc/clayium/api/CValues.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:JvmName("CValues")

/*
* some code is copied from `gregtech.api.GTValues`.
*/
Expand All @@ -16,19 +17,18 @@ const val GUI_DEFAULT_HEIGHT: Int = 166
const val HARDNESS_UNBREAKABLE: Float = -1.0f

/**
* This is worth exactly one normal Item.
* This Constant can be divided by many commonly used Numbers such as
* 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, ... 64 or 81
* without losing precision and is for that reason used as Unit of Amount.
* But it is also small enough to be multiplied with larger Numbers.
* This is worth exactly one normal Item. This Constant can be divided by many commonly used Numbers
* such as 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, ... 64 or 81 without
* losing precision and is for that reason used as Unit of Amount. But it is also small enough to be
* multiplied with larger Numbers.
*
* This is used to determine the amount of Material contained inside a prefixed Ore.
* For example, Nugget = `M / 9` as it contains out of 1/9 of an Ingot.
* This is used to determine the amount of Material contained inside a prefixed Ore. For example,
* Nugget = `M / 9` as it contains out of 1/9 of an Ingot.
*
* Copied from `gregtech.api.GTValues`
*/
const val M: Long = 3628800L

const val W: Int = OreDictionary.WILDCARD_VALUE

const val FALLBACK: Int = -1
const val FALLBACK: Int = -1
18 changes: 13 additions & 5 deletions src/main/kotlin/com/github/trc/clayium/api/ClayEnergy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fun PacketBuffer.readClayEnergy(): ClayEnergy {
@JvmInline
value class ClayEnergy(val energy: Long) : Comparable<ClayEnergy> {

//todo: minimum digits?
// todo: minimum digits?
fun format(): String {
return "${formatWithoutUnit()}CE"
}
Expand All @@ -26,9 +26,10 @@ value class ClayEnergy(val energy: Long) : Comparable<ClayEnergy> {
val digits = abs(energy).toString().length
val microCe = energy.toDouble() * 10.0
val unitIndex = digits / 3
val displayValue = String.format("%.3f", microCe / 10.0.pow(unitIndex * 3))
.replace(matchesExcessZero, "")
.replace(matchesExcessDecimalPoint, "")
val displayValue =
String.format("%.3f", microCe / 10.0.pow(unitIndex * 3))
.replace(matchesExcessZero, "")
.replace(matchesExcessDecimalPoint, "")
return "$displayValue${units[unitIndex]}"
}

Expand All @@ -37,12 +38,19 @@ value class ClayEnergy(val energy: Long) : Comparable<ClayEnergy> {
}

operator fun plus(other: ClayEnergy) = ClayEnergy(energy + other.energy)

operator fun minus(other: ClayEnergy) = ClayEnergy(energy - other.energy)

operator fun times(value: Int) = ClayEnergy(energy * value)

operator fun times(value: Long) = ClayEnergy(energy * value)

operator fun times(value: Double) = ClayEnergy((energy * value).toLong())

operator fun div(value: Int) = ClayEnergy(energy / value)

operator fun div(value: Double) = ClayEnergy((energy.toDouble() / value).toLong())

override operator fun compareTo(other: ClayEnergy) = energy.compareTo(other.energy)

companion object {
Expand All @@ -68,4 +76,4 @@ value class ClayEnergy(val energy: Long) : Comparable<ClayEnergy> {
return ClayEnergy(energy * 1000_00)
}
}
}
}
9 changes: 4 additions & 5 deletions src/main/kotlin/com/github/trc/clayium/api/ClayiumApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ object ClayiumApi {
val PAN_RECIPE_FACTORIES = mutableListOf<IPanRecipeFactory>()

/**
* A Registry of MteRegistries.
* If you want to create new MteRegistry,
* listen to [ClayiumMteRegistryEvent]
* and register your MteRegistry using [ClayiumMteRegistryEvent.mteManager]
* A Registry of MteRegistries. If you want to create new MteRegistry, listen to
* [ClayiumMteRegistryEvent] and register your MteRegistry using
* [ClayiumMteRegistryEvent.mteManager]
*/
val mteManager: CMteManager = CMteManager()
}
}
8 changes: 6 additions & 2 deletions src/main/kotlin/com/github/trc/clayium/api/LaserEnergy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ value class LaserEnergy(val energy: Double) {

fun format(): String {
if (energy == 0.0) return "0"
val digits = floor(log(abs(energy),10.0)).toInt()
val digits = floor(log(abs(energy), 10.0)).toInt()
val unitIndex = digits / 3
val displayValue = String.format("%.0f", energy / 10.0.pow(unitIndex * 3))
return "$displayValue${units[unitIndex]}"
Expand All @@ -21,14 +21,18 @@ value class LaserEnergy(val energy: Double) {
}

operator fun plus(other: LaserEnergy) = LaserEnergy(energy + other.energy)

operator fun minus(other: LaserEnergy) = LaserEnergy(energy - other.energy)

operator fun times(value: Int) = LaserEnergy(energy * value)

operator fun times(value: Long) = LaserEnergy(energy * value)

operator fun compareTo(other: LaserEnergy) = energy.compareTo(other.energy)

companion object {
val ZERO = LaserEnergy(0.0)

val units = listOf("", "k", "M", "G", "T", "P", "E", "Z", "Y")
}
}
}
Loading