mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-12-02 15:03:25 +01:00
Fix nether warts
This commit is contained in:
parent
a84bd5ddc2
commit
27dbc0ff48
@ -1,22 +1,19 @@
|
|||||||
package com.songoda.core.utils;
|
package com.songoda.core.utils;
|
||||||
|
|
||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.CropState;
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.material.Crops;
|
|
||||||
|
|
||||||
public class BlockUtils {
|
public class BlockUtils {
|
||||||
|
|
||||||
@ -82,6 +79,7 @@ public class BlockUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change a pressure plate's redstone state
|
* Change a pressure plate's redstone state
|
||||||
|
*
|
||||||
* @param plate plate to update
|
* @param plate plate to update
|
||||||
* @param power power to set to 0-15 (wood plates are active if greater than 0)
|
* @param power power to set to 0-15 (wood plates are active if greater than 0)
|
||||||
*/
|
*/
|
||||||
@ -189,6 +187,7 @@ public class BlockUtils {
|
|||||||
Logger.getLogger(BlockUtils.class.getName()).log(Level.SEVERE, "Unexpected method error", ex);
|
Logger.getLogger(BlockUtils.class.getName()).log(Level.SEVERE, "Unexpected method error", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change all of the given door states to be inverse; that is, if a door is
|
* Change all of the given door states to be inverse; that is, if a door is
|
||||||
* open, it will be closed afterwards. If the door is closed, it will become
|
* open, it will be closed afterwards. If the door is closed, it will become
|
||||||
@ -312,6 +311,7 @@ public class BlockUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually trigger the updateAdjacentComparators method for containers
|
* Manually trigger the updateAdjacentComparators method for containers
|
||||||
|
*
|
||||||
* @param containerLocation location of the container
|
* @param containerLocation location of the container
|
||||||
*/
|
*/
|
||||||
public static void updateAdjacentComparators(Location containerLocation) {
|
public static void updateAdjacentComparators(Location containerLocation) {
|
||||||
@ -363,7 +363,8 @@ public class BlockUtils {
|
|||||||
if (mat == null || !mat.isCrop()) {
|
if (mat == null || !mat.isCrop()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return block.getData() >= (mat == CompatibleMaterial.BEETROOTS ? 3 : 7);
|
return block.getData() >= (mat == CompatibleMaterial.BEETROOTS
|
||||||
|
|| mat == CompatibleMaterial.NETHER_WART ? 3 : 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +384,8 @@ public class BlockUtils {
|
|||||||
if (mat == null || !mat.isCrop()) {
|
if (mat == null || !mat.isCrop()) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return mat == CompatibleMaterial.BEETROOTS ? 3 : 7;
|
return (mat == CompatibleMaterial.BEETROOTS
|
||||||
|
|| mat == CompatibleMaterial.NETHER_WART ? 3 : 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +405,8 @@ public class BlockUtils {
|
|||||||
if (mat == null || !mat.isCrop()) {
|
if (mat == null || !mat.isCrop()) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return mat == CompatibleMaterial.BEETROOTS ? 3 : 7;
|
return (mat == CompatibleMaterial.BEETROOTS
|
||||||
|
|| mat == CompatibleMaterial.NETHER_WART ? 3 : 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +424,8 @@ public class BlockUtils {
|
|||||||
CompatibleMaterial mat = CompatibleMaterial.getBlockMaterial(block.getType());
|
CompatibleMaterial mat = CompatibleMaterial.getBlockMaterial(block.getType());
|
||||||
if (mat != null && mat.isCrop()) {
|
if (mat != null && mat.isCrop()) {
|
||||||
try {
|
try {
|
||||||
legacySetBlockData.invoke(block, (byte) Math.max(0, Math.min(stage, mat == CompatibleMaterial.BEETROOTS ? 3 : 7)));
|
legacySetBlockData.invoke(block, (byte) Math.max(0, Math.min(stage, (mat == CompatibleMaterial.BEETROOTS
|
||||||
|
|| mat == CompatibleMaterial.NETHER_WART ? 3 : 7))));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(BlockUtils.class.getName()).log(Level.SEVERE, "Unexpected method error", ex);
|
Logger.getLogger(BlockUtils.class.getName()).log(Level.SEVERE, "Unexpected method error", ex);
|
||||||
}
|
}
|
||||||
@ -440,7 +444,8 @@ public class BlockUtils {
|
|||||||
BlockUtilsModern._incrementGrowthStage(block);
|
BlockUtilsModern._incrementGrowthStage(block);
|
||||||
} else {
|
} else {
|
||||||
CompatibleMaterial mat = CompatibleMaterial.getBlockMaterial(block.getType());
|
CompatibleMaterial mat = CompatibleMaterial.getBlockMaterial(block.getType());
|
||||||
if (mat != null && mat.isCrop() && block.getData() < (mat == CompatibleMaterial.BEETROOTS ? 3 : 7)) {
|
if (mat != null && mat.isCrop() && block.getData() < (mat == CompatibleMaterial.BEETROOTS
|
||||||
|
|| mat == CompatibleMaterial.NETHER_WART ? 3 : 7)) {
|
||||||
try {
|
try {
|
||||||
legacySetBlockData.invoke(block, (byte) (block.getData() + 1));
|
legacySetBlockData.invoke(block, (byte) (block.getData() + 1));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user