Jump to content

MikeMacho

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by MikeMacho

  1. This works but it leads me to another problem. To call setBlockState I need the BlockPos-object for the block. I tried to save it into an attribute in the onBlockPlaced-Method of the Block-class but then the BlockPos-attribute is null after restarting the game. So my question is: Is there some kind of livecycle-method in the Block-class that is called when the game starts and has the BlockPos as a parameter or is there another way to get the BlockPos-object of my block from inside the Block-class?
  2. Thanks for your help. I couldn't find a setState-Method (or any method to change the state) in the Block-class. How would I trigger a state change if had set it up like you proposed?
  3. Hello everybody! I have a problem setting the light level of a block. I'm trying to create a custom lamp. When I turn it on or off the lighting is changing, but not as it's supposed to. There seem to be 2 different types of lighting. One of those is directly affected by calling setLightLevel(float value) (which currently is the only thing I do to change the lighting). The other one changes when I restart the game and sometimes in game, but I can't figure out what it's triggered by. For better understanding of what I'm talking about I have some screenshots: How it's supposed to look when it's turned off: And this is how it is not supposed to look when turned off but sometimes does: How it's supposed to look when turned on: And finally how it's not supposed to look when turned on but sometimes does: Sorry for the long post but I think the screenshots help to make my point. Thanks in advance for any help you can give me!
  4. Thank you very much! This works perfectly.
  5. I tried GuiScreen first. Using GuiContainer was a try to fix the problem since all the examples I found on the internet used GuiContainer. My Problem is not about positioning, it's about the GuiTextField not being displayed at all. I recognized that in all the examples I found on the internet the GuiTextField constructor didn't have the componentId parameter. Is it possible that there was a recent update that causes my problem?
  6. Hi! I have a problem with the GuiTextField. I'm trying to show a GUI to enter a String. But my GuiTextField does not show in the GUI when I open it in the game. Here is my code: [embed=425,349]public class CustomGUI extends GuiContainer { public CustomGUI(Container inventorySlotsIn) { super(inventorySlotsIn); } private int distanceFromLeftSide; private GuiTextField idTextField; @Override public void initGui() { super.initGui(); this.distanceFromLeftSide = (this.width - 256) / 2; //net.minecraft.client.gui.GuiTextField.GuiTextField(int componentId, FontRenderer fontrendererObj, int x, int y, int par5Width, int par6Height) this.idTextField = new GuiTextField(1, this.fontRendererObj, this.distanceFromLeftSide + 10, 30, 236, 15); this.idTextField.setEnableBackgroundDrawing(false); this.idTextField.setMaxStringLength(40); this.idTextField.setVisible(true); this.idTextField.setEnabled(true); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); // this.drawString(this.fontRendererObj, "lalala", // this.distanceFromLeftSide + 10, 30, 0x000000); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { this.mc.getTextureManager().bindTexture(new ResourceLocation("textures/gui/demo_background.png")); this.drawTexturedModalRect(this.distanceFromLeftSide, 20, 0, 0, 256, 256); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { super.drawGuiContainerForegroundLayer(mouseX, mouseY); this.idTextField.drawTextBox(); } @Override public boolean doesGuiPauseGame() { return true; } } [/embed] Does anybody have any idea why this only shows the GUI background and not the GuiTextField? Any help would be very appreciated. Thanks Mike
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.