Jump to content

SuperHB

Forge Modder
  • Posts

    209
  • Joined

  • Last visited

Everything posted by SuperHB

  1. I'm not sure if this is the best implementation, but I did it like so: In the GUI class, when the button is pressed (checked with actionPerformed) you use your packet handler to send to server a custom message with the information you need. When the message is sent to the server, you can set the variable on the server side with a handler. Then inside the server handler you can send a packet to players.
  2. I meant if the player is in singleplayer or multiplayer. mc.getMinecraft().isSingleplayer() is false when I connect to a dedicated server or when I join a LAN server, but true if I host one. I thought once I turned on LAN to host, mc.getMinecraft().isSingleplayer() would become false, but it stays true, even if a player joins. Basically, when I host a LAN, I need someway to tell the GUI that the player is no longer playing singleplayer
  3. I'm working on GUI to play pong and I want to add multiplayer to it. I don't want the multiplayer menu to show up when the player is in singleplayer. I have mc.getMinecraft().isSingleplayer() called in the GUI's constructor to check if the player is playing singleplayer or not, but I'm having an issue. This works perfectly fine with dedicated servers, but when playing LAN, players who join isSingleplayer() is false, but true for the host. Is there any other way to fix this? (Or maybe a different way to check if on a server?)
  4. Thank you! It worked. I don't know why I didn't of that myself.
  5. So I'm working on a mod trying to recreate Pac-Man in Minecraft, currently I have an integer that increases by 1 to move that's called in drawScreen. The issue with this is that the amount of times drawScreen is dependent on FPS. To fix this, I tried putting it in updateScreen which is called 20 times per second. The issue with this is that now pacman moves too slowly and changing it to increment by 3 so that it would be the same speed as 60 FPS wouldn't work. This wouldn't work because every time the move integer is increased by 1, another function is called right after to make sure pacman stops if there is a wall in the way. When the integer increments by 3, pacman moves 3 spaces before checking for a wall, which causes him to go through the wall and keep going or get stuck in the wall. I was wondering if there was some way to limit the FPS while in a GUI?
  6. I copied your code and was able to open the control screen. Where are you calling registerKey() though? I had it at the end of addKeys()
  7. This is how I registered my keybinds (https://github.com/KenLPham/ArcadeMod/blob/1.11.2/src/main/java/superhb/arcademod/util/KeyHandler.java) and I don't have any problems with it. When do you call registerKeys? Copying your method worked, but I called registerKey in addKeys() Also I think if you want to use your lang file for the Categories and Key Description you need to use I18n.format() (I'm guessing that's what you want to do considering what you've named it)
  8. Doing some research, this is how you would register sounds in 1.12: https://github.com/Choonster-Minecraft-Mods/TestMod3/blob/2cb7b67adf7ab41e066c3308ac898224b2891752/src/main/java/choonster/testmod3/init/ModSoundEvents.java I'm pretty sure you have to call the registry from preInit (maybe) but it doesn't seem to be from the example. Based on the example linked, I'm guessing you will have to call the registered soundevent like so Minecraft.getMinecraft().getSoundHandler().playSound(new PositionedSoundRecord(ModSoundEvents.RECORD_SOLARIS, SoundCategory.BLOCKS, 1.0f, 1.0f, playerPos)); Hope this helps. If it doesn't, then my help ends here as I haven't worked with 1.12 yet.
  9. I've never worked with 1.12 before. But are you calling playSound on client side? you can also try just calling the sound like so. ResourceLocation local = new ResourceLocation("morecommands:easteregg"); SoundEvent event = new SoundEvent(local); Minecraft.getMinecraft().getSoundHandler().playSound(new PositionedSoundRecord(event, SoundCategory.BLOCKS, 1.0f, 1.0f, new BlockPos(0, 0, 0)));
  10. I'm guessing this is for 1.11 (I'm not sure if 1.12 is different) Did you register your sound with GameRegistry?
  11. Having the transform in defaults doesn't change it. Seems to only work when I have it in facing.
  12. alright, so i literally put "transform": "forge:default-block" everywhere and it now works. It seems like it has to be in the "facing" variants... which also breaks the block from being able to rotate... { "forge_marker": 1, "transform": "forge:default-block", "defaults": { "transform": "forge:default-block", "model": "arcademod:generic_machine.obj", "custom": { "flip-v": true } }, "variants": { "game": { "snake": { "transform": "forge:default-block", "textures": { "#Back": "arcademod:blocks/generic_machine" } }, "tetrominoes": { "transform": "forge:default-block", "model": "arcademod:tetris.obj" }, "pacman": { "transform": "forge:default-block", "model": "arcademod:pacman.obj" } }, "facing": { "south": { "transform": "forge:default-block", "y": 0 }, "west": { "transform": "forge:default-block", "y": 90 }, "north": { "transform": "forge:default-block", "y": 180 }, "east": { "transform": "forge:default-block", "y": 270 } } } } EDIT: Since my ItemMeshDefinition only tries to get the facing=north variant I removed all the other "transform" except for the one under "facing=north" and that fixed my block facing issue. Except for north. I can switch ItemMeshDefinition to get "facing=south" as a way around this. But is this a bug? as putting the transform under "default" or anywhere else didn't work
  13. I added an OBJ block to my mod that also renders the OBJ model as an item. When I try changing the gui display rotation or scale, nothing changes. All it looks like is flat with no rotation. This is my current blockstate json file. I've tried using gui display as well and that didn't work either. I'm pretty sure the model isn't changed for thirdperson or hand display either. { "forge_marker": 1, "defaults": { "model": "arcademod:generic_machine.obj", "custom": { "flip-v": true }, "transform": "forge:default-block" }, "variants": { "game": { "snake": { "textures": { "#Back": "arcademod:blocks/generic_machine" } }, "tetrominoes": { "model": "arcademod:tetris.obj" }, "pacman": { "model": "arcademod:pacman.obj" } }, "facing": { "south": { "y": 0 }, "west": { "y": 90 }, "north": { "y": 180 }, "east": { "y": 270 } } } }
  14. I have a block that uses a OBJ model that is visible with the model also as the ItemBlock. The issue I'm having right now is that the model seems to ignore the display transformations. It did however work with the "transform": "forge:default-block" (or whatever is called). But I can't seem to get it to work with my own display values. This is my current Blockstate file. I've tried putting the display outside of the defaults, in the game values of the game variant, and inside the default. { "forge_marker": 1, "defaults": { "model": "arcademod:generic_machine.obj", "custom": { "flip-v": true }, "display": { "gui": { "rotation": [ 30, 225, 0 ], "translation": [ 0, 0, 0], "scale":[ 0.2, 0.2, 0.2 ] }, "ground": { "rotation": [ 0, 0, 0 ], "translation": [ 0, 3, 0], "scale":[ 0.25, 0.25, 0.25 ] }, "fixed": { "rotation": [ 0, 0, 0 ], "translation": [ 0, 0, 0], "scale":[ 0.5, 0.5, 0.5 ] }, "thirdperson_righthand": { "rotation": [ 75, 45, 0 ], "translation": [ 0, 2.5, 0], "scale": [ 0.375, 0.375, 0.375 ] }, "firstperson_righthand": { "rotation": [ 0, 45, 0 ], "translation": [ 0, 0, 0 ], "scale": [ 0.40, 0.40, 0.40 ] }, "firstperson_lefthand": { "rotation": [ 0, 225, 0 ], "translation": [ 0, 0, 0 ], "scale": [ 0.40, 0.40, 0.40 ] } } }, "variants": { "game": { "snake": { "textures": { "#Back": "arcademod:blocks/generic_machine" } }, "tetrominoes": { "model": "arcademod:tetris.obj" }, "pacman": { "textures": { "#Back": "arcademod:blocks/generic_machine" } } }, "facing": { "south": { "y": 0 }, "west": { "y": 90 }, "north": { "y": 180 }, "east": { "y": 270 } } } }
  15. I think you misunderstood what I'm trying to do. With the code above the GUI is centered but it is cut off on the top and bottom. When I use GlStateManager.scale(0.5F, 0.5F, 0.5F); To scale the GUI to fit it on, the GUI isn't center anymore. Trying to center it by dividing the xSize and ySize by doesn't work either EDIT: I got the GUI to center with a scale of 0.5 using this.drawModalRectWithCustomSizedTexture((width - xSize) + Math.round(xSize * scale), (height - ySize) + Math.round(ySize * scale), 0, 0, xSize, ySize, textureWidth, textureHeight); EDIT 2: Figure out how to center GUI with any scale (probably) using this.drawModalRectWithCustomSizedTexture((Math.round((width / 2) / scale) - Math.round(xSize / 2)), (Math.round((height / 2) / scale) - Math.round(ySize / 2)), 0, 0, xSize, ySize, textureWidth, textureHeight);
  16. public class GuiArcade extends GuiScreen { @Override public void drawScreen (int mouseX, int mouseY, float partialTicks) { this.mc.getTextureManager().bindTexture(gui); this.drawModalRectWithCustomSizedTexture((width / 2) - (xSize / 2), (height / 2) - (ySize / 2), 0, 0, xSize, ySize, textureWidth, textureHeight); } } This is all I have right now as I don't really know how Minecraft scales the GUI. All this does is center the GUI onto the screen, but I don't know how to resize it while keeping it centered. width = from GuiScreen height = from GuiScreen xSize = Width of GUI (In this case 234) ySize = Height of GUI (In this case 300) textureWidth & textureHeight = Texture size (In this case 512)
  17. Hi, I'm currently working on a GUI and it has a size of 234x300. When it is drawn, it gets cut off on the bottom. I'm able to use GlStateManager.scale but the problem with that is that the GUI becomes off centered. The video settings option of GUI Scale makes the GUI smaller, but I'm not sure how it does that while keeping everything centered. Does anyone know how to recreate this for a specific GUI, except not based on the GUI Scale setting? I also need this to happen with any text for the GUI. Picture of GUI being cut off: Picture of GUI fully visible when GUI Scale in setting is set to 'Small':
  18. I'm currently trying to have an ItemBlock change models depending on its variant which is set in the item's NBT data. Currently This is what I have: Registry: public class RegisterUtil { public static void registerAll (FMLPreInitializationEvent event) { registerArcadeMachine(event, ArcadeBlocks.arcadeMachine); } private static void registerBlockWavefrontMeshDefinition (Item item, Block block) { registerItemBlock(item, block); OBJLoader.INSTANCE.addDomain(Reference.MODID); if (item instanceof IItemMeshDefinition) { ModelLoader.setCustomMeshDefinition(item, ((IItemMeshDefinition)item).getMeshDefinition()); for (EnumGame g : EnumGame.values()) { ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName(), "game=" + g.getName())); // Gives me missing model error //ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName().toString() + "_" + g.getName(), "inventory")); // Says parent can't have non-vanilla model (or something along those lines) } //ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName(), "game")); // Gives me missing model error //ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName(), "inventory")); // No error, no model/textures } } @Deprecated private static void registerArcadeMachine (FMLPreInitializationEvent event, Block block) { final ItemBlockArcade item = new ItemBlockArcade(block); if (event.getSide() == Side.CLIENT) registerBlockWavefrontMeshDefinition(item, block); } private static void registerBlock (Block block) { GameRegistry.register(block.setUnlocalizedName(block.getRegistryName().toString())); } private static void registerItemBlock (Item item, Block block) { registerBlock(block); GameRegistry.register(item, block.getRegistryName()); } } ItemBlock: public class ItemBlockArcade extends ItemBlock implements IItemMeshDefinition { public ItemBlockArcade (Block block) { super(block); setMaxDamage(0); setHasSubtypes(true); } public int getMetadata (int damage) { return damage; } // Not really sure how to use ItemMeshDefinition @Override @SideOnly(Side.CLIENT) public ItemMeshDefinition getMeshDefinition () { return new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { //if (stack.hasTagCompound()) return new ModelResourceLocation(Reference.MODID + ":arcade_machine_" + EnumMob.getName(stack.getTagCompound().getInteger("Game")), "inventory"); //else return new ModelResourceLocation(Reference.MODID + ":arcade_machine_snake", "inventory"); if (stack.hasTagCompound()) return new ModelResourceLocation(Reference.MODID + ":arcade_machine", "game=" + EnumMob.getName(stack.getTagCompound().getInteger("Game"))); else return new ModelResourceLocation(Reference.MODID + ":arcade_machine", "game=snake"); } }; } } Blockstate Json { "forge_marker": 1, "defaults": { "model": "arcademod:arcade_machine.obj", "transform": "forge:default-block" }, "variants": { "inventory": [{ "model": "arcademod:arcade_machine.obj", "textures": { "#all": "arcademod:blocks/snake/bottom" } }], "game": { "snake": { "textures": { "#all": "arcademod:blocks/snake/bottom" } }, "tetrominoes": { "textures": { "#all": "arcademod:blocks/tetrominoes/back_panel" } } }, "facing": { "south": { "y": 0 }, "west": { "y": 90 }, "north": { "y": 180 }, "east": { "y": 270 } } } } All the ways I tried so far have just given me a purple/black texture and loaded no model. I'm pretty sure I'm doing something super simple incorrectly.
  19. Actually, one more question. Is it possible to set an offset/rescale the model through minecraft or do I have to use a 3d modeler to correct these?
  20. Oh wow. Thank you! So I wouldn't need a mtl file anymore?
  21. Is it possible to change the texture of Wavefront model with Blockstates? If so, how would I go about doing that?
×
×
  • Create New...

Important Information

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