Jump to content

Franckyi

Members
  • Posts

    130
  • Joined

  • Last visited

Everything posted by Franckyi

  1. Oh you're right, thanks. So if I put if(e.getGui() instanceof GuiInventory) after that, my code will always run if it's in the player inventory, right ?
  2. Hi ! I'm still working on my Item Editor GUI mod. The mod is working well, but I need something else. At the moment, the GUI opens when the player has an item in his mainhand and when he press the "I" hotkey. What I also would like to do, is to detect when a player press the hotkey in his inventory while hovering an item. The problem is, the event I use (KeyInputEvent) only fires when the player is out of a GUI (when he is "in game"). Does someone know how can I do that ?
  3. My bad, didn't know that GuiScrollingList exists.
  4. Ok, I found how to register scroll buttons. But I want to scroll the list using the scroll bar or the mouse wheel. Does someone know how to do that?
  5. Ok then, there you have the source code : Edit : Lol, when I posted the code I saw I always used 'Minecraft.getMinecraft()' instead of 'mc' in my GUIs ^^ Let's fix that
  6. Hi ! I'm still working on my "Item Editor" mod for mapmakers. I'm working on a simple way to add enchantments to an item, so I created a list of all enchantments in Vanilla Minecraft. I created my enchant list by extending GuiListExtended and my list items by implementing IGuiListEntry . Everything seems to be working well, except the scroll bar. I did nothing about it and I don't know how it works. I can't find any tutorials on Internet. I can give you source codes if you need. Can someone help me ?
  7. I have a stack.getSubCompound() method, but no stack.getOrCreateSubCompound() method. And of course when I use the first one I get a NullPointerException.
  8. Well, didn't you say that it wasn't good ? Because if I do the same same thing... if(ctx.getServerHandler().playerEntity.getHeldItemMainhand().getTagCompound() == null) ctx.getServerHandler().playerEntity.getHeldItemMainhand().setTagCompound(new NBTTagCompound()); ctx.getServerHandler().playerEntity.getHeldItemMainhand().getTagCompound().getCompoundTag("tag").getCompoundTag("display").setString("Name", message.text); ...I'm getting the same object with an empty "tag" Tag Compound.
  9. Ok, so my Network setup is working. Thanks to Draco18s for his link and diesieben07 for his tutorial (http://www.minecraftforge.net/forum/index.php?topic=20135.0). This is in my Message Handler class : @Override public IMessage onMessage(final EditItemMessage message, final MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; mainThread.addScheduledTask(new Runnable() { @Override public void run() { System.out.println("New Name : " + message.text); // Help } }); return null; } I know I can get the ItemStack I want by using ctx.getServerHandler().playerEntity.getHeldItemMainhand() , but then I don't know what to do. I just want to change the ItemStack's name using NBT.
  10. Alright, then I'll learn how does Networking work. Thanks.
  11. Hi ! I'm creating a small GUI mod to edit some item stats, like it's name, lore, enchantments etc... The GUI opens if the player has an item in his main hand. But now I'm in trouble with using the NBT system to change an ItemStack's name. After pressing a "Done" button, in the actionPerformed(GuiButton button) , this is what I did : if (button == this.doneButton) { // If it's the correct button if(itemStack.getTagCompound() == null) // If the itemstack doesn't have a TagCompound... itemStack.setTagCompound(new NBTTagCompound()); // ...I'll create an empty one [color=red]itemStack.getTagCompound().getCompoundTag("tag").getCompoundTag("display").setString("Name", name.getText()); // This is where I'm wrong ('name' is the GuiTextField I'm using)[/color] Minecraft.getMinecraft().thePlayer.openGui(ItemEditorMod.instance, ItemEditorGuiHandler.ITEM_EDITOR_MENU, Minecraft.getMinecraft().theWorld, // This is the method to go to the previous GuiScreen (int) Minecraft.getMinecraft().thePlayer.posX, (int) Minecraft.getMinecraft().thePlayer.posY, (int) Minecraft.getMinecraft().thePlayer.posZ); } When I check the NBT tag of the selected item using NBTExplorer, no new compound appears. Can someone help me ?
  12. Yeah, I know there is a better way to do that. In the tutorial (outdated at this point) it registers like tkat. I change it now But the bug is still here...and it does that with all custom blocks now (I updated my repository). [EDIT] Alright, I think I know where I'm wrong. I forgot a bracket in ItemBlock models.
  13. Already done, for all blocks and all variants. Well, maybe I've done a bad formatting on some files. I'll check that.
  14. Hey, it's me again. I had trouble with the StateMapperBase class and I saw this tutorial : http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-8/blockstates-and-metadata/ And it works well, I just had to create the 9 different blocks with 3 "colors" and 3 "states", then to add the "extra" property to all these blocks (because as I saw, there can be only 16 different variations of a block, and 3 colors * 3 states * 2 extras = 18 blocks (and there will be more than 2 extras in the future)). I updated my github repository : https://github.com/Franckyi/Roads All blocks variants are registered in the game and in my custom creative tab. I still have a small problem : As you can see, everything goes well for the "extra=none" variant. But textures in inventory for "extra=linesolid" variants are missing whereas they aren't for the world block, and I don't have any errors in the console. Can someone help me ? (you can look at the source to check file names and content). [EDIT] : I saw that my blockstate files name had uppercase letter (and I only used lowercase letters in my registry/unlocalized names so I'll don't have to change everything if I update my mod to 1.11). But it didn't solve the problem. (I still don't know why I didn't have errors before I changed that, it ignores blockstates files name's case ?)
  15. I'm already using a proxy, but thanks for reminding me
  16. Ok, I'll look at this. Thanks a lot for helping, a lot of people would give up with me
  17. I create properties using blockState.getBaseState().withProperty() ?
  18. But by default, all blocks have only one blockstate, right ? So how can I say that this block has different parameters ?
  19. Ok, so how do I create all block states for my block ?
  20. Ok, but then : I have to register my Block (and my ItemBlock) only one time for all variants ? If true, I don't know how to set up the constructor of my Block. I explain : The Block that I create has 3 properties : the Color, the State and the Extra. All those properties are in basic enums. This is how I was creating all my blocks before : package com.franckyi.roads.blocks; import java.util.ArrayList; import java.util.List; import com.franckyi.roads.Reference; import com.franckyi.roads.RoadsMod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; public class BlockAsphalt extends Block { public BlockAsphalt(AsphaltBlockColor color, AsphaltBlockState state, AsphaltBlockExtra extra) { super(Material.ROCK); setUnlocalizedName( Reference.RoadsBlocks.ASPHALT.getUnlocalizedName() + color.color + state.state + extra.extra); setRegistryName(Reference.RoadsBlocks.ASPHALT.getRegistryName() + color.color + state.state + extra.extra); setCreativeTab(RoadsMod.tab); } public static List<Block> getAllBlocks() { List<Block> list = new ArrayList<Block>(); for (AsphaltBlockColor color : AsphaltBlockColor.values()) { for (AsphaltBlockState state : AsphaltBlockState.values()) { for (AsphaltBlockExtra extra : AsphaltBlockExtra.values()) { list.add(new BlockAsphalt(color, state, extra)); } } } return list; } private enum AsphaltBlockColor { LIGHT("Light"), MEDIUM("Medium"), DARK("Dark"); private String color; AsphaltBlockColor(String color) { this.color = color; } } private enum AsphaltBlockState { NORMAL("Normal"), DAMAGED("Damaged"), BROKEN("Broken"); private String state; AsphaltBlockState(String state) { this.state = state; } } private enum AsphaltBlockExtra { NONE(""), LINESOLID("LineSolid"); private String extra; AsphaltBlockExtra(String extra) { this.extra = extra; } } } This is how I was registering Blocks : package com.franckyi.roads.blocks; import java.util.List; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class RoadsBlocks { public static List<Block> asphalts; public static void init() { asphalts = BlockAsphalt.getAllBlocks(); } public static void register() { for (Block asphalt : asphalts) { registerBlock(asphalt); } } private static void registerBlock(Block block) { GameRegistry.register(block); ItemBlock item = new ItemBlock(block); item.setRegistryName(block.getRegistryName()); GameRegistry.register(item); } public static void registerRenders() { for (Block asphalt : asphalts) { registerRender(asphalt); } } private static void registerRender(Block block) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } } So now, I know I'll not register the renders like this, but using the ModelLoader.setCustomStateMapper() method. I have to create a new StateMapperBase for this method : package com.franckyi.roads.blocks; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMapperBase; public class AsphaltStateMapper extends StateMapperBase { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation("BlockAsphalt" + state.getProperties().get("COLOR") + state.getProperties().get("STATE") + state.getProperties().get("EXTRA"), "inventory"); } } That means that in my Block constructor, I must add the properties to the BlockState, but that means that I have to create a new Block for every properties combination possible, no ? PS : all the sources are in the first post, if you need.
  21. Oh yeah, sorry I'm blind. Then what do I put in the getModelResourceLocation(IBlockState state) method ?
  22. Sorry but I didn't understand everything ^^ I have to create a new class that extends StateMapperBase ? But then when will I call it ?
  23. Hi I'm developing a mod that will contain a lot of texture variations of the same block. The way I'm doing this isn't good, I mean it's VERY long to copy, paste and rename the .json blockstate files for each block variation. So, I know it's possible to have multiple blocks using the same blockstate JSON file, but I don't know how to do this. I'm a beginner at modding (I'm OK with Java). All my files can be found here : https://github.com/Franckyi/Roads Can someone help me ? [EDIT] I'm using 1.10.2 version of Minecraft and 2099 version of Forge. [EDIT2] In the Github repository, I haven't done all the .json files for the "LineSolid" variations of the blocks.
  24. My bad, I was disabling the Log craft (this block can't be crafted) instead of the planks craft. Thanks !
×
×
  • Create New...

Important Information

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