mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed crashes when taking damage
This commit is contained in:
parent
140f02536e
commit
7764024760
3 changed files with 63 additions and 46 deletions
|
@ -22,6 +22,7 @@ import com.minelittlepony.unicopia.command.Commands;
|
||||||
import com.minelittlepony.unicopia.container.SpellbookChapterLoader;
|
import com.minelittlepony.unicopia.container.SpellbookChapterLoader;
|
||||||
import com.minelittlepony.unicopia.container.UScreenHandlers;
|
import com.minelittlepony.unicopia.container.UScreenHandlers;
|
||||||
import com.minelittlepony.unicopia.entity.UEntities;
|
import com.minelittlepony.unicopia.entity.UEntities;
|
||||||
|
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
||||||
import com.minelittlepony.unicopia.entity.effect.UPotions;
|
import com.minelittlepony.unicopia.entity.effect.UPotions;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
|
@ -93,6 +94,7 @@ public class Unicopia implements ModInitializer {
|
||||||
UScreenHandlers.bootstrap();
|
UScreenHandlers.bootstrap();
|
||||||
UTreeGen.bootstrap();
|
UTreeGen.bootstrap();
|
||||||
UGameRules.bootstrap();
|
UGameRules.bootstrap();
|
||||||
|
UDamageTypes.bootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface SidedAccess {
|
public interface SidedAccess {
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
package com.minelittlepony.unicopia.entity.damage;
|
package com.minelittlepony.unicopia.entity.damage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
|
||||||
import net.minecraft.entity.damage.DamageType;
|
import net.minecraft.entity.damage.DamageType;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
|
||||||
public interface UDamageTypes {
|
public interface UDamageTypes {
|
||||||
|
List<RegistryKey<DamageType>> REGISTRY = new ArrayList<>();
|
||||||
|
|
||||||
RegistryKey<DamageType> EXHAUSTION = register("magical_exhaustion");
|
RegistryKey<DamageType> EXHAUSTION = register("magical_exhaustion");
|
||||||
RegistryKey<DamageType> ALICORN_AMULET = register("alicorn_amulet");
|
RegistryKey<DamageType> ALICORN_AMULET = register("alicorn_amulet");
|
||||||
RegistryKey<DamageType> FOOD_POISONING = register("food_poisoning");
|
RegistryKey<DamageType> FOOD_POISONING = register("food_poisoning");
|
||||||
|
@ -25,10 +32,18 @@ public interface UDamageTypes {
|
||||||
RegistryKey<DamageType> PETRIFIED = register("petrified");
|
RegistryKey<DamageType> PETRIFIED = register("petrified");
|
||||||
|
|
||||||
private static RegistryKey<DamageType> register(String name) {
|
private static RegistryKey<DamageType> register(String name) {
|
||||||
return RegistryKey.of(RegistryKeys.DAMAGE_TYPE, Unicopia.id(name));
|
var key = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, Unicopia.id(name));
|
||||||
|
REGISTRY.add(key);
|
||||||
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bootstrap() {
|
static void bootstrap() {
|
||||||
|
DynamicRegistrySetupCallback.EVENT.register(registries -> {
|
||||||
|
registries.getOptional(RegistryKeys.DAMAGE_TYPE).ifPresent(registry -> {
|
||||||
|
REGISTRY.forEach(key -> {
|
||||||
|
Registry.register(registry, key.getValue(), new DamageType(key.getValue().getNamespace() + "." + key.getValue().getPath(), 0));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -634,50 +634,50 @@
|
||||||
"unicopia.race.bat": "Bat Pony",
|
"unicopia.race.bat": "Bat Pony",
|
||||||
"unicopia.race.bat.alt": "Bat Ponies",
|
"unicopia.race.bat.alt": "Bat Ponies",
|
||||||
|
|
||||||
"death.attack.generic.and_also": "%1$s and %2$s",
|
"death.attack.unicopia.generic.and_also": "%1$s and %2$s",
|
||||||
"death.attack.generic.whilst_flying": "%1$s whilst flying",
|
"death.attack.unicopia.generic.whilst_flying": "%1$s whilst flying",
|
||||||
"death.attack.tribe_swap": "%1$s was reborn into a different tribe",
|
"death.attack.unicopia.tribe_swap": "%1$s was reborn into a different tribe",
|
||||||
"death.attack.tribe_swap.player": "%1$s was doomed to be reborn into a different tribe by %2$s",
|
"death.attack.unicopia.tribe_swap.player": "%1$s was doomed to be reborn into a different tribe by %2$s",
|
||||||
"death.attack.sun": "%1$s stared into the sun",
|
"death.attack.unicopia.sun": "%1$s stared into the sun",
|
||||||
"death.attack.sun.player": "%1$s stared into the sun whilst fighting %2$s",
|
"death.attack.unicopia.sun.player": "%1$s stared into the sun whilst fighting %2$s",
|
||||||
"death.attack.sunlight": "%1$s was burned by the sun",
|
"death.attack.unicopia.sunlight": "%1$s was burned by the sun",
|
||||||
"death.attack.sunlight.player": "%1$s was burned by the sun whilst fighting %2$s",
|
"death.attack.unicopia.sunlight.player": "%1$s was burned by the sun whilst fighting %2$s",
|
||||||
"death.attack.petrified": "%1$s turned to stone",
|
"death.attack.unicopia.petrified": "%1$s turned to stone",
|
||||||
"death.attack.petrified.player": "%1$s turned to stone whilst fighting %2$s",
|
"death.attack.unicopia.petrified.player": "%1$s turned to stone whilst fighting %2$s",
|
||||||
"death.attack.magical_exhaustion": "%1$s exhausted themselves",
|
"death.attack.unicopia.magical_exhaustion": "%1$s exhausted themselves",
|
||||||
"death.attack.magical_exhaustion.player": "%1$s exhausted themselves whilst fighting %2$s",
|
"death.attack.unicopia.magical_exhaustion.player": "%1$s exhausted themselves whilst fighting %2$s",
|
||||||
"death.attack.alicorn_amulet": "%1$s was driven insane",
|
"death.attack.unicopia.alicorn_amulet": "%1$s was driven insane",
|
||||||
"death.attack.alicorn_amulet.player": "%1$s went insane whilst fighting %2$s",
|
"death.attack.unicopia.alicorn_amulet.player": "%1$s went insane whilst fighting %2$s",
|
||||||
"death.attack.darkness": "%1$s went missing",
|
"death.attack.unicopia.darkness": "%1$s went missing",
|
||||||
"death.attack.love_draining": "%1$s was drained of all life",
|
"death.attack.unicopia.love_draining": "%1$s was drained of all life",
|
||||||
"death.attack.love_draining.player": "%1$s died to feed %2$s",
|
"death.attack.unicopia.love_draining.player": "%1$s died to feed %2$s",
|
||||||
"death.attack.life_draining": "%1$s was drained of all life",
|
"death.attack.unicopia.life_draining": "%1$s was drained of all life",
|
||||||
"death.attack.life_draining.self": "%1$s was killed by their own spell",
|
"death.attack.unicopia.life_draining.self": "%1$s was killed by their own spell",
|
||||||
"death.attack.life_draining.player": "%1$s was killed by a spell cast by %2$s",
|
"death.attack.unicopia.life_draining.player": "%1$s was killed by a spell cast by %2$s",
|
||||||
"death.attack.bat_screech": "%1$s was frightened to death",
|
"death.attack.unicopia.bat_screech": "%1$s was frightened to death",
|
||||||
"death.attack.bat_screech.player": "%2$s scared %1$s",
|
"death.attack.unicopia.bat_screech.player": "%2$s scared %1$s",
|
||||||
"death.attack.bat_screech.item": "%1$s was frightened to death by %2$s using %3$s",
|
"death.attack.unicopia.bat_screech.item": "%1$s was frightened to death by %2$s using %3$s",
|
||||||
"death.attack.bat_screech.self": "%1$s scared themselves to death",
|
"death.attack.unicopia.bat_screech.self": "%1$s scared themselves to death",
|
||||||
"death.attack.gravity_well_recoil": "%1$s turned into spaghetti",
|
"death.attack.unicopia.gravity_well_recoil": "%1$s turned into spaghetti",
|
||||||
"death.attack.gravity_well_recoil.player": "%1$s turned into spaghetti by a spell cast by %2$s",
|
"death.attack.unicopia.gravity_well_recoil.player": "%1$s turned into spaghetti by a spell cast by %2$s",
|
||||||
"death.attack.gravity_well_recoil.item": "%1$s turned into spaghetti by a spell cast by %2$s using %3$s",
|
"death.attack.unicopia.gravity_well_recoil.item": "%1$s turned into spaghetti by a spell cast by %2$s using %3$s",
|
||||||
"death.attack.gravity_well_recoil.self": "%1$s cast a spell that turned them into spaghetti",
|
"death.attack.unicopia.gravity_well_recoil.self": "%1$s cast a spell that turned them into spaghetti",
|
||||||
"death.attack.smash": "%1$s was crushed under hoof",
|
"death.attack.unicopia.smash": "%1$s was crushed under hoof",
|
||||||
"death.attack.smash.player": "%1$s was crushed by %2$s",
|
"death.attack.unicopia.smash.player": "%1$s was crushed by %2$s",
|
||||||
"death.attack.zap": "%1$s bit into a Zap Apple",
|
"death.attack.unicopia.zap": "%1$s bit into a Zap Apple",
|
||||||
"death.attack.zap.player": "%1$s bit into a Zap Apple whilst fighting %2$s",
|
"death.attack.unicopia.zap.player": "%1$s bit into a Zap Apple whilst fighting %2$s",
|
||||||
"death.attack.paradox": "%1$s imploded",
|
"death.attack.unicopia.paradox": "%1$s imploded",
|
||||||
"death.attack.paradox.player": "%1$s imploded with some help from %2$s",
|
"death.attack.unicopia.paradox.player": "%1$s imploded with some help from %2$s",
|
||||||
"death.attack.food_poisoning": "%1$s died of food poisoning",
|
"death.attack.unicopia.food_poisoning": "%1$s died of food poisoning",
|
||||||
"death.attack.food_poisoning.player": "%2$s poisoned %1$s to death",
|
"death.attack.unicopia.food_poisoning.player": "%2$s poisoned %1$s to death",
|
||||||
"death.attack.black_hole": "%1$s was sucked into a black hole",
|
"death.attack.unicopia.black_hole": "%1$s was sucked into a black hole",
|
||||||
"death.attack.black_hole.player": "%1$s got sucked into %2$s's black hole",
|
"death.attack.unicopia.black_hole.player": "%1$s got sucked into %2$s's black hole",
|
||||||
"death.attack.kick": "%1$s was kicked really hard",
|
"death.attack.unicopia.kick": "%1$s was kicked really hard",
|
||||||
"death.attack.kick.player": "%2$s kicked %1$s really hard",
|
"death.attack.unicopia.kick.player": "%2$s kicked %1$s really hard",
|
||||||
"death.attack.steamroller": "%1$s was flattened",
|
"death.attack.unicopia.steamroller": "%1$s was flattened",
|
||||||
"death.attack.steamroller.player": "%2$s steamrolled %1$s",
|
"death.attack.unicopia.steamroller.player": "%2$s steamrolled %1$s",
|
||||||
"death.attack.stalagmite.pegasus": "%1$s tried to perch on a stalagmite",
|
"death.attack.unicopia.stalagmite.pegasus": "%1$s tried to perch on a stalagmite",
|
||||||
"death.attack.stalagmite.pegasus.player": "%1$s flew into a stalagmite whilst fighting %2$s",
|
"death.attack.unicopia.stalagmite.pegasus.player": "%1$s flew into a stalagmite whilst fighting %2$s",
|
||||||
|
|
||||||
"death.fell.accident.ladder.pegasus": "%1$s forgot they could fly and fell off a ladder",
|
"death.fell.accident.ladder.pegasus": "%1$s forgot they could fly and fell off a ladder",
|
||||||
"death.fell.accident.vines.pegasus": "%1$s forgot they could fly and fell off some vines",
|
"death.fell.accident.vines.pegasus": "%1$s forgot they could fly and fell off some vines",
|
||||||
|
|
Loading…
Reference in a new issue