29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""The singularity must ask the protection layer before removing a block and respect mobGriefing for its blast."""
|
|
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
SRC = (ROOT / "src/main/java/com/pengu/thaumcraft/additions/entity/EntitySingularity.java").read_text(encoding="utf-8")
|
|
GUARD = (ROOT / "src/main/java/com/pengu/thaumcraft/additions/misc/TerritoryGuard.java").read_text(encoding="utf-8")
|
|
|
|
|
|
def main():
|
|
assert "new BlockEvent.BreakEvent(" in GUARD and "EVENT_BUS.post(event)" in GUARD
|
|
assert "FakePlayerFactory.getMinecraft" in GUARD
|
|
|
|
# the block-eating branch is gated by the guard before any breakBlock / setBlockToAir
|
|
gate = SRC.index("this.canDestroy(i, var22, var23)")
|
|
assert gate < SRC.index(".breakBlock(this.worldObj, i, var22, var23"), "guard must precede breakBlock"
|
|
assert gate < SRC.index("this.worldObj.setBlockToAir(i, var22, var23)")
|
|
assert "TerritoryGuard.canRemoveBlock(this.worldObj, x, y, z, this.getOwnerEntity())" in SRC
|
|
|
|
# explosion attribution accessor, plus the end-of-life blast no longer ignores mobGriefing
|
|
assert "public EntityPlayer getOwnerEntity()" in SRC
|
|
assert 'this.suckedItems / 200.0F, true)' not in SRC
|
|
print("ok")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|