diff --git a/build.gradle b/build.gradle index fd612aab0..888e8cc6c 100644 --- a/build.gradle +++ b/build.gradle @@ -41,12 +41,16 @@ repositories { maven { url "https://dl.bintray.com/cyclopsmc/dev/" } + maven { + url "http://files.minecraftforge.net/maven" + } } dependencies { deobfCompile "mezz.jei:jei_1.12.2:+" deobfCompile "mcp.mobius.waila:Hwyla:+" deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.12.2-+" + deobfCompile "com.github.glitchfiend.biomesoplenty:BiomesOPlenty:1.12.2-7.0.1.2334:deobf" } processResources { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java index 524ae3d1d..d35a2f9c5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.entity; +import biomesoplenty.common.block.BlockBOPGrass; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; import net.minecraft.block.Block; @@ -24,9 +25,22 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; +import net.minecraftforge.fml.common.registry.GameRegistry; public class EntityWorm extends Entity{ + @GameRegistry.ObjectHolder("biomesoplenty:grass") + public static final Block biomesOPlentyGrass = null; + + @GameRegistry.ObjectHolder("biomesoplenty:dirt") + public static final Block biomesOPlentyDirt = null; + + @GameRegistry.ObjectHolder("biomesoplenty:farmland_0") + public static final Block biomesOPlentyFarmland0 = null; + + @GameRegistry.ObjectHolder("biomesoplenty:farmland_1") + public static final Block biomesOPlentyFarmland1 = null; + public int timer; public EntityWorm(World world){ @@ -43,6 +57,38 @@ public class EntityWorm extends Entity{ Block blockUp = stateUp.getBlock(); return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.isReplaceable(world, posUp); } + else if(biomesOPlentyGrass != null && block == biomesOPlentyGrass){ + switch((BlockBOPGrass.BOPGrassType)state.getValue(BlockBOPGrass.VARIANT)){ + case LOAMY: + case SANDY: + case SILTY: + case ORIGIN: + case DAISY: + BlockPos posUp = pos.up(); + IBlockState stateUp = world.getBlockState(posUp); + Block blockUp = stateUp.getBlock(); + return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.isReplaceable(world, posUp); + } + return false; + } + else if(biomesOPlentyDirt != null && block == biomesOPlentyDirt) { + BlockPos posUp = pos.up(); + IBlockState stateUp = world.getBlockState(posUp); + Block blockUp = stateUp.getBlock(); + return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.isReplaceable(world, posUp); + } + else if(biomesOPlentyFarmland0 != null && block == biomesOPlentyFarmland0) { + BlockPos posUp = pos.up(); + IBlockState stateUp = world.getBlockState(posUp); + Block blockUp = stateUp.getBlock(); + return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.isReplaceable(world, posUp); + } + else if(biomesOPlentyFarmland1 != null && block == biomesOPlentyFarmland0) { + BlockPos posUp = pos.up(); + IBlockState stateUp = world.getBlockState(posUp); + Block blockUp = stateUp.getBlock(); + return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.isReplaceable(world, posUp); + } else{ return false; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java index 16e6d55ab..8bf19bc49 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java @@ -10,11 +10,14 @@ package de.ellpeck.actuallyadditions.mod.items; +import biomesoplenty.common.block.BlockBOPGrass; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.entity.EntityWorm; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; + +import net.minecraft.block.Block; import net.minecraft.block.BlockGrass; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; @@ -35,6 +38,7 @@ 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.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -42,6 +46,9 @@ import java.util.List; public class ItemWorm extends ItemBase{ + @GameRegistry.ObjectHolder("biomesoplenty:grass") + public static final Block biomesOPlentyGrass = null; + public ItemWorm(String name){ super(name); @@ -92,6 +99,18 @@ public class ItemWorm extends ItemBase{ EntityItem item = new EntityItem(event.getWorld(), pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, stack); world.spawnEntity(item); } + else if(state.getBlock() == biomesOPlentyGrass){ + switch((BlockBOPGrass.BOPGrassType)state.getValue(BlockBOPGrass.VARIANT)){ + case LOAMY: + case SANDY: + case SILTY: + case ORIGIN: + case DAISY: + ItemStack stack = new ItemStack(InitItems.itemWorm, world.rand.nextInt(2) + 1); + EntityItem item = new EntityItem(event.getWorld(), pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, stack); + world.spawnEntity(item); + } + } } } }