2015-08-18 20:40:55 -04:00
package team.chisel.block ;
2015-01-04 18:15:15 +00:00
import java.util.List ;
2015-08-18 20:40:55 -04:00
import com.cricketcraft.chisel.api.ICarvable ;
import com.cricketcraft.chisel.api.carving.CarvableHelper ;
import com.cricketcraft.chisel.api.carving.IVariationInfo ;
import com.cricketcraft.chisel.api.rendering.ClientUtils ;
import team.chisel.Chisel ;
import team.chisel.init.ChiselTabs ;
2015-01-04 18:15:15 +00:00
import net.minecraft.block.Block ;
import net.minecraft.block.BlockSand ;
import net.minecraft.client.renderer.texture.IIconRegister ;
import net.minecraft.creativetab.CreativeTabs ;
import net.minecraft.item.Item ;
import net.minecraft.util.IIcon ;
import net.minecraft.world.IBlockAccess ;
import cpw.mods.fml.relauncher.Side ;
import cpw.mods.fml.relauncher.SideOnly ;
public class BlockCarvableSand extends BlockSand implements ICarvable {
2015-01-07 19:50:18 -05:00
public CarvableHelper carverHelper ;
private boolean isAlpha ;
public BlockCarvableSand () {
super ();
2015-04-23 20:33:29 -04:00
carverHelper = new CarvableHelper ( this );
2015-01-08 05:46:10 -05:00
setCreativeTab ( ChiselTabs . tabOtherChiselBlocks );
2015-01-07 19:50:18 -05:00
}
public BlockCarvableSand setStained ( boolean a ) {
this . isAlpha = a ;
return this ;
}
@Override
@SideOnly ( Side . CLIENT )
public int getRenderBlockPass () {
return isAlpha ? 1 : 0 ;
}
@Override
public IIcon getIcon ( int side , int metadata ) {
return carverHelper . getIcon ( side , metadata );
}
@Override
public IIcon getIcon ( IBlockAccess world , int x , int y , int z , int side ) {
return carverHelper . getIcon ( world , x , y , z , side );
}
@Override
public int damageDropped ( int i ) {
return i ;
}
@Override
public void registerBlockIcons ( IIconRegister register ) {
carverHelper . registerBlockIcons ( "Chisel" , this , register );
}
2015-08-06 00:00:22 -04:00
@SuppressWarnings ({ "unchecked" , "rawtypes" })
2015-01-07 19:50:18 -05:00
@Override
public void getSubBlocks ( Item item , CreativeTabs tabs , List list ) {
carverHelper . registerSubBlocks ( this , tabs , list );
}
@Override
public int getRenderType () {
2015-04-26 02:35:16 -04:00
return ClientUtils . renderCTMId ;
2015-01-07 19:50:18 -05:00
}
@Override
2015-07-15 00:35:00 -04:00
public IVariationInfo getManager ( IBlockAccess world , int x , int y , int z , int metadata ) {
2015-01-07 19:50:18 -05:00
return carverHelper . getVariation ( metadata );
}
2015-01-15 13:09:34 -05:00
@Override
2015-07-15 00:35:00 -04:00
public IVariationInfo getManager ( int meta ) {
return carverHelper . getVariation ( meta );
2015-01-15 13:09:34 -05:00
}
2015-01-07 19:50:18 -05:00
public static class SoundType extends Block . SoundType {
public final String soundNameStep ;
public final String soundNameBreak ;
public final String soundNamePlace ;
/**
2015-01-15 13:09:34 -05:00
* Creates a SoundType with automatic names for step and break sounds. Sound names dig.soundName and step.soundName must be specified in the sounds.json
2015-01-07 19:50:18 -05:00
*
* @param soundName
2015-01-15 13:09:34 -05:00
* block of the sound. Will automatically be expanded to "mod:dig.soundName" and "mod:step.soundName" respectively)
2015-01-07 19:50:18 -05:00
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType ( String soundName , float volume , float frequency ) {
super ( soundName , volume , frequency );
this . soundNameStep = null ;
this . soundNameBreak = null ;
this . soundNamePlace = null ;
}
/**
2015-01-15 13:09:34 -05:00
* Creates a SoundType with manual names for step and break sounds. Sound names must be specified in the sounds.json
2015-01-07 19:50:18 -05:00
*
* @param soundNameBreak
* block break sound
* @param soundNameStep
* block step sound
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType ( String soundNameBreak , String soundNameStep , float volume , float frequency ) {
super ( soundNameStep , volume , frequency );
this . soundNameStep = soundNameStep ;
this . soundNameBreak = soundNameBreak ;
this . soundNamePlace = null ;
}
/**
2015-01-15 13:09:34 -05:00
* Creates a SoundType with manual names for step, break and place sounds. Sound names must be specified in the sounds.json
2015-01-07 19:50:18 -05:00
*
* @param soundNameBreak
* block break sound
* @param soundNameStep
* block step sound
* @param soundNamePlace
* block place sound
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType ( String soundNameBreak , String soundNameStep , String soundNamePlace , float volume , float frequency ) {
super ( soundNameStep , volume , frequency );
this . soundNameStep = soundNameStep ;
this . soundNameBreak = soundNameBreak ;
this . soundNamePlace = soundNamePlace ;
}
@Override
public String getBreakSound () {
if ( soundNameBreak == null )
return Chisel . MOD_ID + ":dig." + this . soundName ;
else
return this . soundNameBreak ;
}
@Override
public String getStepResourcePath () {
if ( soundNameStep == null )
return Chisel . MOD_ID + ":step." + this . soundName ;
else
return this . soundNameStep ;
}
@Override
public String func_150496_b () {
if ( soundNamePlace == null )
return getBreakSound ();
else
return this . soundNamePlace ;
}
}
2015-01-04 18:15:15 +00:00
}