-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
11 changed files
with
136 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,6 @@ public interface IHarvestService { | |
|
||
IToolType.Builder0 createToolTypeBuilder(); | ||
|
||
void resetCache(); | ||
|
||
} |
25 changes: 0 additions & 25 deletions
25
src/api/java/mcp/mobius/waila/api/component/ToolComponent.java
This file was deleted.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
src/pluginHarvest/java/mcp/mobius/waila/plugin/harvest/component/ToolComponent.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,46 @@ | ||
package mcp.mobius.waila.plugin.harvest.component; | ||
|
||
import mcp.mobius.waila.api.ITooltipComponent; | ||
import mcp.mobius.waila.api.__internal__.ApiSide; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@ApiSide.ClientOnly | ||
public class ToolComponent implements ITooltipComponent { | ||
|
||
private final ItemStack icon; | ||
private final @Nullable Boolean matches; | ||
|
||
public ToolComponent(ItemStack icon, @Nullable Boolean matches) { | ||
this.icon = icon; | ||
this.matches = matches; | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return 10; | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return Minecraft.getInstance().font.lineHeight; | ||
} | ||
|
||
@Override | ||
public void render(GuiGraphics ctx, int x, int y, float delta) { | ||
ctx.pose().pushPose(); | ||
ctx.pose().translate(-1, -2, 0); | ||
ctx.pose().scale(0.8f, 0.8f, 1f); | ||
ctx.pose().translate(x / 0.8f, y / 0.8f, 0); | ||
ctx.renderItem(icon, 0, 0); | ||
ctx.pose().popPose(); | ||
|
||
if (matches == null) return; | ||
if (matches) { | ||
//TODO | ||
} | ||
} | ||
|
||
} |
82 changes: 57 additions & 25 deletions
82
src/pluginHarvest/java/mcp/mobius/waila/plugin/harvest/provider/HarvestProvider.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
31 changes: 10 additions & 21 deletions
31
src/pluginHarvest/java/mcp/mobius/waila/plugin/harvest/service/HarvestService.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,40 +1,29 @@ | ||
package mcp.mobius.waila.plugin.harvest.service; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
import mcp.mobius.waila.api.IToolType; | ||
import mcp.mobius.waila.api.__internal__.IHarvestService; | ||
import mcp.mobius.waila.plugin.harvest.provider.HarvestProvider; | ||
import mcp.mobius.waila.plugin.harvest.tool.ToolType; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.Tier; | ||
import net.minecraft.world.level.block.Block; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class HarvestService implements IHarvestService { | ||
|
||
private static Function<Tier, @Nullable TagKey<Block>> tierTagKeyFunction = tier -> null; | ||
private static Supplier<List<Tier>> tierListSupplier = List::of; | ||
|
||
@Nullable | ||
public static TagKey<Block> getTierTag(Tier tier) { | ||
return tierTagKeyFunction.apply(tier); | ||
} | ||
|
||
public static List<Tier> getTiers() { | ||
return tierListSupplier.get(); | ||
} | ||
|
||
@Override | ||
public void addToolType(ResourceLocation id, IToolType toolType) { | ||
ToolType.MAP.put(id, (ToolType) toolType); | ||
var impl = (ToolType) toolType; | ||
impl.id = id; | ||
ToolType.MAP.put(id, impl); | ||
} | ||
|
||
@Override | ||
public IToolType.Builder0 createToolTypeBuilder() { | ||
return new ToolType(); | ||
} | ||
|
||
@Override | ||
public void resetCache() { | ||
HarvestProvider.INSTANCE.toolsCache.clear(); | ||
HarvestProvider.INSTANCE.tierCache.clear(); | ||
} | ||
|
||
} |
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