mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-23 17:09:21 +00:00
1.7-4
This commit is contained in:
@@ -244,8 +244,9 @@ public abstract class HandlerP extends Function {
|
||||
|
||||
Sprinkler config = SprinklerConfig.SPRINKLERS_2D.get(id);
|
||||
if (config != null) {
|
||||
|
||||
Location sprinklerLoc = location.clone().add(0.5, 1.5, 0.5);
|
||||
Location sprinklerLoc;
|
||||
if (MainConfig.OraxenHook) sprinklerLoc = location.clone().add(0.5, 1.03125, 0.5);
|
||||
else sprinklerLoc = location.clone().add(0.5, 1.5, 0.5);
|
||||
|
||||
if (FurnitureUtil.hasFurniture(sprinklerLoc)) return false;
|
||||
Sprinkler sprinkler = new Sprinkler(config.getKey(), config.getRange(), 0);
|
||||
@@ -286,6 +287,11 @@ public abstract class HandlerP extends Function {
|
||||
return customInterface.doesExist(StringUtils.chop(id) + nextStage);
|
||||
}
|
||||
|
||||
public String getNextStage(String id) {
|
||||
int nextStage = Integer.parseInt(id.substring(id.length()-1)) + 1;
|
||||
return StringUtils.chop(id) + nextStage;
|
||||
}
|
||||
|
||||
public boolean fillWaterCan(String id, NBTItem nbtItem, ItemStack itemStack, Player player) {
|
||||
WaterCan config = WaterCanConfig.CANS.get(id);
|
||||
if (config != null) {
|
||||
@@ -348,8 +354,9 @@ public abstract class HandlerP extends Function {
|
||||
if (customWorld == null) return false;
|
||||
|
||||
if (fertilizer.isBefore()) {
|
||||
Location above = potLoc.clone().add(0.5,1.5,0.5);
|
||||
if (MainConfig.OraxenHook) above.subtract(0, 0.46875, 0);
|
||||
Location above;
|
||||
if (MainConfig.OraxenHook) above = potLoc.clone().add(0.5,1.03125,0.5);
|
||||
else above = potLoc.clone().add(0.5,1.5,0.5);
|
||||
|
||||
if (FurnitureUtil.hasFurniture(above)) {
|
||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.beforePlant);
|
||||
|
||||
@@ -21,7 +21,6 @@ import dev.lone.itemsadder.api.CustomBlock;
|
||||
import dev.lone.itemsadder.api.CustomFurniture;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import dev.lone.itemsadder.api.Events.CustomBlockBreakEvent;
|
||||
import dev.lone.itemsadder.api.Events.CustomBlockInteractEvent;
|
||||
import dev.lone.itemsadder.api.Events.FurnitureBreakEvent;
|
||||
import dev.lone.itemsadder.api.Events.FurnitureInteractEvent;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
@@ -38,7 +37,10 @@ import net.momirealms.customcrops.objects.requirements.RequirementInterface;
|
||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||
import net.momirealms.customcrops.utils.FurnitureUtil;
|
||||
import net.momirealms.customcrops.utils.LimitationUtil;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -63,27 +65,41 @@ public class ItemsAdderFrameHandler extends ItemsAdderHandler {
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final Entity entity = event.getBukkitEntity();
|
||||
final Location location = entity.getLocation();;
|
||||
|
||||
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(namespacedID);
|
||||
if (sprinkler != null) {
|
||||
|
||||
if (!AntiGrief.testPlace(player, entity.getLocation())) return;
|
||||
|
||||
super.onInteractSprinkler(entity.getLocation(), player, player.getInventory().getItemInMainHand(), sprinkler);
|
||||
return;
|
||||
}
|
||||
|
||||
if (namespacedID.contains("_stage_")) {
|
||||
if (!namespacedID.equals(BasicItemConfig.deadCrop) && !hasNextStage(namespacedID) && MainConfig.canRightClickHarvest) {
|
||||
if (!(MainConfig.emptyHand && player.getInventory().getItemInMainHand().getType() != Material.AIR)) {
|
||||
if (!AntiGrief.testBreak(player, entity.getLocation())) return;
|
||||
CustomFurniture.remove(entity, false);
|
||||
this.onInteractRipeCrop(entity.getLocation(), namespacedID, player);
|
||||
if (!namespacedID.equals(BasicItemConfig.deadCrop)) {
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
if (!hasNextStage(namespacedID)) {
|
||||
if (MainConfig.canRightClickHarvest && !(MainConfig.emptyHand && itemInHand.getType() != Material.AIR)) {
|
||||
if (!AntiGrief.testBreak(player, entity.getLocation())) return;
|
||||
CustomFurniture.remove(entity, false);
|
||||
this.onInteractRipeCrop(location, namespacedID, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//has next stage
|
||||
else if (MainConfig.enableBoneMeal && itemInHand.getType() == Material.BONE_MEAL) {
|
||||
if (!AntiGrief.testPlace(player, location)) return;
|
||||
if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
if (Math.random() < MainConfig.boneMealChance) {
|
||||
entity.getWorld().spawnParticle(MainConfig.boneMealSuccess, location.clone().add(0,0.5, 0),3,0.2,0.2,0.2);
|
||||
CustomFurniture.remove(entity, false);
|
||||
CustomFurniture.spawn(getNextStage(namespacedID), location.getBlock());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!AntiGrief.testPlace(player, entity.getLocation())) return;
|
||||
Location potLoc = entity.getLocation().clone().subtract(0, 1, 0).getBlock().getLocation();
|
||||
if (!AntiGrief.testPlace(player, location)) return;
|
||||
Location potLoc = location.clone().subtract(0, 1, 0).getBlock().getLocation();
|
||||
super.tryMisc(player, player.getInventory().getItemInMainHand(), potLoc);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +198,7 @@ public class ItemsAdderFrameHandler extends ItemsAdderHandler {
|
||||
}
|
||||
|
||||
if (MainConfig.limitation && LimitationUtil.reachFrameLimit(potLoc)) {
|
||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitWire.replace("{max}", String.valueOf(MainConfig.wireAmount)));
|
||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitFrame.replace("{max}", String.valueOf(MainConfig.frameAmount)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,39 +106,45 @@ public class ItemsAdderWireHandler extends ItemsAdderHandler {
|
||||
if (block == null) return;
|
||||
CustomBlock cb = CustomBlock.byAlreadyPlaced(block);
|
||||
if (cb == null) return;
|
||||
Location seedLoc = block.getLocation().clone().add(0,1,0);
|
||||
Location location = block.getLocation();
|
||||
|
||||
final String blockID = cb.getNamespacedID();
|
||||
|
||||
//interact crop
|
||||
if (blockID.contains("_stage_")) {
|
||||
|
||||
//ripe crops
|
||||
if (!blockID.equals(BasicItemConfig.deadCrop) && !hasNextStage(blockID) && MainConfig.canRightClickHarvest) {
|
||||
if (!(MainConfig.emptyHand && event.hasItem())) {
|
||||
|
||||
if (!AntiGrief.testBreak(player, seedLoc)) return;
|
||||
|
||||
CustomBlock.remove(seedLoc);
|
||||
this.onInteractRipeCrop(seedLoc, blockID, player);
|
||||
ItemStack itemInHand = event.getItem();
|
||||
if (!blockID.equals(BasicItemConfig.deadCrop)) {
|
||||
if (!hasNextStage(blockID)) {
|
||||
if (MainConfig.canRightClickHarvest && !(MainConfig.emptyHand && itemInHand != null && itemInHand.getType() != Material.AIR)) {
|
||||
if (!AntiGrief.testBreak(player, location)) return;
|
||||
CustomBlock.remove(location);
|
||||
this.onInteractRipeCrop(location, blockID, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//has next stage
|
||||
else if (MainConfig.enableBoneMeal && itemInHand != null && itemInHand.getType() == Material.BONE_MEAL) {
|
||||
if (!AntiGrief.testPlace(player, location)) return;
|
||||
if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
if (Math.random() < MainConfig.boneMealChance) {
|
||||
location.getWorld().spawnParticle(MainConfig.boneMealSuccess, location.clone().add(0.5,0.5, 0.5),3,0.2,0.2,0.2);
|
||||
CustomBlock.remove(location);
|
||||
CustomBlock.place(getNextStage(blockID), location);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!AntiGrief.testPlace(player, seedLoc)) return;
|
||||
|
||||
Location potLoc = block.getLocation().clone().subtract(0,1,0);
|
||||
super.tryMisc(player, event.getItem(), potLoc);
|
||||
if (!AntiGrief.testPlace(player, location)) return;
|
||||
Location potLoc = location.clone().subtract(0,1,0);
|
||||
super.tryMisc(player, itemInHand, potLoc);
|
||||
}
|
||||
|
||||
//interact pot (must have an item)
|
||||
else if (blockID.equals(BasicItemConfig.wetPot) || blockID.equals(BasicItemConfig.dryPot)) {
|
||||
|
||||
if (!AntiGrief.testPlace(player, seedLoc)) return;
|
||||
if (!AntiGrief.testPlace(player, location)) return;
|
||||
|
||||
ItemStack itemInHand = event.getItem();
|
||||
Location potLoc = block.getLocation();
|
||||
if (super.tryMisc(player, itemInHand, potLoc)) return;
|
||||
if (super.tryMisc(player, itemInHand, location)) return;
|
||||
|
||||
if (event.getBlockFace() != BlockFace.UP) return;
|
||||
|
||||
@@ -150,6 +156,7 @@ public class ItemsAdderWireHandler extends ItemsAdderHandler {
|
||||
Crop crop = CropConfig.CROPS.get(cropName);
|
||||
if (crop == null) return;
|
||||
|
||||
Location seedLoc = location.clone().add(0,1,0);
|
||||
CustomWorld customWorld = cropManager.getCustomWorld(seedLoc.getWorld());
|
||||
if (customWorld == null) return;
|
||||
|
||||
@@ -166,7 +173,7 @@ public class ItemsAdderWireHandler extends ItemsAdderHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (MainConfig.limitation && LimitationUtil.reachWireLimit(potLoc)) {
|
||||
if (MainConfig.limitation && LimitationUtil.reachWireLimit(location)) {
|
||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitWire.replace("{max}", String.valueOf(MainConfig.wireAmount)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,18 +19,12 @@ package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import dev.lone.itemsadder.api.CustomFurniture;
|
||||
import io.th0rgal.oraxen.OraxenPlugin;
|
||||
import io.th0rgal.oraxen.events.OraxenFurnitureBreakEvent;
|
||||
import io.th0rgal.oraxen.events.OraxenFurnitureInteractEvent;
|
||||
import io.th0rgal.oraxen.events.OraxenNoteBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.events.OraxenNoteBlockInteractEvent;
|
||||
import io.th0rgal.oraxen.items.OraxenItems;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicsManager;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
|
||||
import io.th0rgal.oraxen.utils.drops.Drop;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
import net.momirealms.customcrops.api.event.SeedPlantEvent;
|
||||
@@ -169,7 +163,7 @@ public class OraxenFrameHandler extends OraxenHandler {
|
||||
}
|
||||
}
|
||||
if (MainConfig.limitation && LimitationUtil.reachFrameLimit(potLoc)) {
|
||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitWire.replace("{max}", String.valueOf(MainConfig.wireAmount)));
|
||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitFrame.replace("{max}", String.valueOf(MainConfig.frameAmount)));
|
||||
return;
|
||||
}
|
||||
CCSeason[] seasons = crop.getSeasons();
|
||||
@@ -213,24 +207,42 @@ public class OraxenFrameHandler extends OraxenHandler {
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final ItemFrame itemFrame = event.getItemFrame();
|
||||
final Location location = itemFrame.getLocation();
|
||||
|
||||
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
||||
if (sprinkler != null) {
|
||||
if (!AntiGrief.testPlace(player, itemFrame.getLocation())) return;
|
||||
super.onInteractSprinkler(itemFrame.getLocation(), player, player.getInventory().getItemInMainHand(), sprinkler);
|
||||
super.onInteractSprinkler(location, player, player.getInventory().getItemInMainHand(), sprinkler);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id.contains("_stage_")) {
|
||||
if (!id.equals(BasicItemConfig.deadCrop) && !hasNextStage(id) && MainConfig.canRightClickHarvest) {
|
||||
if (!(MainConfig.emptyHand && player.getInventory().getItemInMainHand().getType() != Material.AIR)) {
|
||||
if (!AntiGrief.testBreak(player, itemFrame.getLocation())) return;
|
||||
itemFrame.remove();
|
||||
this.onInteractRipeCrop(itemFrame.getLocation(), id, player);
|
||||
if (!id.equals(BasicItemConfig.deadCrop)) {
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
if (!hasNextStage(id)) {
|
||||
if (MainConfig.canRightClickHarvest && !(MainConfig.emptyHand && itemInHand.getType() != Material.AIR)) {
|
||||
if (!AntiGrief.testBreak(player, location)) return;
|
||||
itemFrame.remove();
|
||||
this.onInteractRipeCrop(location, id, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//has next stage
|
||||
else if (MainConfig.enableBoneMeal && itemInHand.getType() == Material.BONE_MEAL) {
|
||||
if (!AntiGrief.testPlace(player, location)) return;
|
||||
if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
if (Math.random() < MainConfig.boneMealChance) {
|
||||
itemFrame.getWorld().spawnParticle(MainConfig.boneMealSuccess, location.clone().add(0,0.5, 0),3,0.2,0.2,0.2);
|
||||
String nextStage = getNextStage(id);
|
||||
itemFrame.setItem(customInterface.getItemStack(nextStage));
|
||||
itemFrame.getPersistentDataContainer().set(OraxenHook.FURNITURE, PersistentDataType.STRING, nextStage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!AntiGrief.testPlace(player, itemFrame.getLocation())) return;
|
||||
Location potLoc = itemFrame.getLocation().clone().subtract(0,1,0).getBlock().getLocation();
|
||||
|
||||
if (!AntiGrief.testPlace(player, location)) return;
|
||||
Location potLoc = location.clone().subtract(0,1,0).getBlock().getLocation();
|
||||
super.tryMisc(player, player.getInventory().getItemInMainHand(), potLoc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Rotation;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -40,8 +39,6 @@ import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic.FURNITURE_KEY;
|
||||
|
||||
public class OraxenHook implements CustomInterface {
|
||||
|
||||
@@ -22,7 +22,6 @@ import io.th0rgal.oraxen.items.OraxenItems;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicListener;
|
||||
import io.th0rgal.oraxen.utils.drops.Drop;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
import net.momirealms.customcrops.api.event.SeedPlantEvent;
|
||||
@@ -58,39 +57,41 @@ public class OraxenWireHandler extends OraxenHandler{
|
||||
public void onBreakNoteBlock(OraxenNoteBlockBreakEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
String id = event.getNoteBlockMechanic().getItemID();
|
||||
if (id.equals(BasicItemConfig.dryPot) || id.equals(BasicItemConfig.wetPot)) {
|
||||
// not necessary because string break event would be triggered too
|
||||
|
||||
Location location = event.getBlock().getLocation();
|
||||
Player player = event.getPlayer();
|
||||
// String id = event.getNoteBlockMechanic().getItemID();
|
||||
// if (id.equals(BasicItemConfig.dryPot) || id.equals(BasicItemConfig.wetPot)) {
|
||||
//
|
||||
// Location location = event.getBlock().getLocation();
|
||||
// Player player = event.getPlayer();
|
||||
//
|
||||
// if (!AntiGrief.testBreak(player, location)) {
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
// super.onBreakPot(location);
|
||||
//
|
||||
// Location seedLocation = location.clone().add(0,1,0);
|
||||
// StringBlockMechanic mechanic = StringBlockMechanicListener.getStringMechanic(seedLocation.getBlock());
|
||||
// if (mechanic == null) return;
|
||||
// String seedID = mechanic.getItemID();
|
||||
//
|
||||
// if (seedID.contains("_stage_")) {
|
||||
|
||||
if (!AntiGrief.testBreak(player, location)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
super.onBreakPot(location);
|
||||
|
||||
Location seedLocation = location.clone().add(0,1,0);
|
||||
StringBlockMechanic mechanic = StringBlockMechanicListener.getStringMechanic(seedLocation.getBlock());
|
||||
if (mechanic == null) return;
|
||||
String seedID = mechanic.getItemID();
|
||||
|
||||
if (seedID.contains("_stage_")) {
|
||||
|
||||
seedLocation.getBlock().setType(Material.AIR);
|
||||
if (seedID.equals(BasicItemConfig.deadCrop)) return;
|
||||
// seedLocation.getBlock().setType(Material.AIR);
|
||||
// if (seedID.equals(BasicItemConfig.deadCrop)) return;
|
||||
//ripe or not
|
||||
if (hasNextStage(seedID)) {
|
||||
Drop drop = mechanic.getDrop();
|
||||
if (drop != null && player.getGameMode() != GameMode.CREATIVE) {
|
||||
drop.spawns(location, new ItemStack(Material.AIR));
|
||||
}
|
||||
super.onBreakUnripeCrop(location);
|
||||
return;
|
||||
}
|
||||
super.onBreakRipeCrop(seedLocation, seedID, player, false, false);
|
||||
}
|
||||
}
|
||||
// if (hasNextStage(seedID)) {
|
||||
// Drop drop = mechanic.getDrop();
|
||||
// if (drop != null && player.getGameMode() != GameMode.CREATIVE) {
|
||||
// drop.spawns(location, new ItemStack(Material.AIR));
|
||||
// }
|
||||
// super.onBreakUnripeCrop(location);
|
||||
// return;
|
||||
// }
|
||||
// super.onBreakRipeCrop(seedLocation, seedID, player, false, false);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,18 +153,16 @@ public class OraxenWireHandler extends OraxenHandler{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final Location blockLoc = event.getItemFrame().getLocation();
|
||||
|
||||
//TODO Check if air is block
|
||||
final Block block = event.getBlock();
|
||||
|
||||
if (!AntiGrief.testPlace(player, block.getLocation())) return;
|
||||
if (!AntiGrief.testPlace(player, blockLoc)) return;
|
||||
|
||||
FurnitureMechanic mechanic = event.getFurnitureMechanic();
|
||||
if (mechanic == null) return;
|
||||
String id = mechanic.getItemID();
|
||||
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
||||
if (sprinkler != null) {
|
||||
super.onInteractSprinkler(block.getLocation(), player, player.getInventory().getItemInMainHand(), sprinkler);
|
||||
super.onInteractSprinkler(blockLoc, player, player.getInventory().getItemInMainHand(), sprinkler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +179,7 @@ public class OraxenWireHandler extends OraxenHandler{
|
||||
if (event.getBlockFace() != BlockFace.UP) return;
|
||||
|
||||
String id = OraxenItems.getIdByItem(itemInHand);
|
||||
if (id == null) return;
|
||||
if (id.endsWith("_seeds")) {
|
||||
String cropName = id.substring(0, id.length() - 6);
|
||||
Crop crop = CropConfig.CROPS.get(cropName);
|
||||
@@ -189,7 +189,7 @@ public class OraxenWireHandler extends OraxenHandler{
|
||||
CustomWorld customWorld = cropManager.getCustomWorld(seedLoc.getWorld());
|
||||
if (customWorld == null) return;
|
||||
|
||||
if (FurnitureUtil.hasFurniture(seedLoc.clone().add(0.5,0.5,0.5))) return;
|
||||
if (FurnitureUtil.hasFurniture(seedLoc.clone().add(0.5,0.03125,0.5))) return;
|
||||
if (seedLoc.getBlock().getType() != Material.AIR) return;
|
||||
|
||||
PlantingCondition plantingCondition = new PlantingCondition(seedLoc, player);
|
||||
@@ -240,22 +240,41 @@ public class OraxenWireHandler extends OraxenHandler{
|
||||
public void onInteractStringBlock(OraxenStringBlockInteractEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
final String id = event.getStringBlockMechanic().getItemID();
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
if (time - (coolDown.getOrDefault(player, time - 50)) < 50) return;
|
||||
coolDown.put(player, time);
|
||||
|
||||
final Block block = event.getBlock();
|
||||
final String id = event.getStringBlockMechanic().getItemID();
|
||||
|
||||
if (id.contains("_stage_")) {
|
||||
|
||||
Location seedLoc = block.getLocation();
|
||||
|
||||
ItemStack itemInHand = event.getItemInHand();
|
||||
//ripe crops
|
||||
if (!id.equals(BasicItemConfig.deadCrop) && !hasNextStage(id) && MainConfig.canRightClickHarvest) {
|
||||
if (!id.equals(BasicItemConfig.deadCrop)) {
|
||||
|
||||
if (!(MainConfig.emptyHand && (event.getItemInHand() != null && event.getItemInHand().getType() != Material.AIR))) {
|
||||
if (!hasNextStage(id)) {
|
||||
if (MainConfig.canRightClickHarvest && !(MainConfig.emptyHand && itemInHand != null && itemInHand.getType() != Material.AIR)) {
|
||||
if (!AntiGrief.testBreak(player, seedLoc)) return;
|
||||
|
||||
if (!AntiGrief.testBreak(player, seedLoc)) return;
|
||||
|
||||
block.setType(Material.AIR);
|
||||
this.onInteractRipeCrop(seedLoc, id, player);
|
||||
block.setType(Material.AIR);
|
||||
this.onInteractRipeCrop(seedLoc, id, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//has next stage
|
||||
else if (MainConfig.enableBoneMeal && itemInHand != null && itemInHand.getType() == Material.BONE_MEAL) {
|
||||
if (!AntiGrief.testPlace(player, seedLoc)) return;
|
||||
if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
if (Math.random() < MainConfig.boneMealChance) {
|
||||
seedLoc.getWorld().spawnParticle(MainConfig.boneMealSuccess, seedLoc.clone().add(0.5,0.5, 0.5),3,0.2,0.2,0.2);
|
||||
StringBlockMechanicFactory.setBlockModel(block, getNextStage(id));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,9 @@ public class FrameCropImpl implements CropModeInterface {
|
||||
|
||||
if (chunk.isEntitiesLoaded()) {
|
||||
|
||||
Location cropLoc = location.clone().add(0.5,0.5,0.5);
|
||||
if (MainConfig.OraxenHook) cropLoc.subtract(0, 0.46875, 0);
|
||||
Location cropLoc;
|
||||
if (MainConfig.OraxenHook) cropLoc = location.clone().add(0.5,0.03125,0.5);
|
||||
else cropLoc = location.clone().add(0.5,0.5,0.5);
|
||||
|
||||
ItemFrame itemFrame = FurnitureUtil.getItemFrame(cropLoc);
|
||||
if (itemFrame == null) return true;
|
||||
@@ -105,7 +106,6 @@ public class FrameCropImpl implements CropModeInterface {
|
||||
if (fertilizer instanceof Gigantic gigantic) {
|
||||
chance += gigantic.getChance();
|
||||
}
|
||||
System.out.println(chance);
|
||||
if (Math.random() < chance) {
|
||||
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||
customInterface.removeFurniture(itemFrame);
|
||||
|
||||
@@ -70,11 +70,10 @@ public class WireCropImpl implements CropModeInterface{
|
||||
if (potID == null) return true;
|
||||
|
||||
Fertilizer fertilizer = cropManager.getFertilizer(potLoc);
|
||||
|
||||
boolean certainGrow = potID.equals(BasicItemConfig.wetPot);
|
||||
|
||||
int nextStage = Integer.parseInt(cropNameList[2]) + 1;
|
||||
String temp = StringUtils.chop(blockID);
|
||||
|
||||
if (customInterface.doesExist(temp + nextStage)) {
|
||||
if (fertilizer instanceof SpeedGrow speedGrow && Math.random() < speedGrow.getChance()) {
|
||||
if (customInterface.doesExist(temp + (nextStage+1))) {
|
||||
@@ -111,7 +110,7 @@ public class WireCropImpl implements CropModeInterface{
|
||||
|
||||
private void addStage(Location seedLoc, String stage) {
|
||||
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||
customInterface.removeBlock(seedLoc);
|
||||
if (!MainConfig.OraxenHook) customInterface.removeBlock(seedLoc);
|
||||
customInterface.placeWire(seedLoc, stage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,7 +49,9 @@ public class LimitationUtil {
|
||||
int n = 0;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
Location square = chunkLocation.clone().add(i + 0.5, 0.5, j + 0.5);
|
||||
Location square;
|
||||
if (MainConfig.OraxenHook) square = chunkLocation.clone().add(i + 0.5, 0.03125, j + 0.5);
|
||||
else square = chunkLocation.clone().add(i + 0.5, 0.5, j + 0.5);
|
||||
for (int k = minHeight; k <= maxHeight; ++k) {
|
||||
square.add(0.0, 1.0, 0.0);
|
||||
if (FurnitureUtil.hasFurniture(square) && ++n > MainConfig.frameAmount) {
|
||||
|
||||
Reference in New Issue
Block a user