Leaves, partial
Logic is hopefully there, rendering is incorrect (it needs a color handler). Also, shit is going to happen w.r.t. "fancy graphics".
This commit is contained in:
parent
74dc1e1ff5
commit
a90bd955fb
9 changed files with 180 additions and 10 deletions
BIN
graphics/hevea_leaves.xcf
Normal file
BIN
graphics/hevea_leaves.xcf
Normal file
Binary file not shown.
112
src/java/mmm/materials/MLeaves.java
Normal file
112
src/java/mmm/materials/MLeaves.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
package mmm.materials;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mmm.utils.URegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
|
||||
public class MLeaves
|
||||
extends BlockLeaves
|
||||
{
|
||||
|
||||
private final MWood wood;
|
||||
|
||||
|
||||
public MLeaves( final MWood wood )
|
||||
{
|
||||
this.wood = wood;
|
||||
URegistry.setIdentifiers( this , "materials" , "leaves" , wood.NAME );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Item getItemDropped( final IBlockState state , final Random rand , final int fortune )
|
||||
{
|
||||
// LOL NO FIXME
|
||||
// Should be
|
||||
// return Item.getItemFromBlock( this.wood.SAPLING );
|
||||
return Item.getItemFromBlock( Blocks.SAPLING );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void dropApple( final World worldIn , final BlockPos pos , final IBlockState state , final int chance )
|
||||
{
|
||||
final Item fruit = this.wood.getFruit( );
|
||||
if ( fruit != null && worldIn.rand.nextInt( chance ) < this.wood.getFruitDropChance( ) ) {
|
||||
Block.spawnAsEntity( worldIn , pos , new ItemStack( fruit ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getSaplingDropChance( final IBlockState state )
|
||||
{
|
||||
return this.wood.getSaplingDropChance( );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List< ItemStack > onSheared( final ItemStack item , final IBlockAccess world , final BlockPos pos ,
|
||||
final int fortune )
|
||||
{
|
||||
return Arrays.asList( new ItemStack( this ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockPlanks.EnumType getWoodType( final int meta )
|
||||
{
|
||||
// Fuck you and fuck this useless fuckery. For fuck's sake.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState( )
|
||||
{
|
||||
return new BlockStateContainer( this , new IProperty[] {
|
||||
BlockLeaves.CHECK_DECAY , BlockLeaves.DECAYABLE
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta( final int meta )
|
||||
{
|
||||
return this.getDefaultState( ) //
|
||||
.withProperty( BlockLeaves.DECAYABLE , Boolean.valueOf( ( meta & 4 ) == 0 ) ) //
|
||||
.withProperty( BlockLeaves.CHECK_DECAY , Boolean.valueOf( ( meta & 8 ) > 0 ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMetaFromState( final IBlockState state )
|
||||
{
|
||||
int meta = 0;
|
||||
if ( !state.getValue( BlockLeaves.DECAYABLE ) ) {
|
||||
meta |= 4;
|
||||
}
|
||||
if ( state.getValue( BlockLeaves.CHECK_DECAY ) ) {
|
||||
meta |= 8;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,14 +10,14 @@ import net.minecraft.block.state.IBlockState;
|
|||
|
||||
|
||||
|
||||
public class MWoodLog
|
||||
public class MLog
|
||||
extends BlockLog
|
||||
{
|
||||
|
||||
private final MWood wood;
|
||||
public final MWood wood;
|
||||
|
||||
|
||||
public MWoodLog( final MWood wood )
|
||||
public MLog( final MWood wood )
|
||||
{
|
||||
super( );
|
||||
this.wood = wood;
|
|
@ -10,14 +10,14 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
|
||||
|
||||
|
||||
public class MWoodPlanks
|
||||
public class MPlanks
|
||||
extends Block
|
||||
{
|
||||
|
||||
private MWood wood;
|
||||
public final MWood wood;
|
||||
|
||||
|
||||
public MWoodPlanks( MWood wood )
|
||||
public MPlanks( final MWood wood )
|
||||
{
|
||||
super( Material.WOOD );
|
||||
this.wood = wood;
|
|
@ -6,6 +6,7 @@ import mmm.utils.URegistry;
|
|||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
|
@ -16,20 +17,25 @@ public class MWood
|
|||
{
|
||||
|
||||
public final String NAME;
|
||||
public final MWoodLog LOG;
|
||||
public final MWoodPlanks PLANKS;
|
||||
public final MLeaves LEAVES;
|
||||
public final MLog LOG;
|
||||
public final MPlanks PLANKS;
|
||||
|
||||
private MapColor barkColor = MapColor.WOOD;
|
||||
private MapColor plankColor = MapColor.WOOD;
|
||||
private int baseFireEncouragement = 5;
|
||||
private int baseFlammability = 5;
|
||||
private int saplingDropChance = 20;
|
||||
private int fruitDropChance = 0;
|
||||
private Item fruit = null;
|
||||
|
||||
|
||||
public MWood( final String name )
|
||||
{
|
||||
this.NAME = name;
|
||||
this.LOG = new MWoodLog( this );
|
||||
this.PLANKS = new MWoodPlanks( this );
|
||||
this.LEAVES = new MLeaves( this );
|
||||
this.LOG = new MLog( this );
|
||||
this.PLANKS = new MPlanks( this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,6 +53,21 @@ public class MWood
|
|||
}
|
||||
|
||||
|
||||
public MWood setSaplingDropChance( final int chance )
|
||||
{
|
||||
this.saplingDropChance = chance;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public MWood setFruit( final Item fruit , final float dropChance )
|
||||
{
|
||||
this.fruit = fruit;
|
||||
this.fruitDropChance = (int) ( 200 * dropChance );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public MWood setBaseFireInfo( final int encouragement , final int flammability )
|
||||
{
|
||||
this.baseFireEncouragement = encouragement;
|
||||
|
@ -61,6 +82,8 @@ public class MWood
|
|||
Blocks.FIRE.setFireInfo( this.LOG , this.baseFireEncouragement , this.baseFlammability );
|
||||
URegistry.addBlock( this.PLANKS );
|
||||
Blocks.FIRE.setFireInfo( this.PLANKS , this.baseFireEncouragement , this.baseFlammability * 4 );
|
||||
URegistry.addBlock( this.LEAVES );
|
||||
Blocks.FIRE.setFireInfo( this.LEAVES , this.baseFireEncouragement * 6 , this.baseFlammability * 12 );
|
||||
|
||||
URegistry.addRecipeRegistrar( this );
|
||||
return this;
|
||||
|
@ -79,6 +102,24 @@ public class MWood
|
|||
}
|
||||
|
||||
|
||||
public int getSaplingDropChance( )
|
||||
{
|
||||
return this.saplingDropChance;
|
||||
}
|
||||
|
||||
|
||||
public int getFruitDropChance( )
|
||||
{
|
||||
return this.fruitDropChance;
|
||||
}
|
||||
|
||||
|
||||
public Item getFruit( )
|
||||
{
|
||||
return this.fruit;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerRecipes( )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"variants": {
|
||||
"check_decay=false,decayable=false": { "model": "mmm:materials/leaves/hevea" } ,
|
||||
"check_decay=false,decayable=true": { "model": "mmm:materials/leaves/hevea" } ,
|
||||
"check_decay=true,decayable=false": { "model": "mmm:materials/leaves/hevea" } ,
|
||||
"check_decay=true,decayable=true": { "model": "mmm:materials/leaves/hevea" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:block/leaves",
|
||||
"textures": {
|
||||
"all": "mmm:blocks/materials/leaves/hevea"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "mmm:block/materials/leaves/hevea"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 603 B |
Reference in a new issue