Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.9 #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 0 additions & 124 deletions .idea/uiDesigner.xml

This file was deleted.

8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'

version = "0.0.2"
version = "0.0.3"
group= "uk.co.haxyshideout.ChocoCraft2" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ChocoCraft2"

Expand All @@ -24,9 +24,9 @@ configurations {
}

minecraft {
version = "1.8-11.14.3.1550"
version = "1.9-12.16.0.1865-1.9"
runDir = "run"
mappings = "snapshot_20151106"
mappings = "snapshot_20160312"
}

reobfJar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,59 @@
package uk.co.haxyshideout.chococraft2.blocks;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import uk.co.haxyshideout.chococraft2.config.Additions;
import uk.co.haxyshideout.haxylib.blocks.GenericBush;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* Created by clienthax on 12/4/2015.
*/
public class GysahlStemBlock extends GenericBush implements IGrowable {

public class GysahlStemBlock extends GenericBush implements IGrowable
{
public static final Integer MAXSTAGE = 4;
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, MAXSTAGE);

public GysahlStemBlock() {
public GysahlStemBlock()
{
setTickRandomly(true);
this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, 0));
float f = 0.4F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
this.setStepSound(soundTypeGrass);
this.setStepSound(SoundType.GROUND);
this.setHardness(0f);
}

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
public AxisAlignedBB getCollisionBoundingBox(IBlockState worldIn, World pos, BlockPos state)
{
float f = 0.4F;
return new AxisAlignedBB(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
}

@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
{
return new ItemStack(Additions.gysahlSeedsItem);
}

@Override
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
if(worldIn.isRemote)
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (worldIn.isRemote)
return;

super.updateTick(worldIn, pos, state, rand);
Expand All @@ -53,16 +63,19 @@ public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random ra
@Override
public java.util.List<net.minecraft.item.ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
//if stage = max stage, drop gysahl green item, else drop nothing
// if stage = max stage, drop gysahl green item, else drop nothing
List<ItemStack> ret = new ArrayList<ItemStack>();
if(state.getValue(STAGE) == MAXSTAGE) {
Random rand = world instanceof World ? ((World)world).rand : new Random();
if (state.getValue(STAGE) == MAXSTAGE)
{
Random rand = world instanceof World ? ((World) world).rand : new Random();
ret.add(getGysahlItem(rand));

//If fully grown give a seed drop chance
// If fully grown give a seed drop chance
int seedAmount = 3 + fortune;
for(int i = 0; i < seedAmount; i++) {
if(rand.nextInt(15) < 7) {
for (int i = 0; i < seedAmount; i++)
{
if (rand.nextInt(15) < 7)
{
ret.add(new ItemStack(Additions.gysahlSeedsItem));
}
}
Expand All @@ -71,52 +84,60 @@ public java.util.List<net.minecraft.item.ItemStack> getDrops(IBlockAccess world,
return ret;
}

private ItemStack getGysahlItem(Random random) {
private ItemStack getGysahlItem(Random random)
{
Item item;
int chance = random.nextInt(200);
if(chance < 10)
if (chance < 10)
item = Additions.gysahlGoldenItem;
else if(chance < 30)
else if (chance < 30)
item = Additions.gysahlLoverlyItem;
else
item = Additions.gysahlGreenItem;


return new ItemStack(item);
}

@Override
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) {
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
{
return true;
}

@Override
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) {
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
return true;
}

@Override
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) {
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
super.updateTick(worldIn, pos, state, rand);
this.growStem(worldIn, rand, pos, state);
}

private void growStem(World worldIn, Random rand, BlockPos pos, IBlockState state) {
if(worldIn.getLightFromNeighbors(pos) >= 9) {
if( (Integer) state.getValue(STAGE) < MAXSTAGE) {
private void growStem(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
if (worldIn.getLightFromNeighbors(pos) >= 9)
{
if ((Integer) state.getValue(STAGE) < MAXSTAGE)
{
float growthChance = getGrowthChance(this, worldIn, pos);
if(rand.nextInt((int)(25F / growthChance) + 1) == 0) {
if (rand.nextInt((int) (25F / growthChance) + 1) == 0)
{
worldIn.setBlockState(pos, state.cycleProperty(STAGE), 2);
}
}
}
}

public void setGrowthStage(World world, BlockPos pos, IBlockState state) {
public void setGrowthStage(World world, BlockPos pos, IBlockState state)
{
world.setBlockState(pos, state.withProperty(STAGE, 4), 2);
}

//Stolen from BlockCrops
// Stolen from BlockCrops
public float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
{
float f = 1.0F;
Expand All @@ -129,7 +150,7 @@ public float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
float f1 = 0.0F;
IBlockState iblockstate = worldIn.getBlockState(blockUnder.add(i, 0, j));

if (iblockstate.getBlock().canSustainPlant(worldIn, blockUnder.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn))
if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockUnder.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn))
{
f1 = 1.0F;

Expand Down Expand Up @@ -172,7 +193,6 @@ public float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
return f;
}


/**
* Convert the given metadata into a BlockState for this Block
*/
Expand All @@ -192,10 +212,8 @@ public int getMetaFromState(IBlockState state)
}

@Override
protected BlockState createBlockState()
protected BlockStateContainer createBlockState()
{
return new BlockState(this, STAGE);
return new BlockStateContainer(this, STAGE);
}


}
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package uk.co.haxyshideout.chococraft2.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import uk.co.haxyshideout.haxylib.blocks.GenericBlock;

/**
* Created by clienthax on 13/4/2015.
*/
public class StrawBlock extends GenericBlock {

public StrawBlock() {
public class StrawBlock extends GenericBlock
{
public StrawBlock()
{
super(Material.carpet);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
setOpaque(false);
setFullCube(false);
setStepSound(Block.soundTypeGrass);
setStepSound(SoundType.GROUND);
}

@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState worldIn, World pos, BlockPos state)
{
return new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
}
}
Loading