Jump to content

HenryFoster

Members
  • Posts

    19
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

HenryFoster's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I'm making advancements. I found a way to move the player using the MovementInput class and : import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; . It worked perfectly however only if I call the method via an event like LeftClickBlock event. When I want to call the method using a keybind: @SubscribeEvent public static void keyPress(KeyInputEvent event) { if(KeyBindings.myKey.isPressed()) { if(!pressed) { pressed = true; }else { pressed = false; } if(pressed) { pmc.moveStraightTo(0,0,4); }else { pmc.resetPlayerInput(); } } } I get a NullPointer Exception: Edit: Im an idiot I did not registered the keybind properly
  2. Hi, I want to write a simple autowalk/run mod but I have problems understanding how the Playercontroller works. I had two approaches: 1. simulating keypresses I thought this would be an easy idea using something like this: KeyBinding.onTick(minecraft.gameSettings.keyBindUseItem.getKeyCode()); I gues this method executes this keypress for the time of a single tick? So if I want to move consistently i would need to call this method on every tick using PlayerTickEvent and checking a boolean every time if autowalk is on or off? I think this idea is not so good as you could not use the chat while autowalking. 2. So my next idea was to to access the playercontroller and find some kind of move method. But I could find out how it exactly works and what I need to do to make sure that the player walks like i would just press the W key. I found some code online but I could not find the methods in my libs: player.func_70031_b(true); the player if from type EntityPlayerSP
  3. Ahrggh I should have posted the whole file to make it clear sorry: https://pastebin.com/AG4TNv8K I have it verry similar to yours. But when you add a dependency like this: compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.15' it works only when you start the mod from your IDE. If I build the jar it does not contain my other libs. I somehow need to tell gradle explicidly to put my two dependencies into the jar.
  4. Little update: Finally I found a way to tell gradle to build a jar with my dependencies. I also checked the final jarfile if they are really there and they are. So far so good. This is how my new build.gradle (I only copied the parts I changed compared to the default one) repositories { mavenCentral() } configurations { embed } dependencies { minecraft 'net.minecraftforge:forge:1.13.2-25.0.191' embed 'org.hibernate:hibernate-agroal:5.3.10.Final' embed group: 'mysql', name: 'mysql-connector-java', version: '8.0.15' compile 'org.hibernate:hibernate-agroal:5.3.10.Final' compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.15' } jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } } I still think I did this kinda wrong because I have the dependencies 2times there. One time for compiling and onetime for embeding but I don't managed to make it work otherwise. When I start minecraft with my mod The game crashed whilst initializing game. I will add the full errorlog below. I thought that this maybe caused by my code so I removed all my classes that are using hibernate and jdbc but I get the same errorlog. crash-2019-04-29_16.30.59-client.txt
  5. Hi, I want to add 2 additional libs to my mod (JDBC and Hibernate). I edited my buil.gradle and ran: gradlew build First try: dependencies { minecraft 'net.minecraftforge:forge:1.13.2-25.0.191' compile 'org.hibernate:hibernate-agroal:5.3.10.Final' <--- compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.15' <--- } jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } from { <--- configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } <---- } <--- } I got the fatjar but when I started the game it crashed with an unexpected error occured without a log. Is this the right way to add external libs into a forgemod? Second try: I tryed to do it like in this wiki: https://github.com/MinecraftForge/ForgeGradle/wiki/Dependencies buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } jcenter() mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true } } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' version = '1.0' group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'modid' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. minecraft { mappings channel: 'snapshot', version: '20180921-1.13' runs { client { workingDirectory project.file('run') property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } server { workingDirectory project.file('run') property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } } } configurations { compile } dependencies { minecraft 'net.minecraftforge:forge:1.13.2-25.0.191' compile 'org.hibernate:hibernate-agroal:5.3.10.Final' compile 'mysql:mysql-connector-java:8.0.15' } // Example for how to get properties into the manifest for reading by the runtime.. jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } def reobfFile = file("$buildDir/reobfJar/output.jar") def reobfArtifact = artifacts.add('default', reobfFile) { type 'jar' builtBy 'reobfJar' } publishing { publications { mavenJava(MavenPublication) { artifact reobfArtifact } } repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } } But it failed building: * What went wrong: A problem occurred evaluating root project 'TutorialMod'. > Could not resolve all files for configuration ':compile'. > Cannot resolve external dependency org.hibernate:hibernate-agroal:5.3.10.Final because no repositories are defined. Required by: project : > Cannot resolve external dependency mysql:mysql-connector-java:8.0.15 because no repositories are defined. Required by: project : > Cannot resolve external dependency net.minecraftforge:forge:1.13.2-25.0.191 because no repositories are defined. Required by: project : * Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'TutorialMod'. ... Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':compile'. ... Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Cannot resolve external dependency org.hibernate:hibernate-agroal:5.3.10.Final because no repositories are defined. This seems kinda strange because the repository is defined and he had no problems finding it in my first try. I gues I dont understand gradle enough. I just worked with Maven before and I used a maven-plugin there to build a jar-with-dependencies.
  6. Here is the Full code and two examples: @SubscribeEvent public static void getTooltip(GuiOpenEvent event) throws FileNotFoundException, UnsupportedEncodingException { GuiScreen chestScreen = Minecraft.getInstance().currentScreen; EntityPlayer player = Minecraft.getInstance().player; if (chestScreen instanceof GuiContainer && pressed) { GuiContainer c = (GuiContainer) chestScreen; Container container = c.inventorySlots; NonNullList<ItemStack> itemStackList = container.getInventory(); PrintWriter writer; writer = new PrintWriter("C:\\Users\\N3XUS\\Desktop\\test\\test.txt", "UTF-8"); ItemStack itemStack = itemStackList.get(13); List<ITextComponent> liste = itemStack.getTooltip(player, TooltipFlags.NORMAL); for(ITextComponent itex: liste) { writer.println(itex.getUnformattedComponentText()); for(ITextComponent itex2: itex.getSiblings()) { writer.print(itex2.getString()); } writer.println(); } writer.println("======================================================================================="); writer.close(); } } Diamond Sword Flame When in main hand: 1.6 Attack Speed 7 Attack Damage =================== Potion of the Turtle Master Slowness IV (0:40) Resistance III (0:40) When Applied: -60% Speed
  7. Yea I also considered this but I have to see if this also workes with custom items with custom ToolTips. I will try it out thanks. It seems I got it: List<ITextComponent> liste = itemStack.getTooltip(player, TooltipFlags.NORMAL); for(ITextComponent itex: liste) { System.out.println("----------------------------------------------"); for(ITextComponent itex2: itex.getSiblings()) { System.out.println(itex2.getString()); } } [15:10:28.607] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:67]: ---------------------------------------------- [15:10:28.607] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:69]: Wooden Sword [15:10:28.608] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:67]: ---------------------------------------------- [15:10:28.608] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:67]: ---------------------------------------------- [15:10:28.608] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:67]: ---------------------------------------------- [15:10:28.608] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:69]: 1.6 Attack Speed [15:10:28.608] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:67]: ---------------------------------------------- [15:10:28.609] [Client thread/INFO] [STDOUT/]: [KeyInputHandler:pickup:69]: 4 Attack Damage Ok now I get how the ITextComponent works. Now I can gett exactly the data I want thank you!
  8. I want to have something like name: woodenswpord enchantments: null modifires: mainhand Attackspeed: 1,6 Attackdamage: 4 as list or string or anything that I can use to put it into a "database" or file maybe using Java Objectserialisation. The idea of my mod is export all the data of my chests so I can do querrys on that data like getting the amount of swords with an attack of 4 or more. Just as an example.
  9. Thank you now I get all what I want! Do you have an idea what kind of format this is? I mean sure I could parse the data easy by hand but maybe there is a better way. I only worked with XML and Json before. [TextComponent{text='', siblings=[TranslatableComponent{key='item.minecraft.wooden_sword', args=[], siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}], style=Style{hasParent=false, color=, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null} }, TextComponent{text='', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null} }, TranslatableComponent{key='item.modifiers.mainhand', args=[], siblings=[], style=Style{hasParent=false, color=, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null} }, TextComponent{text=' ', siblings=[TranslatableComponent{key='attribute.modifier.equals.0', args=[1.6, TranslatableComponent{key='attribute.name.generic.attackSpeed', args=[], siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}], siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}], style=Style{hasParent=false, color=, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null} }, TextComponent{text=' ', siblings=[TranslatableComponent{key='attribute.modifier.equals.0', args=[4, TranslatableComponent{key='attribute.name.generic.attackDamage', args=[], siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}], siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}], style=Style{hasParent=false, color=, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null} }]
  10. Hi, I'm trying to understand how I can get the description of an Item. I'm talking about the tab that apears when you hower over an item: currently I'm using itemStack.getTextComponent() I get this output: TextComponent{text='[', siblings=[TextComponent{text='', siblings=[TranslatableComponent{key='item.minecraft.wooden_sword', args=[], siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=HoverEvent{action=SHOW_ITEM, value='TextComponent{text='{id:"minecraft:wooden_sword",Count:1b}',siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=null}}], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=HoverEvent{action=SHOW_ITEM, value='TextComponent{text='{id:"minecraft:wooden_sword",Count:1b}', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=null}}, TextComponent{text=']', siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=HoverEvent{action=SHOW_ITEM, value='TextComponent{text='{id:"minecraft:wooden_sword",Count:1b}', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=null}}], style=Style{hasParent=false, color=, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=HoverEvent{action=SHOW_ITEM, value='TextComponent{text='{id:"minecraft:wooden_sword",Count:1b}', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=null}} But I dont think that this is right. It shows the name of the item but it does not show the Attackvalue and Attack speed for example. Is there a proper way to get the whole information from this "hover tab"? Also What format is this? First I thought its json but its not.
  11. Sorry if I get this wrong. From what I understand forge had huge changes with 1.13 which is why it took so long to update? Will 1.14 require the same amount of work?
  12. Thank you alot I got this working perfectly now. I will post my rusults later today.
  13. @SubscribeEvent public static void pickup(RightClickBlock event) { GuiScreen chestScreen = Minecraft.getMinecraft().currentScreen; if (chestScreen instanceof GuiContainer) { GuiContainer c = (GuiContainer) chestScreen; Container container = c.inventorySlots; NonNullList<ItemStack> itemStackList = container.getInventory(); for(int i = 0; i <= itemStackList.size(); i++) { ItemStack itemStack = itemStackList.get(i); System.out.println(itemStack.getItem().getUnlocalizedName()); } } } Got some help on reddit but it still dont work because the if condition is not true when I klick the Chest. I gues the event dont work with this? Its working with the GuiContainerEvent. Thanks to : The only problem is that it runns the event over and over until I close the chest. and the event is not canclable.
×
×
  • Create New...

Important Information

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