package game.tileentity; import game.init.Blocks; import game.material.Material; import game.nbt.NBTTagCompound; import game.util.ExtMath; import game.world.BlockPos; import game.world.World; public class TileEntityNote extends TileEntity { /** Note to play */ public byte note; /** stores the latest redstone state */ public boolean previousRedstoneState; public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setByte("note", this.note); } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.note = compound.getByte("note"); this.note = (byte)ExtMath.clampi(this.note, 0, 24); } /** * change pitch by -> (currentPitch + 1) % 25 */ public void changePitch() { this.note = (byte)((this.note + 1) % 25); this.markDirty(); } public void triggerNote(World worldIn, BlockPos p_175108_2_) { if (worldIn.getState(p_175108_2_.up()).getBlock().getMaterial() == Material.air) { // Material material = worldIn.getBlockState(p_175108_2_.down()).getBlock().getMaterial(); // int i = 0; // // if (material == Material.rock) // { // i = 1; // } // // if (material == Material.sand) // { // i = 2; // } // // if (material == Material.glass) // { // i = 3; // } // // if (material == Material.wood) // { // i = 4; // } worldIn.addBlockEvent(p_175108_2_, Blocks.noteblock, 0, this.note); } } public int getColor() { return 0x80ff00; } }