Jump to content

Kekz

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by Kekz

  1. I'm sorry, but how can I make sure that I only execute buildLabyrinth and clearLabyrinth on the server side? I tried putting if (!worldIn.isRemote) { // do building / removing } around the whole process in both methods, but that doesn't seem to work. Building the maze doesn't work too now and clearing it still doesn't clear all blocks correctly as before.
  2. Ok, thanks for the feedback I'll change that. Does this mean that I should also call buildLabyrinth only on the server side? because that method is not causing any problems Thanks I'll look into that
  3. I am trying to remove some blocks I placed with worldIn.setBlockState(new BlockPos(pos.getX() + j, pos.getY() + 1, pos.getZ() + i), Blocks.BEDROCK.getDefaultState()); by using worldIn.setBlockToAir(new BlockPos(px + j, py + 4, pz + i)); Both the building and removing processes happen in my onItemUse() method of my 2 custom items. In MazeGenerator.java blocks are placed in the onItemUse() method, and in MazeScapeKey.java they are removed in onItemUse(). The removing process itself happens in a method in MazeGenerator.java This rarely works, as only some of the blocks are removed, while other blocks are still there, but disappear as soon as i right click on them. Sometimes all the blocks are removed correctly, sometimes only a few. I have tried using worldIn.markBlockRangeForRenderUpdate() after setting all the blocks to air, but that doesn't seem to help. What am I doing wrong? As far as I understand, this behaviour means that the Server has succesfully removed the blocks, but the Client is still rendering them. How can I ensure that the Client realizes that those blocks are no longer there? My whole code I am grateful for any help,
  4. An epic saga. How can we help you if we don’t have the log? We can’t. Well, you asked where the log is and he showed you, right there in the folder named "logs". What more could you need?
  5. How can I prevent that? The method spawns a lot of blocks and having that done twice would be very costly. Or does it have to be called twice?
  6. I override the method onItemUse() for my own item. This is what it looks like: @Override /** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (imageName != null && colorMatrix != null) { for (int i = 0; i < colorMatrix.length; i++) { // build each line of the blockMatrix for (int j = 0; j < colorMatrix[0].length; j++) { if (colorMatrix[i][j] != null) worldIn.setBlockState(new BlockPos(pos.getX() + j, pos.getY() + 1, pos.getZ() + i), Blocks.WOOL.getDefaultState().withProperty(COLOR, colorMatrix[i][j])); else worldIn.setBlockState(new BlockPos(pos.getX() + j, pos.getY() + 1, pos.getZ() + i), Blocks.TNT.getDefaultState()); } } System.out.println("TEST TEST TEST"); player.sendMessage(new TextComponentString("Image build successfully!")); } else { player.sendMessage(new TextComponentString("There was an error building your image. Image name: " + imageName + "; colorMatrix: " + colorMatrix)); } return EnumActionResult.PASS; } Whenever I right click with my Item, some blocks are placed after which the message "Image build successfully" is displayed twice in the in game chat. If there is an error, the error message is also displayed twice. The console output looks like this: [16:53:44] [main/INFO] [STDOUT]: [me.opkekz.imagespawner.item.ImageSpawnerItem:onItemUse:91]: TEST TEST TEST [16:53:44] [main/INFO] [minecraft/GuiNewChat]: [CHAT] Image build successfully! [16:53:44] [Server thread/INFO] [STDOUT]: [me.opkekz.imagespawner.item.ImageSpawnerItem:onItemUse:91]: TEST TEST TEST [16:53:44] [main/INFO] [minecraft/GuiNewChat]: [CHAT] Image build successfully! This means that the onItemUse() method is being called twice. What could cause this? If you need any more information please let me know. Thanks in advance.
  7. I think you need to put that in the init function. I used ClientCommandHandler and it correctly registered the command, it just never displayed the GUI like it should. I use @EventHandler public void serverStarting(FMLServerStartingEvent event) { event.registerServerCommand(new ImageSpawnerCommand()); } ImageSpawnerCommand extends CommandBase. I don't know if that would work with a dedicated server though, I use it only for singleplayer.
  8. Would it be better to extend net.minecraft.command.CommandBase and do the "displayGuiScreen" in the execute method, or would that also create problems? (Registering would be done with @EventHandler public void serverStarting(FMLServerStartingEvent event) { event.registerServerCommand(new GuiHandler()); } )
  9. Yeah, that's what I did. I only needed it to learn how to implement a basic item but the tutorial is 2 years old so some stuff was outdated. I updated my lang file to: item.imagespawner:imagespawner.name=Image Spawner This combined with renaming the file back to en_US.lang finally worked. Thanks!
  10. I also have these methods, from the tutorial in my ImageSpawnerItem.java class. Maybe these are causing some problems? @Override public String getUnlocalizedName() { return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override public String getUnlocalizedName(ItemStack itemStack) { return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } Edit: I deleted these methods, Item still shows up as: item.imagespawner:imagespawner.name
  11. I tried this and now the item is called item.imagespawner:imagespawner:imagespawner.name
  12. The enum was suggested in a tutorial, so I just followed that since I'm new to modding. Currently, it says item.imagespawner:imagespawner.name So instead of: setUnlocalizedName(Reference.ImageSpawnerEnum.IMAGESPAWNER.getUnlocalizedName()); setRegistryName(Reference.ImageSpawnerEnum.IMAGESPAWNER.getRegistryName()); I would do: setRegistryName(Reference.ImageSpawnerEnum.IMAGESPAWNER.getRegistryName()); setUnlocalizedName(this.getRegistryName().toString()); ?
  13. I know that similar questions have been asked and I followed the steps given in those answers but my Item still doesn't display a proper name. I followed a somewhat outdated tutorial while building the bases for my mod. Since then I added most of what my Item is supposed to do. The only thing left is the item name, I already have a texture. Maybe someone can find a mistake I made in the folder setup, or maybe I used the wrong name. I checked everything and can't find my error. My folder structure with location of en_us.lang (I also tried naming it en_US.lang, still didn't work): Also classes: Main mod class: Reference.java: ModItems.java: The first part of the item class: My en_us.lang file contains this line: item.imagespawner.name=Image Spawner As far as I understand, after "item." I have to write the unlocalized name, which I did. I also put it in the right folder (as far as I know) but it still won't work. I would be very thankful for any kind of help. If you need any more information let me know.
  14. Figured it out btw: Create a PropertyEnum constant for the EnumDyeColor "COLOR": public static final PropertyEnum<EnumDyeColor> COLOR = PropertyEnum.<EnumDyeColor>create("color", EnumDyeColor.class); Select a color for wool (should also work for clay): Blocks.WOOL.getDefaultState().withProperty(COLOR, EnumDyeColor.WHITE);
  15. Is there a way to spawn colored wool with worldIn.setBlockState(pos, state); I use Blocks.CLAY.getDefaultState(); to spawn a clay block, but I can only find Blocks.WOOL; with no option for colored wool.
  16. That seems the best solution, it already works for small 10 x 10 matrices.
  17. Thanks. The String thing is only the way I currently have it implemented, without Minecraft modding in mind....
  18. Is there an event for that? I tried the example from the Forge Doc with the EntityItemPickUpEvent, and that works. Couldn't find any Events that are called on Item use. At least now I have somewhere to start.
  19. Thanks, but that's not the part of the mod I'm having issues with ^^
  20. Each pixel of the image will be mapped to a String, in this case a Minecraftblock. Then these blocks will be spawned in order to create the image.
  21. Thanks, I will look into those methods. For clarification: I wrote some code that takes an image and transforms each pixel into a String, like "yellow". I thought I could make a mod out of this, where you can instantly spawn an image. (May already exist)
  22. I don't plan on releasing the mod, it's just a project I'm doing and I wanted to try to implement it in Minecraft. I tried some methods that I found on other posts with similar questions, but none worked: For example: @Subscribe public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { String command = "Hello, Test!"; Minecraft.getMinecraft().getConnection().sendPacket((new CPacketChatMessage("/help"))); return par1ItemStack; } I couldn't figure out how to use the "@Subscribe" annotation properly
  23. I'm new to Minecraft modding but have experience in Java. I used some tutorials in order to add an item, so now I want to give this item a purpose. There are 2 main things I'm trying to solve: If the player right clicks on the ground while holding my item, I need to save the coordinates, in order to spawn blocks at that location I somehow need to write commands in the in game chat to spawn the blocks, I was thinking something like "/setblock <COORDINATES_FROM_RIGHT_CLICK> <BLOCK_TYPE>. (maybe there is a better way?) I probably need some kind of EventHandler for both, but I have no idea where to start. Maybe someone can give me some tips and help me go in the right direction, I would be very thankful. In the following I will post the code I have so far. Main mod class: Reference class: ModItems class: Item class: If there are more information I can give, please let me know.
×
×
  • Create New...

Important Information

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