Merge pull request #659 from GirafiStudios/BOP-1.8.9-3.0.x
Added Loamy, Sandy & Silty Farmland + UseHoeEventHandler. Closes #589
This commit is contained in:
commit
f131d97f89
22 changed files with 447 additions and 68 deletions
|
@ -112,6 +112,8 @@ public class BOPBlocks
|
||||||
public static Block grass;
|
public static Block grass;
|
||||||
public static Block waterlily;
|
public static Block waterlily;
|
||||||
public static Block dirt;
|
public static Block dirt;
|
||||||
|
public static Block farmland_0;
|
||||||
|
public static Block farmland_1;
|
||||||
public static Block stone_formations;
|
public static Block stone_formations;
|
||||||
public static Block hard_ice;
|
public static Block hard_ice;
|
||||||
public static Block dried_sand;
|
public static Block dried_sand;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright 2014-2016, the Biomes O' Plenty Team
|
* Copyright 2014-2016, the Biomes O' Plenty Team
|
||||||
*
|
*
|
||||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||||
*
|
*
|
||||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import biomesoplenty.common.util.block.VariantPagingHelper;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
@ -34,10 +35,8 @@ import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
|
|
||||||
public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
{
|
{
|
||||||
// TODO: make it ploughable into farmland
|
|
||||||
|
|
||||||
// add properties
|
// add properties
|
||||||
public static enum BOPDirtType implements IStringSerializable
|
public static enum BOPDirtType implements IStringSerializable, VariantPagingHelper.IPagedVariants
|
||||||
{
|
{
|
||||||
LOAMY, SANDY, SILTY;
|
LOAMY, SANDY, SILTY;
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +54,7 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
public static final PropertyBool COARSE = PropertyBool.create("coarse");
|
public static final PropertyBool COARSE = PropertyBool.create("coarse");
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { COARSE, VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { COARSE, VARIANT });}
|
||||||
|
|
||||||
// implement IBOPBlock
|
// implement IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
@ -71,20 +70,20 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
return (Boolean.TRUE.equals(state.getValue(COARSE)) ? "coarse_" : "") + ((BOPDirtType) state.getValue(VARIANT)).getName() + "_dirt";
|
return (Boolean.TRUE.equals(state.getValue(COARSE)) ? "coarse_" : "") + ((BOPDirtType) state.getValue(VARIANT)).getName() + "_dirt";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPDirt() {
|
public BlockBOPDirt() {
|
||||||
|
|
||||||
super(Material.ground);
|
super(Material.ground);
|
||||||
|
|
||||||
// set some defaults
|
// set some defaults
|
||||||
this.setTickRandomly(true);
|
this.setTickRandomly(true);
|
||||||
this.setHardness(0.5F);
|
this.setHardness(0.5F);
|
||||||
this.setHarvestLevel("shovel", 0);
|
this.setHarvestLevel("shovel", 0);
|
||||||
this.setStepSound(Block.soundTypeGravel);
|
this.setStepSound(Block.soundTypeGravel);
|
||||||
this.setDefaultState( this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(false)).withProperty(VARIANT, BOPDirtType.LOAMY) );
|
this.setDefaultState( this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(false)).withProperty(VARIANT, BOPDirtType.LOAMY) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getStateFromMeta(int meta)
|
public IBlockState getStateFromMeta(int meta)
|
||||||
{
|
{
|
||||||
|
@ -98,17 +97,17 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
// both variant and coarseness saved in meta, first bit coarseness, other bits variant
|
// both variant and coarseness saved in meta, first bit coarseness, other bits variant
|
||||||
return (Boolean.TRUE.equals(state.getValue(COARSE)) ? 8 : 0) | ((BOPDirtType) state.getValue(VARIANT)).ordinal();
|
return (Boolean.TRUE.equals(state.getValue(COARSE)) ? 8 : 0) | ((BOPDirtType) state.getValue(VARIANT)).ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// our blocks usually drop their current state as opposed to a single 'default' state
|
// our blocks usually drop their current state as opposed to a single 'default' state
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(IBlockState state)
|
public int damageDropped(IBlockState state)
|
||||||
{
|
{
|
||||||
return this.getMetaFromState(state);
|
return this.getMetaFromState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSustainPlantType(IBlockAccess world, BlockPos pos, EnumPlantType plantType)
|
public boolean canSustainPlantType(IBlockAccess world, BlockPos pos, EnumPlantType plantType)
|
||||||
{
|
{
|
||||||
switch (plantType)
|
switch (plantType)
|
||||||
{
|
{
|
||||||
// support desert, plains and cave plants
|
// support desert, plains and cave plants
|
||||||
|
@ -127,13 +126,13 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
|
public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
|
||||||
{
|
{
|
||||||
return this.canSustainPlantType(world, pos, plantable.getPlantType(world, pos.offset(direction)));
|
return this.canSustainPlantType(world, pos, plantable.getPlantType(world, pos.offset(direction)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||||
|
@ -143,14 +142,14 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
pullGrassFromNeighbors(world, pos, grassState, rand, 4, 1, 3, 1);
|
pullGrassFromNeighbors(world, pos, grassState, rand, 4, 1, 3, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOPGrass variants spread randomly to BOPDirt on the grass's updateTick
|
// BOPGrass variants spread randomly to BOPDirt on the grass's updateTick
|
||||||
// However, vanilla grass does not. This function fixes this by 'pulling' grass from nearby vanilla grass blocks at the same rate as it would spread to vanilla dirt
|
// However, vanilla grass does not. This function fixes this by 'pulling' grass from nearby vanilla grass blocks at the same rate as it would spread to vanilla dirt
|
||||||
public void pullGrassFromNeighbors(World world, BlockPos pos, IBlockState grassState, Random rand, int tries, int xzSpread, int downSpread, int upSpread)
|
public void pullGrassFromNeighbors(World world, BlockPos pos, IBlockState grassState, Random rand, int tries, int xzSpread, int downSpread, int upSpread)
|
||||||
{
|
{
|
||||||
// if there's not enough light then there's no chance of this block becoming grassy
|
// if there's not enough light then there's no chance of this block becoming grassy
|
||||||
if (world.getLightFromNeighbors(pos.up()) < 4 || world.getBlockState(pos.up()).getBlock().getLightOpacity(world, pos.up()) > 2) {return;}
|
if (world.getLightFromNeighbors(pos.up()) < 4 || world.getBlockState(pos.up()).getBlock().getLightOpacity(world, pos.up()) > 2) {return;}
|
||||||
|
|
||||||
int numNearbyGrassSpreadingBlocks = 0;
|
int numNearbyGrassSpreadingBlocks = 0;
|
||||||
BlockPos pos1;
|
BlockPos pos1;
|
||||||
for (int dy = -downSpread; dy <= upSpread; dy++)
|
for (int dy = -downSpread; dy <= upSpread; dy++)
|
||||||
|
@ -169,7 +168,7 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (numNearbyGrassSpreadingBlocks == 0) {return;}
|
if (numNearbyGrassSpreadingBlocks == 0) {return;}
|
||||||
|
|
||||||
// each grass block gets 4 tries to spread grass, chance of this block being chosen each time is 1 / volume of blocks close enough
|
// each grass block gets 4 tries to spread grass, chance of this block being chosen each time is 1 / volume of blocks close enough
|
||||||
// overall chance of spread = 1 - chance of not spreading
|
// overall chance of spread = 1 - chance of not spreading
|
||||||
int vol = (xzSpread * 2 + 1) * (xzSpread * 2 + 1) * (upSpread + downSpread + 1);
|
int vol = (xzSpread * 2 + 1) * (xzSpread * 2 + 1) * (upSpread + downSpread + 1);
|
||||||
|
@ -179,8 +178,8 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
world.setBlockState(pos, grassState);
|
world.setBlockState(pos, grassState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get the blockstate which corresponds to the type of grass which grows on this dirt
|
// get the blockstate which corresponds to the type of grass which grows on this dirt
|
||||||
public static IBlockState getGrassBlockState(IBlockState state)
|
public static IBlockState getGrassBlockState(IBlockState state)
|
||||||
{
|
{
|
||||||
|
@ -190,7 +189,7 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
switch ((BOPDirtType) state.getValue(VARIANT))
|
switch ((BOPDirtType) state.getValue(VARIANT))
|
||||||
{
|
{
|
||||||
case LOAMY:
|
case LOAMY:
|
||||||
return BOPBlocks.grass.getDefaultState().withProperty(BlockBOPGrass.VARIANT, BlockBOPGrass.BOPGrassType.LOAMY);
|
return BOPBlocks.grass.getDefaultState().withProperty(BlockBOPGrass.VARIANT, BlockBOPGrass.BOPGrassType.LOAMY);
|
||||||
case SANDY:
|
case SANDY:
|
||||||
|
@ -202,15 +201,15 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
|
||||||
return Blocks.grass.getDefaultState();
|
return Blocks.grass.getDefaultState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getGrassBlock(IBlockState state)
|
public Block getGrassBlock(IBlockState state)
|
||||||
{
|
{
|
||||||
return getGrassBlockState(state).getBlock();
|
return getGrassBlockState(state).getBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGrassBlockMeta(IBlockState state)
|
public int getGrassBlockMeta(IBlockState state)
|
||||||
{
|
{
|
||||||
return this.getGrassBlock(state).getMetaFromState(getGrassBlockState(state));
|
return this.getGrassBlock(state).getMetaFromState(getGrassBlockState(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
217
src/main/java/biomesoplenty/common/block/BlockBOPFarmland.java
Normal file
217
src/main/java/biomesoplenty/common/block/BlockBOPFarmland.java
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright 2014-2016, the Biomes O' Plenty Team
|
||||||
|
*
|
||||||
|
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||||
|
*
|
||||||
|
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
|
import biomesoplenty.api.block.BOPBlocks;
|
||||||
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
|
import biomesoplenty.common.util.block.VariantPagingHelper;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockDirt;
|
||||||
|
import net.minecraft.block.BlockFarmland;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.EnumPlantType;
|
||||||
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class BlockBOPFarmland extends BlockFarmland implements IBOPBlock
|
||||||
|
{
|
||||||
|
public static VariantPagingHelper<BlockBOPFarmland, BlockBOPDirt.BOPDirtType> paging = new VariantPagingHelper<BlockBOPFarmland, BlockBOPDirt.BOPDirtType>(2, BlockBOPDirt.BOPDirtType.class);
|
||||||
|
|
||||||
|
private static IProperty currentVariantProperty;
|
||||||
|
|
||||||
|
public static void createAllPages()
|
||||||
|
{
|
||||||
|
int numPages = paging.getNumPages();
|
||||||
|
for (int i = 0; i < numPages; ++i)
|
||||||
|
{
|
||||||
|
currentVariantProperty = paging.getVariantProperty(i);
|
||||||
|
paging.addBlock(i, new BlockBOPFarmland());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IProperty variantProperty;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockState createBlockState()
|
||||||
|
{
|
||||||
|
this.variantProperty = currentVariantProperty;
|
||||||
|
return new BlockState(this, new IProperty[] { MOISTURE, this.variantProperty });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] { this.variantProperty }; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IProperty[] getNonRenderingProperties() { return null; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty)).getName() + "_farmland";
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockBOPFarmland()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.setHardness(0.6F);
|
||||||
|
this.setHarvestLevel("shovel", 0);
|
||||||
|
this.setStepSound(soundTypeGravel);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(MOISTURE, Integer.valueOf(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(this.variantProperty, paging.getVariant(this, meta & 1)).withProperty(MOISTURE, Integer.valueOf(meta >> 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
BlockBOPDirt.BOPDirtType dirt = (BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty);
|
||||||
|
int meta = paging.getIndex(dirt);
|
||||||
|
meta |= state.getValue(MOISTURE) << 1;
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTick(World world, BlockPos pos, IBlockState state, Random random)
|
||||||
|
{
|
||||||
|
int i = (state.getValue(MOISTURE)).intValue();
|
||||||
|
|
||||||
|
if (!this.hasWater(world, pos) && !world.canLightningStrike(pos.up()))
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
world.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(i - 1)), 2);
|
||||||
|
}
|
||||||
|
else if (!this.hasCrops(world, pos))
|
||||||
|
{
|
||||||
|
world.setBlockState(pos, this.getDirtBlockState(world.getBlockState(pos)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i < 7)
|
||||||
|
{
|
||||||
|
world.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(7)), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasWater(World world, BlockPos pos)
|
||||||
|
{
|
||||||
|
for (BlockPos.MutableBlockPos mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-4, 0, -4), pos.add(4, 1, 4)))
|
||||||
|
{
|
||||||
|
if (world.getBlockState(mutableblockpos).getBlock().getMaterial() == Material.water)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasCrops(World world, BlockPos pos)
|
||||||
|
{
|
||||||
|
Block block = world.getBlockState(pos.up()).getBlock();
|
||||||
|
return block instanceof IPlantable && canSustainPlant(world, pos, EnumFacing.UP, (IPlantable)block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||||
|
{
|
||||||
|
if (world.getBlockState(pos.up()).getBlock().getMaterial().isSolid())
|
||||||
|
{
|
||||||
|
world.setBlockState(pos, this.getDirtBlockState(world.getBlockState(pos)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFallenUpon(World world, BlockPos pos, Entity entity, float fallDistance)
|
||||||
|
{
|
||||||
|
if (entity instanceof EntityLivingBase)
|
||||||
|
{
|
||||||
|
if (!world.isRemote && world.rand.nextFloat() < fallDistance - 0.5F)
|
||||||
|
{
|
||||||
|
if (!(entity instanceof EntityPlayer) && !world.getGameRules().getBoolean("mobGriefing"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
world.setBlockState(pos, this.getDirtBlockState(world.getBlockState(pos)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||||
|
{
|
||||||
|
return Item.getItemFromBlock(BOPBlocks.dirt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return BOPBlocks.dirt.getMetaFromState(this.getDirtBlockState(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player)
|
||||||
|
{
|
||||||
|
return new ItemStack(BOPBlocks.dirt, 1, BOPBlocks.dirt.getMetaFromState(this.getDirtBlockState(world.getBlockState(pos))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
|
||||||
|
{
|
||||||
|
EnumPlantType plantType = plantable.getPlantType(world, pos.up());
|
||||||
|
|
||||||
|
switch (plantType)
|
||||||
|
{
|
||||||
|
case Crop:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.canSustainPlant(world, pos, direction, plantable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockState getDirtBlockState(IBlockState state)
|
||||||
|
{
|
||||||
|
switch ((BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty))
|
||||||
|
{
|
||||||
|
case LOAMY:
|
||||||
|
return BOPBlocks.dirt.getDefaultState().withProperty(BlockBOPDirt.VARIANT, BlockBOPDirt.BOPDirtType.LOAMY);
|
||||||
|
case SANDY:
|
||||||
|
return BOPBlocks.dirt.getDefaultState().withProperty(BlockBOPDirt.VARIANT, BlockBOPDirt.BOPDirtType.SANDY);
|
||||||
|
case SILTY:
|
||||||
|
return BOPBlocks.dirt.getDefaultState().withProperty(BlockBOPDirt.VARIANT, BlockBOPDirt.BOPDirtType.SILTY);
|
||||||
|
default:
|
||||||
|
return Blocks.dirt.getStateFromMeta(BlockDirt.DirtType.DIRT.getMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,9 +45,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockBOPGrass extends BlockGrass implements IBOPBlock, ISustainsPlantType
|
public class BlockBOPGrass extends BlockGrass implements IBOPBlock, ISustainsPlantType
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO: make it ploughable into farmland
|
|
||||||
|
|
||||||
// add properties (note we also inherit the SNOWY property from BlockGrass)
|
// add properties (note we also inherit the SNOWY property from BlockGrass)
|
||||||
public static enum BOPGrassType implements IStringSerializable
|
public static enum BOPGrassType implements IStringSerializable
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright 2014-2016, the Biomes O' Plenty Team
|
||||||
|
*
|
||||||
|
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||||
|
*
|
||||||
|
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package biomesoplenty.common.handler;
|
||||||
|
|
||||||
|
import biomesoplenty.common.block.BlockBOPDirt;
|
||||||
|
import biomesoplenty.common.block.BlockBOPFarmland;
|
||||||
|
import biomesoplenty.common.block.BlockBOPGrass;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockDirt;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
public class UseHoeEventHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void useHoe(UseHoeEvent event)
|
||||||
|
{
|
||||||
|
if (event.getResult() != Event.Result.DEFAULT || event.isCanceled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
World world = event.world;
|
||||||
|
BlockPos pos = event.pos;
|
||||||
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
Block block = state.getBlock();
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
if (block instanceof BlockBOPDirt)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
if (state.getValue(BlockBOPDirt.COARSE))
|
||||||
|
{
|
||||||
|
world.setBlockState(pos, state.withProperty(BlockBOPDirt.COARSE, Boolean.valueOf(false)));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
world.setBlockState(pos, BlockBOPFarmland.paging.getVariantState((BlockBOPDirt.BOPDirtType) state.getValue(BlockBOPDirt.VARIANT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (block instanceof BlockBOPGrass)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
BlockBOPGrass grass = (BlockBOPGrass) state.getBlock();
|
||||||
|
Block dirtBlock = grass.getDirtBlockState(state).getBlock();
|
||||||
|
|
||||||
|
if (dirtBlock instanceof BlockBOPDirt)
|
||||||
|
{
|
||||||
|
BlockBOPDirt.BOPDirtType dirtType = (BlockBOPDirt.BOPDirtType) grass.getDirtBlockState(state).getValue(BlockBOPDirt.VARIANT);
|
||||||
|
world.setBlockState(pos, BlockBOPFarmland.paging.getVariantState(dirtType));
|
||||||
|
}
|
||||||
|
else if (dirtBlock instanceof BlockDirt && state.getValue(BlockBOPGrass.VARIANT) != BlockBOPGrass.BOPGrassType.SMOLDERING)
|
||||||
|
{
|
||||||
|
world.setBlockState(pos, Blocks.farmland.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
if (!event.entityPlayer.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
|
event.current.damageItem(1, event.entityLiving);
|
||||||
|
}
|
||||||
|
event.world.playSoundEffect((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), (double) ((float) pos.getZ() + 0.5F), block.stepSound.getStepSound(), (state.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, state.getBlock().stepSound.getFrequency() * 0.8F);
|
||||||
|
event.entityPlayer.swingItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ import static biomesoplenty.api.item.BOPItems.blood_bucket;
|
||||||
import static biomesoplenty.api.item.BOPItems.honey_bucket;
|
import static biomesoplenty.api.item.BOPItems.honey_bucket;
|
||||||
import static biomesoplenty.api.item.BOPItems.poison_bucket;
|
import static biomesoplenty.api.item.BOPItems.poison_bucket;
|
||||||
import static biomesoplenty.api.item.BOPItems.hot_spring_water_bucket;
|
import static biomesoplenty.api.item.BOPItems.hot_spring_water_bucket;
|
||||||
|
|
||||||
|
import biomesoplenty.common.block.*;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockSlab;
|
import net.minecraft.block.BlockSlab;
|
||||||
import net.minecraft.block.BlockStairs;
|
import net.minecraft.block.BlockStairs;
|
||||||
|
@ -32,44 +34,6 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.api.item.BOPItems;
|
import biomesoplenty.api.item.BOPItems;
|
||||||
import biomesoplenty.common.block.BlockBOPAsh;
|
|
||||||
import biomesoplenty.common.block.BlockBOPBamboo;
|
|
||||||
import biomesoplenty.common.block.BlockBOPBiomeBlock;
|
|
||||||
import biomesoplenty.common.block.BlockBOPBones;
|
|
||||||
import biomesoplenty.common.block.BlockBOPCoral;
|
|
||||||
import biomesoplenty.common.block.BlockBOPCrystal;
|
|
||||||
import biomesoplenty.common.block.BlockBOPDirt;
|
|
||||||
import biomesoplenty.common.block.BlockBOPDoor;
|
|
||||||
import biomesoplenty.common.block.BlockBOPDoubleOtherSlab;
|
|
||||||
import biomesoplenty.common.block.BlockBOPDoublePlant;
|
|
||||||
import biomesoplenty.common.block.BlockBOPDoubleWoodSlab;
|
|
||||||
import biomesoplenty.common.block.BlockBOPFence;
|
|
||||||
import biomesoplenty.common.block.BlockBOPFenceGate;
|
|
||||||
import biomesoplenty.common.block.BlockBOPFlesh;
|
|
||||||
import biomesoplenty.common.block.BlockBOPFlower;
|
|
||||||
import biomesoplenty.common.block.BlockBOPGem;
|
|
||||||
import biomesoplenty.common.block.BlockBOPGemOre;
|
|
||||||
import biomesoplenty.common.block.BlockBOPGeneric;
|
|
||||||
import biomesoplenty.common.block.BlockBOPGrass;
|
|
||||||
import biomesoplenty.common.block.BlockBOPHalfOtherSlab;
|
|
||||||
import biomesoplenty.common.block.BlockBOPHalfWoodSlab;
|
|
||||||
import biomesoplenty.common.block.BlockBOPHive;
|
|
||||||
import biomesoplenty.common.block.BlockBOPHoney;
|
|
||||||
import biomesoplenty.common.block.BlockBOPLeaves;
|
|
||||||
import biomesoplenty.common.block.BlockBOPLilypad;
|
|
||||||
import biomesoplenty.common.block.BlockBOPLog;
|
|
||||||
import biomesoplenty.common.block.BlockBOPMud;
|
|
||||||
import biomesoplenty.common.block.BlockBOPMushroom;
|
|
||||||
import biomesoplenty.common.block.BlockBOPPlanks;
|
|
||||||
import biomesoplenty.common.block.BlockBOPPlant;
|
|
||||||
import biomesoplenty.common.block.BlockBOPSand;
|
|
||||||
import biomesoplenty.common.block.BlockBOPSapling;
|
|
||||||
import biomesoplenty.common.block.BlockBOPSeaweed;
|
|
||||||
import biomesoplenty.common.block.BlockBOPStone;
|
|
||||||
import biomesoplenty.common.block.BlockBOPTerrarium;
|
|
||||||
import biomesoplenty.common.block.BlockBOPTurnip;
|
|
||||||
import biomesoplenty.common.block.BlockBOPVine;
|
|
||||||
import biomesoplenty.common.block.BlockBOPWoodStairs;
|
|
||||||
import biomesoplenty.common.command.BOPCommand;
|
import biomesoplenty.common.command.BOPCommand;
|
||||||
import biomesoplenty.common.enums.BOPWoods;
|
import biomesoplenty.common.enums.BOPWoods;
|
||||||
import biomesoplenty.common.fluids.BloodFluid;
|
import biomesoplenty.common.fluids.BloodFluid;
|
||||||
|
@ -171,7 +135,11 @@ public class ModBlocks
|
||||||
leaves_3 = registerBlock( BlockBOPLeaves.paging.getBlock(3), "leaves_3" );
|
leaves_3 = registerBlock( BlockBOPLeaves.paging.getBlock(3), "leaves_3" );
|
||||||
leaves_4 = registerBlock( BlockBOPLeaves.paging.getBlock(4), "leaves_4" );
|
leaves_4 = registerBlock( BlockBOPLeaves.paging.getBlock(4), "leaves_4" );
|
||||||
leaves_5 = registerBlock( BlockBOPLeaves.paging.getBlock(5), "leaves_5" );
|
leaves_5 = registerBlock( BlockBOPLeaves.paging.getBlock(5), "leaves_5" );
|
||||||
|
|
||||||
|
BlockBOPFarmland.createAllPages();
|
||||||
|
farmland_0 = registerBlock( BlockBOPFarmland.paging.getBlock(0), "farmland_0");
|
||||||
|
farmland_1 = registerBlock( BlockBOPFarmland.paging.getBlock(1), "farmland_1");
|
||||||
|
|
||||||
// 22 tree types, 8 per BlockBOPSapling instance, needs 3 'pages'
|
// 22 tree types, 8 per BlockBOPSapling instance, needs 3 'pages'
|
||||||
BlockBOPSapling.createAllPages();
|
BlockBOPSapling.createAllPages();
|
||||||
sapling_0 = registerBlock( BlockBOPSapling.paging.getBlock(0), "sapling_0");
|
sapling_0 = registerBlock( BlockBOPSapling.paging.getBlock(0), "sapling_0");
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class ModHandlers
|
||||||
MinecraftForge.EVENT_BUS.register(new PotionParalysisEventHandler());
|
MinecraftForge.EVENT_BUS.register(new PotionParalysisEventHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new PotionPossessionEventHandler());
|
MinecraftForge.EVENT_BUS.register(new PotionPossessionEventHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new ItemEventHandler());
|
MinecraftForge.EVENT_BUS.register(new ItemEventHandler());
|
||||||
|
MinecraftForge.EVENT_BUS.register(new UseHoeEventHandler());
|
||||||
FMLCommonHandler.instance().bus().register(new AchievementEventHandler());
|
FMLCommonHandler.instance().bus().register(new AchievementEventHandler());
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
|
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"moisture=0,variant=loamy": { "model": "biomesoplenty:loamy_farmland_dry" },
|
||||||
|
"moisture=1,variant=loamy": { "model": "biomesoplenty:loamy_farmland_dry" },
|
||||||
|
"moisture=2,variant=loamy": { "model": "biomesoplenty:loamy_farmland_dry" },
|
||||||
|
"moisture=3,variant=loamy": { "model": "biomesoplenty:loamy_farmland_dry" },
|
||||||
|
"moisture=4,variant=loamy": { "model": "biomesoplenty:loamy_farmland_dry" },
|
||||||
|
"moisture=5,variant=loamy": { "model": "biomesoplenty:loamy_farmland_dry" },
|
||||||
|
"moisture=6,variant=loamy": { "model": "biomesoplenty:loamy_farmland_dry" },
|
||||||
|
"moisture=7,variant=loamy": { "model": "biomesoplenty:loamy_farmland_moist" },
|
||||||
|
"moisture=0,variant=sandy": { "model": "biomesoplenty:sandy_farmland_dry" },
|
||||||
|
"moisture=1,variant=sandy": { "model": "biomesoplenty:sandy_farmland_dry" },
|
||||||
|
"moisture=2,variant=sandy": { "model": "biomesoplenty:sandy_farmland_dry" },
|
||||||
|
"moisture=3,variant=sandy": { "model": "biomesoplenty:sandy_farmland_dry" },
|
||||||
|
"moisture=4,variant=sandy": { "model": "biomesoplenty:sandy_farmland_dry" },
|
||||||
|
"moisture=5,variant=sandy": { "model": "biomesoplenty:sandy_farmland_dry" },
|
||||||
|
"moisture=6,variant=sandy": { "model": "biomesoplenty:sandy_farmland_dry" },
|
||||||
|
"moisture=7,variant=sandy": { "model": "biomesoplenty:sandy_farmland_moist" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"moisture=0,variant=silty": { "model": "biomesoplenty:silty_farmland_dry" },
|
||||||
|
"moisture=1,variant=silty": { "model": "biomesoplenty:silty_farmland_dry" },
|
||||||
|
"moisture=2,variant=silty": { "model": "biomesoplenty:silty_farmland_dry" },
|
||||||
|
"moisture=3,variant=silty": { "model": "biomesoplenty:silty_farmland_dry" },
|
||||||
|
"moisture=4,variant=silty": { "model": "biomesoplenty:silty_farmland_dry" },
|
||||||
|
"moisture=5,variant=silty": { "model": "biomesoplenty:silty_farmland_dry" },
|
||||||
|
"moisture=6,variant=silty": { "model": "biomesoplenty:silty_farmland_dry" },
|
||||||
|
"moisture=7,variant=silty": { "model": "biomesoplenty:silty_farmland_moist" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"forge_marker": 1,
|
||||||
|
"defaults": {
|
||||||
|
"model": "biomesoplenty:loamy_farmland_dry"
|
||||||
|
},
|
||||||
|
"variants": {
|
||||||
|
"inventory": [{
|
||||||
|
"transform": "forge:default-block"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"forge_marker": 1,
|
||||||
|
"defaults": {
|
||||||
|
"model": "biomesoplenty:sandy_farmland_dry"
|
||||||
|
},
|
||||||
|
"variants": {
|
||||||
|
"inventory": [{
|
||||||
|
"transform": "forge:default-block"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"forge_marker": 1,
|
||||||
|
"defaults": {
|
||||||
|
"model": "biomesoplenty:silty_farmland_dry"
|
||||||
|
},
|
||||||
|
"variants": {
|
||||||
|
"inventory": [{
|
||||||
|
"transform": "forge:default-block"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
|
@ -206,6 +206,9 @@ tile.ethereal_fence.name=Ethereal Fence
|
||||||
tile.ethereal_fence_gate.name=Ethereal Fence Gate
|
tile.ethereal_fence_gate.name=Ethereal Fence Gate
|
||||||
tile.ethereal_wood_slab.name=Ethereal Wood Slab
|
tile.ethereal_wood_slab.name=Ethereal Wood Slab
|
||||||
tile.ethereal_stairs.name=Ethereal Wood Stairs
|
tile.ethereal_stairs.name=Ethereal Wood Stairs
|
||||||
|
tile.farmland_0.loamy_farmland.name=Loamy Farmland
|
||||||
|
tile.farmland_0.sandy_farmland.name=Sandy Farmland
|
||||||
|
tile.farmland_1.silty_farmland.name=Silty Farmland
|
||||||
tile.fir_fence.name=Fir Fence
|
tile.fir_fence.name=Fir Fence
|
||||||
tile.fir_fence_gate.name=Fir Fence Gate
|
tile.fir_fence_gate.name=Fir Fence Gate
|
||||||
tile.fir_wood_slab.name=Fir Wood Slab
|
tile.fir_wood_slab.name=Fir Wood Slab
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "block/farmland",
|
||||||
|
"textures": {
|
||||||
|
"particle": "biomesoplenty:blocks/dirt_loamy",
|
||||||
|
"dirt": "biomesoplenty:blocks/dirt_loamy",
|
||||||
|
"top": "biomesoplenty:blocks/farmland_dry_loamy"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "block/farmland",
|
||||||
|
"textures": {
|
||||||
|
"particle": "biomesoplenty:blocks/dirt_loamy",
|
||||||
|
"dirt": "biomesoplenty:blocks/dirt_loamy",
|
||||||
|
"top": "biomesoplenty:blocks/farmland_moist_loamy"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "block/farmland",
|
||||||
|
"textures": {
|
||||||
|
"particle": "biomesoplenty:blocks/dirt_sandy",
|
||||||
|
"dirt": "biomesoplenty:blocks/dirt_sandy",
|
||||||
|
"top": "biomesoplenty:blocks/farmland_dry_sandy"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "block/farmland",
|
||||||
|
"textures": {
|
||||||
|
"particle": "biomesoplenty:blocks/dirt_sandy",
|
||||||
|
"dirt": "biomesoplenty:blocks/dirt_sandy",
|
||||||
|
"top": "biomesoplenty:blocks/farmland_moist_sandy"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "block/farmland",
|
||||||
|
"textures": {
|
||||||
|
"particle": "biomesoplenty:blocks/dirt_silty",
|
||||||
|
"dirt": "biomesoplenty:blocks/dirt_silty",
|
||||||
|
"top": "biomesoplenty:blocks/farmland_dry_silty"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "block/farmland",
|
||||||
|
"textures": {
|
||||||
|
"particle": "biomesoplenty:blocks/dirt_silty",
|
||||||
|
"dirt": "biomesoplenty:blocks/dirt_silty",
|
||||||
|
"top": "biomesoplenty:blocks/farmland_moist_silty"
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 567 B After Width: | Height: | Size: 567 B |
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 649 B |
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 617 B |
Loading…
Reference in a new issue