-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Monifactory/backport-1
[backport] cherrypick backport
- Loading branch information
Showing
139 changed files
with
1,005 additions
and
756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 23 additions & 8 deletions
31
src/api/java/com/enderio/api/capacitor/CapacitorModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
package com.enderio.api.capacitor; | ||
|
||
import com.mojang.serialization.Codec; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.StringRepresentable; | ||
|
||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
/** | ||
* Capacitor key types, for use in loot capacitors for targeting increases to general stats. | ||
*/ | ||
public enum CapacitorModifier { | ||
ENERGY_CAPACITY, | ||
ENERGY_USE, | ||
public enum CapacitorModifier implements StringRepresentable { | ||
ENERGY_CAPACITY(1), | ||
ENERGY_USE(2), | ||
FUEL_EFFICIENCY(3), | ||
BURNING_ENERGY_GENERATION(4), | ||
|
||
/** | ||
* This should always go last as the loot picker will exclude the final item in this enum | ||
* @apiNote Capacitors should never multiply the FIXED modifiers... | ||
*/ | ||
FIXED; | ||
FIXED(0); | ||
|
||
public final ResourceLocation id; | ||
public static final Codec<CapacitorModifier> CODEC = StringRepresentable.fromEnum(CapacitorModifier::values); | ||
|
||
private final int id; | ||
public final ResourceLocation modifierId; | ||
|
||
public static final List<CapacitorModifier> SELECTABLE_MODIFIERS = List.of( | ||
ENERGY_CAPACITY, | ||
ENERGY_USE | ||
ENERGY_USE, | ||
FUEL_EFFICIENCY, | ||
BURNING_ENERGY_GENERATION | ||
); | ||
|
||
CapacitorModifier() { | ||
this.id = new ResourceLocation("enderio", "capacitor." + name().toLowerCase(Locale.ROOT)); | ||
CapacitorModifier(int id) { | ||
this.id = id; | ||
this.modifierId = new ResourceLocation("enderio", "capacitor." + name().toLowerCase(Locale.ROOT)); | ||
} | ||
|
||
@Override | ||
public String getSerializedName() { | ||
return name().toLowerCase(Locale.ROOT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/api/java/com/enderio/api/capacitor/SteppedScalable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.enderio.api.capacitor; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public record SteppedScalable( | ||
CapacitorModifier modifier, | ||
Supplier<Integer> base, | ||
Supplier<Integer> step | ||
) implements CapacitorScalable { | ||
|
||
@Override | ||
public Supplier<Float> scaleF(Supplier<CapacitorData> data) { | ||
return () -> scale(base.get(), step.get(), data.get().getModifier(modifier)); | ||
} | ||
|
||
@Override | ||
public Supplier<Integer> scaleI(Supplier<CapacitorData> data) { | ||
return () -> Math.round(scale(base.get(), step.get(), data.get().getModifier(modifier))); | ||
} | ||
|
||
private static float scale(int base, int step, float level) { | ||
return base + step * level; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@javax.annotation.ParametersAreNonnullByDefault | ||
@net.minecraft.MethodsReturnNonnullByDefault | ||
@com.tterrag.registrate.util.nullness.FieldsAreNonnullByDefault | ||
|
||
package com.enderio.api.capacitor; | ||
package com.enderio.api.capacitor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 10 additions & 6 deletions
16
...com/enderio/api/conduit/ConduitTypes.java → ...nderio/api/conduit/ConduitRegistries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.