Merge pull request #794 from GirafiStudios/BOP-1.9.4-4.1.x

Added path blocks for BoP grasses Closes #737
This commit is contained in:
Adubbz 2016-06-22 17:51:10 +10:00 committed by GitHub
commit dd3adbb48c
16 changed files with 242 additions and 45 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
/build/ /build/
/bin/ /bin/
/out/
/Mixin/ /Mixin/
/repo/ /repo/
/run/ /run/

View File

@ -1,4 +1,4 @@
minecraft_version=1.9.4 minecraft_version=1.9.4
forge_version=12.17.0.1949 forge_version=12.17.0.1968
mod_version=4.1.0 mod_version=4.1.0
mappings_version=snapshot_nodoc_20160519 mappings_version=snapshot_nodoc_20160519

View File

@ -119,6 +119,7 @@ public class BOPBlocks
public static Block turnip_block; public static Block turnip_block;
public static Block flesh; public static Block flesh;
public static Block grass; public static Block grass;
public static Block grass_path;
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_0;

View File

@ -99,11 +99,13 @@ public class BlockBOPFarmland extends BlockFarmland implements IBOPBlock
this.setDefaultState(this.blockState.getBaseState().withProperty(MOISTURE, Integer.valueOf(0))); this.setDefaultState(this.blockState.getBaseState().withProperty(MOISTURE, Integer.valueOf(0)));
} }
@Override
public IBlockState getStateFromMeta(int meta) public IBlockState getStateFromMeta(int meta)
{ {
return this.getDefaultState().withProperty(this.variantProperty, paging.getVariant(this, meta & 1)).withProperty(MOISTURE, Integer.valueOf(meta >> 1)); return this.getDefaultState().withProperty(this.variantProperty, paging.getVariant(this, meta & 1)).withProperty(MOISTURE, Integer.valueOf(meta >> 1));
} }
@Override
public int getMetaFromState(IBlockState state) public int getMetaFromState(IBlockState state)
{ {
BlockBOPDirt.BOPDirtType dirt = (BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty); BlockBOPDirt.BOPDirtType dirt = (BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty);

View File

@ -0,0 +1,132 @@
package biomesoplenty.common.block;
import biomesoplenty.api.block.BOPBlocks;
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.BlockGrassPath;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
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.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random;
public class BlockBOPGrassPath extends BlockGrassPath implements IBOPBlock
{
public static VariantPagingHelper<BlockBOPGrassPath, BlockBOPDirt.BOPDirtType> paging = new VariantPagingHelper<BlockBOPGrassPath, BlockBOPDirt.BOPDirtType>(3, 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 BlockBOPGrassPath());
}
}
public IProperty variantProperty;
@Override
protected BlockStateContainer createBlockState()
{
this.variantProperty = currentVariantProperty;
return new BlockStateContainer(this, new IProperty[] { this.variantProperty });
}
@Override
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
@Override
public IProperty[] getPresetProperties() { return new IProperty[] { this.variantProperty }; }
@Override
public IProperty[] getNonRenderingProperties() { return null; }
@Override
public String getStateName(IBlockState state) {
return "grass_" + ((BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty)).getName() + "_path";
}
@Override
@SideOnly(Side.CLIENT)
public IBlockColor getBlockColor() { return null; }
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor() { return null; }
public BlockBOPGrassPath() {
super();
this.setHardness(0.65F);
this.setSoundType(SoundType.PLANT);
this.disableStats();
this.setHarvestLevel("shovel", 0);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(this.variantProperty, paging.getVariant(this, Math.min(2, meta & 7)));
}
@Override
public int getMetaFromState(IBlockState state)
{
BlockBOPDirt.BOPDirtType dirt = (BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty);
return paging.getIndex(dirt);
}
@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(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
{
return new ItemStack(this, 1, BOPBlocks.dirt.getMetaFromState(this.getDirtBlockState(world.getBlockState(pos))));
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn)
{
if (world.getBlockState(pos.up()).getMaterial().isSolid())
{
world.setBlockState(pos, this.getDirtBlockState(world.getBlockState(pos)));
}
}
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());
}
}
}

View File

@ -0,0 +1,50 @@
package biomesoplenty.common.handler;
import biomesoplenty.common.block.BlockBOPDirt;
import biomesoplenty.common.block.BlockBOPGrass;
import biomesoplenty.common.block.BlockBOPGrassPath;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class GrassPathEventHandler
{
@SubscribeEvent
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) {
ItemStack stack = event.getItemStack();
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
BlockPos pos = event.getPos();
EnumFacing facing = event.getFace();
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockBOPGrass && stack != null && stack.getItem() instanceof ItemSpade)
{
Block dirtBlock = BlockBOPGrass.getDirtBlockState(state).getBlock();
if (dirtBlock instanceof BlockBOPDirt)
{
if (facing != EnumFacing.DOWN && world.getBlockState(pos.up()).getMaterial() == Material.AIR)
{
world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!world.isRemote)
{
BlockBOPDirt.BOPDirtType dirtType = (BlockBOPDirt.BOPDirtType) BlockBOPGrass.getDirtBlockState(state).getValue(BlockBOPDirt.VARIANT);
world.setBlockState(pos, BlockBOPGrassPath.paging.getVariantState(dirtType), 11);
stack.damageItem(1, player);
}
}
}
}
}
}

View File

@ -14,50 +14,10 @@ import static biomesoplenty.api.item.BOPItems.honey_bucket;
import static biomesoplenty.api.item.BOPItems.hot_spring_water_bucket; import static biomesoplenty.api.item.BOPItems.hot_spring_water_bucket;
import static biomesoplenty.api.item.BOPItems.poison_bucket; import static biomesoplenty.api.item.BOPItems.poison_bucket;
import biomesoplenty.common.block.*;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
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.BlockBOPFarmland;
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.BlockBOPStoneFormations;
import biomesoplenty.common.block.BlockBOPTerrarium;
import biomesoplenty.common.block.BlockBOPTurnip;
import biomesoplenty.common.block.BlockBOPVine;
import biomesoplenty.common.block.BlockBOPWoodStairs;
import biomesoplenty.common.block.IBOPBlock;
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;
@ -107,9 +67,12 @@ public class ModBlocks
grass = registerBlock( new BlockBOPGrass(), "grass" ); grass = registerBlock( new BlockBOPGrass(), "grass" );
dirt = registerBlock( new BlockBOPDirt(), "dirt" ); dirt = registerBlock( new BlockBOPDirt(), "dirt" );
BlockBOPGrassPath.createAllPages();
grass_path = registerBlock( BlockBOPGrassPath.paging.getBlock(0), "grass_path", null);
BlockBOPFarmland.createAllPages(); BlockBOPFarmland.createAllPages();
farmland_0 = registerBlock( BlockBOPFarmland.paging.getBlock(0), "farmland_0", null); farmland_0 = registerBlock( BlockBOPFarmland.paging.getBlock(0), "farmland_0", null);
farmland_1 = registerBlock( BlockBOPFarmland.paging.getBlock(1), "farmland_1", null); farmland_1 = registerBlock( BlockBOPFarmland.paging.getBlock(1), "farmland_1", null);
stone = registerBlock( new BlockBOPStone(), "stone" ); stone = registerBlock( new BlockBOPStone(), "stone" );
crag_rock = registerBlock( (new BlockBOPGeneric()), "crag_rock" ); crag_rock = registerBlock( (new BlockBOPGeneric()), "crag_rock" );
@ -126,7 +89,7 @@ public class ModBlocks
gem_ore = registerBlock( new BlockBOPGemOre(), "gem_ore" ); gem_ore = registerBlock( new BlockBOPGemOre(), "gem_ore" );
gem_block = registerBlock( new BlockBOPGem(), "gem_block" ); gem_block = registerBlock( new BlockBOPGem(), "gem_block" );
hive = registerBlock( new BlockBOPHive(), "hive" ); hive = registerBlock( new BlockBOPHive(), "hive" );
honey_block = registerBlock( new BlockBOPHoney(), "honey_block" ); honey_block = registerBlock( new BlockBOPHoney(), "honey_block" );
bone_segment = registerBlock( new BlockBOPBones(), "bone_segment" ); bone_segment = registerBlock( new BlockBOPBones(), "bone_segment" );
//Material Blocks //Material Blocks

View File

@ -12,6 +12,7 @@ import biomesoplenty.common.handler.AchievementEventHandler;
import biomesoplenty.common.handler.BucketEventHandler; import biomesoplenty.common.handler.BucketEventHandler;
import biomesoplenty.common.handler.DyeEventHandler; import biomesoplenty.common.handler.DyeEventHandler;
import biomesoplenty.common.handler.FlippersEventHandler; import biomesoplenty.common.handler.FlippersEventHandler;
import biomesoplenty.common.handler.GrassPathEventHandler;
import biomesoplenty.common.handler.GuiEventHandler; import biomesoplenty.common.handler.GuiEventHandler;
import biomesoplenty.common.handler.ItemEventHandler; import biomesoplenty.common.handler.ItemEventHandler;
import biomesoplenty.common.handler.TrailsEventHandler; import biomesoplenty.common.handler.TrailsEventHandler;
@ -43,6 +44,7 @@ public class ModHandlers
MinecraftForge.EVENT_BUS.register(new ItemEventHandler()); MinecraftForge.EVENT_BUS.register(new ItemEventHandler());
MinecraftForge.EVENT_BUS.register(new UseHoeEventHandler()); MinecraftForge.EVENT_BUS.register(new UseHoeEventHandler());
MinecraftForge.EVENT_BUS.register(new AchievementEventHandler()); MinecraftForge.EVENT_BUS.register(new AchievementEventHandler());
MinecraftForge.EVENT_BUS.register(new GrassPathEventHandler());
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
{ {

View File

@ -0,0 +1,7 @@
{
"variants": {
"variant=loamy": { "model": "biomesoplenty:grass_loamy_path" },
"variant=sandy": { "model": "biomesoplenty:grass_sandy_path" },
"variant=silty": { "model": "biomesoplenty:grass_silty_path" }
}
}

View File

@ -280,6 +280,9 @@ tile.grass.sandy_grass_block.name=Sandy Grass Block
tile.grass.silty_grass_block.name=Silty Grass Block tile.grass.silty_grass_block.name=Silty Grass Block
tile.grass.origin_grass_block.name=Origin Grass Block tile.grass.origin_grass_block.name=Origin Grass Block
tile.grass.overgrown_netherrack.name=Overgrown Netherrack tile.grass.overgrown_netherrack.name=Overgrown Netherrack
tile.grass_path.grass_loamy_path.name=Loamy Grass Path
tile.grass_path.grass_sandy_path.name=Sandy Grass Path
tile.grass_path.grass_silty_path.name=Silty Grass Path
tile.hellbark_fence.name=Hellbark Fence tile.hellbark_fence.name=Hellbark Fence
tile.hellbark_fence_gate.name=Hellbark Fence Gate tile.hellbark_fence_gate.name=Hellbark Fence Gate
tile.hellbark_wood_slab.name=Hellbark Wood Slab tile.hellbark_wood_slab.name=Hellbark Wood Slab

View File

@ -0,0 +1,9 @@
{
"parent": "block/grass_path",
"textures": {
"particle": "biomesoplenty:blocks/dirt_loamy",
"top": "blocks/grass_path_top",
"side": "biomesoplenty:blocks/grass_loamy_path_side",
"bottom": "biomesoplenty:blocks/dirt_loamy"
}
}

View File

@ -0,0 +1,9 @@
{
"parent": "block/grass_path",
"textures": {
"particle": "biomesoplenty:blocks/dirt_sandy",
"top": "blocks/grass_path_top",
"side": "biomesoplenty:blocks/grass_sandy_path_side",
"bottom": "biomesoplenty:blocks/dirt_sandy"
}
}

View File

@ -0,0 +1,9 @@
{
"parent": "block/grass_path",
"textures": {
"particle": "biomesoplenty:blocks/dirt_silty",
"top": "blocks/grass_path_top",
"side": "biomesoplenty:blocks/grass_silty_path_side",
"bottom": "biomesoplenty:blocks/dirt_silty"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "biomesoplenty:block/grass_loamy_path"
}

View File

@ -0,0 +1,3 @@
{
"parent": "biomesoplenty:block/grass_sandy_path"
}

View File

@ -0,0 +1,3 @@
{
"parent": "biomesoplenty:block/grass_silty_path"
}