2014-12-15 00:11:48 +00:00
package com.cricketcraft.chisel.block ;
2014-12-14 20:05:39 +00:00
2015-01-07 19:50:18 -05:00
import java.util.List ;
2014-04-21 19:13:15 +01:00
import net.minecraft.block.Block ;
import net.minecraft.block.material.Material ;
import net.minecraft.client.renderer.texture.IIconRegister ;
import net.minecraft.creativetab.CreativeTabs ;
import net.minecraft.item.Item ;
2015-01-15 13:09:34 -05:00
import net.minecraft.item.ItemStack ;
2014-04-21 19:13:15 +01:00
import net.minecraft.util.IIcon ;
import net.minecraft.world.IBlockAccess ;
2014-12-16 22:27:44 +00:00
2015-01-07 19:50:18 -05:00
import com.cricketcraft.chisel.Chisel ;
import com.cricketcraft.chisel.api.ICarvable ;
import com.cricketcraft.chisel.carving.CarvableHelper ;
import com.cricketcraft.chisel.carving.CarvableVariation ;
2015-01-08 05:46:10 -05:00
import com.cricketcraft.chisel.init.ChiselTabs ;
2015-01-07 19:50:18 -05:00
import cpw.mods.fml.relauncher.Side ;
import cpw.mods.fml.relauncher.SideOnly ;
2014-06-14 10:49:32 +01:00
2014-11-30 18:10:51 -05:00
public class BlockCarvable extends Block implements ICarvable {
2015-01-07 19:50:18 -05:00
public CarvableHelper carverHelper ;
private boolean isAlpha ;
public BlockCarvable () {
this ( Material . rock );
}
public BlockCarvable ( Material m ) {
super ( m );
carverHelper = new CarvableHelper ();
setResistance ( 10 . 0F );
setHardness ( 2 . 0F );
2015-01-08 05:46:10 -05:00
setCreativeTab ( ChiselTabs . tabOtherChiselBlocks );
2015-01-07 19:50:18 -05:00
}
public BlockCarvable 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 );
}
@Override
public void getSubBlocks ( Item item , CreativeTabs tabs , List list ) {
carverHelper . registerSubBlocks ( this , tabs , list );
}
@Override
public int getRenderType () {
2015-01-08 01:59:50 -05:00
return Chisel . renderCTMId ;
2015-01-07 19:50:18 -05:00
}
@Override
2015-01-15 13:09:34 -05:00
public CarvableVariation getVariation ( 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:50:37 -05:00
2015-01-15 13:09:34 -05:00
@Override
public CarvableVariation getVariation ( ItemStack stack ) {
return carverHelper . getVariation ( stack . getItemDamage ());
}
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:50:37 -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:50:37 -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:50:37 -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:50:37 -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 ;
}
}
2014-09-15 03:52:47 +02:00
2014-04-21 19:13:15 +01:00
}