aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-01-02 14:31:16 +0800
committershedaniel <daniel@shedaniel.me>2020-01-02 14:31:16 +0800
commit5e2eccadbd91171c01cdb209d1338bcfb7786b1c (patch)
tree6c7387de5baea8b335e8abe58651018f77ad2d41 /src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
parente8714fe8fc1dcaec7ad299c63e2b657870c8fb40 (diff)
downloadRoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.tar.gz
RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.tar.bz2
RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.zip
3.3
Fix #58 Close #134 Close #158 Fix #227
Diffstat (limited to 'src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java')
-rw-r--r--src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
index 54b7e542d..c8e761e25 100644
--- a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
+++ b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
@@ -16,89 +16,89 @@ import net.minecraft.container.Container;
import java.util.function.Supplier;
public interface AutoTransferHandler {
-
+
default double getPriority() {
return 0d;
}
-
+
Result handle(Context context);
-
- public interface Result {
+
+ interface Result {
static Result createSuccessful() {
return new ResultImpl();
}
-
+
static Result createNotApplicable() {
return new ResultImpl(false);
}
-
+
static Result createFailed(String errorKey) {
return new ResultImpl(errorKey, new IntArrayList(), 1744764928);
}
-
+
static Result createFailedCustomButtonColor(String errorKey, int color) {
return new ResultImpl(errorKey, new IntArrayList(), color);
}
-
+
static Result createFailed(String errorKey, IntList redSlots) {
return new ResultImpl(errorKey, redSlots, 1744764928);
}
-
+
static Result createFailedCustomButtonColor(String errorKey, IntList redSlots, int color) {
return new ResultImpl(errorKey, redSlots, color);
}
-
+
int getColor();
-
+
boolean isSuccessful();
-
+
boolean isApplicable();
-
+
String getErrorKey();
-
+
IntList getIntegers();
}
-
- public interface Context {
+
+ interface Context {
static Context create(boolean actuallyCrafting, AbstractContainerScreen<?> containerScreen, RecipeDisplay recipeDisplay) {
return new ContextImpl(actuallyCrafting, containerScreen, () -> recipeDisplay);
}
-
+
default MinecraftClient getMinecraft() {
return MinecraftClient.getInstance();
}
-
+
boolean isActuallyCrafting();
-
+
AbstractContainerScreen<?> getContainerScreen();
-
+
RecipeDisplay getRecipe();
-
+
default Container getContainer() {
return getContainerScreen().getContainer();
}
-
+
default ContainerScreenOverlay getOverlay() {
return ScreenHelper.getLastOverlay();
}
}
-
- public final class ResultImpl implements Result {
+
+ final class ResultImpl implements Result {
private boolean successful, applicable;
private String errorKey;
private IntList integers = new IntArrayList();
private int color;
-
+
private ResultImpl() {
this.successful = true;
this.applicable = true;
}
-
+
public ResultImpl(boolean applicable) {
this.successful = false;
this.applicable = applicable;
}
-
+
public ResultImpl(String errorKey, IntList integers, int color) {
this.successful = false;
this.applicable = true;
@@ -107,58 +107,58 @@ public interface AutoTransferHandler {
this.integers = integers;
this.color = color;
}
-
+
@Override
public int getColor() {
return color;
}
-
+
@Override
public boolean isSuccessful() {
return successful;
}
-
+
@Override
public boolean isApplicable() {
return applicable;
}
-
+
@Override
public String getErrorKey() {
return errorKey;
}
-
+
@Override
public IntList getIntegers() {
return integers;
}
}
-
- public final class ContextImpl implements Context {
+
+ final class ContextImpl implements Context {
boolean actuallyCrafting;
AbstractContainerScreen<?> containerScreen;
Supplier<RecipeDisplay> recipeDisplaySupplier;
-
+
private ContextImpl(boolean actuallyCrafting, AbstractContainerScreen<?> containerScreen, Supplier<RecipeDisplay> recipeDisplaySupplier) {
this.actuallyCrafting = actuallyCrafting;
this.containerScreen = containerScreen;
this.recipeDisplaySupplier = recipeDisplaySupplier;
}
-
+
@Override
public boolean isActuallyCrafting() {
return actuallyCrafting;
}
-
+
@Override
public AbstractContainerScreen<?> getContainerScreen() {
return containerScreen;
}
-
+
@Override
public RecipeDisplay getRecipe() {
return recipeDisplaySupplier.get();
}
}
-
+
}