Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Leaderboard

Popular Content

Showing content with the highest reputation on 08/27/23 in Posts

  1. try to display the BAR through the picture GitHub Here is a working example
  2. You don't need to do all that registry access yourself. You can just use the "smart constructor": DamageSource damagesource = this.level.damageSources().source(MyDamageTypes.SPEAR, this, entity1 == null ? this : entity1); If you look at the code for DamageSources.trident() that's pretty much what it does.
  3. I did it this way: I have a class with all the Damage Types I need to declare and then in the bootstrap method I register them public static final ResourceKey<DamageType> SPEAR = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("mod_id", "spear")); public static void bootstrap(BootstapContext<DamageType> context) { context.register(SPEAR, new DamageType("spear", 0.1F)); } Then, where I need to use that damage type, I can call it like this DamageSource damagesource = new DamageSource(this.level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(MyDamageTypes.SPEAR), this, entity1 == null ? this : entity1); In this case I'm providing 2 more arguments to the constructor since I need them, but these depends on the type of damage. What I'm trying to mimic here is something similar to the trident damage, so that's why I need those parameters. Anyawy the key here is how you retrieve the DamageType this.level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(MyDamageTypes.SPEAR) Essentially we get the RegistryAccess instance from a Level (world) instance (in this case the Level instance of the entity I'm calling this in). From here we get the Damage Type registry and from here we get the DamageType we want providing a Resouce Key (in this case we provide oure resource key). This method is similar to how vanilla/forge implements it, you can see the vanilla game damage sources inside the DamageSources class After all this you need the JSON files inside your mod's assets data folder. Under <your_mod_id> you need to add a new folder called "damage_type". Inside you need to add a json file named like the damage type you're adding. In the example above I'm adding a "spear" damage type, so I create a "spear.json" file in which I specify the damage type properties { "exhaustion": 0.1, "message_id": "spear", "scaling": "when_caused_by_living_non_player" } This may vary based on the damage type you're trying to add/mimic and of course on your needs. You may also want to add your damage type to the minecraft tags, if there is one that fits your new damage type, under minecraft/tags/damage_type. In my case my new damage is a projectile type one, so I added the "is_projectile.json" file { "replace": false, "values": [ "mod_id:spear" ] }
  4. 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.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.