Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] Creating custom damage source to allow custom death messages


Recommended Posts

@Override
	public boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity) {
		float health = ((LivingEntity) entity).getMaxHealth();
		return entity.hurt(DamageSource.OUT_OF_WORLD, health);
	}

I have this current code above ^

I know there is a way to create my own damage source, but I couldn't find a way to have it deal void damage. Also, how would I go about specifying in the lang file to add a new death message?

If anyone could point me in the right direction that would be great.

Link to post
Share on other sites
14 minutes ago, Novality said:

I know there is a way to create my own damage source,

just create a new DamageSource with:

 new DamageSource(name)

 

15 minutes ago, Novality said:

but I couldn't find a way to have it deal void damage.

what did you mean by "deal void damage"?
-> you already damage the Entity via Void

 

15 minutes ago, Novality said:

Also, how would I go about specifying in the lang file to add a new death message?

use this for the death message without player:

"death.attack.name": "%1$s message", -> %1$s, will replace with the player name

and this with player:

"death.attack.name.player": "%1$s message %2$s", -> %1$s, target and %2$s is the attacker

 

Note: DamageSource are not namespaced save so add your mod id to name of a DamageSource to prevent problems with other mods

Link to post
Share on other sites
9 minutes ago, Luis_ST said:

what did you mean by "deal void damage"?
-> you already damage the Entity via Void

If I create my own damagesource i no longer will need to damage it with "entity.hurt(DamageSource.OUT_OF_WORLD, health);" right? Otherwise that'll kill the entity and I wont get the death message I want. Using "new DamageSource(name)" how can I specify that it should deal OUT_OF_WORLD damage?

Link to post
Share on other sites
2 minutes ago, diesieben07 said:

What? Either it's out of world damage or it's not. It cannot be both.

What do you want to achieve?

I want to deal void damage to an entity (which I've already done).
If it's a player that is killed, I want to override the "Player fell out of the world." death message and implement my own.

Link to post
Share on other sites
2 minutes ago, Novality said:

If it's a player that is killed, I want to override the "Player fell out of the world." death message and implement my own.

Then it cannot be void damage. Void damage by definition causes this message, because it's void damage. If you do not want this message it cannot be void damage.

Link to post
Share on other sites
1 hour ago, Novality said:

I want to deal void damage to an entity (which I've already done).
If it's a player that is killed, I want to override the "Player fell out of the world." death message and implement my own.

If you want to deal void damage (it's important because some entities like the wither check for it) and you want a custom death message, then you can just add the two lines below to your language file and customize them however you want. I'm not sure if this is really a good idea but it does work.

"death.attack.outOfWorld": "%1$s fell out of the world",
"death.attack.outOfWorld.player": "%1$s didn't want to live in the same world as %2$s"

As Luis_ST said, %1$s is the player's name and %2$s is the attacker entity's name.

Link to post
Share on other sites
1 hour ago, uSkizzik said:

If you want to deal void damage (it's important because some entities like the wither check for it) and you want a custom death message, then you can just add the two lines below to your language file and customize them however you want. I'm not sure if this is really a good idea but it does work.


"death.attack.outOfWorld": "%1$s fell out of the world",
"death.attack.outOfWorld.player": "%1$s didn't want to live in the same world as %2$s"

As Luis_ST said, %1$s is the player's name and %2$s is the attacker entity's name.

This will change the void damage source message in general.

Link to post
Share on other sites
2 hours ago, Novality said:

I want to deal void damage to an entity (which I've already done).
If it's a player that is killed, I want to override the "Player fell out of the world." death message and implement my own.

the best way would be to create your own DamageSource like:

DamageSource VOID = new DamageSource(MOD_ID + "_void");

and add your own death message, e.g.:

"death.attack.mod_id_void": "%1$s killed with void",
"death.attack.mod_id_void.player": "%1$s killed himself with void whilst fighting %2$s"

 

  • Thanks 1
Link to post
Share on other sites
3 minutes ago, Luis_ST said:

the best way would be to create your own DamageSource like:


DamageSource VOID = new DamageSource(MOD_ID + "_void");

and add your own death message, e.g.:


"death.attack.mod_id_void": "%1$s killed with void",
"death.attack.mod_id_void.player": "%1$s killed himself with void whilst fighting %2$s"

 

Thank you. Disappointed though that this won't deal OUT_OF_WORLD damage but it's still pog.

Link to post
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.

Guest
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

    • i am looking for a mod that shows all the chunks that have been loaded or a mod that shows all of the chunks that are currently loaded for 1.17.1
    • Heya. I have been trying to figure out why using /tp keeps crashing me when Im using forge 1.16.5. the crash report is below. please help me out. ---- Minecraft Crash Report ---- // Don't do that. Time: 7/25/21 5:11 PM Description: Exception generating new chunk java.lang.IllegalArgumentException: bound must be positive     at java.util.Random.nextInt(Random.java:388) ~[?:1.8.0_51] {}     at net.minecraft.world.gen.feature.structure.Structure.func_236392_a_(Structure.java:202) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.structure.Structure.func_242785_a(Structure.java:221) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.StructureFeature.func_242771_a(SourceFile:35) ~[?:?] {re:classloading}     at net.minecraft.world.gen.ChunkGenerator.func_242705_a(SourceFile:278) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.gen.ChunkGenerator.func_242707_a(SourceFile:267) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.chunk.ChunkStatus.lambda$static$2(ChunkStatus.java:41) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.chunk.ChunkStatus$$Lambda$2265/387194988.doWork(Unknown Source) ~[?:?] {}     at net.minecraft.world.chunk.ChunkStatus.func_223198_a(ChunkStatus.java:198) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ChunkManager.lambda$null$18(ChunkManager.java:524) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6523/918777125.apply(Unknown Source) ~[?:?] {}     at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[datafixerupper-4.0.26.jar:?] {re:classloading,re:classloading}     at net.minecraft.world.server.ChunkManager.lambda$chunkGenerate$20(ChunkManager.java:522) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6520/530773096.apply(Unknown Source) ~[?:?] {}     at java.util.concurrent.CompletableFuture.uniCompose(CompletableFuture.java:952) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:926) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) ~[?:1.8.0_51] {}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter.func_219083_b(SourceFile:58) ~[?:?] {re:classloading}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter$$Lambda$6464/1211192729.run(Unknown Source) ~[?:?] {}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.func_213148_e(SourceFile:94) ~[?:?] {re:classloading}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.func_213145_a(SourceFile:137) ~[?:?] {re:classloading}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.run(SourceFile:105) ~[?:?] {re:classloading}     at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_51] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace:     at java.util.Random.nextInt(Random.java:388) ~[?:1.8.0_51] {}     at net.minecraft.world.gen.feature.structure.Structure.func_236392_a_(Structure.java:202) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.structure.Structure.func_242785_a(Structure.java:221) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.StructureFeature.func_242771_a(SourceFile:35) ~[?:?] {re:classloading}     at net.minecraft.world.gen.ChunkGenerator.func_242705_a(SourceFile:278) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.gen.ChunkGenerator.func_242707_a(SourceFile:267) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.chunk.ChunkStatus.lambda$static$2(ChunkStatus.java:41) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.chunk.ChunkStatus$$Lambda$2265/387194988.doWork(Unknown Source) ~[?:?] {}     at net.minecraft.world.chunk.ChunkStatus.func_223198_a(ChunkStatus.java:198) ~[?:?] {re:classloading,pl:accesstransformer:B} -- Chunk to be generated -- Details:     Location: 170,-183     Position hash: -785979014998     Generator: net.minecraft.world.gen.NoiseChunkGenerator@68c16e02 Stacktrace:     at net.minecraft.world.server.ChunkManager.lambda$null$18(ChunkManager.java:524) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6523/918777125.apply(Unknown Source) ~[?:?] {}     at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[datafixerupper-4.0.26.jar:?] {re:classloading,re:classloading,re:classloading}     at net.minecraft.world.server.ChunkManager.lambda$chunkGenerate$20(ChunkManager.java:522) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6520/530773096.apply(Unknown Source) ~[?:?] {}     at java.util.concurrent.CompletableFuture.uniCompose(CompletableFuture.java:952) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:926) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) ~[?:1.8.0_51] {}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter.func_219083_b(SourceFile:58) ~[?:?] {re:classloading}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter$$Lambda$6464/1211192729.run(Unknown Source) ~[?:?] {}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.func_213148_e(SourceFile:94) ~[?:?] {re:classloading} -- Affected level -- Details:     All players: 1 total; [ServerPlayerEntity['KrystalTheFox_'/132, l='ServerLevel[Modded Survival]', x=2748.50, y=77.00, z=-2911.50]]     Chunk stats: ServerChunkCache: 3347     Level dimension: minecraft:overworld     Level spawn location: World: (51,64,-90), Chunk: (at 3,4,6 in 3,-6; contains blocks 48,0,-96 to 63,255,-81), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)     Level time: 42412 game time, 227 day time     Level name: Modded Survival     Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false     Level weather: Rain time: 120492 (now: false), thunder time: 52965 (now: false)     Known server brands: forge     Level was modded: true     Level storage version: 0x04ABD - Anvil Stacktrace:     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:854) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:787) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:78) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:642) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:232) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer$$Lambda$6334/1896438195.run(Unknown Source) [?:?] {}     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] {} -- System Details -- Details:     Minecraft Version: 1.16.5     Minecraft Version ID: 1.16.5     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 1148904608 bytes (1095 MB) / 2147483648 bytes (2048 MB) up to 2147483648 bytes (2048 MB)     CPUs: 4     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     ModLauncher: 8.0.9+86+master.3cf110c     ModLauncher launch target: fmlclient     ModLauncher naming: srg     ModLauncher services:          /mixin-0.8.2.jar mixin PLUGINSERVICE          /eventbus-4.0.0.jar eventbus PLUGINSERVICE          /forge-1.16.5-36.0.45.jar object_holder_definalize PLUGINSERVICE          /forge-1.16.5-36.0.45.jar runtime_enum_extender PLUGINSERVICE          /accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE          /forge-1.16.5-36.0.45.jar capability_inject_definalize PLUGINSERVICE          /forge-1.16.5-36.0.45.jar runtimedistcleaner PLUGINSERVICE          /mixin-0.8.2.jar mixin TRANSFORMATIONSERVICE          /forge-1.16.5-36.0.45.jar fml TRANSFORMATIONSERVICE      FML: 36.0     Forge: net.minecraftforge:36.0.45     FML Language Providers:          javafml@36.0         minecraft@1     Mod List:          forge-1.16.5-36.0.45-client.jar                   |Minecraft                     |minecraft                     |1.16.5              |DONE      |NOSIGNATURE         dungeons_mobs-1.16.5-1.0.5.jar                    |Dungeons Mobs                 |dungeons_mobs                 |1.0.5               |DONE      |NOSIGNATURE         repurposed_structures-1.16.5-2.6.6-forge.jar      |Repurposed Structures         |repurposed_structures         |1.16.5-2.6.6-forge  |DONE      |NOSIGNATURE         illagers_plus-1.16.4v1.5.jar                      |Illagers+                     |illagers_plus                 |1.16.4v1.5          |DONE      |NOSIGNATURE         enchantwithmob-1.16.5-1.4.6.jar                   |Enchant With Mob              |enchantwithmob                |1.16.5-1.4.6        |DONE      |NOSIGNATURE         Ma-Enchants-1.16.5-3.6.0 (1).jar                  |Ma Enchants                   |ma-enchants                   |1.16.5-3.6.0        |DONE      |NOSIGNATURE         forge-1.16.5-36.0.45-universal.jar                |Forge                         |forge                         |36.0.45             |DONE      |22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90         torohealth-1.16.4-forge-4.jar                     |ToroHealth                    |torohealth                    |NONE                |DONE      |NOSIGNATURE         extragolems-11.3.0.jar                            |Extra Golems                  |golems                        |11.3.0              |DONE      |NOSIGNATURE         Deeper+in+The+Caves+Remake+1.1.jar                |Deeper In The Caves Remake    |stacked_dimensions_warden     |1.0.0               |DONE      |NOSIGNATURE         MobBattleMod-1.16.2-2.3.4 (2).jar                 |Mob Battle Mod                |mobbattle                     |1.16.2-2.3.4        |DONE      |NOSIGNATURE         supertools-1.16.5-4.5.jar                         |Vanilla+ Tools                |supertools                    |version             |DONE      |NOSIGNATURE     Crash Report UUID: 2888177d-2bf6-4908-99f1-1b7b6465ec05     Player Count: 1 / 8; [ServerPlayerEntity['KrystalTheFox_'/132, l='ServerLevel[Modded Survival]', x=2748.50, y=77.00, z=-2911.50]]     Data Packs: vanilla, mod:dungeons_mobs (incompatible), mod:repurposed_structures, mod:illagers_plus, mod:enchantwithmob, mod:ma-enchants (incompatible), mod:forge, mod:torohealth, mod:golems (incompatible), mod:stacked_dimensions_warden, mod:mobbattle (incompatible), mod:supertools (incompatible)     Type: Integrated Server (map_client.txt)     Is Modded: Definitely; Client brand changed to 'forge'
    • I installed a Forge server, ran the normal .jar file, accepted the EULA, tried to run the forge.jar file but it doesn't give me any folders (like the mods or config) folder. Already looked through the forum here but there weren't any help. I also updated to the newest Java version but it doesn't help.
    • I have a custom inventory that saves when i have the world running but when I rejoin the items are not there in the slots.
    • Hello, I have a weird issue with my server where I have to be on the multiplayer page on the same version as my friends for them to join the server. This has happened on all versions, no matter what mod, Forge and vanilla. It's not a LAN, and I've port forwarded, and I'm kinda new to this stuff anyways. Anybody have a reason to this?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.