mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
migrate to new buildscript
Class Registries are merged together into one. All subprojects are also merged into one. It's probably possible to split stuff into multiple source sets and not merging the registries, but I'm just too lazy for that.
This commit is contained in:
341 files changed
+1027
-11951
No files matched your search
@@ -0,0 +1,92 @@
|
||||
package minetweaker.api.tooltip;
|
||||
|
||||
import minetweaker.*;
|
||||
import minetweaker.api.formatting.IFormattedText;
|
||||
import minetweaker.api.item.*;
|
||||
import minetweaker.api.util.IngredientMap;
|
||||
import minetweaker.api.util.IngredientMap.IngredientMapEntry;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenExpansion("minetweaker.item.IIngredient")
|
||||
public class IngredientTooltips {
|
||||
|
||||
private static final IngredientMap<IFormattedText> TOOLTIPS = new IngredientMap<>();
|
||||
private static final IngredientMap<IFormattedText> SHIFT_TOOLTIPS = new IngredientMap<>();
|
||||
|
||||
@ZenMethod
|
||||
public static void addTooltip(IIngredient ingredient, IFormattedText tooltip) {
|
||||
MineTweakerAPI.apply(new AddTooltipAction(ingredient, tooltip, false));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShiftTooltip(IIngredient ingredient, IFormattedText tooltip) {
|
||||
MineTweakerAPI.apply(new AddTooltipAction(ingredient, tooltip, true));
|
||||
}
|
||||
|
||||
public static List<IFormattedText> getTooltips(IItemStack item) {
|
||||
return TOOLTIPS.getEntries(item);
|
||||
}
|
||||
|
||||
public static List<IFormattedText> getShiftTooltips(IItemStack item) {
|
||||
return SHIFT_TOOLTIPS.getEntries(item);
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddTooltipAction implements IUndoableAction {
|
||||
|
||||
private final IIngredient ingredient;
|
||||
private final IFormattedText tooltip;
|
||||
private final boolean shift;
|
||||
private IngredientMapEntry<IFormattedText> entry;
|
||||
|
||||
public AddTooltipAction(IIngredient ingredient, IFormattedText tooltip, boolean shift) {
|
||||
this.ingredient = ingredient;
|
||||
this.tooltip = tooltip;
|
||||
this.shift = shift;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
entry = (shift ? SHIFT_TOOLTIPS : TOOLTIPS).register(ingredient, tooltip);
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().invalidateTooltips(ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
if(shift) {
|
||||
SHIFT_TOOLTIPS.unregister(entry);
|
||||
} else {
|
||||
TOOLTIPS.unregister(entry);
|
||||
}
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().invalidateTooltips(ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding tooltip for " + ingredient + ": " + tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing tooltip for " + ingredient + ": " + tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user