generated from jaredlll08/MultiLoader-Template
-
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
23 changed files
with
109 additions
and
11 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
59 changes: 59 additions & 0 deletions
59
common/src/main/java/de/griefed/addemall/client/BlockToolHud.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,59 @@ | ||
package de.griefed.addemall.client; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import de.griefed.addemall.Constants; | ||
import de.griefed.addemall.event.KeyInputHandler; | ||
import de.griefed.addemall.item.ModItems; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiComponent; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class BlockToolHud { | ||
|
||
protected static final ResourceLocation TOOL_MULTI_ACTIVATED = new ResourceLocation(Constants.MOD_ID, "textures/item/multi.png"); | ||
protected static final ResourceLocation TOOL_MULTI_DEACTIVATED = new ResourceLocation(Constants.MOD_ID, "textures/item/multi_deactivated.png"); | ||
protected static final ResourceLocation TOOL_SHOVEL = new ResourceLocation(Constants.MOD_ID, "textures/item/shovel.png"); | ||
protected static final ResourceLocation TOOL_HOE = new ResourceLocation(Constants.MOD_ID, "textures/item/hoe.png"); | ||
protected static final ResourceLocation TOOL_BAR = new ResourceLocation(Constants.MOD_ID, "textures/item/bar.png"); | ||
|
||
protected static void renderToolSettings(PoseStack stack, int x, int height) { | ||
Player player = Minecraft.getInstance().player; | ||
if (player == null) { | ||
return; | ||
} | ||
if (player.getMainHandItem().is(ModItems.BLOCK_TOOL.get())) { | ||
RenderSystem.setShader(GameRenderer::getPositionTexShader); | ||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); | ||
|
||
RenderSystem.setShaderTexture(0, TOOL_BAR); | ||
// X coord Y coord u v wid hei twi the | ||
GuiComponent.blit(stack, x + 96, height - 23, 0, 0, 65, 23, 65, 23); | ||
|
||
if (KeyInputHandler.BLOCKTOOL_MULTI_ACTIVE) { | ||
RenderSystem.setShaderTexture(0, TOOL_MULTI_ACTIVATED); | ||
GuiComponent.blit(stack, x + 100, height - 19, 0, 0, 16, 16, 16, 16); | ||
} else { | ||
RenderSystem.setShaderTexture(0, TOOL_MULTI_DEACTIVATED); | ||
GuiComponent.blit(stack, x + 100, height - 19, 0, 0, 16, 16, 16, 16); | ||
} | ||
|
||
if (KeyInputHandler.BLOCKTOOL_SHOVELMODE) { | ||
RenderSystem.setShaderTexture(0, TOOL_SHOVEL); | ||
GuiComponent.blit(stack, x + 120, height - 19, 0, 0, 16, 16, 16, 16); | ||
} else { | ||
RenderSystem.setShaderTexture(0, TOOL_HOE); | ||
GuiComponent.blit(stack, x + 120, height - 19, 0, 0, 16, 16, 16, 16); | ||
} | ||
|
||
// TODO draw selected block | ||
// TODO draw amount available | ||
/*if (block selected) { | ||
RenderSystem.setShaderTexture(0, stack of selected block with amount of material available); | ||
GuiComponent.blit(stack, x + 140, height - 19, 0, 0, 16, 16, 16, 16); | ||
}*/ | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.44 KB
common/src/main/resources/assets/addemall/textures/item/multi_deactivated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
20 changes: 20 additions & 0 deletions
20
fabric/src/main/java/de/griefed/addemall/client/BlockToolHudOverlay.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,20 @@ | ||
package de.griefed.addemall.client; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; | ||
import net.minecraft.client.Minecraft; | ||
|
||
public class BlockToolHudOverlay extends BlockToolHud implements HudRenderCallback { | ||
@Override | ||
public void onHudRender(PoseStack matrixStack, float tickDelta) { | ||
int x, y; | ||
Minecraft instance = Minecraft.getInstance(); | ||
int width = instance.getWindow().getGuiScaledWidth(); | ||
int height = instance.getWindow().getGuiScaledHeight(); | ||
|
||
x = width / 2; | ||
y = height; | ||
|
||
renderToolSettings(matrixStack, x, y); | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
forge/src/main/java/de/griefed/addemall/client/BlockToolHudOverlay.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,17 @@ | ||
package de.griefed.addemall.client; | ||
|
||
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent; | ||
import net.minecraftforge.client.gui.overlay.IGuiOverlay; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
|
||
public class BlockToolHudOverlay extends BlockToolHud { | ||
public static final IGuiOverlay TOOL_SETTINGS = ((gui, poseStack, partialTick, width, height) -> { | ||
int x = width / 2; | ||
renderToolSettings(poseStack, x, height); | ||
}); | ||
|
||
@SubscribeEvent | ||
public static void registerGuiOverlays(RegisterGuiOverlaysEvent event) { | ||
event.registerAboveAll("tool.settings", BlockToolHudOverlay.TOOL_SETTINGS); | ||
} | ||
} |
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