Files
CatServer/patches/net/minecraft/entity/ai/EntityAIEatGrass.java.patch
2019-02-24 22:29:41 +08:00

32 lines
1.9 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIEatGrass.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIEatGrass.java
@@ -10,6 +10,8 @@
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
public class EntityAIEatGrass extends EntityAIBase
{
@@ -78,7 +80,8 @@
if (IS_TALL_GRASS.apply(this.entityWorld.getBlockState(blockpos)))
{
- if (this.entityWorld.getGameRules().getBoolean("mobGriefing"))
+ // TODO: Needs testing
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.grassEaterEntity, this.grassEaterEntity.world.getWorld().getBlockAt(blockpos.getX(), blockpos.getY(), blockpos.getZ()), Material.AIR, !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.entityWorld, this.grassEaterEntity)).isCancelled())
{
this.entityWorld.destroyBlock(blockpos, false);
}
@@ -91,7 +94,8 @@
if (this.entityWorld.getBlockState(blockpos1).getBlock() == Blocks.GRASS)
{
- if (this.entityWorld.getGameRules().getBoolean("mobGriefing"))
+ // TODO: Needs testing
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.grassEaterEntity, this.grassEaterEntity.world.getWorld().getBlockAt(blockpos.getX(), blockpos.getY(), blockpos.getZ()), Material.AIR, !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.entityWorld, this.grassEaterEntity)).isCancelled())
{
this.entityWorld.playEvent(2001, blockpos1, Block.getIdFromBlock(Blocks.GRASS));
this.entityWorld.setBlockState(blockpos1, Blocks.DIRT.getDefaultState(), 2);