diff --git a/.gitignore b/.gitignore index fd5e5e737..f8e2af748 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /build/ /bin/ +/out/ /Mixin/ /repo/ /run/ diff --git a/build.properties b/build.properties index 88d419d89..27a8406da 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ minecraft_version=1.9.4 -forge_version=12.17.0.1949 +forge_version=12.17.0.1968 mod_version=4.1.0 mappings_version=snapshot_nodoc_20160519 diff --git a/src/main/java/biomesoplenty/api/block/BOPBlocks.java b/src/main/java/biomesoplenty/api/block/BOPBlocks.java index 175cc5497..f99325283 100644 --- a/src/main/java/biomesoplenty/api/block/BOPBlocks.java +++ b/src/main/java/biomesoplenty/api/block/BOPBlocks.java @@ -119,6 +119,7 @@ public class BOPBlocks public static Block turnip_block; public static Block flesh; public static Block grass; + public static Block grass_path; public static Block waterlily; public static Block dirt; public static Block farmland_0; diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPFarmland.java b/src/main/java/biomesoplenty/common/block/BlockBOPFarmland.java index a232bd4eb..3ee362cb3 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPFarmland.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPFarmland.java @@ -99,11 +99,13 @@ public class BlockBOPFarmland extends BlockFarmland implements IBOPBlock this.setDefaultState(this.blockState.getBaseState().withProperty(MOISTURE, Integer.valueOf(0))); } + @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(this.variantProperty, paging.getVariant(this, meta & 1)).withProperty(MOISTURE, Integer.valueOf(meta >> 1)); } + @Override public int getMetaFromState(IBlockState state) { BlockBOPDirt.BOPDirtType dirt = (BlockBOPDirt.BOPDirtType) state.getValue(this.variantProperty); diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPGrassPath.java b/src/main/java/biomesoplenty/common/block/BlockBOPGrassPath.java new file mode 100644 index 000000000..a9d2ca6fc --- /dev/null +++ b/src/main/java/biomesoplenty/common/block/BlockBOPGrassPath.java @@ -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 paging = new VariantPagingHelper(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 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()); + } + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/handler/GrassPathEventHandler.java b/src/main/java/biomesoplenty/common/handler/GrassPathEventHandler.java new file mode 100644 index 000000000..b66f3bf91 --- /dev/null +++ b/src/main/java/biomesoplenty/common/handler/GrassPathEventHandler.java @@ -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); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/init/ModBlocks.java b/src/main/java/biomesoplenty/common/init/ModBlocks.java index 129f1b16c..aae74fdf8 100644 --- a/src/main/java/biomesoplenty/common/init/ModBlocks.java +++ b/src/main/java/biomesoplenty/common/init/ModBlocks.java @@ -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.poison_bucket; +import biomesoplenty.common.block.*; import com.google.common.collect.ImmutableSet; 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.enums.BOPWoods; import biomesoplenty.common.fluids.BloodFluid; @@ -106,10 +66,13 @@ public class ModBlocks //Terrain Blocks grass = registerBlock( new BlockBOPGrass(), "grass" ); dirt = registerBlock( new BlockBOPDirt(), "dirt" ); + + BlockBOPGrassPath.createAllPages(); + grass_path = registerBlock( BlockBOPGrassPath.paging.getBlock(0), "grass_path", null); BlockBOPFarmland.createAllPages(); - farmland_0 = registerBlock( BlockBOPFarmland.paging.getBlock(0), "farmland_0", null); - farmland_1 = registerBlock( BlockBOPFarmland.paging.getBlock(1), "farmland_1", null); + farmland_0 = registerBlock( BlockBOPFarmland.paging.getBlock(0), "farmland_0", null); + farmland_1 = registerBlock( BlockBOPFarmland.paging.getBlock(1), "farmland_1", null); stone = registerBlock( new BlockBOPStone(), "stone" ); crag_rock = registerBlock( (new BlockBOPGeneric()), "crag_rock" ); @@ -126,7 +89,7 @@ public class ModBlocks gem_ore = registerBlock( new BlockBOPGemOre(), "gem_ore" ); gem_block = registerBlock( new BlockBOPGem(), "gem_block" ); 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" ); //Material Blocks diff --git a/src/main/java/biomesoplenty/common/init/ModHandlers.java b/src/main/java/biomesoplenty/common/init/ModHandlers.java index 89173e992..5ceb2cbd1 100644 --- a/src/main/java/biomesoplenty/common/init/ModHandlers.java +++ b/src/main/java/biomesoplenty/common/init/ModHandlers.java @@ -12,6 +12,7 @@ import biomesoplenty.common.handler.AchievementEventHandler; import biomesoplenty.common.handler.BucketEventHandler; import biomesoplenty.common.handler.DyeEventHandler; import biomesoplenty.common.handler.FlippersEventHandler; +import biomesoplenty.common.handler.GrassPathEventHandler; import biomesoplenty.common.handler.GuiEventHandler; import biomesoplenty.common.handler.ItemEventHandler; import biomesoplenty.common.handler.TrailsEventHandler; @@ -43,6 +44,7 @@ public class ModHandlers MinecraftForge.EVENT_BUS.register(new ItemEventHandler()); MinecraftForge.EVENT_BUS.register(new UseHoeEventHandler()); MinecraftForge.EVENT_BUS.register(new AchievementEventHandler()); + MinecraftForge.EVENT_BUS.register(new GrassPathEventHandler()); if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { diff --git a/src/main/resources/assets/biomesoplenty/blockstates/grass_path.json b/src/main/resources/assets/biomesoplenty/blockstates/grass_path.json new file mode 100644 index 000000000..6e511c035 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/blockstates/grass_path.json @@ -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" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/biomesoplenty/lang/en_US.lang b/src/main/resources/assets/biomesoplenty/lang/en_US.lang index 134684b3f..d930b769f 100644 --- a/src/main/resources/assets/biomesoplenty/lang/en_US.lang +++ b/src/main/resources/assets/biomesoplenty/lang/en_US.lang @@ -280,6 +280,9 @@ tile.grass.sandy_grass_block.name=Sandy Grass Block tile.grass.silty_grass_block.name=Silty Grass Block tile.grass.origin_grass_block.name=Origin Grass Block 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_gate.name=Hellbark Fence Gate tile.hellbark_wood_slab.name=Hellbark Wood Slab diff --git a/src/main/resources/assets/biomesoplenty/models/block/grass_loamy_path.json b/src/main/resources/assets/biomesoplenty/models/block/grass_loamy_path.json new file mode 100644 index 000000000..6749eec1b --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/block/grass_loamy_path.json @@ -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" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/biomesoplenty/models/block/grass_sandy_path.json b/src/main/resources/assets/biomesoplenty/models/block/grass_sandy_path.json new file mode 100644 index 000000000..4a20cef2e --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/block/grass_sandy_path.json @@ -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" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/biomesoplenty/models/block/grass_silty_path.json b/src/main/resources/assets/biomesoplenty/models/block/grass_silty_path.json new file mode 100644 index 000000000..7eb7f4d4f --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/block/grass_silty_path.json @@ -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" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/biomesoplenty/models/item/grass_loamy_path.json b/src/main/resources/assets/biomesoplenty/models/item/grass_loamy_path.json new file mode 100644 index 000000000..6c374a4a8 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/item/grass_loamy_path.json @@ -0,0 +1,3 @@ +{ + "parent": "biomesoplenty:block/grass_loamy_path" +} \ No newline at end of file diff --git a/src/main/resources/assets/biomesoplenty/models/item/grass_sandy_path.json b/src/main/resources/assets/biomesoplenty/models/item/grass_sandy_path.json new file mode 100644 index 000000000..5132900ab --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/item/grass_sandy_path.json @@ -0,0 +1,3 @@ +{ + "parent": "biomesoplenty:block/grass_sandy_path" +} \ No newline at end of file diff --git a/src/main/resources/assets/biomesoplenty/models/item/grass_silty_path.json b/src/main/resources/assets/biomesoplenty/models/item/grass_silty_path.json new file mode 100644 index 000000000..54191d1d0 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/item/grass_silty_path.json @@ -0,0 +1,3 @@ +{ + "parent": "biomesoplenty:block/grass_silty_path" +} \ No newline at end of file