Jump to content

Special Ability Tools


kenoba10

Recommended Posts

  • Replies 73
  • Created
  • Last Reply

Top Posters In This Topic

Block brokenBlock = Block.blocksList[world.getBlockId(x, y, z)];
int meta = world.getBlockMetadata(x, y, z);
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

Ok does this just check if it is a smelting recipe or should this be all the code I need for it to work?

Link to comment
Share on other sites

Yes.

For the auto-smelting pickaxe this is my code but how do I drop the item I've messed around and whenever I try something it crashes when i break the block and doesnt work

public boolean onBlockDestroyed(ItemStack itemStack, World world, int par1, int par2, int par3, int par4, EntityLivingBase entityLivingBase) {

	Block brokenBlock = Block.blocksList[world.getBlockId(par1, par1, par3)];
	int meta = world.getBlockMetadata(par1, par2, par3);
	ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

	if(result != null) {

		//How do I drop the item?

	}

	return true;

}

Link to comment
Share on other sites

EntityItem item = new EntityItem(world, i, j, k, result);
world.spawnEntityInWorld(item);

When i login and break a block I crash and when i log back in theres  the ingot and the ore on the ground if it was an ore block i broke

public boolean onBlockDestroyed(ItemStack itemStack, World world, int par1, int par2, int par3, int par4, EntityLivingBase entityLivingBase) {

	Block brokenBlock = Block.blocksList[world.getBlockId(par2, par3, par4)];
	int meta = world.getBlockMetadata(par2, par3, par4);
	ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

	if(result != null) {

		EntityItem drop = new EntityItem(world, par2, par3, par4, result);
		world.spawnEntityInWorld(drop);

	}

	return false;

}

Link to comment
Share on other sites

Okay, well I kind of need a crash log for that.

Ok here

---- Minecraft Crash Report ----

// I feel sad now :(

 

Time: 7/21/13 4:09 PM

Description: Unexpected error

 

java.lang.NullPointerException

at net.minecraft.item.ItemStack.<init>(ItemStack.java:71)

at Kenoba10.Too_Much_Tools.NetherStar.ItemNetherStarPickaxe.onBlockDestroyed(ItemNetherStarPickaxe.java:33)

at net.minecraft.item.ItemStack.onBlockDestroyed(ItemStack.java:402)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDestroyBlock(PlayerControllerMP.java:174)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDamageBlock(PlayerControllerMP.java:293)

at net.minecraft.client.Minecraft.sendClickBlockToController(Minecraft.java:1307)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1868)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:898)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:826)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)

at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.item.ItemStack.<init>(ItemStack.java:71)

at Kenoba10.Too_Much_Tools.NetherStar.ItemNetherStarPickaxe.onBlockDestroyed(ItemNetherStarPickaxe.java:33)

at net.minecraft.item.ItemStack.onBlockDestroyed(ItemStack.java:402)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDestroyBlock(PlayerControllerMP.java:174)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDamageBlock(PlayerControllerMP.java:293)

at net.minecraft.client.Minecraft.sendClickBlockToController(Minecraft.java:1307)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player747'/302, l='MpServer', x=204.59, y=62.62, z=251.30]]

Chunk stats: MultiplayerChunkCache: 441

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: World: (232,64,256), Chunk: (at 8,4,0 in 14,16; contains blocks 224,0,256 to 239,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 29596 game time, 1312 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false

Forced entities: 70 total; [EntityZombie['Zombie'/137, l='MpServer', x=243.69, y=27.00, z=275.47], EntityBat['Bat'/136, l='MpServer', x=248.75, y=32.10, z=243.50], EntityCow['Cow'/142, l='MpServer', x=264.59, y=69.00, z=237.47], EntitySkeleton['Skeleton'/128, l='MpServer', x=239.50, y=30.00, z=273.50], EntityZombie['Zombie'/133, l='MpServer', x=247.34, y=27.00, z=211.94], EntityZombie['Zombie'/132, l='MpServer', x=243.30, y=11.00, z=208.70], EntityBat['Bat'/135, l='MpServer', x=248.41, y=32.10, z=243.47], EntitySkeleton['Skeleton'/134, l='MpServer', x=245.09, y=24.00, z=218.47], EntityCow['Cow'/152, l='MpServer', x=283.31, y=65.00, z=254.47], EntityZombie['Zombie'/153, l='MpServer', x=276.50, y=21.00, z=273.50], EntitySkeleton['Skeleton'/42, l='MpServer', x=133.59, y=42.00, z=213.94], EntitySkeleton['Skeleton'/43, l='MpServer', x=132.50, y=41.00, z=222.50], EntityZombie['Zombie'/41, l='MpServer', x=127.97, y=53.00, z=326.47], EntityZombie['Zombie'/46, l='MpServer', x=142.31, y=38.00, z=274.56], EntityCreeper['Creeper'/47, l='MpServer', x=140.94, y=30.00, z=291.59], EntityBat['Bat'/44, l='MpServer', x=132.00, y=27.10, z=241.56], EntityZombie['Zombie'/45, l='MpServer', x=134.72, y=24.00, z=258.50], EntitySquid['Squid'/51, l='MpServer', x=157.50, y=56.38, z=223.13], EntityMinecartChest['entity.MinecartChest.name'/49, l='MpServer', x=139.50, y=32.50, z=330.50], EntityOcelot['Ocelot'/48, l='MpServer', x=138.06, y=65.00, z=318.56], EntityBat['Bat'/55, l='MpServer', x=156.53, y=36.10, z=296.75], EntityZombie['Zombie'/54, l='MpServer', x=146.31, y=26.00, z=250.88], EntityZombie['Zombie'/53, l='MpServer', x=146.50, y=26.00, z=252.50], EntityBat['Bat'/52, l='MpServer', x=146.59, y=18.10, z=247.75], EntityCreeper['Creeper'/58, l='MpServer', x=145.50, y=51.00, z=323.50], EntityMinecartChest['entity.MinecartChest.name'/57, l='MpServer', x=147.50, y=36.50, z=318.50], EntityCreeper['Creeper'/56, l='MpServer', x=145.00, y=31.00, z=310.41], EntityZombie['Zombie'/63, l='MpServer', x=175.03, y=54.00, z=249.47], EntityCow['Cow'/62, l='MpServer', x=171.50, y=67.00, z=225.50], EntitySquid['Squid'/61, l='MpServer', x=172.50, y=56.38, z=213.50], EntityClientPlayerMP['Player747'/302, l='MpServer', x=204.59, y=62.62, z=251.30], EntityItem['item.item.dyePowder.black'/64, l='MpServer', x=161.38, y=18.13, z=256.84], EntityBat['Bat'/65, l='MpServer', x=174.72, y=33.10, z=292.53], EntityCreeper['Creeper'/66, l='MpServer', x=160.50, y=31.00, z=314.50], EntityCow['Cow'/77, l='MpServer', x=187.88, y=63.00, z=175.91], EntityCow['Cow'/78, l='MpServer', x=188.78, y=63.00, z=208.75], EntitySkeleton['Skeleton'/79, l='MpServer', x=183.53, y=28.00, z=235.88], EntityMinecartChest['entity.MinecartChest.name'/85, l='MpServer', x=182.50, y=28.50, z=329.50], EntityCow['Cow'/84, l='MpServer', x=186.47, y=67.00, z=312.63], EntityCow['Cow'/86, l='MpServer', x=191.03, y=64.00, z=330.13], EntitySkeleton['Skeleton'/81, l='MpServer', x=190.50, y=21.00, z=269.50], EntityCow['Cow'/80, l='MpServer', x=183.06, y=63.00, z=251.91], EntityCow['Cow'/83, l='MpServer', x=189.97, y=63.00, z=308.88], EntityCreeper['Creeper'/82, l='MpServer', x=188.50, y=33.00, z=265.53], EntityCow['Cow'/93, l='MpServer', x=204.50, y=71.00, z=175.50], EntityCow['Cow'/95, l='MpServer', x=201.13, y=65.00, z=180.13], EntityCow['Cow'/94, l='MpServer', x=206.44, y=65.00, z=191.25], EntityBat['Bat'/102, l='MpServer', x=201.13, y=28.02, z=285.50], EntityCow['Cow'/103, l='MpServer', x=201.69, y=64.00, z=284.72], EntitySkeleton['Skeleton'/100, l='MpServer', x=195.59, y=17.21, z=283.30], EntityCreeper['Creeper'/101, l='MpServer', x=200.69, y=26.36, z=277.69], EntityCreeper['Creeper'/98, l='MpServer', x=194.09, y=21.00, z=268.97], EntitySpider['Spider'/99, l='MpServer', x=191.50, y=22.00, z=272.75], EntityCow['Cow'/96, l='MpServer', x=196.81, y=64.00, z=188.88], EntitySkeleton['Skeleton'/97, l='MpServer', x=196.50, y=21.00, z=267.50], EntityCreeper['Creeper'/110, l='MpServer', x=208.50, y=26.00, z=269.50], EntityCreeper['Creeper'/111, l='MpServer', x=213.00, y=28.00, z=270.63], EntityBat['Bat'/108, l='MpServer', x=227.88, y=13.01, z=239.03], EntitySpider['Spider'/109, l='MpServer', x=208.72, y=58.77, z=250.94], EntityCow['Cow'/104, l='MpServer', x=192.44, y=63.00, z=316.09], EntityEnderman['Enderman'/117, l='MpServer', x=211.22, y=39.00, z=324.34], EntityCow['Cow'/116, l='MpServer', x=223.31, y=64.00, z=316.22], EntitySpider['Spider'/115, l='MpServer', x=211.28, y=48.00, z=305.47], EntityCreeper['Creeper'/114, l='MpServer', x=221.63, y=53.00, z=307.03], EntitySpider['Spider'/113, l='MpServer', x=212.53, y=40.00, z=319.25], EntityCreeper['Creeper'/112, l='MpServer', x=208.28, y=26.00, z=272.97], EntityCreeper['Creeper'/127, l='MpServer', x=225.69, y=17.00, z=250.44], EntityBat['Bat'/126, l='MpServer', x=230.25, y=32.10, z=230.38], EntityCreeper['Creeper'/125, l='MpServer', x=227.31, y=11.00, z=234.63], EntityCreeper['Creeper'/124, l='MpServer', x=232.50, y=32.00, z=207.00]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:440)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2298)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:851)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)

at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

 

-- System Details --

Details:

Minecraft Version: 1.6.2

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_25, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 810777376 bytes (773 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 7171 (401576 bytes; 0 MB) allocated, 1027 (57512 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 1, tallocated: 63

FML: MCP v8.04 FML v6.2.19.787 Minecraft Forge 9.10.0.787 4 mods loaded, 4 mods active

mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{6.2.19.787} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{9.10.0.787} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

TooMuchTools{1.0} [Too Much Tools] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: Intel® HD Graphics Family GL version 3.1.0 - Build 8.15.10.2430, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Pack: Default

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: 1971 (110376 bytes; 0 MB) allocated, 223 (12488 bytes; 0 MB) used

Link to comment
Share on other sites

if(brokenBlock != null)
{
	ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

	if(result != null)
	{
		EntityItem drop = new EntityItem(world, par2, par3, par4, result);
		world.spawnEntityInWorld(drop);
		return false;
	}
}

Link to comment
Share on other sites

if(brokenBlock != null)
{
	ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

	if(result != null)
	{
		EntityItem drop = new EntityItem(world, par2, par3, par4, result);
		world.spawnEntityInWorld(drop);
		return false;
	}
}

Thanks but when I break it with the pick the first time i break that ore type I get an ingot and the ore, the rest of the then I just get the ore back

Link to comment
Share on other sites

if(world.getBlockId(i, j, k) == Block.wood.blockID)
	{
		for(int x = -1; x <= 1; x++)
		{
			for(int y = 0; y <= 15; y++)
			{
				for(int z = -1; z <= 1; z++)
				{
					if(world.getBlockId(i + x, j + y, k + z) == Block.wood.blockID)
					{
						int meta = world.getBlockMetadata(i + x, j + y, k + z);
						ItemStack drop = new ItemStack(Block.wood, 1, meta);
						EntityItem item = new EntityItem(world, i + x, j + y, k + z, drop);
						world.setBlock(i + x, j + y, k + z, 0);
						world.spawnEntityInWorld(item);
					}
				}
			}
		}
	}

 

That first if statement seems EXTREMELY redundant... But oh well :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

if(brokenBlock != null)
{
	ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

	if(result != null)
	{
		EntityItem drop = new EntityItem(world, par2, par3, par4, result);
		world.spawnEntityInWorld(drop);
		return false;
	}
}

Thanks but when I break it with the pick the first time i break that ore type I get an ingot and the ore, the rest of the then I just get the ore back

 

That makes sense. The problem with the ore is the fact that what a block drops is set inside the block's class. And to my knowledge, there is no way to void that block drop. But I guess you could do a hackish type job by using gamerules... By that I mean set block drops to false and then back to true again once it dropped the item.

 

As to it only working once... I am not sure :/

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

That first if statement seems EXTREMELY redundant... But oh well :P

It's to tell it that breaking a block beneath a wood block won't have the "timber" effect. If that weren't there it could work by breaking it otherwise. Thanks for the concern, though.

Link to comment
Share on other sites

That first if statement seems EXTREMELY redundant... But oh well :P

It's to tell it that breaking a block beneath a wood block won't have the "timber" effect. If that weren't there it could work by breaking it otherwise. Thanks for the concern, though.

 

That still doesn't quite work out logically in my mind... Why check the block you are breaking is wood, if you are wanting to check the block under it? That is what caused my confusion in the first place.

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

That still doesn't quite work out logically in my mind... Why check the block you are breaking is wood, if you are wanting to check the block under it? That is what caused my confusion in the first place.

So for example, you are using the axe to break a dirt block. Above the dirt block is a tree. The timber effect should not take place since you are breaking dirt. That is why it checks for logs first, so that "hey, you're breaking a wood block now, let's know out the rest of 'em" will happen.

Link to comment
Share on other sites

That still doesn't quite work out logically in my mind... Why check the block you are breaking is wood, if you are wanting to check the block under it? That is what caused my confusion in the first place.

So for example, you are using the axe to break a dirt block. Above the dirt block is a tree. The timber effect should not take place since you are breaking dirt. That is why it checks for logs first, so that "hey, you're breaking a wood block now, let's know out the rest of 'em" will happen.

 

That makes sense now :P I didn't think of that... Good job mate! Glad someone has common sense :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

if(brokenBlock != null)
{
	ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

	if(result != null)
	{
		EntityItem drop = new EntityItem(world, par2, par3, par4, result);
		world.spawnEntityInWorld(drop);
		return false;
	}
}

For the pickaxe do you know of any way to prevent the default block drop and when I break the ore for the first time it gives me an ingot and the ore. The rest of the time i only get the ore.

Link to comment
Share on other sites

if(brokenBlock != null)
{
	ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(brokenBlock, 1, meta));

	if(result != null)
	{
		EntityItem drop = new EntityItem(world, par2, par3, par4, result);
		world.spawnEntityInWorld(drop);
		return false;
	}
}

Thanks but when I break it with the pick the first time i break that ore type I get an ingot and the ore, the rest of the then I just get the ore back

 

That makes sense. The problem with the ore is the fact that what a block drops is set inside the block's class. And to my knowledge, there is no way to void that block drop. But I guess you could do a hackish type job by using gamerules... By that I mean set block drops to false and then back to true again once it dropped the item.

 

As to it only working once... I am not sure :/

Ok how could I do that gamerule thing? Also when I overrided canHarvestBlock when I broke a block I got the ingot back and niot the ore but it took a super long time to mine and then for all blocks mined with the pick this happened

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • rp.crazyheal.xyz mods  
    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
  • Topics

×
×
  • Create New...

Important Information

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