Browse Source

entity leave world snuvi event

Kajetan Johannes Hammerle 2 years ago
parent
commit
6138617ce0

+ 10 - 5
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -15,6 +15,7 @@ import me.km.utils.*;
 import net.minecraft.block.*;
 import net.minecraft.command.ICommandSource;
 import net.minecraft.entity.*;
+import net.minecraft.entity.item.FallingBlockEntity;
 import net.minecraft.entity.player.*;
 import net.minecraft.inventory.*;
 import net.minecraft.inventory.container.ClickType;
@@ -683,6 +684,14 @@ public class ScriptEvents implements BlockHarvest, Craft {
         });
     }
 
+    @SubscribeEvent(receiveCanceled = true)
+    public void onEntityLeaveWorld(EntityLeaveWorldEvent e) {
+        Entity ent = e.getEntity();
+        handleEvent(e, "entity_leave", (sc) -> {
+            setEntity(sc, ent);
+        });
+    }
+
     @SubscribeEvent
     public void onServerTick(TickEvent.ServerTickEvent e) {
         if(e.phase == TickEvent.Phase.END) {
@@ -724,11 +733,7 @@ public class ScriptEvents implements BlockHarvest, Craft {
                     GameRules rules = w.getGameRules();
                     if(rules != null) {
                         try {
-                            Boolean br = rules.getBoolean(GameRules.MOB_GRIEFING);
-                            if(br == null) {
-                                System.out.println("Boolean is null");
-                            }
-                            b = !br;
+                            b = !rules.getBoolean(GameRules.MOB_GRIEFING);
                         } catch(Exception ex) {
                             System.out.println("onMobGriefing Exception");
                             ex.printStackTrace();

+ 1 - 1
src/main/resources/META-INF/mods.toml

@@ -3,7 +3,7 @@ loaderVersion="[35,)"
 license="All rights reserved"
 [[mods]]
 modId="km"
-version="0.0.47"
+version="0.0.48"
 displayName="Kajetans Mod"
 credits="kajetanjohannes"
 authors="kajetanjohannes"