Implemented mechanics

This commit is contained in:
2021-08-03 01:26:08 +02:00
parent 5510a73c20
commit 220c7c7ff7
4 changed files with 29 additions and 17 deletions

View File

@@ -1,7 +1,9 @@
package de.steev.bm.events;
import de.steev.bm.changes.interaction.replanting;
import de.steev.bm.main;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -16,12 +18,6 @@ public class InteractEvent implements Listener {
this.plugin = plugin;
}
/**
* Carrot: Carrot 3
* Potato: potato 2
* Wheat: 2 Wheat, 2 Wheat Seeds
* Beetroots: 1 Beetroot, 3 Beetroot seeds
*/
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event){
if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
@@ -30,17 +26,30 @@ public class InteractEvent implements Listener {
Block target = event.getClickedBlock();
/** the location of the clicked block */
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
Material[] drops;
int[] amounts;
// Detects which type to replant
// TODO: do the replant implementation
switch(target.getType().toString()){
case "CARROT":
case "CARROTS":
/** Droping items */
drops = new Material[] { Material.CARROT };
amounts = new int[] {3};
replanting.planting(drops, amounts, target);
break;
case "POTATO":
case "POTATOES":
drops = new Material[] { Material.POTATO };
amounts = new int[] {2};
replanting.planting(drops, amounts, target);
break;
case "WHEAT":
drops = new Material[] { Material.WHEAT, Material.WHEAT_SEEDS };
amounts = new int[] {1,2};
replanting.planting(drops, amounts, target);
break;
case "BEETROOT":
case "BEETROOTS":
drops = new Material[] { Material.BEETROOT, Material.BEETROOT_SEEDS };
amounts = new int[] {1,2};
replanting.planting(drops, amounts, target);
break;
}
}