Quicksand that can replace dirt or grass

This commit is contained in:
Emmanuel BENOîT 2016-07-10 15:28:59 +02:00
parent ae03058d20
commit 7ba899b576
6 changed files with 119 additions and 0 deletions

View file

@ -0,0 +1,88 @@
package mmm.materials;
import mmm.utils.I_UTintedBlock;
import mmm.utils.I_UTintedItem;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.biome.BiomeColorHelper;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class MSwampPit
extends MQuicksand
implements I_UTintedBlock , I_UTintedItem
{
public MSwampPit( )
{
super( "swamp_pit" , Blocks.GRASS.getDefaultState( ) );
}
@Override
public IBlockState[] getReplacedBlocks( )
{
return new IBlockState[] {
this.forType , Blocks.DIRT.getDefaultState( )
};
}
@Override
public boolean canSustainPlant( IBlockState state , IBlockAccess world , BlockPos pos , EnumFacing direction ,
IPlantable plantable )
{
return false;
}
@Override
@SideOnly( Side.CLIENT )
public IBlockColor getBlockTint( )
{
return new IBlockColor( ) {
@Override
public int colorMultiplier( final IBlockState state , final IBlockAccess worldIn , final BlockPos pos ,
final int tintIndex )
{
final boolean inWorld = worldIn != null && pos != null;
final int baseTint = inWorld
? BiomeColorHelper.getGrassColorAtPos( worldIn , pos )
: ColorizerGrass.getGrassColor( .5f , .5f );
return baseTint;
}
};
}
@Override
@SideOnly( Side.CLIENT )
public IItemColor getItemTint( )
{
final IBlockColor bTint = this.getBlockTint( );
final IBlockState ds = this.getDefaultState( );
return new IItemColor( ) {
@Override
public int getColorFromItemstack( final ItemStack stack , final int tintIndex )
{
return bTint.colorMultiplier( ds , null , null , tintIndex );
}
};
}
}

View file

@ -11,6 +11,7 @@ public class MTraps
{
public final MQuicksand QUICKSAND;
public final MQuicksand RED_QUICKSAND;
public final MSwampPit SWAMP_PIT;
public final MMud MUD;
@ -23,6 +24,7 @@ public class MTraps
URegistry.addBlock( this.RED_QUICKSAND = new MQuicksand( "red_sand" , //
Blocks.SAND.getDefaultState( ) //
.withProperty( BlockSand.VARIANT , BlockSand.EnumType.RED_SAND ) ) );
URegistry.addBlock( this.SWAMP_PIT = new MSwampPit( ) );
URegistry.addBlock( this.MUD = new MMud( ) );
}
}

View file

@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "mmm:materials/trap/swamp_pit" }
}
}

View file

@ -0,0 +1,21 @@
{
"parent": "minecraft:block/grass",
"textures": {
"particle": "minecraft:blocks/dirt",
"all": "mmm:blocks/materials/trap/swamp_pit"
} ,
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "down", "tintindex": 0 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "up", "tintindex": 0 },
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "north", "tintindex": 0 },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "south", "tintindex": 0 },
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "west", "tintindex": 0 },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "east", "tintindex": 0 }
}
}
]
}

View file

@ -0,0 +1,3 @@
{
"parent": "mmm:block/materials/trap/swamp_pit"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B