Fix GT replant sometimes planting floating plants

This commit is contained in:
nossr50 2020-11-10 13:17:58 -08:00
parent 7887232d93
commit 8f6819edc5
4 changed files with 72 additions and 7 deletions

View File

@ -1,10 +1,13 @@
Version 2.1.156
Fixed a bug where Green Thumb would replant blocks floating in the air
Fixed a bug where the admin and party chat toggles in chat.yml didn't function as intended
* Fixed a bug where Master Angler rank 1 level requirement was set too high (default configs)
Added some errors that trigger if a plugin hooking into mcMMO is grabbing leaderboards for child skills through our SQL/FlatFile class (which don't exist)
mcMMO will automatically fix some errors in logic for user settings in skillranks.yml
Corrected some logic errors when checking for oddities in skillranks.yml
* Fixed a bug where Master Angler rank 1 was set too high (default configs)
Removed incorrect translations of Master Angler from various locales
Modified Master Angler stat lines in /fishing
Updated Green Thumb description to mention that it needs a hoe
NOTES:
You don't need to touch your config files, this update handles everything automagically.

View File

@ -11,8 +11,11 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Cocoa;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DelayedCropReplant extends BukkitRunnable {
@ -21,7 +24,7 @@ public class DelayedCropReplant extends BukkitRunnable {
private final Material cropMaterial;
private boolean wasImmaturePlant;
private final BlockBreakEvent blockBreakEvent;
private BlockFace cropFace;
private @Nullable BlockFace cropFace;
/**
* Replants a crop after a delay setting the age to desiredCropAge
@ -48,6 +51,7 @@ public class DelayedCropReplant extends BukkitRunnable {
public void run() {
Block cropBlock = cropLocation.getBlock();
BlockState currentState = cropBlock.getState();
PlantAnchorType plantAnchorType = PlantAnchorType.NORMAL;
//Remove the metadata marking the block as recently replanted
new markPlantAsOld(blockBreakEvent.getBlock().getLocation()).runTaskLater(mcMMO.p, 10);
@ -81,6 +85,10 @@ public class DelayedCropReplant extends BukkitRunnable {
directional.setFacing(cropFace);
newState.setBlockData(directional);
if(newData instanceof Cocoa) {
plantAnchorType = PlantAnchorType.COCOA;
}
}
//Age the crop
@ -89,15 +97,69 @@ public class DelayedCropReplant extends BukkitRunnable {
newState.setBlockData(ageable);
newState.update(true);
newState.update(true, true);
//Play an effect
ParticleEffectUtils.playGreenThumbEffect(cropLocation);
new PhysicsBlockUpdate(newState.getBlock(), cropFace, plantAnchorType).runTaskLater(mcMMO.p, 1);
}
}
private enum PlantAnchorType {
NORMAL,
COCOA
}
private static class PhysicsBlockUpdate extends BukkitRunnable {
private final Block plantBlock;
private final PlantAnchorType plantAnchorType;
private BlockFace plantFace;
private PhysicsBlockUpdate(@NotNull Block plantBlock, @Nullable BlockFace plantFace, @NotNull PlantAnchorType plantAnchorType) {
this.plantBlock = plantBlock;
this.plantAnchorType = plantAnchorType;
if(plantFace != null) {
this.plantFace = plantFace;
}
}
@Override
public void run() {
//Update neighbors
switch (plantAnchorType) {
case COCOA:
checkPlantIntegrity(plantFace);
break;
case NORMAL:
checkPlantIntegrity(BlockFace.DOWN);
break;
}
}
private void checkPlantIntegrity(@NotNull BlockFace blockFace) {
Block neighbor = plantBlock.getRelative(blockFace);
if(plantAnchorType == PlantAnchorType.COCOA) {
if(!neighbor.getType().toString().toLowerCase().contains("jungle")) {
plantBlock.breakNaturally();
}
} else {
switch (neighbor.getType()) {
case AIR:
case CAVE_AIR:
case WATER:
case LAVA:
plantBlock.breakNaturally();
break;
default:
}
}
}
}
private static class markPlantAsOld extends BukkitRunnable {
private final Location cropLoc;

View File

@ -28,7 +28,7 @@ public class StringUtils {
}
public static String ticksToSeconds(double ticks) {
return shortDecimal.format(ticks / 20) + "s";
return shortDecimal.format(ticks / 20);
}

View File

@ -252,8 +252,8 @@ Fishing.SubSkill.FishermansDiet.Description=Improves hunger restored from fished
Fishing.SubSkill.FishermansDiet.Stat=Fisherman's Diet:&a Rank {0}
Fishing.SubSkill.MasterAngler.Name=Master Angler
Fishing.SubSkill.MasterAngler.Description=Fish are caught more frequently
Fishing.SubSkill.MasterAngler.Stat=Fishing minimum wait time bonus: &a-{0} seconds
Fishing.SubSkill.MasterAngler.Stat.Extra=Fishing maximum wait time bonus: &a-{0} seconds
Fishing.SubSkill.MasterAngler.Stat=Fishing min wait time reduction: &a-{0} seconds
Fishing.SubSkill.MasterAngler.Stat.Extra=Fishing max wait time reduction: &a-{0} seconds
Fishing.SubSkill.IceFishing.Name=Ice Fishing
Fishing.SubSkill.IceFishing.Description=Allows you to fish in icy biomes
Fishing.SubSkill.IceFishing.Stat=Ice Fishing
@ -274,7 +274,7 @@ Herbalism.SubSkill.GreenTerra.Name=Green Terra
Herbalism.SubSkill.GreenTerra.Description=Spread the Terra, 3x Drops, Boosts Green Thumb
Herbalism.SubSkill.GreenTerra.Stat=Green Terra Duration
Herbalism.SubSkill.GreenThumb.Name=Green Thumb
Herbalism.SubSkill.GreenThumb.Description=Auto-Plants crops when harvesting
Herbalism.SubSkill.GreenThumb.Description=Auto-Plants crops when harvesting with hoe
Herbalism.SubSkill.GreenThumb.Stat=Green Thumb Chance
Herbalism.SubSkill.GreenThumb.Stat.Extra=Green Thumb Stage: &a Crops grow in stage {0}
Herbalism.Effect.4=Green Thumb (Blocks)