mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 02:20:01 +03:00
70 lines
3.9 KiB
Diff
70 lines
3.9 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIHarvestFarmland.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIHarvestFarmland.java
|
|
@@ -29,7 +29,7 @@
|
|
{
|
|
if (this.runDelay <= 0)
|
|
{
|
|
- if (!this.villager.world.getGameRules().getBoolean("mobGriefing"))
|
|
+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.villager.world, this.villager))
|
|
{
|
|
return false;
|
|
}
|
|
@@ -61,7 +61,9 @@
|
|
|
|
if (this.currentTask == 0 && block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate))
|
|
{
|
|
- world.destroyBlock(blockpos, true);
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.villager, blockpos, Blocks.AIR, 0).isCancelled()) {
|
|
+ world.destroyBlock(blockpos, true);
|
|
+ }
|
|
}
|
|
else if (this.currentTask == 1 && iblockstate.getMaterial() == Material.AIR)
|
|
{
|
|
@@ -74,26 +76,42 @@
|
|
|
|
if (!itemstack.isEmpty())
|
|
{
|
|
+ Block planted = null;
|
|
if (itemstack.getItem() == Items.WHEAT_SEEDS)
|
|
{
|
|
- world.setBlockState(blockpos, Blocks.WHEAT.getDefaultState(), 3);
|
|
+ // world.setBlockState(blockpos, Blocks.WHEAT.getDefaultState(), 3);
|
|
+ planted = Blocks.WHEAT;
|
|
flag = true;
|
|
}
|
|
else if (itemstack.getItem() == Items.POTATO)
|
|
{
|
|
- world.setBlockState(blockpos, Blocks.POTATOES.getDefaultState(), 3);
|
|
+ // world.setBlockState(blockpos, Blocks.POTATOES.getDefaultState(), 3);
|
|
+ planted = Blocks.POTATOES;
|
|
flag = true;
|
|
}
|
|
else if (itemstack.getItem() == Items.CARROT)
|
|
{
|
|
- world.setBlockState(blockpos, Blocks.CARROTS.getDefaultState(), 3);
|
|
+ // world.setBlockState(blockpos, Blocks.CARROTS.getDefaultState(), 3);
|
|
+ planted = Blocks.CARROTS;
|
|
flag = true;
|
|
}
|
|
else if (itemstack.getItem() == Items.BEETROOT_SEEDS)
|
|
{
|
|
- world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
|
|
+ // world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
|
|
+ planted = Blocks.BEETROOTS;
|
|
flag = true;
|
|
+ } else if (itemstack.getItem() instanceof net.minecraftforge.common.IPlantable) {
|
|
+ if (((net.minecraftforge.common.IPlantable) itemstack.getItem()).getPlantType(world, blockpos) == net.minecraftforge.common.EnumPlantType.Crop) {
|
|
+ // world.setBlockState(blockpos, ((net.minecraftforge.common.IPlantable) itemstack.getItem()).getPlant(world, blockpos), 3);
|
|
+ planted = ((net.minecraftforge.common.IPlantable) itemstack.getItem()).getPlant(world, blockpos).getBlock();
|
|
+ flag = true;
|
|
+ }
|
|
}
|
|
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.villager, blockpos, planted, 0).isCancelled()) {
|
|
+ world.setBlockState(blockpos, planted.getDefaultState(), 3);
|
|
+ } else {
|
|
+ flag = false;
|
|
+ }
|
|
}
|
|
|
|
if (flag)
|