net.minecraft.util.com.google.common.io.Files 的maven依赖
时间: 2023-08-31 15:06:12 浏览: 269
你可以在你的`pom.xml`文件中添加以下依赖,以使用`net.minecraft.util.com.google.common.io.Files`类:
```xml
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
</dependency>
```
这里使用了`com.google.guava`库,版本号为`30.1-jre`。需要注意的是,这个库可能会有其他的依赖项,你需要根据你的具体情况进行调整。
相关问题
package com.HudShow.hud.gui; import com.HudShow.hud.HudShow; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecra查错
在代码中,最后一行的 "net.minecra查错" 应该是 "net.minecraft",因为该行代码被截断了,导致最后一个字符被省略了。正确的代码应该是:
```
package com.HudShow.hud.gui;
import com.HudShow.hud.HudShow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft;
```
package com.HudShow.hud.gui; import com.HudShow.hud.HudShow; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(modid = HudShow.MODID) public class HealthHud extends Gui { private final Minecraft mc; public HealthHud() { mc = Minecraft.getMinecraft(); } public void render() { float health = mc.player.getHealth(); float maxHealth = mc.player.getMaxHealth(); int width = (int) ((health / maxHealth) * 120); mc.draw(1, 1, 0, 0, width, 20, 170, 0, 0, 1); String healthShow = String.valueOf(mc.player.getHealth()); int StringWidth = (width - healthShow.length()) / 2; mc.fontRenderer.drawString("§l" + healthShow, StringWidth, 6, 120, true); } public void render2(RenderGameOverlayEvent event) { int posX = (event.getResolution().getScaledWidth()) / 2; int posY = (event.getResolution().getScaledHeight()) / 2; GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("hud:textures/gui/frame_health.png")); drawModalRectWithCustomSizedTexture(posX - 207, posY - 112, 0, 0, 91, 45, 182, 91); } }查错
这段代码中存在一个错误:方法 `mc.draw()` 不存在。
应该使用 `Gui.drawRect()` 方法来绘制矩形。
正确的代码应该是:
```
package com.HudShow.hud.gui;
import com.HudShow.hud.HudShow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = HudShow.MODID)
public class HealthHud extends Gui {
private final Minecraft mc;
public HealthHud() {
mc = Minecraft.getMinecraft();
}
public void render() {
float health = mc.player.getHealth();
float maxHealth = mc.player.getMaxHealth();
int width = (int) ((health / maxHealth) * 120);
Gui.drawRect(1, 1, 1 + width, 21, 0xFFFF0000);
String healthShow = String.valueOf(mc.player.getHealth());
int StringWidth = (width - mc.fontRenderer.getStringWidth(healthShow)) / 2;
mc.fontRenderer.drawString("§l" + healthShow, StringWidth + 1, 6, 120, true);
}
public void render2(RenderGameOverlayEvent event) {
int posX = (event.getResolution().getScaledWidth()) / 2;
int posY = (event.getResolution().getScaledHeight()) / 2;
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("hud:textures/gui/frame_health.png"));
drawModalRectWithCustomSizedTexture(posX - 207, posY - 112, 0, 0, 91, 45, 182, 91);
}
}
```
阅读全文