-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
418 additions
and
23 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
9 changes: 9 additions & 0 deletions
9
src/main/java/cc/sukazyo/nukos/carpet/anvils/AnvilAlgorithm.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,9 @@ | ||
package cc.sukazyo.nukos.carpet.anvils; | ||
|
||
import java.util.Optional; | ||
|
||
public interface AnvilAlgorithm { | ||
|
||
Optional<AnvilResult> updateResult (AnvilContext context); | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/cc/sukazyo/nukos/carpet/anvils/AnvilAlgorithms.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,38 @@ | ||
package cc.sukazyo.nukos.carpet.anvils; | ||
|
||
import carpet.api.settings.CarpetRule; | ||
import cc.sukazyo.nukos.carpet.anvils.algorithms.VanillaAlgorithm; | ||
import cc.sukazyo.nukos.carpet.anvils.algorithms.VanillaReforgedAlgorithm; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.util.Pair; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class AnvilAlgorithms { | ||
|
||
public static Pair<AnvilAlgorithm, String> validateAndGet (String name) { | ||
|
||
return switch (name) { | ||
case "vanilla" -> new Pair<>(new VanillaAlgorithm(), name); | ||
case "vanilla-reforged" -> new Pair<>(new VanillaReforgedAlgorithm(), name); | ||
default -> new Pair<>(null, null); | ||
}; | ||
|
||
} | ||
|
||
public static AnvilAlgorithm getFromName (String name) { | ||
return validateAndGet(name).getLeft(); | ||
} | ||
|
||
public static class Validator extends carpet.api.settings.Validator<String> { | ||
|
||
@Override | ||
public String validate ( | ||
@Nullable ServerCommandSource source, CarpetRule<String> changingRule, | ||
String newValue, String userInput | ||
) { | ||
return validateAndGet(userInput).getRight(); | ||
} | ||
|
||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/cc/sukazyo/nukos/carpet/anvils/AnvilContext.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 cc.sukazyo.nukos.carpet.anvils; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class AnvilContext { | ||
|
||
public final ItemStack input1; | ||
public final ItemStack input2; | ||
public final String newItemName; | ||
|
||
public final PlayerEntity player; | ||
|
||
public AnvilContext ( | ||
ItemStack input1, ItemStack input2, String newItemName, | ||
PlayerEntity player | ||
) { | ||
this.input1 = input1; | ||
this.input2 = input2; | ||
this.newItemName = newItemName; | ||
this.player = player; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/cc/sukazyo/nukos/carpet/anvils/AnvilResult.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,19 @@ | ||
package cc.sukazyo.nukos.carpet.anvils; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
public class AnvilResult { | ||
|
||
public ItemStack output = ItemStack.EMPTY; | ||
public int levelCost = 0; | ||
public int ingotUsed = 0; | ||
|
||
public AnvilResult setOutput (ItemStack output) { this.output = output; return this; } | ||
public AnvilResult setLevelCost (int levelCost) { this.levelCost = levelCost; return this; } | ||
public AnvilResult setIngotUsed (int ingotUsed) { this.ingotUsed = ingotUsed; return this; } | ||
|
||
public static AnvilResult empty () { | ||
return new AnvilResult(); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/cc/sukazyo/nukos/carpet/anvils/algorithms/VanillaAlgorithm.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,16 @@ | ||
package cc.sukazyo.nukos.carpet.anvils.algorithms; | ||
|
||
import cc.sukazyo.nukos.carpet.anvils.AnvilAlgorithm; | ||
import cc.sukazyo.nukos.carpet.anvils.AnvilContext; | ||
import cc.sukazyo.nukos.carpet.anvils.AnvilResult; | ||
|
||
import java.util.Optional; | ||
|
||
public class VanillaAlgorithm implements AnvilAlgorithm { | ||
|
||
@Override | ||
public Optional<AnvilResult> updateResult (AnvilContext context) { | ||
return Optional.empty(); | ||
} | ||
|
||
} |
Oops, something went wrong.