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.

7194.f.null

Members
  • Joined

  • Last visited

  1. I did this on Forge 47.1.44 first, I made ModDamageTypes interface by copying net.minecraft.world.damagesource.DamageTypes public interface ModDamageTypes { ResourceKey<DamageType> DEHYDRATION = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(MyModCommon.MODID, "dehydration") ); ResourceKey<DamageType> BEACON_BEAM = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(MymodCommon.MODID, "beacon_beam") ); } And then I made a ModDamageSources class by copying net.minecraft.world.damagesource.DamageSources public class ModDamageSources { private final Registry<DamageType> damageTypes; private final DamageSource dehydration; private final DamageSource beaconBeam; public ModDamageSources(RegistryAccess pRegistry) { this.damageTypes = pRegistry.registryOrThrow(Registries.DAMAGE_TYPE); this.dehydration = this.source(ModDamageTypes.DEHYDRATION); this.beaconBeam = this.source(ModDamageTypes.BEACON_BEAM); } private DamageSource source(ResourceKey<DamageType> pDamageTypeKey) { return new DamageSource(this.damageTypes.getHolderOrThrow(pDamageTypeKey)); } private DamageSource source(ResourceKey<DamageType> pDamageTypeKey, @Nullable Entity pEntity) { return new DamageSource(this.damageTypes.getHolderOrThrow(pDamageTypeKey), pEntity); } private DamageSource source(ResourceKey<DamageType> pDamageTypeKey, @Nullable Entity pCausingEntity, @Nullable Entity pDirectEntity) { return new DamageSource(this.damageTypes.getHolderOrThrow(pDamageTypeKey), pCausingEntity, pDirectEntity); } public DamageSource dehydration() { return this.dehydration; } public DamageSource beaconBeam() { return this.beaconBeam; } } In ModCommonEvents class @SubscribeEvent public static void onPlayerTick(TickEvent.PlayerTickEvent event) { if(event.side == LogicalSide.SERVER && !event.player.isCreative()) { event.player.getCapability(PlayerThirstProvider.PLAYER_THIRST) .ifPresent(thirst -> { if (thirst.getThirst() > 0 && event.player.getRandom().nextFloat() < 0.005f) { thirst.subThirst(1); ModNetworking.sendToPlayer( new ThirstDataSyncS2CPacket(thirst.getThirst()), () -> (ServerPlayer)event.player ); } if (thirst.getThirst() == 0 && event.player.getRandom().nextFloat() < 0.005f) { DamageSource dehydration = new ModDamageSources(event.player.level().registryAccess()).dehydration(); event.player.hurt(dehydration, 2f); } }); } } Also, in src/main/resources/data/mymod/damage_type/ there needs to be dehydration.json and beacon_beam.json { "exhaustion": 0.1, "message_id": "dehydration", "scaling": "never" } { "exhaustion": 0.1, "message_id": "beacon_beam", "scaling": "never" } And this will work in dev env copying vanilla minecraft can always get me somewhere, but I am pretty sure this is not the proper way to do this.

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.