Add compatibility for worms to Biomes'O'Plenty soils.

This commit is contained in:
Andrew Pietila 2018-03-23 16:31:40 -05:00
parent 5b3c3fa46f
commit 76940f21d3
3 changed files with 69 additions and 0 deletions

View file

@ -41,12 +41,16 @@ repositories {
maven { maven {
url "https://dl.bintray.com/cyclopsmc/dev/" url "https://dl.bintray.com/cyclopsmc/dev/"
} }
maven {
url "http://files.minecraftforge.net/maven"
}
} }
dependencies { dependencies {
deobfCompile "mezz.jei:jei_1.12.2:+" deobfCompile "mezz.jei:jei_1.12.2:+"
deobfCompile "mcp.mobius.waila:Hwyla:+" deobfCompile "mcp.mobius.waila:Hwyla:+"
deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.12.2-+" deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.12.2-+"
deobfCompile "com.github.glitchfiend.biomesoplenty:BiomesOPlenty:1.12.2-7.0.1.2334:deobf"
} }
processResources { processResources {

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.entity; package de.ellpeck.actuallyadditions.mod.entity;
import biomesoplenty.common.block.BlockBOPGrass;
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.Block; import net.minecraft.block.Block;
@ -24,9 +25,22 @@ 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;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class EntityWorm extends Entity{ 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 int timer;
public EntityWorm(World world){ public EntityWorm(World world){
@ -43,6 +57,38 @@ public class EntityWorm extends Entity{
Block blockUp = stateUp.getBlock(); Block blockUp = stateUp.getBlock();
return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.isReplaceable(world, posUp); 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{ else{
return false; return false;
} }

View file

@ -10,11 +10,14 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import biomesoplenty.common.block.BlockBOPGrass;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm; import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGrass; import net.minecraft.block.BlockGrass;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase; 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.Event.Result;
import net.minecraftforge.fml.common.eventhandler.EventPriority; 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.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -42,6 +46,9 @@ import java.util.List;
public class ItemWorm extends ItemBase{ public class ItemWorm extends ItemBase{
@GameRegistry.ObjectHolder("biomesoplenty:grass")
public static final Block biomesOPlentyGrass = null;
public ItemWorm(String name){ public ItemWorm(String name){
super(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); EntityItem item = new EntityItem(event.getWorld(), pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, stack);
world.spawnEntity(item); 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);
}
}
} }
} }
} }