-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6 rename the mod icon [api] rewrite registries, hence the 2.0 entity inventory registry [impl] jukebox record tooltip campfire item inventory donkey & llama inventory tooltip player inventory tooltip [runtime] show player's ender chest when hovering it pet owner tooltip status effect tooltip align ":" config side info spawn egg icon player head icon
- Loading branch information
Showing
75 changed files
with
1,652 additions
and
737 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
38 changes: 38 additions & 0 deletions
38
megane-api/src/main/java/badasintended/megane/api/provider/EnergyProvider.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 badasintended.megane.api.provider; | ||
|
||
import badasintended.megane.api.registry.BaseTooltipRegistry; | ||
|
||
import java.util.function.Function; | ||
|
||
public interface EnergyProvider<T> extends BaseTooltipRegistry.Provider<T> { | ||
|
||
static <T> EnergyProvider<T> of(Function<T, Double> stored, Function<T, Double> max) { | ||
return of(t -> true, stored, max); | ||
} | ||
|
||
static <T> EnergyProvider<T> of(Function<T, Boolean> hasEnergy, Function<T, Double> stored, Function<T, Double> max) { | ||
return new EnergyProvider<T>() { | ||
@Override | ||
public boolean hasEnergy(T t) { | ||
return hasEnergy.apply(t); | ||
} | ||
|
||
@Override | ||
public double getStored(T t) { | ||
return stored.apply(t); | ||
} | ||
|
||
@Override | ||
public double getMax(T t) { | ||
return max.apply(t); | ||
} | ||
}; | ||
} | ||
|
||
boolean hasEnergy(T t); | ||
|
||
double getStored(T t); | ||
|
||
double getMax(T t); | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
megane-api/src/main/java/badasintended/megane/api/provider/FluidProvider.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,54 @@ | ||
package badasintended.megane.api.provider; | ||
|
||
import badasintended.megane.api.registry.BaseTooltipRegistry; | ||
import net.minecraft.text.Text; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
|
||
public interface FluidProvider<T> extends BaseTooltipRegistry.Provider<T> { | ||
|
||
static <T> FluidProvider<T> of(Function<T, Integer> slotCount, BiFunction<T, Integer, Text> name, BiFunction<T, Integer, Double> stored, BiFunction<T, Integer, Double> max) { | ||
return of(t -> true, slotCount, name, stored, max); | ||
} | ||
|
||
static <T> FluidProvider<T> of(Function<T, Boolean> hasFluid, Function<T, Integer> slotCount, BiFunction<T, Integer, Text> name, BiFunction<T, Integer, Double> stored, BiFunction<T, Integer, Double> max) { | ||
return new FluidProvider<T>() { | ||
@Override | ||
public boolean hasFluid(T t) { | ||
return hasFluid.apply(t); | ||
} | ||
|
||
@Override | ||
public int getSlotCount(T t) { | ||
return slotCount.apply(t); | ||
} | ||
|
||
@Override | ||
public Text getFluidName(T t, int slot) { | ||
return name.apply(t, slot); | ||
} | ||
|
||
@Override | ||
public double getStored(T t, int slot) { | ||
return stored.apply(t, slot); | ||
} | ||
|
||
@Override | ||
public double getMax(T t, int slot) { | ||
return max.apply(t, slot); | ||
} | ||
}; | ||
} | ||
|
||
boolean hasFluid(T t); | ||
|
||
int getSlotCount(T t); | ||
|
||
Text getFluidName(T t, int slot); | ||
|
||
double getStored(T t, int slot); | ||
|
||
double getMax(T t, int slot); | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
megane-api/src/main/java/badasintended/megane/api/provider/InventoryProvider.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,40 @@ | ||
package badasintended.megane.api.provider; | ||
|
||
import badasintended.megane.api.registry.BaseTooltipRegistry; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
|
||
public interface InventoryProvider<T> extends BaseTooltipRegistry.Provider<T> { | ||
|
||
static <T> InventoryProvider<T> of(Function<T, Integer> size, BiFunction<T, Integer, ItemStack> stack) { | ||
return of(t -> true, size, stack); | ||
} | ||
|
||
static <T> InventoryProvider<T> of(Function<T, Boolean> hasInventory, Function<T, Integer> size, BiFunction<T, Integer, ItemStack> stack) { | ||
return new InventoryProvider<T>() { | ||
@Override | ||
public boolean hasInventory(T t) { | ||
return hasInventory.apply(t); | ||
} | ||
|
||
@Override | ||
public int size(T t) { | ||
return size.apply(t); | ||
} | ||
|
||
@Override | ||
public ItemStack getStack(T t, int slot) { | ||
return stack.apply(t, slot); | ||
} | ||
}; | ||
} | ||
|
||
boolean hasInventory(T t); | ||
|
||
int size(T t); | ||
|
||
ItemStack getStack(T t, int slot); | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
megane-api/src/main/java/badasintended/megane/api/provider/ProgressProvider.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,56 @@ | ||
package badasintended.megane.api.provider; | ||
|
||
import badasintended.megane.api.registry.BaseTooltipRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
|
||
public interface ProgressProvider<T> extends BaseTooltipRegistry.Provider<T> { | ||
|
||
static <T> ProgressProvider<T> of(Function<T, int[]> inputSlots, Function<T, int[]> outputSlots, BiFunction<T, Integer, ItemStack> stack, Function<T, Integer> percentage) { | ||
return of(t -> true, inputSlots, outputSlots, stack, percentage); | ||
} | ||
|
||
static <T> ProgressProvider<T> of(Function<T, Boolean> hasProgress, Function<T, int[]> inputSlots, Function<T, int[]> outputSlots, BiFunction<T, Integer, ItemStack> stack, Function<T, Integer> percentage) { | ||
return new ProgressProvider<T>() { | ||
@Override | ||
public boolean hasProgress(T t) { | ||
return hasProgress.apply(t); | ||
} | ||
|
||
@Override | ||
public int[] getInputSlots(T t) { | ||
return inputSlots.apply(t); | ||
} | ||
|
||
@Override | ||
public int[] getOutputSlots(T t) { | ||
return outputSlots.apply(t); | ||
} | ||
|
||
@Override | ||
public @NotNull ItemStack getStack(T t, int slot) { | ||
return stack.apply(t, slot); | ||
} | ||
|
||
@Override | ||
public int getPercentage(T t) { | ||
return percentage.apply(t); | ||
} | ||
}; | ||
} | ||
|
||
boolean hasProgress(T t); | ||
|
||
int[] getInputSlots(T t); | ||
|
||
int[] getOutputSlots(T t); | ||
|
||
@NotNull | ||
ItemStack getStack(T t, int slot); | ||
|
||
int getPercentage(T t); | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
megane-api/src/main/java/badasintended/megane/api/registry/BaseTooltipRegistry.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,50 @@ | ||
package badasintended.megane.api.registry; | ||
|
||
import java.util.*; | ||
|
||
@SuppressWarnings("unchecked") | ||
public abstract class BaseTooltipRegistry<T, P extends BaseTooltipRegistry.Provider<? extends T>> { | ||
|
||
protected final Map<Class<? extends T>, P> entries = new HashMap<>(); | ||
protected final Set<Class<?>> nulls = new HashSet<>(); | ||
|
||
private final Class<T> tClass; | ||
|
||
public BaseTooltipRegistry(Class<T> tClass) { | ||
this.tClass = tClass; | ||
} | ||
|
||
public Map<Class<? extends T>, P> getEntries() { | ||
return entries; | ||
} | ||
|
||
public <K extends T> void register(Class<K> clazz, Provider<K> provider) { | ||
getEntries().put(clazz, (P) provider); | ||
} | ||
|
||
public P get(T v) { | ||
if (nulls.contains(v.getClass())) return null; | ||
|
||
Class<?> clazz = v.getClass(); | ||
boolean containsKey = getEntries().containsKey(clazz); | ||
|
||
if (!containsKey) do { | ||
clazz = clazz.getSuperclass(); | ||
containsKey = getEntries().containsKey(clazz); | ||
} while (!containsKey && clazz != tClass); | ||
|
||
if (containsKey) { | ||
P provider = getEntries().get(clazz); | ||
getEntries().putIfAbsent((Class<? extends T>) v.getClass(), provider); | ||
return provider; | ||
} | ||
|
||
nulls.add(v.getClass()); | ||
return null; | ||
} | ||
|
||
public interface Provider<T> { | ||
|
||
} | ||
|
||
} |
77 changes: 0 additions & 77 deletions
77
megane-api/src/main/java/badasintended/megane/api/registry/EnergyTooltipRegistry.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
19091c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qsefthuopq you may want to update your translation