-
Recently Browsing
- No registered users viewing this page.
-
Posts
-
I digged a bit into the vanilla code and i found MultiPlayerGameMode#destroyTicks (requires an AT). The only problem is this is client only, if you subscribe to ClientTickEvent in a client only EventHandler class you can access to the MultiPlayerGameMode instance via Minecraft#gameMode. If you use destroyTicks % 20 == 0 you can call the code each second, inside there you send a custom Packet to the server which will damage the Player on server. As I said before, this is unfortunately client only, which means it can easily be modified by other Mods. For this reason it will be difficult to verify this on the server, in this case you might damage the Player even though it doesn't mine a Block.
-
public class GuiSkill extends GuiScreen { final ResourceLocation texture = new ResourceLocation(Unital.MOD_ID, "textures/gui/skillM.png"); int guiWidth = 175; int guiHeight = 228; GuiButton button1; GuiButtonSkills arrow; GuiTextField textBox; final int BUTTON1 = 0, ARROW = 1; String title = "Skills upgrade"; @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); Minecraft.getMinecraft().renderEngine.bindTexture(texture); int centerX = (width / 2) - guiWidth / 2; int centerY = (height / 2) - guiHeight / 2; //drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight); //drawString(fontRendererObj, "Tutorial", centerX, centerY, 0x6028ff); GlStateManager.pushMatrix(); { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().renderEngine.bindTexture(texture); drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight); } GlStateManager.popMatrix(); GlStateManager.pushMatrix(); { GlStateManager.translate((width / 2) - fontRenderer.getStringWidth(title), centerY + 10, 0); GlStateManager.scale(2, 2, 2); fontRenderer.drawString(title, 0, 0, 0x6028ff); } GlStateManager.popMatrix(); //super.drawScreen(mouseX, mouseY, partialTicks); button1.drawButton(mc, mouseX, mouseY); arrow.drawButton(mc, mouseX, mouseY); ItemStack icon = new ItemStack(Blocks.OBSIDIAN); GlStateManager.pushMatrix(); { GlStateManager.translate(centerX, centerY, 0); GlStateManager.scale(2, 2, 2); mc.getRenderItem().renderItemAndEffectIntoGUI(icon, 0, 0); } GlStateManager.popMatrix(); textBox.drawTextBox(); List<String> text = new ArrayList<String>(); text.add(I18n.format("gui.tooltip")); text.add(I18n.format("gui.tooltip2", mc.world.provider.getDimension())); text.add(icon.getDisplayName()); drawTooltip(text, mouseX, mouseY, centerX, centerY, 16 * 2, 16 * 2); } public void drawTooltip(List<String> lines, int mouseX, int mouseY, int posX, int posY, int width, int height) { if (mouseX >= posX && mouseX <= posX + width && mouseY >= posY && mouseY <= posY + height) { drawHoveringText(lines, mouseX, mouseY); } } @Override public void initGui() { buttonList.clear(); buttonList.add(button1 = new GuiButton(BUTTON1, (width / 2) - 100 / 2, height - 40, 100, 20, "Close")); buttonList.add(arrow = new GuiButtonTutorial(ARROW, 100, 100)); textBox = new GuiTextField(0, fontRenderer, 0, 0, 100, 20); updateButtons(); super.initGui(); } public void updateButtons() { if (title.equals("Close")) { button1.enabled = true; } else { button1.enabled = false; } } public void updateTextBoxes() { if (!textBox.getText().isEmpty()) { if (!textBox.isFocused()) { title = textBox.getText(); } } updateButtons(); } @Override protected void actionPerformed(GuiButton button) throws IOException { switch (button.id) { case BUTTON1: mc.displayGuiScreen(null); break; case ARROW: mc.displayGuiScreen(new GuiInventory(mc.player)); break; } updateButtons(); super.actionPerformed(button); } @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { textBox.textboxKeyTyped(typedChar, keyCode); updateTextBoxes(); super.keyTyped(typedChar, keyCode); } @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { textBox.mouseClicked(mouseX, mouseY, mouseButton); updateTextBoxes(); super.mouseClicked(mouseX, mouseY, mouseButton); } @Override public boolean doesGuiPauseGame() { return false; } }
-
By Adil Yilan · Posted
@Luis_ST I am trying to have damage to be consistent during mining process. If it takes 10 seconds to mine it, I would like to reduce health by 1 hit point for every second of mining. So if player starts to mine, after 1 second it should already show that 1/2 of heart is lost. If player decides to stop mining after 4 seconds, he should still end up with 2 hearts lost, even though block was not mined at the end. I don't think that is possible with your solution or did I miss something? -
Player#displayClientMessage Note in your case the second argument must be true
-
Have you guys checked out this amazing Minecraft gameplay video? It's mind blowing ! Watch the LIVE streaming here : https://shrinke.me/922u3Vb
-
-
Topics
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.