Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root.setOnMousePressed(event -> {
- for (Node n : root.getChildren()) {
- if (n instanceof Block) {
- Block block = (Block) n;
- block.setOnMouseClicked(e -> {
- if (event.getButton() == MouseButton.PRIMARY) {
- Object obj = e.getSource();
- if (obj instanceof Block) {
- Block b = (Block) obj;
- Block newB = new Block("minecraft_cobblestone.png", true);
- newB.setTranslateX(b.getTranslateX());
- newB.setTranslateY(b.getTranslateY());
- newB.setDepth(20);
- newB.setTranslateZ(b.getTranslateZ() - 20);
- newB.setHeight(20);
- newB.setWidth(20);
- root.getChildren().add(newB);
- }
- }
- if (event.getButton() == MouseButton.SECONDARY) {
- Object obj = e.getSource();
- if (obj instanceof Block) {
- Block b = (Block) obj;
- if (b.isBreakable()) {
- root.getChildren().remove(b);
- }
- }
- }
- });
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement