check for deny

This commit is contained in:
Shadows_of_Fire 2018-01-26 02:34:20 -05:00
parent 287e43c6ad
commit 9670fc7669
2 changed files with 13 additions and 8 deletions

View file

@ -12,10 +12,14 @@ package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior;
import net.minecraft.block.*; import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.BlockFarmland;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -85,11 +89,10 @@ public class EntityWorm extends Entity{
DefaultFarmerBehavior.useHoeAt(world, pos); DefaultFarmerBehavior.useHoeAt(world, pos);
state = this.world.getBlockState(pos); state = this.world.getBlockState(pos);
block = state.getBlock(); isFarmland = state.getBlock() instanceof BlockFarmland;
isFarmland = block instanceof BlockFarmland;
IBlockState stateToModify = isFarmland ? state : Blocks.FARMLAND.getDefaultState(); if(isFarmland)
this.world.setBlockState(pos, stateToModify.withProperty(BlockFarmland.MOISTURE, 7), 2); this.world.setBlockState(pos, state.withProperty(BlockFarmland.MOISTURE, 7), 2);
if(!isFarmland){ if(!isFarmland){
this.world.setBlockToAir(pos.up()); this.world.setBlockToAir(pos.up());

View file

@ -32,6 +32,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.UseHoeEvent; import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -77,9 +79,9 @@ public class ItemWorm extends ItemBase{
return super.onItemUse(player, world, pos, hand, side, par8, par9, par10); return super.onItemUse(player, world, pos, hand, side, par8, par9, par10);
} }
@SubscribeEvent @SubscribeEvent(priority = EventPriority.LOW)
public void onHoe(UseHoeEvent event){ public void onHoe(UseHoeEvent event){
if(ConfigBoolValues.WORMS.isEnabled()){ if(ConfigBoolValues.WORMS.isEnabled() && event.getResult() != Result.DENY){
World world = event.getWorld(); World world = event.getWorld();
if(!world.isRemote){ if(!world.isRemote){
BlockPos pos = event.getPos(); BlockPos pos = event.getPos();