From e8423ce9fda082fc812a31f16d26899c6cd86ef4 Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Sun, 19 Apr 2026 17:32:38 -0700 Subject: [PATCH 1/2] Added context.new_material and rephrased context.material --- .../entity/EntityFormsBlockScriptEvent.java | 21 +++++++++++++------ .../utilities/BukkitImplDeprecations.java | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java index 95d02da061..724a15d67b 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java @@ -1,10 +1,11 @@ package com.denizenscript.denizen.events.entity; +import com.denizenscript.denizen.events.BukkitScriptEvent; import com.denizenscript.denizen.objects.EntityTag; import com.denizenscript.denizen.objects.LocationTag; import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizen.utilities.BukkitImplDeprecations; import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; -import com.denizenscript.denizen.events.BukkitScriptEvent; import com.denizenscript.denizencore.objects.ObjectTag; import com.denizenscript.denizencore.scripts.ScriptEntryData; import org.bukkit.event.EventHandler; @@ -28,7 +29,8 @@ public class EntityFormsBlockScriptEvent extends BukkitScriptEvent implements Li // // @Context // returns the LocationTag the block. - // returns the MaterialTag of the block. + // returns the MaterialTag of the original block. + // returns the MaterialTag of the block that will be formed. // returns the EntityTag that formed the block. // // --> @@ -37,7 +39,8 @@ public EntityFormsBlockScriptEvent() { registerCouldMatcher(" forms "); } - public MaterialTag material; + public MaterialTag old_material; + public MaterialTag new_material; public LocationTag location; public EntityTag entity; public EntityBlockFormEvent event; @@ -47,7 +50,7 @@ public boolean matches(ScriptPath path) { if (!path.tryArgObject(0, entity)) { return false; } - if (!path.tryArgObject(2, material)) { + if (!path.tryArgObject(2, new_material)) { return false; } if (!runInCheck(path, location)) { @@ -65,7 +68,12 @@ public ScriptEntryData getScriptEntryData() { public ObjectTag getContext(String name) { return switch (name) { case "location" -> location; - case "material" -> material; + case "material" -> { + BukkitImplDeprecations.entityFormsBlockMaterialContext.warn(); + yield old_material; + } + case "old_material" -> old_material; + case "new_material" -> new_material; case "entity" -> entity; default -> super.getContext(name); }; @@ -74,7 +82,8 @@ public ObjectTag getContext(String name) { @EventHandler public void onEntityFormsBlock(EntityBlockFormEvent event) { location = new LocationTag(event.getBlock().getLocation()); - material = new MaterialTag(event.getBlock()); + old_material = new MaterialTag(event.getBlock()); + new_material = new MaterialTag(event.getNewState()); entity = new EntityTag(event.getEntity()); this.event = event; fire(event); diff --git a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java index 1b6a37b84a..bdbdc1027a 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java +++ b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java @@ -489,6 +489,9 @@ public class BukkitImplDeprecations { // Added 2025/09/22 public static Warning playerSteerEntityEvent = new FutureWarning("playerSteerEntityEvent", "The 'player steers ' event is deprecated in favor of the 'player input' event in MC 1.21+."); + // Added 2026/04/19 + public static Warning entityFormsBlockMaterialContext = new FutureWarning("entityFormsBlockMaterialContext", "'context.material' in the 'entity forms block' script event is deprecated in favor of 'context.old_material'."); + // ==================== PAST deprecations of things that are already gone but still have a warning left behind ==================== // Removed upstream 2023/10/29 without warning. From 65e40ff40f38855c460e0ab77d76f17828410f61 Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Mon, 20 Apr 2026 13:17:37 -0700 Subject: [PATCH 2/2] minor changes --- .../entity/EntityFormsBlockScriptEvent.java | 21 ++++++------------- .../utilities/BukkitImplDeprecations.java | 3 --- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java index 724a15d67b..c282dbf1b1 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityFormsBlockScriptEvent.java @@ -4,7 +4,6 @@ import com.denizenscript.denizen.objects.EntityTag; import com.denizenscript.denizen.objects.LocationTag; import com.denizenscript.denizen.objects.MaterialTag; -import com.denizenscript.denizen.utilities.BukkitImplDeprecations; import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; import com.denizenscript.denizencore.objects.ObjectTag; import com.denizenscript.denizencore.scripts.ScriptEntryData; @@ -28,9 +27,8 @@ public class EntityFormsBlockScriptEvent extends BukkitScriptEvent implements Li // For example, when a snowman forms snow. // // @Context - // returns the LocationTag the block. - // returns the MaterialTag of the original block. - // returns the MaterialTag of the block that will be formed. + // returns the LocationTag of the block. + // returns the MaterialTag of what the block will become. // returns the EntityTag that formed the block. // // --> @@ -39,8 +37,7 @@ public EntityFormsBlockScriptEvent() { registerCouldMatcher(" forms "); } - public MaterialTag old_material; - public MaterialTag new_material; + public MaterialTag material; public LocationTag location; public EntityTag entity; public EntityBlockFormEvent event; @@ -50,7 +47,7 @@ public boolean matches(ScriptPath path) { if (!path.tryArgObject(0, entity)) { return false; } - if (!path.tryArgObject(2, new_material)) { + if (!path.tryArgObject(2, material)) { return false; } if (!runInCheck(path, location)) { @@ -68,12 +65,7 @@ public ScriptEntryData getScriptEntryData() { public ObjectTag getContext(String name) { return switch (name) { case "location" -> location; - case "material" -> { - BukkitImplDeprecations.entityFormsBlockMaterialContext.warn(); - yield old_material; - } - case "old_material" -> old_material; - case "new_material" -> new_material; + case "material" -> material; case "entity" -> entity; default -> super.getContext(name); }; @@ -82,8 +74,7 @@ public ObjectTag getContext(String name) { @EventHandler public void onEntityFormsBlock(EntityBlockFormEvent event) { location = new LocationTag(event.getBlock().getLocation()); - old_material = new MaterialTag(event.getBlock()); - new_material = new MaterialTag(event.getNewState()); + material = new MaterialTag(event.getNewState()); entity = new EntityTag(event.getEntity()); this.event = event; fire(event); diff --git a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java index bdbdc1027a..1b6a37b84a 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java +++ b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java @@ -489,9 +489,6 @@ public class BukkitImplDeprecations { // Added 2025/09/22 public static Warning playerSteerEntityEvent = new FutureWarning("playerSteerEntityEvent", "The 'player steers ' event is deprecated in favor of the 'player input' event in MC 1.21+."); - // Added 2026/04/19 - public static Warning entityFormsBlockMaterialContext = new FutureWarning("entityFormsBlockMaterialContext", "'context.material' in the 'entity forms block' script event is deprecated in favor of 'context.old_material'."); - // ==================== PAST deprecations of things that are already gone but still have a warning left behind ==================== // Removed upstream 2023/10/29 without warning.