Skip to content

Commit

Permalink
Add removeEntity for world instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
LLytho committed Jun 23, 2022
1 parent 580a647 commit 3d0c776
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## [Unreleased]
- /
-

## [1.1.7]
- Add `removeEntity` for world instructions

## [1.1.6-beta]
- Fix https://github.com/AlmostReliable/ponderjs-forge/issues/4

Expand All @@ -29,6 +32,7 @@

<!-- Versions -->
[unreleased]: https://github.com/AlmostReliable/ponderjs-forge/compare/v1.18-1.1.1...HEAD
[1.1.7-beta]: https://github.com/AlmostReliable/ponderjs-forge/releases/tag/v1.18-1.1.7
[1.1.6-beta]: https://github.com/AlmostReliable/ponderjs-forge/releases/tag/v1.18-1.1.6-beta
[1.1.5-beta]: https://github.com/AlmostReliable/ponderjs-forge/releases/tag/v1.18-1.1.5-beta
[1.1.4-beta]: https://github.com/AlmostReliable/ponderjs-forge/releases/tag/v1.18-1.1.4-beta
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.daemon=false
# Mod data
mod_id=ponderjs
mod_name=PonderJS
mod_version=1.1.6
mod_version=1.1.7
mod_base_package=com.almostreliable
mod_authors=kotakotik22, AlmostReliable
mod_description=Allows creating ponder scenes and tags with KubeJS.
Expand Down
16 changes: 16 additions & 0 deletions run/kubejs/client_scripts/removeEntity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
onEvent("ponder.registry", (event) => {
event
.create("minecraft:dirt")
.scene("removing_an_entity", "Yeet", (scene, util) => {
scene.showStructure();
scene.idle(10);

const centerBlockPos = util.grid.at(2, 0, 2);
const centerTop = util.vector.topOf(centerBlockPos);

const entity = scene.world.createEntity("sheep", centerTop);
scene.idle(30);
scene.world.removeEntity(entity);
scene.idle(60);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ public void modifyBlocks(Selection selection, UnaryOperator<BlockState> stateFun
public void modifyBlock(BlockPos pos, UnaryOperator<BlockState> stateFunc, boolean spawnParticles) {
super.modifyBlock(pos, stateFunc, spawnParticles);
}

public void removeEntity(ElementLink<EntityElement> link) {
addInstruction(scene -> {
EntityElement resolve = scene.resolve(link);
if (resolve != null) {
resolve.ifPresent(Entity::discard);
}
});
}
}

public class ExtendedSpecialInstructions extends SpecialInstructions {
Expand Down

0 comments on commit 3d0c776

Please sign in to comment.