
FizixRichard
Members-
Content Count
11 -
Joined
-
Last visited
Community Reputation
0 NeutralAbout FizixRichard
-
Rank
Tree Puncher
-
Hi, I’ve created various custom equipment such as weapons, armour and tools. I want these items to increase in performance as you use them. So, I want to modify the attributes of these custom items after creation. For example, increase its durability or attack power. This is for that one instance of the item in your inventory, not for the item family. Whats the best way of going about this? I’m still a beginner so a simpler method may be best for me.
-
Today a weird problem has occurred. I'm using Intellij Idea. I opened my mod project to find various imports were't resolving. Namely: import net.minecraftforge.fml.loading.FMLPaths; FMLPaths is red import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; LogManager and Logger are red. Then within my script the logger is red, and events on the loading listeners are red. I tried refreshing dependencies, and reimporting the build.gradle to no avail. Even more strangely... if I attempt to run the mod, it works as though nothing were wrong. I opened some of my other mod projects, same thing happens. It's affecting all of them. It appears to exist in the IDE only. Additionally, I just opened one of my classes that appeared fine (wasn't highlighted in red in the IDE project tree) and its not showing errors on import net.minecraftforge.eventbus.api.SubscribeEvent; SubscribeEvent is in red. Here is my build.gradle in case it helps: 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' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' apply plugin: 'maven-publish' version = modMinecraftVersion + "-" + modVersion; group = modGroup archivesBaseName = modFileName + "-" + version; sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. minecraft { mappings channel: mappingsChannel, version: mappingsVersion // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Default run configurations. // These can be tweaked, removed, or duplicated as needed. runs { client { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } server { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } data { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' args '--mod', 'cerulean', '--all', '--output', file('src/generated/resources/') mods { examplemod { source sourceSets.main } } } } } repositories { maven {url "http://tehnut.info/maven"} } dependencies { minecraft "net.minecraftforge:forge:" + modMinecraftVersion + "-" + modForgeVersion // You may put jars on which you depend on in ./libs or you may define them like so.. compile fg.deobf("mcp.mobius.waila:Hwyla:1.10.6-B67_1.14.4") } // Example for how to get properties into the manifest for reading by the runtime.. jar { manifest { attributes([ "Specification-Title": modID, "Specification-Vendor": modGroup, "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" : modGroup, "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } // Example configuration to allow publishing using the maven-publish task // we define a custom artifact that is sourced from the reobfJar output task // and then declare that to be published // Note you'll need to add a repository here 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" } } } My gradle.properties # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false modID = cerulean modGroup = com.fizix.cerulean modVersion = 1.0.0 modFileName = Cerulean modMinecraftVersion = 1.14.4 modForgeVersion = 28.1.0 mappingsChannel = snapshot mappingsVersion = 20190916-1.14.3 And the mods.toml modLoader="javafml" loaderVersion="[28,)" #mandatory (28 is current forge version) #issueTrackerURL="http://my.issue.tracker/" #optional [[mods]] modId="cerulean" version = "1.0.0" displayName="Cerulean" #updateJSONURL="http://myurl.me/" displayURL="http://example.com/" #logoFile="examplemod.png" #optional credits="Thanks for this example mod goes to Java" authors="Love, Cheese and small house plants" description=''' Description / info ''' # Dependencies [[dependencies.cerulean]] modId="forge" mandatory=true versionRange="[28,)" ordering="NONE" side="BOTH" [[dependencies.cerulean]] modId="minecraft" mandatory=true versionRange="[1.14.4]" ordering="NONE" side="BOTH"
-
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
Got it. My loot tables json wasn't valid. Thank you for all your help. I'm surprised it didn't throw a parse error tbh -
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
Done. Could this have something to do with it? lootcontext > lootTableManager > registeredLootTables > {ResourceLocation@18432} "minecraft:empty" -> {LootTable@15258} lootcontext > lootTables = {LinkedHashSet@18751} size = 0 It's registered to minecraft:empty. "LootTable@15258" is the loottable, loot tables under lootcontext is 0, pools is empty, path is empty. -
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
I've checked the debugger and it's not throwing any errors. If I check to see whether LOOT_TABLE is set, it's fine. Check 1: reads "Loot table exists" Check 2: reads "Item Stack List contains 0 records" if (LOOT_TABLE == LootTables.EMPTY) { LOGGER.debug("Loot table is empty"); } else { LOGGER.debug("Loot table exists"); } LootContext.Builder builder = new LootContext.Builder((ServerWorld) world); LootTable loottable = ServerLifecycleHooks.getCurrentServer().getLootTableManager().getLootTableFromLocation(LOOT_TABLE); LootContext lootcontext = builder.withParameter(LootParameters.POSITION, player.getPosition()).withParameter(LootParameters.THIS_ENTITY, player).build(LootParameterSets.GIFT); List<ItemStack> itemstacklist = loottable.generate(lootcontext); LOGGER.debug("Item Stack List contains " + itemstacklist.size() + " records"); I've tried this with various parameter sets and it returns the same. If there is anything wrong with the loot table json, it would throw an error or warning wouldn't it? -
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
Thanks. I have checked the classes, but I'm not sure what to set. Sorry. When I try with EMPTY the for loop doesn't fire. It's just a standard loot table with a list of items. for(ItemStack itemstack : loottable.generate(builder.build(LootParameterSets.EMPTY))) { LOGGER.debug("Spawning Loot"); ItemEntity entityitem = new ItemEntity(world, player.posX, player.posY + 1.5D, player.posZ, itemstack); world.addEntity(entityitem); } -
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
Thank you. I understand what you're saying now. But, I'm not finding any information anywhere. I can't figure out how to set the LootParameterSet for this. I'm still learning, but I don't think this is something complicated. I'm clearly missing something obvious, but without any documentation or guides, I'm finding myself going around in circles. Does anyone know how to declare the LootParameterSet for builder.build() to generate the ItemStack? LootContext.Builder builder = new LootContext.Builder((ServerWorld) world); LootTable loottable = ServerLifecycleHooks.getCurrentServer().getLootTableManager().getLootTableFromLocation(LOOT_TABLE); for(ItemStack itemstack : loottable.generate(builder.build(???))) { ItemEntity entityitem = new ItemEntity(world, player.posX, player.posY + 1.5D, player.posZ, itemstack); world.addEntity(entityitem); } -
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
But when I pass builder, or builder.build() (the LootContext I created) it says that it's incorrect. I know I'm probablty being really dumb here, but what am I doing wrong? for (ItemStack itemstack : loottable.generate(builder.build())) { } What does it want? -
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
I did wonder about that. I was literally converting. But, how do I set the parameters and what are they? The class in MC just asks for a LootContext, which would be builder? It doesn't seem to specify the parameters anywhere -
[1.14.4] Loot Tables - item gives player random loot
FizixRichard replied to FizixRichard's topic in Modder Support
Thanks for the reply. I'm a beginner so I'm struggling a bit here. How do I use LootTable.generate()? I'm not finding any examples or documentation online. Updated code to: LootTable loottable = ServerLifecycleHooks.getCurrentServer().getLootTableManager().getLootTableFromLocation(LOOT_TABLE); LootContext.Builder builder = new LootContext.Builder((ServerWorld) world); for (ItemStack itemstack : loottable.generate(world.rand, builder.build())) with: for (ItemStack itemstack : loottable.generate(world.rand, builder.build())) builder.build() isn't accepted. -
Hi all, I'm creating a custom item, which when the player uses it, gives the player random items from a loot table. I'm generating the custom item which appears in game, I have a loot table setup, and can use the item. Where I'm struggling is getting random loot from the loot table and giving it to the player. When I look online I can see how to do it the 1.12 way, which uses loottable.generateLootForPools(). But, this doesn't work in 1.14, generateLootForPools() doesn't appear to exist. Something like this in 1.12: for (ItemStack itemstack : loottable.generateLootForPools(world.rand, builder.build())){ ItemEntity entityitem = new ItemEntity(world, player.posX, player.posY + 1.5D, player.posZ, itemstack); world.spawnEntity(entityitem);} Does anyone know how to do this in 1.14? Here is the relevant code from my custom item's class... I'm setting the loot table resource: private static final ResourceLocation LOOT_TABLE = new ResourceLocation("mymod:mymod_loot"); I have an action for when the player right clicks the item in their hand, which destroys the item and calls "generateLoot()" @Overridepublic ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn){ LOGGER.debug("Right Clicked"); ItemStack itemstack = playerIn.getHeldItem(handIn); // Remove item itemstack.shrink(1); if (!worldIn.isRemote) { generateLoot(worldIn, playerIn); } return new ActionResult<>(ActionResultType.SUCCESS, itemstack);} The generateLoot method: private void generateLoot(World world,PlayerEntity player) { LootTable table = ServerLifecycleHooks.getCurrentServer().getLootTableManager().getLootTableFromLocation(LOOT_TABLE); LootContext.Builder builder = new LootContext.Builder((ServerWorld) world); // Here is where I need to generate random loot from loot table and give to player(???) } Any help would be greatly appreciated