Jump to content

TominoCZ

Members
  • Posts

    117
  • Joined

  • Last visited

Everything posted by TominoCZ

  1. Do I really have to learn the long code ?
  2. It's pretty complicated... I made a block that opens a gui. You can click "host game" there.. and now I want to save the name of the player to the block.. and if a player with the same name clicks that blocks, another type of gui opens... I want it cuz I want to reset the host player name after the block breaks(of course when you place a new one, it will reset the value...) And I don't have any TileEntity... I don't even know how to make one....
  3. Actually no.. I need to set NBT Tag of a block at specific location(I'd use world.getBlock())..
  4. I can add the tags for players like this: NBTTagCompound tag = player.getEntityData(); tag.setInteger("IsHost", 1); But how can I add such a tag to a block?
  5. I want to make my mod to generate a dimension from a schematic file and if the dimension is not already in the world folder(not generated)... Is there some kind of easy way of doing that?
  6. You're right.. I fixed the problem right before you answered this question.. but thanks alot! I used this.buttonList.Clear();
  7. When I click a button in my gui, the sound plays alot of times instead of just once because th e gui is being spawned multiple times. this im my gui class: public class GuiConfirm extends GuiScreen { public boolean doesGuiPauseGame() { return false; } @Override public void drawScreen(int x, int y, float ticks) { this.buttonList.add(new GuiButton(0, this.width / 2 - 90, this.height / 2, 64, 20, I18n.format("Yes", new Object[0]))); this.buttonList.add(new GuiButton(1, this.width / 2 + 20, this.height / 2, 64, 20, I18n.format("No", new Object[0]))); fontRendererObj.drawString("Teleport to the PAYDAY2 Dimension?", this.width / 2 - 90, this.height / 2 - 50, 0x000000); GL11.glColor4f(1, 1, 1, 1); drawDefaultBackground(); super.drawScreen(x, y, ticks); //I know this makes the looping.. but I tried other ways of rendering it once and nothing works.. } @Override protected void actionPerformed(GuiButton button) { if (button.id == 0){ this.mc.displayGuiScreen((GuiScreen) null); this.mc.setIngameFocus(); } if (button.id == 1){ this.mc.displayGuiScreen((GuiScreen) null); this.mc.setIngameFocus(); } } } How can I make the Gui spawn only once?
  8. Actually nevermind.. I used block replacing...
  9. Well if I navigate to the BlockContrainer.class in net.minecraft.block then there is nothing like counting players or anything similar. the code itself seems a little too short.
  10. My GuiLobby class: public class GuiLobby extends GuiScreen{ public boolean doesGuiPauseGame() { return false; } int guiWidth = 256; int guiHeight = 168; @Override public void drawScreen(int x, int y, float ticks){ int guiX = (width - guiWidth) /2 ; int guiY = (height - guiHeight) /2 ; GL11.glColor4f(1, 1, 1, 1); drawDefaultBackground(); mc.renderEngine.bindTexture(new ResourceLocation(Main.MODID + ":" + "textures/gui/Lobby.png")); drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight); fontRendererObj.drawString("CRIME.NET", guiX + 40, guiY + 5, 0x404040); super.drawScreen(x, y, ticks); } } This is what the gui looks like for now by the way... http://s30.postimg.org/v3tnvkze9/2015_09_06_18_19_03.png[/img] So how can I make it that when another player is already in the gui, nobody else can open it(on a LAN/server of course)?
  11. GUYS NVM cuz: I removed both @SideOnly in the Main class and tossed everything in the Init method except the registering of the GuiHandler. Then it works even on the server. It was crashing, because the GuiHandler registered only on the server, not the client(that's why I removed the @SideOnly()).
  12. Download the log files here: http://www65.zippyshare.com/v/E1qgvxY1/file.html
  13. My Block class: public class LobbyBlock extends Block{ public LobbyBlock(Material rock) { super(rock); this.setBlockName("LobbyBlock"); this.setBlockTextureName(Main.MODID + ":" + "0"); this.setCreativeTab(Tabs.CreativeTab); this.setLightLevel(1F); this.setLightOpacity(2555); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { //player.openGui(Main.instance, 0, world, x, y, z); FMLNetworkHandler.openGui(player, Main.instance, 0, world, x, y, z); return true; } } My GuiHandler class: public class GuiHandler implements IGuiHandler { public GuiHandler (){ } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0){ return new GuiLobby(); } return null; } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // TODO Auto-generated method stub return null; } } My Main class: @Mod(modid = Main.MODID, name = Main.NAME, version = "PreAlpha 0.0.3") public class Main { @Instance(Main.MODID) public static Main instance; public static final String MODID = "PAYDAY2"; public static final String NAME = "PAYDAY 2"; public static final String VERSION = "PreAlpha 0.0.3"; public Main() { } @EventHandler @SideOnly(Side.CLIENT) public void preInit(FMLPreInitializationEvent event) { Blocks.registerBlocks(); Items.registerItems(); Recipes.initShapedRecipes(); Recipes.initShalessRecipes(); } @EventHandler @SideOnly(Side.SERVER) public void Init(FMLInitializationEvent event) { NetworkRegistry.INSTANCE.registerGuiHandler(Main.instance, new GuiHandler()); Blocks.registerBlocks(); Items.registerItems(); Recipes.initShapedRecipes(); Recipes.initShalessRecipes(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } Now if I start the Server and the Client, join the server and click the block, the Client crashes. No exact information in the log. Maybe its the GuiHandler.. Maybe the "new GuiLobby();" crashes it... I really don't know. Any ideas why it crashes everytime?
  14. It works! Now it opens a gui with a text! But now there's an only problem.. it's not compatible with a server.. Do you know how to do that please?
  15. Well, I haven't found any tutorial about GUI so far. Everything was a different video... If you know, where I could find one, tell me please.
  16. Ok, thanks for information. I just hope I can make it . Because the block is the main thing.. without it.. you can't do anything in the mod .
  17. I got this code in my custom block's class file: package com.tominocz.PAYDAY2; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.SoundHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class LobbyBlock extends Block{ SoundHandler sh; public LobbyBlock(Material rock) { super(rock); this.setBlockName("LobbyBlock"); this.setBlockTextureName(Main.MODID + ":" + "0"); this.setCreativeTab(Main.PAYDAY2Tab); this.setLightLevel(1F); this.setLightOpacity(2555); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if (world.isRemote) { return true; } else { //HERE I WANT THE CODE FOR OPENING MY CUSTOM GUI/HUD System.out.println("clicked"); return false; } } } And I got this in the main class: package com.tominocz.PAYDAY2; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = Main.MODID, version = Main.VERSION) public class Main { public static final String MODID = "PAYDAY2"; public static final String NAME = "PAYDAY 2 RELOADED"; public static final String VERSION = "0.01"; public static CreativeTabs PAYDAY2Tab = new PAYDAY2Tab(MODID); public static Block LobbyBlock = new LobbyBlock(Material.rock); public static Item Logo = new PAYDAY2Logo(); @EventHandler public void preInit(FMLPreInitializationEvent event) { GameRegistry.registerBlock(LobbyBlock, "LobbyBlock"); GameRegistry.registerItem(Logo, "Logo"); } @EventHandler public void Init(FMLInitializationEvent event) { } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } Now I need the code to open my custom gui/hud like when opening a chest or a crafting table.. but I also want to add buttons in there.. Is it possible?
  18. Ok, I've figured it out this way: public class LobbyBlock extends Block{ public float eyeHeight; public LobbyBlock(Material rock) { super(rock); this.setBlockName("LobbyBlock"); this.setBlockTextureName(Main.MODID + ":" + "0"); this.setCreativeTab(Main.PAYDAY2Tab); this.setLightLevel(1F); this.setLightOpacity(2555); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if (world.isRemote) { return true; } else { System.out.println("test"); return true; } } }
  19. so I add: ..... this.onBlockActivated(); } @Override public void onBlockActivated(){ [action] } to the block's class right? And another question... does it matter if I don't put the "@Override" there?
  20. I'm making a mod including some custom blocks. Now I need to make them clickable(like chests or workbenches). This is an example of the code of my custom block: public class LobbyBlock extends Block{ public LobbyBlock(Material rock) { super(rock); this.setBlockName("LobbyBlock"); this.setBlockTextureName(Main.MODID + ":" + "0"); this.setCreativeTab(Main.PAYDAY2Tab); this.setLightLevel(1F); this.setLightOpacity(2555); } } And this is the code I currently have in the main class: @Mod(modid = Main.MODID, version = Main.VERSION) public class Main { public static final String MODID = "PAYDAY2"; public static final String NAME = "PAYDAY 2 RELOADED"; public static final String VERSION = "0.01"; public static Block LobbyBlock = new LobbyBlock(Material.rock); @EventHandler public void preInit(FMLPreInitializationEvent event) { GameRegistry.registerBlock(LobbyBlock, "LobbyBlock"); } @EventHandler public void Init(FMLInitializationEvent event) { } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } What should I add to make it do what I want(the clickableness )?
  21. Can you make a sample code of this for me please? I am.. not even a beginner.. I just don't understand everything.. Could you do this for me please? The code I mean..
  22. I want to have an image showing in the main menu. Now what would the code look like, if I wanted to do such thing? Any ideas(please be specific)?
  23. I want to automatically switch the gui scale to "Auto" when pressing my button. Any Ideas what would the code look like?
×
×
  • Create New...

Important Information

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