|
主程序- package net.kuakeh.closetoreality.procedures;
- import net.minecraft.world.entity.LivingEntity;
- import net.minecraft.world.entity.Entity;
- import net.minecraft.world.damagesource.DamageSource;
- import net.kuakeh.closetoreality.ClosetorealityMod;
- import java.util.Map;
- import java.util.HashMap;
- public class WhentouchingmagmaProcedure {
- public WhentouchingmagmaProcedure() {
- PlayerTickEvents.END.register((player) -> {
- Map<String, Object> dependencies = new HashMap<>();
- dependencies.put("entity", player);
- dependencies.put("x", player.getX());
- dependencies.put("y", player.getY());
- dependencies.put("z", player.getZ());
- dependencies.put("world", player.level);
- execute(dependencies);
- });
- }
- public static void execute(Map<String, Object> dependencies) {
- if (dependencies.get("entity") == null) {
- if (!dependencies.containsKey("entity"))
- ClosetorealityMod.LOGGER.warn("Failed to load dependency entity for procedure Whentouchingmagma!");
- return;
- }
- Entity entity = (Entity) dependencies.get("entity");
- if (entity.isInLava()) {
- if (entity instanceof LivingEntity _entity)
- _entity.hurt(new DamageSource("touchingmagma").bypassArmor(), 1);
- }
- }
- }
复制代码
唯一的流程
- /*
- * MCreator note: This file will be REGENERATED on each build.
- */
- package net.kuakeh.closetoreality.init;
- import net.kuakeh.closetoreality.procedures.WhentouchingmagmaProcedure;
- @SuppressWarnings("InstantiationOfUtilityClass")
- public class ClosetorealityModProcedures {
- public static void load() {
- new WhentouchingmagmaProcedure();
- }
- }
复制代码 |
|