Fix bed rule for no-sleep dimensions

- Write destroy_on_use instead of the unknown explodes key
- Test bed rules for overworld, nether and end bases
This commit is contained in:
Brian Fopiano committed 2026-11-28 08:18:44 -05:00
1 parent 77969617d8
commit c71feb62e0
2 files changed
+46 -1

No files matched your search

@@ -143,7 +143,7 @@ public class DataFixerV1217 extends DataFixerV1213 {
attributes.put("minecraft:gameplay/bed_rule", new JSONObject()
.put("can_set_spawn", "never")
.put("can_sleep", "never")
.put("explodes", true));
.put("destroy_on_use", true));
}
attributes.put("minecraft:gameplay/respawn_anchor_works", json.remove("respawn_anchor_works"));
@@ -0,0 +1,45 @@
package art.arcane.iris.pack.datapack.v1217;
import art.arcane.iris.pack.datapack.IDataFixer.Dimension;
import art.arcane.volmlib.util.json.JSONObject;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class DataFixerV1217BedRuleTest {
private final DataFixerV1217 fixer = new DataFixerV1217();
@Test
public void overworldBedsSleepWhenDark() {
JSONObject rule = bedRule(Dimension.OVERWORLD);
assertEquals("when_dark", rule.getString("can_sleep"));
assertEquals("always", rule.getString("can_set_spawn"));
assertTrue(rule.has("error_message"));
}
@Test
public void netherBedsAreDestroyedOnUse() {
assertDestroyedOnUse(bedRule(Dimension.NETHER));
}
@Test
public void endBedsAreDestroyedOnUse() {
assertDestroyedOnUse(bedRule(Dimension.END));
}
private JSONObject bedRule(Dimension dimension) {
return fixer.createDimension(dimension, -64, 384, 384, null)
.getJSONObject("attributes")
.getJSONObject("minecraft:gameplay/bed_rule");
}
private static void assertDestroyedOnUse(JSONObject rule) {
assertEquals("never", rule.getString("can_sleep"));
assertEquals("never", rule.getString("can_set_spawn"));
assertTrue(rule.getBoolean("destroy_on_use"));
assertFalse(rule.has("explodes"));
}
}