Make payload blocks run onDestroyed() of the block payload it carries when destroyed. (#8253)

* Payloads go boom.

* When a payload unit dies too

* Keep the functionality, but limit it to a rule
This commit is contained in:
MEEPofFaith
2024-03-29 12:17:19 -07:00
committed by GitHub
parent 520c423a59
commit d8c1ea17e1
8 changed files with 28 additions and 0 deletions

View File

@@ -51,6 +51,11 @@ public class BuildPayload implements Payload{
build.updatePayload(unitHolder, buildingHolder);
}
@Override
public void destroyed(){
build.onDestroyed();
}
@Override
public ItemStack[] requirements(){
return build.block.requirements;

View File

@@ -54,6 +54,8 @@ public interface Payload extends Position{
return 0f;
}
default void destroyed(){};
/** writes the payload for saving. */
void write(Writes write);

View File

@@ -151,6 +151,12 @@ public class PayloadBlock extends Block{
}
}
@Override
public void onDestroyed(){
if(payload != null) payload.destroyed();
super.onDestroyed();
}
public boolean blends(int direction){
return PayloadBlock.blends(this, direction);
}

View File

@@ -190,6 +190,12 @@ public class PayloadConveyor extends Block{
super.draw();
}
@Override
public void onDestroyed(){
if(item != null) item.destroyed();
super.onDestroyed();
}
@Override
public void draw(){
super.draw();