|
@@ -715,9 +715,29 @@ public class ScriptEvents implements BlockHarvest, Craft {
|
|
|
@SubscribeEvent(receiveCanceled = true)
|
|
|
public void onMobGriefing(EntityMobGriefingEvent e) {
|
|
|
handleEvent(e, "mob_griefing", (sc) -> {
|
|
|
- setEntity(sc, e.getEntity());
|
|
|
- sc.setVar("cancel",
|
|
|
- !e.getEntity().world.getGameRules().getBoolean(GameRules.MOB_GRIEFING));
|
|
|
+ Entity ent = e.getEntity();
|
|
|
+ setEntity(sc, ent);
|
|
|
+ if(ent != null) {
|
|
|
+ World w = ent.world;
|
|
|
+ if(w != null) {
|
|
|
+ GameRules rules = w.getGameRules();
|
|
|
+ if(rules != null) {
|
|
|
+ boolean b = true;
|
|
|
+ try {
|
|
|
+ b = !rules.getBoolean(GameRules.MOB_GRIEFING);
|
|
|
+ } catch(Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ sc.setVar("cancel", b);
|
|
|
+ } else {
|
|
|
+ System.out.println("Rules are null");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ System.out.println("World is null");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ System.out.println("Entity is null");
|
|
|
+ }
|
|
|
}, (sc) -> {
|
|
|
handleVar(sc, "mob_griefing", "cancel", (v) -> {
|
|
|
e.setResult(v.getBoolean(sc) ? Result.DENY : Result.ALLOW);
|