mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
2.1.116
This commit is contained in:
parent
6168309ec9
commit
4cd91350db
@ -1,3 +1,6 @@
|
|||||||
|
Version 2.1.116
|
||||||
|
Fixed directional plants not maintaining their direction when replanted
|
||||||
|
|
||||||
Version 2.1.115
|
Version 2.1.115
|
||||||
Green Thumb now requires a hoe to activate
|
Green Thumb now requires a hoe to activate
|
||||||
Hoes no longer give free replants
|
Hoes no longer give free replants
|
||||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>2.1.115</version>
|
<version>2.1.116</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -6,8 +6,11 @@ import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.data.Ageable;
|
import org.bukkit.block.data.Ageable;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.Directional;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@ -18,6 +21,7 @@ public class DelayedCropReplant extends BukkitRunnable {
|
|||||||
private final Material cropMaterial;
|
private final Material cropMaterial;
|
||||||
private boolean wasImmaturePlant;
|
private boolean wasImmaturePlant;
|
||||||
private final BlockBreakEvent blockBreakEvent;
|
private final BlockBreakEvent blockBreakEvent;
|
||||||
|
private BlockFace cropFace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replants a crop after a delay setting the age to desiredCropAge
|
* Replants a crop after a delay setting the age to desiredCropAge
|
||||||
@ -25,6 +29,13 @@ public class DelayedCropReplant extends BukkitRunnable {
|
|||||||
* @param desiredCropAge desired age of the crop
|
* @param desiredCropAge desired age of the crop
|
||||||
*/
|
*/
|
||||||
public DelayedCropReplant(BlockBreakEvent blockBreakEvent, BlockState cropState, int desiredCropAge, boolean wasImmaturePlant) {
|
public DelayedCropReplant(BlockBreakEvent blockBreakEvent, BlockState cropState, int desiredCropAge, boolean wasImmaturePlant) {
|
||||||
|
BlockData cropData = cropState.getBlockData();
|
||||||
|
|
||||||
|
if(cropData instanceof Directional) {
|
||||||
|
Directional cropDir = (Directional) cropData;
|
||||||
|
cropFace = cropDir.getFacing();
|
||||||
|
}
|
||||||
|
|
||||||
//The plant was either immature or something cancelled the event, therefor we need to treat it differently
|
//The plant was either immature or something cancelled the event, therefor we need to treat it differently
|
||||||
this.blockBreakEvent = blockBreakEvent;
|
this.blockBreakEvent = blockBreakEvent;
|
||||||
this.wasImmaturePlant = wasImmaturePlant;
|
this.wasImmaturePlant = wasImmaturePlant;
|
||||||
@ -51,22 +62,33 @@ public class DelayedCropReplant extends BukkitRunnable {
|
|||||||
//The space is not currently occupied by a block so we can fill it
|
//The space is not currently occupied by a block so we can fill it
|
||||||
cropBlock.setType(cropMaterial);
|
cropBlock.setType(cropMaterial);
|
||||||
|
|
||||||
|
|
||||||
//Get new state (necessary?)
|
//Get new state (necessary?)
|
||||||
BlockState newState = cropBlock.getState();
|
BlockState newState = cropBlock.getState();
|
||||||
// newState.update();
|
BlockData newData = newState.getBlockData();
|
||||||
|
|
||||||
Ageable ageable = (Ageable) newState.getBlockData();
|
int age = 0;
|
||||||
|
|
||||||
//Crop age should always be 0 if the plant was immature
|
//Crop age should always be 0 if the plant was immature
|
||||||
if(wasImmaturePlant) {
|
if(!wasImmaturePlant) {
|
||||||
ageable.setAge(0);
|
age = desiredCropAge;
|
||||||
} else {
|
|
||||||
//Otherwise make the plant the desired age
|
//Otherwise make the plant the desired age
|
||||||
ageable.setAge(desiredCropAge);
|
}
|
||||||
|
|
||||||
|
if(newData instanceof Directional) {
|
||||||
|
//Cocoa Version
|
||||||
|
Directional directional = (Directional) newState.getBlockData();
|
||||||
|
directional.setFacing(cropFace);
|
||||||
|
|
||||||
|
newState.setBlockData(directional);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Age the crop
|
//Age the crop
|
||||||
|
Ageable ageable = (Ageable) newState.getBlockData();
|
||||||
|
ageable.setAge(age);
|
||||||
newState.setBlockData(ageable);
|
newState.setBlockData(ageable);
|
||||||
|
|
||||||
|
|
||||||
newState.update(true);
|
newState.update(true);
|
||||||
|
|
||||||
//Play an effect
|
//Play an effect
|
||||||
|
Loading…
Reference in New Issue
Block a user