Files
Chisel/src/main/java/info/jbcs/minecraft/chisel/block/BlockCarvable.java
T

162 lines
5.1 KiB
Java
Raw Normal View History

package info.jbcs.minecraft.chisel.block;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.api.ICarvable;
import info.jbcs.minecraft.chisel.carving.CarvableHelper;
import info.jbcs.minecraft.chisel.carving.CarvableVariation;
2014-10-28 21:10:08 -04:00
import info.jbcs.minecraft.chisel.init.ModTabs;
2014-12-14 20:05:39 +00:00
import java.util.List;
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;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
2014-12-14 20:05:39 +00:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2014-11-30 18:10:51 -05:00
public class BlockCarvable extends Block implements ICarvable {
public CarvableHelper carverHelper;
2014-11-30 18:10:51 -05:00
private boolean isAlpha;
2014-11-30 18:10:51 -05:00
public BlockCarvable() {
this(Material.rock);
}
2014-11-30 18:10:51 -05:00
public BlockCarvable(Material m) {
super(m);
carverHelper = new CarvableHelper();
2014-10-28 21:10:08 -04:00
setCreativeTab(ModTabs.tabChiselBlocks);
}
2014-11-30 18:10:51 -05:00
public BlockCarvable setStained(boolean a) {
this.isAlpha = a;
return this;
}
@Override
@SideOnly(Side.CLIENT)
2014-11-30 18:10:51 -05:00
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
2014-11-30 18:10:51 -05:00
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
2014-11-30 18:10:51 -05:00
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side);
}
@Override
2014-11-30 18:10:51 -05:00
public int damageDropped(int i) {
return i;
}
@Override
2014-11-30 18:10:51 -05:00
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
2014-11-30 18:10:51 -05:00
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
2014-11-30 18:10:51 -05:00
public int getRenderType() {
return Chisel.RenderCTMId;
}
@Override
2014-11-30 18:10:51 -05:00
public CarvableVariation getVariation(int metadata) {
return carverHelper.getVariation(metadata);
}
2014-11-30 18:10:51 -05:00
public static class SoundType extends Block.SoundType {
public final String soundNameStep;
public final String soundNameBreak;
public final String soundNamePlace;
/**
* 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
*
2014-11-30 18:10:51 -05:00
* @param soundName block of the sound. Will automatically be expanded to
* "mod:dig.soundName" and "mod:step.soundName" respectively)
* @param volume default 1.0f
* @param frequency default 1.0f
*/
2014-11-30 18:10:51 -05:00
public SoundType(String soundName, float volume, float frequency) {
super(soundName, volume, frequency);
this.soundNameStep = null;
this.soundNameBreak = null;
this.soundNamePlace = null;
}
/**
* Creates a SoundType with manual names for step and break sounds.
* Sound names must be specified in the sounds.json
*
2014-11-30 18:10:51 -05:00
* @param soundNameBreak block break sound
* @param soundNameStep block step sound
* @param volume default 1.0f
* @param frequency default 1.0f
*/
2014-11-30 18:10:51 -05:00
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
super(soundNameStep, volume, frequency);
this.soundNameStep = soundNameStep;
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = null;
}
/**
* Creates a SoundType with manual names for step, break and place
* sounds. Sound names must be specified in the sounds.json
*
2014-11-30 18:10:51 -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
*/
2014-11-30 18:10:51 -05:00
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
2014-11-30 18:10:51 -05:00
public String getBreakSound() {
if (soundNameBreak == null)
return Chisel.MOD_ID + ":dig." + this.soundName;
else
return this.soundNameBreak;
}
@Override
2014-11-30 18:10:51 -05:00
public String getStepResourcePath() {
if (soundNameStep == null)
return Chisel.MOD_ID + ":step." + this.soundName;
else
return this.soundNameStep;
}
@Override
2014-11-30 18:10:51 -05:00
public String func_150496_b() {
if (soundNamePlace == null)
return getBreakSound();
else
return this.soundNamePlace;
}
}
}